Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-18 22:24:07

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       addBiasRailInefficiency_(
0029           conf.getParameter<ParameterSet>("PSPDigitizerAlgorithm").getParameter<bool>("AddBiasRailInefficiency")) {
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 " << addBiasRailInefficiency_;
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 (addBiasRailInefficiency_ && 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   if (std::fmod(yin, block_unit) > implant || std::fmod(yout, block_unit) > implant)
0072     return true;
0073   else
0074     return false;
0075 }
0076 //
0077 // -- Read Bad Channels from the Condidion DB and kill channels/module accordingly
0078 //
0079 void PSPDigitizerAlgorithm::module_killing_DB(const Phase2TrackerGeomDetUnit* pixdet) {
0080   // this method is dummy at the moment. Will be implemented once we have the corresponding objectcondition DB
0081 }