Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-20 22:40:05

0001 #include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDUncalibratedRecHitAlgoBase.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include "CommonTools/Utils/interface/FormulaEvaluator.h"
0005 
0006 class ETLUncalibRecHitAlgo : public ETLUncalibratedRecHitAlgoBase {
0007 public:
0008   /// Constructor
0009   ETLUncalibRecHitAlgo(const edm::ParameterSet& conf, edm::ConsumesCollector& sumes)
0010       : MTDUncalibratedRecHitAlgoBase<ETLDataFrame>(conf, sumes),
0011         adcNBits_(conf.getParameter<uint32_t>("adcNbits")),
0012         adcSaturation_(conf.getParameter<double>("adcSaturation")),
0013         adcLSB_(adcSaturation_ / (1 << adcNBits_)),
0014         toaLSBToNS_(conf.getParameter<double>("toaLSB_ns")),
0015         tofDelay_(conf.getParameter<double>("tofDelay")),
0016         timeError_(conf.getParameter<std::string>("timeResolutionInNs")),
0017         timeCorr_p0_(conf.getParameter<double>("timeCorr_p0")),
0018         timeCorr_p1_(conf.getParameter<double>("timeCorr_p1")),
0019         timeCorr_p2_(conf.getParameter<double>("timeCorr_p2")),
0020         timeCorr_p3_(conf.getParameter<double>("timeCorr_p3")) {}
0021   /// Destructor
0022   ~ETLUncalibRecHitAlgo() override {}
0023 
0024   /// get event and eventsetup information
0025   void getEvent(const edm::Event&) final {}
0026   void getEventSetup(const edm::EventSetup&) final {}
0027 
0028   /// make the rec hit
0029   FTLUncalibratedRecHit makeRecHit(const ETLDataFrame& dataFrame) const final;
0030 
0031 private:
0032   const uint32_t adcNBits_;
0033   const double adcSaturation_;
0034   const double adcLSB_;
0035   const double toaLSBToNS_;
0036   const double tofDelay_;
0037   const reco::FormulaEvaluator timeError_;
0038   const double timeCorr_p0_;
0039   const double timeCorr_p1_;
0040   const double timeCorr_p2_;
0041   const double timeCorr_p3_;
0042 };
0043 
0044 FTLUncalibratedRecHit ETLUncalibRecHitAlgo::makeRecHit(const ETLDataFrame& dataFrame) const {
0045   constexpr int iSample = 2;  //only in-time sample
0046   const auto& sample = dataFrame.sample(iSample);
0047 
0048   double time = double(sample.toa()) * toaLSBToNS_ - tofDelay_;
0049   double time_over_threshold = double(sample.tot()) * toaLSBToNS_;
0050   const std::array<double, 1> time_over_threshold_V = {{time_over_threshold}};
0051 
0052   unsigned char flag = 0;
0053 
0054   LogDebug("ETLUncalibRecHit") << "ADC+: set the charge to: " << time_over_threshold << ' ' << sample.tot() << ' '
0055                                << toaLSBToNS_;
0056 
0057   if (time_over_threshold == 0) {
0058     LogDebug("ETLUncalibRecHit") << "ADC+: set the time to: " << time << ' ' << sample.toa() << ' ' << toaLSBToNS_;
0059 
0060   } else {
0061     // Time-walk correction for toa
0062     double timeWalkCorr = timeCorr_p0_ + timeCorr_p1_ * time_over_threshold +
0063                           timeCorr_p2_ * time_over_threshold * time_over_threshold +
0064                           timeCorr_p3_ * time_over_threshold * time_over_threshold * time_over_threshold;
0065 
0066     time -= timeWalkCorr;
0067 
0068     LogDebug("ETLUncalibRecHit") << "ADC+: set the time to: " << time << ' ' << sample.toa() << ' ' << toaLSBToNS_
0069                                  << " .Timewalk correction: " << timeWalkCorr;
0070   }
0071 
0072   LogDebug("ETLUncalibRecHit") << "Final uncalibrated time_over_threshold: " << time_over_threshold;
0073 
0074   const std::array<double, 1> emptyV = {{0.}};
0075 
0076   double timeError = timeError_.evaluate(time_over_threshold_V, emptyV);
0077 
0078   return FTLUncalibratedRecHit(dataFrame.id(),
0079                                dataFrame.row(),
0080                                dataFrame.column(),
0081                                {time_over_threshold_V[0], 0.f},
0082                                {time, 0.f},
0083                                timeError,
0084                                -1.f,
0085                                -1.f,
0086                                flag);
0087 }
0088 #include "FWCore/Framework/interface/MakerMacros.h"
0089 DEFINE_EDM_PLUGIN(ETLUncalibratedRecHitAlgoFactory, ETLUncalibRecHitAlgo, "ETLUncalibRecHitAlgo");