Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:19

0001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalRecHitSimpleAlgo_HH
0002 #define RecoLocalCalo_EcalRecAlgos_EcalRecHitSimpleAlgo_HH
0003 
0004 /** \class EcalRecHitSimpleAlgo
0005   *  Simple algoritm to make rechits from uncalibrated rechits
0006   *
0007   *  \author Shahram Rahatlou, University of Rome & INFN, March 2006
0008   */
0009 
0010 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalRecHitAbsAlgo.h"
0011 #include "DataFormats/EcalDigi/interface/EcalDataFrame.h"
0012 #include "TMath.h"
0013 #include <iostream>
0014 
0015 class EcalRecHitSimpleAlgo : public EcalRecHitAbsAlgo {
0016 public:
0017   // default ctor
0018   EcalRecHitSimpleAlgo() {
0019     adcToGeVConstant_ = -1;
0020     adcToGeVConstantIsSet_ = false;
0021   }
0022 
0023   void setADCToGeVConstant(const float& value) override {
0024     adcToGeVConstant_ = value;
0025     adcToGeVConstantIsSet_ = true;
0026   }
0027 
0028   // destructor
0029   ~EcalRecHitSimpleAlgo() override{};
0030 
0031   /// Compute parameters
0032   EcalRecHit makeRecHit(const EcalUncalibratedRecHit& uncalibRH,
0033                         const float& intercalibConstant,
0034                         const float& timeIntercalib = 0,
0035                         const uint32_t& flags = 0) const override {
0036     if (!adcToGeVConstantIsSet_) {
0037       std::cout << "EcalRecHitSimpleAlgo::makeRecHit: adcToGeVConstant_ not set before calling this method!"
0038                 << " will use -1 and produce bogus rechits!" << std::endl;
0039     }
0040 
0041     float clockToNsConstant = 25;
0042     float energy = uncalibRH.amplitude() * adcToGeVConstant_ * intercalibConstant;
0043     float time = uncalibRH.jitter() * clockToNsConstant + timeIntercalib;
0044 
0045     EcalRecHit rh(uncalibRH.id(), energy, time);
0046     rh.setChi2(uncalibRH.chi2());
0047     rh.setEnergyError(uncalibRH.amplitudeError() * adcToGeVConstant_ * intercalibConstant);
0048     /* rh.setOutOfTimeEnergy( uncalibRH.outOfTimeEnergy() * adcToGeVConstant_ * intercalibConstant ); */
0049     /* rh.setOutOfTimeChi2( uncalibRH.outOfTimeChi2() ); */
0050     rh.setTimeError(uncalibRH.jitterErrorBits());
0051 
0052     // Now fill flags
0053 
0054     bool good = true;
0055 
0056     if (uncalibRH.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered)) {
0057       rh.setFlag(EcalRecHit::kLeadingEdgeRecovered);
0058       good = false;
0059     }
0060     if (uncalibRH.checkFlag(EcalUncalibratedRecHit::kSaturated)) {
0061       // leading edge recovery failed - still keep the information
0062       // about the saturation and do not flag as dead
0063       rh.setFlag(EcalRecHit::kSaturated);
0064       good = false;
0065     }
0066     if (uncalibRH.isSaturated()) {
0067       rh.setFlag(EcalRecHit::kSaturated);
0068       good = false;
0069     }
0070     if (uncalibRH.checkFlag(EcalUncalibratedRecHit::kOutOfTime)) {
0071       rh.setFlag(EcalRecHit::kOutOfTime);
0072       good = false;
0073     }
0074     if (uncalibRH.checkFlag(EcalUncalibratedRecHit::kPoorReco)) {
0075       rh.setFlag(EcalRecHit::kPoorReco);
0076       good = false;
0077     }
0078     if (uncalibRH.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain6)) {
0079       rh.setFlag(EcalRecHit::kHasSwitchToGain6);
0080     }
0081     if (uncalibRH.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain1)) {
0082       rh.setFlag(EcalRecHit::kHasSwitchToGain1);
0083     }
0084 
0085     if (good)
0086       rh.setFlag(EcalRecHit::kGood);
0087     return rh;
0088   }
0089 
0090 private:
0091   float adcToGeVConstant_;
0092   bool adcToGeVConstantIsSet_;
0093 };
0094 #endif