Go to the documentation of this file.00001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
00002 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
00003
00018 #include "Math/SVector.h"
00019 #include "Math/SMatrix.h"
00020 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecAbsAlgo.h"
00021 #include "CondFormats/EcalObjects/interface/EcalWeightSet.h"
00022 #include "SimCalorimetry/EcalSimAlgos/interface/EcalShapeBase.h"
00023
00024 #include <vector>
00025
00026 template<class C> class EcalUncalibRecHitRecWeightsAlgo
00027 {
00028 public:
00029
00030 virtual ~EcalUncalibRecHitRecWeightsAlgo<C>() { };
00031
00033 virtual EcalUncalibratedRecHit makeRecHit(
00034 const C& dataFrame
00035 , const double* pedestals
00036 , const double* pedestalsRMS
00037 , const double* gainRatios
00038 , const EcalWeightSet::EcalWeightMatrix** weights
00039 , const EcalShapeBase & testbeamPulseShape
00040 ) {
00041 double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
00042 uint32_t flag = 0;
00043
00044
00045
00046 ROOT::Math::SVector<double,C::MAXSAMPLES> frame;
00047 int gainId0 = 1;
00048 int iGainSwitch = 0;
00049 bool isSaturated = 0;
00050 for(int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
00051 int gainId = dataFrame.sample(iSample).gainId();
00052
00053 if ( gainId == 0 )
00054 {
00055 gainId = 3;
00056 isSaturated = 1;
00057 }
00058
00059 if (gainId != gainId0) iGainSwitch = 1;
00060 if (!iGainSwitch)
00061 frame(iSample) = double(dataFrame.sample(iSample).adc());
00062 else
00063 frame(iSample) = double(((double)(dataFrame.sample(iSample).adc()) - pedestals[gainId-1]) * gainRatios[gainId-1]);
00064 }
00065
00066
00067 ROOT::Math::SVector <double,3> param = (*(weights[iGainSwitch])) * frame;
00068 amplitude_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iAmplitude);
00069 pedestal_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iPedestal);
00070 if (amplitude_) jitter_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iTime);
00071
00072
00073
00074 if (isSaturated)
00075 {
00076 flag = EcalUncalibratedRecHit::kSaturated;
00077 amplitude_ = double((4095. - pedestals[2]) * gainRatios[2]);
00078 }
00079 return EcalUncalibratedRecHit( dataFrame.id(), amplitude_, pedestal_, jitter_, chi2_, flag);
00080 }
00081
00083 };
00084 #endif