CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitMaxSampleAlgo_HH
00002 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitMaxSampleAlgo_HH
00003 
00011 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecAbsAlgo.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 
00014 
00015 template<class C> class EcalUncalibRecHitMaxSampleAlgo : public EcalUncalibRecHitRecAbsAlgo<C>
00016 {
00017   
00018  public:
00019   
00020   virtual ~EcalUncalibRecHitMaxSampleAlgo<C>() { };
00021   virtual EcalUncalibratedRecHit makeRecHit(const C& dataFrame, const double* pedestals,
00022                                             const double* gainRatios,
00023                                             const EcalWeightSet::EcalWeightMatrix** weights,
00024                                             const EcalWeightSet::EcalChi2WeightMatrix** chi2Matrix);
00025 
00026  private:
00027   int16_t  amplitude_,  pedestal_, jitter_, sampleAdc_, gainId_;
00028   double   chi2_;
00029 
00030 };
00031 
00033 template<class C> EcalUncalibratedRecHit  
00034 EcalUncalibRecHitMaxSampleAlgo<C>::makeRecHit(const C& dataFrame, const double* pedestals,
00035                                               const double* gainRatios,
00036                                               const EcalWeightSet::EcalWeightMatrix** weights,
00037                                               const EcalWeightSet::EcalChi2WeightMatrix** chi2Matrix) {
00038 
00039   amplitude_ = std::numeric_limits<int16_t>::min();
00040   pedestal_  = 4095;
00041   jitter_    = -1;
00042   chi2_      = -1;
00043   //bool isSaturated = 0;
00044   uint32_t flags = 0;
00045   for(int16_t iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
00046     
00047     gainId_ = dataFrame.sample(iSample).gainId(); 
00048 
00049     if (gainId_ == 0 )
00050       {
00051         flags = EcalUncalibratedRecHit::kSaturated;
00052       }
00053 
00054     // ampli gain 12
00055     if ( gainId_ == 1){
00056       sampleAdc_ = dataFrame.sample(iSample).adc();
00057     }
00058       
00059     else
00060       {
00061         if ( gainId_ == 2){       // ampli gain 6
00062           sampleAdc_ = 200 + (dataFrame.sample(iSample).adc() - 200) * 2 ;
00063         }
00064         else  {  // accounts for gainId_==3 or 0 - ampli gain 1 and gain0
00065           sampleAdc_ = 200 + (dataFrame.sample(iSample).adc() - 200) * 12 ;
00066         }
00067       }
00068     
00069     if( sampleAdc_ >amplitude_ )          {
00070       amplitude_ = sampleAdc_;
00071       jitter_    = iSample;
00072     }// if statement
00073     
00074     if (sampleAdc_<pedestal_) pedestal_ = sampleAdc_;
00075 
00076   }// loop on samples
00077       
00078       
00079   return EcalUncalibratedRecHit( dataFrame.id(), static_cast<double>(amplitude_-pedestal_) , static_cast<double>(pedestal_), static_cast<double>(jitter_ - 5), chi2_, flags );
00080 }
00081 
00082 #endif