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/PSPDigitizerAlgorithm.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 using namespace edm;
0014 
0015 void PSPDigitizerAlgorithm::init(const edm::EventSetup& es) {
0016   if (use_LorentzAngle_DB_) {  // Get Lorentz angle from DB record
0017     siPhase2OTLorentzAngle_ = &es.getData(siPhase2OTLorentzAngleToken_);
0018   }
0019 
0020   geom_ = &es.getData(geomToken_);
0021 }
0022 
0023 PSPDigitizerAlgorithm::PSPDigitizerAlgorithm(const edm::ParameterSet& conf, edm::ConsumesCollector iC)
0024     : Phase2TrackerDigitizerAlgorithm(conf.getParameter<ParameterSet>("AlgorithmCommon"),
0025                                       conf.getParameter<ParameterSet>("PSPDigitizerAlgorithm"),
0026                                       iC),
0027       geomToken_(iC.esConsumes()),
0028       biasRailInefficiencyFlag_(
0029           conf.getParameter<ParameterSet>("PSPDigitizerAlgorithm").getParameter<int>("BiasRailInefficiencyFlag")) {
0030   if (use_LorentzAngle_DB_)
0031     siPhase2OTLorentzAngleToken_ = iC.esConsumes();
0032   pixelFlag_ = false;
0033   LogDebug("PSPDigitizerAlgorithm") << "Algorithm constructed "
0034                                     << "Configuration parameters:"
0035                                     << "Threshold/Gain = "
0036                                     << "threshold in electron Endcap = " << theThresholdInE_Endcap_
0037                                     << "threshold in electron Barrel = " << theThresholdInE_Barrel_ << " "
0038                                     << theElectronPerADC_ << " " << theAdcFullScale_ << " The delta cut-off is set to "
0039                                     << tMax_ << " pix-inefficiency " << addPixelInefficiency_
0040                                     << "Bias Rail Inefficiency " << biasRailInefficiencyFlag_;
0041 }
0042 PSPDigitizerAlgorithm::~PSPDigitizerAlgorithm() { LogDebug("PSPDigitizerAlgorithm") << "Algorithm deleted"; }
0043 //
0044 // -- Select the Hit for Digitization (sigScale will be implemented in future)
0045 //
0046 bool PSPDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const {
0047   if (biasRailInefficiencyFlag_ > 0 && isInBiasRailRegion(hit))
0048     return false;
0049   double toa = hit.tof() - tCorr;
0050   return (toa > theTofLowerCut_ && toa < theTofUpperCut_);
0051 }
0052 //
0053 // -- Compare Signal with Threshold
0054 //
0055 bool PSPDigitizerAlgorithm::isAboveThreshold(const digitizerUtility::SimHitInfo* hitInfo,
0056                                              float charge,
0057                                              float thr) const {
0058   return (charge >= thr);
0059 }
0060 //
0061 //  Check whether the Hit is in the Inefficient Bias Rail Region
0062 //
0063 bool PSPDigitizerAlgorithm::isInBiasRailRegion(const PSimHit& hit) const {
0064   constexpr float implant = 0.1467;  // Implant length (1.467 mm)
0065   constexpr float bRail = 0.00375;   // Bias Rail region which causes inefficiency (37.5micron)
0066   // Do coordinate transformation of the local Y from module middle point considering 32 implants and 31 inter-impant regions with bias rail
0067   constexpr float block_len = 16 * implant + 15.5 * bRail;
0068   constexpr float block_unit = implant + bRail;
0069   float yin = hit.entryPoint().y() + block_len;
0070   float yout = hit.exitPoint().y() + block_len;
0071   bool result = false;
0072 
0073   // Flag= 1 corresponds to optimistic case when the entire trajectory is withon the bias rail region the SimHit will be rejected
0074   if (biasRailInefficiencyFlag_ == 1 && (std::fmod(yin, block_unit) > implant && std::fmod(yout, block_unit) > implant))
0075     result = true;
0076   // Flag= 2 corresponds to pessimistic case i.e iven in a small part of the trajectory is inside the bias rain region the SimHit is rejected
0077   else if (biasRailInefficiencyFlag_ == 2 &&
0078            (std::fmod(yin, block_unit) > implant || std::fmod(yout, block_unit) > implant))
0079     result = true;
0080   return result;
0081 }
0082 //
0083 // -- Read Bad Channels from the Condidion DB and kill channels/module accordingly
0084 //
0085 void PSPDigitizerAlgorithm::module_killing_DB(const Phase2TrackerGeomDetUnit* pixdet) {
0086   // this method is dummy at the moment. Will be implemented once we have the corresponding objectcondition DB
0087 }