File indexing completed on 2024-09-07 04:37:35
0001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
0002 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "Math/SVector.h"
0016 #include "Math/SMatrix.h"
0017 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecAbsAlgo.h"
0018 #include "CondFormats/EcalObjects/interface/EcalWeightSet.h"
0019 #include "SimCalorimetry/EcalSimAlgos/interface/EcalShapeBase.h"
0020
0021 #include <vector>
0022
0023 template <class C>
0024 class EcalUncalibRecHitRecWeightsAlgo {
0025 public:
0026
0027 virtual ~EcalUncalibRecHitRecWeightsAlgo() {}
0028
0029
0030 virtual EcalUncalibratedRecHit makeRecHit(const C& dataFrame,
0031 const double* pedestals,
0032 const double* pedestalsRMS,
0033 const double* gainRatios,
0034 const EcalWeightSet::EcalWeightMatrix** weights,
0035 const EcalShapeBase& testbeamPulseShape) {
0036 double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
0037 uint32_t flag = 0;
0038
0039
0040 ROOT::Math::SVector<double, C::MAXSAMPLES> frame;
0041 int gainId0 = 1;
0042 int iGainSwitch = 0;
0043 bool isSaturated = false;
0044 for (int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
0045 int gainId = dataFrame.sample(iSample).gainId();
0046
0047 if (gainId == 0) {
0048 gainId = 3;
0049
0050
0051
0052 if (iSample == 4 || iSample == 5 || iSample == 6)
0053 isSaturated = true;
0054 }
0055
0056
0057
0058
0059 if ((gainId != gainId0) && (iSample == 4 || iSample == 5 || iSample == 6))
0060 iGainSwitch = 1;
0061 if (!iGainSwitch)
0062 frame(iSample) = double(dataFrame.sample(iSample).adc());
0063 else
0064 frame(iSample) =
0065 double(((double)(dataFrame.sample(iSample).adc()) - pedestals[gainId - 1]) * gainRatios[gainId - 1]);
0066 }
0067
0068
0069 ROOT::Math::SVector<double, 3> param = (*(weights[iGainSwitch])) * frame;
0070 amplitude_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iAmplitude);
0071 pedestal_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iPedestal);
0072 if (amplitude_)
0073 jitter_ = -param(EcalUncalibRecHitRecAbsAlgo<C>::iTime) / amplitude_;
0074 else
0075 jitter_ = 0.;
0076
0077
0078 if (isSaturated) {
0079 flag = EcalUncalibratedRecHit::kSaturated;
0080 amplitude_ = double((4095. - pedestals[2]) * gainRatios[2]);
0081 }
0082 return EcalUncalibratedRecHit(dataFrame.id(), amplitude_, pedestal_, jitter_, chi2_, flag);
0083 }
0084
0085
0086 };
0087 #endif