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
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_) {
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
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
0054
0055 bool PSPDigitizerAlgorithm::isAboveThreshold(const digitizerUtility::SimHitInfo* hitInfo,
0056 float charge,
0057 float thr) const {
0058 return (charge >= thr);
0059 }
0060
0061
0062
0063 bool PSPDigitizerAlgorithm::isInBiasRailRegion(const PSimHit& hit) const {
0064 constexpr float implant = 0.1467;
0065 constexpr float bRail = 0.00375;
0066
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
0074 if (biasRailInefficiencyFlag_ == 1 && (std::fmod(yin, block_unit) > implant && std::fmod(yout, block_unit) > implant))
0075 result = true;
0076
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
0084
0085 void PSPDigitizerAlgorithm::module_killing_DB(const Phase2TrackerGeomDetUnit* pixdet) {
0086
0087 }