Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-12 23:30:29

0001 #include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDRecHitAlgoBase.h"
0002 
0003 #include "RecoLocalFastTime/Records/interface/MTDTimeCalibRecord.h"
0004 #include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDTimeCalib.h"
0005 
0006 class MTDRecHitAlgo : public MTDRecHitAlgoBase {
0007 public:
0008   /// Constructor
0009   MTDRecHitAlgo(const edm::ParameterSet& conf, edm::ConsumesCollector& sumes);
0010 
0011   /// Destructor
0012   ~MTDRecHitAlgo() override {}
0013 
0014   /// get event and eventsetup information
0015   void getEvent(const edm::Event&) final {}
0016   void getEventSetup(const edm::EventSetup&) final;
0017 
0018   /// make the rec hit
0019   FTLRecHit makeRecHit(const FTLUncalibratedRecHit& uRecHit, uint32_t& flags) const final;
0020 
0021 private:
0022   double thresholdToKeep_, calibration_;
0023   const MTDTimeCalib* time_calib_;
0024   edm::ESGetToken<MTDTimeCalib, MTDTimeCalibRecord> tcToken_;
0025 };
0026 
0027 MTDRecHitAlgo::MTDRecHitAlgo(const edm::ParameterSet& conf, edm::ConsumesCollector& sumes)
0028     : MTDRecHitAlgoBase(conf, sumes),
0029       thresholdToKeep_(conf.getParameter<double>("thresholdToKeep")),
0030       calibration_(conf.getParameter<double>("calibrationConstant")) {
0031   tcToken_ = sumes.esConsumes<MTDTimeCalib, MTDTimeCalibRecord>(edm::ESInputTag("", "MTDTimeCalib"));
0032 }
0033 
0034 void MTDRecHitAlgo::getEventSetup(const edm::EventSetup& es) {
0035   auto pTC = es.getHandle(tcToken_);
0036   time_calib_ = pTC.product();
0037 }
0038 
0039 FTLRecHit MTDRecHitAlgo::makeRecHit(const FTLUncalibratedRecHit& uRecHit, uint32_t& flags) const {
0040   unsigned char flagsWord = uRecHit.flags();
0041   float timeError = uRecHit.timeError();
0042 
0043   float energy = 0.;
0044   float time = 0.;
0045 
0046   /// position and positionError in unit cm
0047   float position = -1.f;
0048   float positionError = -1.f;
0049 
0050   switch (flagsWord) {
0051     // BTL bar geometry with only the right SiPM information available
0052     case 0x2: {
0053       energy = uRecHit.amplitude().second;
0054       time = uRecHit.time().second;
0055 
0056       break;
0057     }
0058     // BTL bar geometry with left and right SiPMs information available
0059     case 0x3: {
0060       energy = 0.5 * (uRecHit.amplitude().first + uRecHit.amplitude().second);
0061       time = 0.5 * (uRecHit.time().first + uRecHit.time().second);
0062 
0063       position = uRecHit.position();
0064       positionError = uRecHit.positionError();
0065 
0066       break;
0067     }
0068     // ETL, BTL tile geometry, BTL bar geometry with only the left SiPM information available
0069     default: {
0070       energy = uRecHit.amplitude().first;
0071       time = uRecHit.time().first;
0072 
0073       break;
0074     }
0075   }
0076 
0077   // --- Energy calibration: for the time being this is just a conversion pC --> MeV
0078   energy *= calibration_;
0079 
0080   // --- Time calibration: for the time being just removes a time offset in BTL
0081   time += time_calib_->getTimeCalib(uRecHit.id());
0082 
0083   FTLRecHit rh(uRecHit.id(), uRecHit.row(), uRecHit.column(), energy, time, timeError, position, positionError);
0084 
0085   // Now fill flags
0086   // all rechits from the digitizer are "good" at present
0087   if (energy > thresholdToKeep_) {
0088     flags = FTLRecHit::kGood;
0089     rh.setFlag(flags);
0090   } else {
0091     flags = FTLRecHit::kKilled;
0092     rh.setFlag(flags);
0093   }
0094 
0095   return rh;
0096 }
0097 
0098 #include "FWCore/Framework/interface/MakerMacros.h"
0099 DEFINE_EDM_PLUGIN(MTDRecHitAlgoFactory, MTDRecHitAlgo, "MTDRecHitAlgo");