Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:55

0001 #include <iostream>
0002 #include <cmath>
0003 
0004 #include "SimTracker/SiPhase2Digitizer/plugins/PSSDigitizerAlgorithm.h"
0005 
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 
0010 // Geometry
0011 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0012 
0013 #include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerCondDataRecords.h"
0014 
0015 using namespace edm;
0016 
0017 void PSSDigitizerAlgorithm::init(const edm::EventSetup& es) {
0018   if (use_LorentzAngle_DB_)  // Get Lorentz angle from DB record
0019     siPhase2OTLorentzAngle_ = &es.getData(siPhase2OTLorentzAngleToken_);
0020 
0021   if (use_deadmodule_DB_)  // Get Bad Channel (SiStripBadStrip) from DB
0022     badChannelPayload_ = &es.getData(badChannelToken_);
0023 
0024   geom_ = &es.getData(geomToken_);
0025 }
0026 PSSDigitizerAlgorithm::PSSDigitizerAlgorithm(const edm::ParameterSet& conf, edm::ConsumesCollector iC)
0027     : Phase2TrackerDigitizerAlgorithm(conf.getParameter<ParameterSet>("AlgorithmCommon"),
0028                                       conf.getParameter<ParameterSet>("PSSDigitizerAlgorithm"),
0029                                       iC),
0030       geomToken_(iC.esConsumes()) {
0031   if (use_LorentzAngle_DB_)
0032     siPhase2OTLorentzAngleToken_ = iC.esConsumes();
0033 
0034   if (use_deadmodule_DB_) {
0035     std::string badChannelLabel_ = conf.getParameter<ParameterSet>("SSDigitizerAlgorithm")
0036                                        .getUntrackedParameter<std::string>("BadChannelLabel", "");
0037     badChannelToken_ = iC.esConsumes(edm::ESInputTag{"", badChannelLabel_});
0038   }
0039 
0040   pixelFlag_ = false;
0041   LogDebug("PSSDigitizerAlgorithm") << "Algorithm constructed "
0042                                     << "Configuration parameters: "
0043                                     << "Threshold/Gain = "
0044                                     << "threshold in electron Endcap = " << theThresholdInE_Endcap_
0045                                     << "threshold in electron Barrel = " << theThresholdInE_Barrel_ << " "
0046                                     << theElectronPerADC_ << " " << theAdcFullScale_ << " The delta cut-off is set to "
0047                                     << tMax_ << " pix-inefficiency " << addPixelInefficiency_;
0048 }
0049 PSSDigitizerAlgorithm::~PSSDigitizerAlgorithm() { LogDebug("PSSDigitizerAlgorithm") << "Algorithm deleted"; }
0050 //
0051 // -- Select the Hit for Digitization (sigScale will be implemented in future)
0052 //
0053 bool PSSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const {
0054   double toa = hit.tof() - tCorr;
0055   return (toa > theTofLowerCut_ && toa < theTofUpperCut_);
0056 }
0057 //
0058 // -- Compare Signal with Threshold
0059 //
0060 bool PSSDigitizerAlgorithm::isAboveThreshold(const digitizerUtility::SimHitInfo* const hisInfo,
0061                                              float charge,
0062                                              float thr) const {
0063   return (charge >= thr);
0064 }
0065 //
0066 // -- Read Bad Channels from the Condidion DB and kill channels/module accordingly
0067 //
0068 void PSSDigitizerAlgorithm::module_killing_DB(const Phase2TrackerGeomDetUnit* pixdet) {
0069   uint32_t detId = pixdet->geographicalId().rawId();
0070 
0071   signal_map_type& theSignal = _signal[detId];
0072   signal_map_type signalNew;
0073 
0074   SiStripBadStrip::Range range = badChannelPayload_->getRange(detId);
0075   for (std::vector<unsigned int>::const_iterator badChannel = range.first; badChannel != range.second; ++badChannel) {
0076     const auto& firstStrip = badChannelPayload_->decodePhase2(*badChannel).firstStrip;
0077     const auto& channelRange = badChannelPayload_->decodePhase2(*badChannel).range;
0078 
0079     for (int index = 0; index < channelRange; index++) {
0080       for (auto& s : theSignal) {
0081         auto& channel = s.first;
0082         if (channel == firstStrip + index)
0083           s.second.set(0.);
0084       }
0085     }
0086   }
0087 }