CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitLeadingEdgeAlgo.h

Go to the documentation of this file.
00001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitLeadingEdgeAlgo_HH
00002 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitLeadingEdgeAlgo_HH
00003 
00013 #include "Math/SVector.h"
00014 #include "Math/SMatrix.h"
00015 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecAbsAlgo.h"
00016 
00017 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00018 
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 
00021 
00022 template < class C > class EcalUncalibRecHitLeadingEdgeAlgo : public EcalUncalibRecHitRecAbsAlgo < C > {
00023       public:
00024         // destructor
00025         EcalUncalibRecHitLeadingEdgeAlgo < C > () : leadingSample_(0), shape_(0) { };
00026         virtual ~ EcalUncalibRecHitLeadingEdgeAlgo < C > () { };
00027 
00028         void setLeadingEdgeSample( int isample ) { leadingSample_ = isample; }
00029         int getLeadingEdgeSample() { return leadingSample_; }
00030 
00031         void setPulseShape( std::vector<double> & shape ) { shape_ = shape; }
00032         std::vector<double> & getPulseShape() { return shape_; }
00033 
00035         virtual EcalUncalibratedRecHit makeRecHit(const C & dataFrame, 
00036                         const double *pedestals,
00037                         const double *gainRatios,
00038                         const EcalWeightSet::EcalWeightMatrix** weights, 
00039                         const EcalWeightSet::EcalChi2WeightMatrix** chi2Matrix
00040                         )
00041         {
00042                 double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
00043 
00044                 // compute amplitude
00045                 amplitude_ = double (((double) (dataFrame.sample( leadingSample_ ).adc() -
00046                                               pedestals[ dataFrame.sample( leadingSample_ ).gainId() - 1]) * 
00047                                               saturationCorrection( leadingSample_ ) *
00048                                               gainRatios[ dataFrame.sample( leadingSample_ ).gainId() - 1] )); 
00049 
00050 
00051 
00052                 return EcalUncalibratedRecHit(dataFrame.id(), amplitude_, pedestal_, jitter_, chi2_);
00053         }
00054 
00055         // saturation correction  
00056         double saturationCorrection(int unsaturatedSample)
00057         {
00058                 if ( unsaturatedSample > 0 && unsaturatedSample < (int)shape_.size() ) {
00059                         return 1./ shape_[ unsaturatedSample ];
00060                 } else {
00061                         edm::LogError("EcalUncalibRecHitLeadingEdgeAlgo") << "Invalid sample " << unsaturatedSample 
00062                                 << " for a shape vector of size " << shape_.size();
00063                         return 0;
00064                 }
00065         }
00066 
00067         private:
00068                 int leadingSample_;
00069                 std::vector< double > shape_;
00070 };
00071 #endif