Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-07-04 00:49:27

0001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitMaxSampleAlgo_HH
0002 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitMaxSampleAlgo_HH
0003 
0004 /** \class EcalUncalibRecHitMaxSampleAlgo
0005   *  Amplitude reconstucted by the difference MAX_adc - min_adc
0006   *  jitter is sample number of MAX_adc, pedestal is min_adc
0007   *
0008   *  \author G. Franzoni, E. Di Marco
0009   */
0010 
0011 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecAbsAlgo.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 
0014 template <class C>
0015 class EcalUncalibRecHitMaxSampleAlgo : public EcalUncalibRecHitRecAbsAlgo<C> {
0016 public:
0017   ~EcalUncalibRecHitMaxSampleAlgo() override{};
0018   EcalUncalibratedRecHit makeRecHit(const C& dataFrame,
0019                                     const double* pedestals,
0020                                     const double* gainRatios,
0021                                     const EcalWeightSet::EcalWeightMatrix** weights,
0022                                     const EcalWeightSet::EcalChi2WeightMatrix** chi2Matrix) override;
0023 
0024 private:
0025   int16_t amplitude_, pedestal_, jitter_, sampleAdc_, gainId_;
0026   double chi2_;
0027 };
0028 
0029 /// compute rechits
0030 template <class C>
0031 EcalUncalibratedRecHit EcalUncalibRecHitMaxSampleAlgo<C>::makeRecHit(
0032     const C& dataFrame,
0033     const double* pedestals,
0034     const double* gainRatios,
0035     const EcalWeightSet::EcalWeightMatrix** weights,
0036     const EcalWeightSet::EcalChi2WeightMatrix** chi2Matrix) {
0037   amplitude_ = std::numeric_limits<int16_t>::min();
0038   pedestal_ = 4095;
0039   jitter_ = -1;
0040   chi2_ = -1;
0041   //bool isSaturated = 0;
0042   uint32_t flags = 0;
0043   for (int16_t iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
0044     gainId_ = dataFrame.sample(iSample).gainId();
0045 
0046     if (gainId_ == 0) {
0047       flags = EcalUncalibratedRecHit::kSaturated;
0048     }
0049 
0050     // ampli gain 12
0051     if (gainId_ == 1) {
0052       sampleAdc_ = dataFrame.sample(iSample).adc();
0053     }
0054 
0055     else {
0056       if (gainId_ == 2) {  // ampli gain 6
0057         sampleAdc_ = 200 + (dataFrame.sample(iSample).adc() - 200) * 2;
0058       } else {  // accounts for gainId_==3 or 0 - ampli gain 1 and gain0
0059         sampleAdc_ = 200 + (dataFrame.sample(iSample).adc() - 200) * 12;
0060       }
0061     }
0062 
0063     if (sampleAdc_ > amplitude_) {
0064       amplitude_ = sampleAdc_;
0065       jitter_ = iSample;
0066     }  // if statement
0067 
0068     if (sampleAdc_ < pedestal_)
0069       pedestal_ = sampleAdc_;
0070 
0071   }  // loop on samples
0072 
0073   return EcalUncalibratedRecHit(dataFrame.id(),
0074                                 static_cast<double>(amplitude_ - pedestal_),
0075                                 static_cast<double>(pedestal_),
0076                                 static_cast<double>(jitter_ - 5),
0077                                 chi2_,
0078                                 flags);
0079 }
0080 
0081 #endif