CMS 3D CMS Logo

Phase2TrackerDigitizerAlgorithm.h
Go to the documentation of this file.
1 #ifndef SimTracker_SiPhase2Digitizer_Phase2TrackerDigitizerAlgorithm_h
2 #define SimTracker_SiPhase2Digitizer_Phase2TrackerDigitizerAlgorithm_h
3 
4 #include <map>
5 #include <memory>
6 #include <vector>
7 
15 
19 
20 // Units and Constants
22 #include "CLHEP/Units/GlobalPhysicalConstants.h"
23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
24 
25 // forward declarations
26 // For the random numbers
27 namespace CLHEP {
28  class HepRandomEngine;
29  class RandGaussQ;
30  class RandFlat;
31 } // namespace CLHEP
32 
33 class DetId;
39 class SiPixelQuality;
41 class TrackerGeometry;
42 class TrackerTopology;
44 
45 // REMEMBER CMS conventions:
46 // -- Energy: GeV
47 // -- momentum: GeV/c
48 // -- mass: GeV/c^2
49 // -- Distance, position: cm
50 // -- Time: ns
51 // -- Angles: radian
52 // Some constants in convenient units
53 constexpr double c_cm_ns = CLHEP::c_light * CLHEP::ns / CLHEP::cm;
54 constexpr double c_inv = 1.0 / c_cm_ns;
55 
57 public:
59  const edm::ParameterSet& conf_specific,
62 
63  // initialization that cannot be done in the constructor
64  virtual void init(const edm::EventSetup& es) = 0;
65  virtual void initializeEvent(CLHEP::HepRandomEngine& eng);
66 
67  // run the algorithm to digitize a single det
68  virtual void accumulateSimHits(const std::vector<PSimHit>::const_iterator inputBegin,
69  const std::vector<PSimHit>::const_iterator inputEnd,
70  const size_t inputBeginGlobalIndex,
71  const uint32_t tofBin,
72  const Phase2TrackerGeomDetUnit* pixdet,
73  const GlobalVector& bfield);
74  virtual void digitize(const Phase2TrackerGeomDetUnit* pixdet,
75  std::map<int, digitizerUtility::DigiSimInfo>& digi_map,
76  const TrackerTopology* tTopo);
77  virtual bool select_hit(const PSimHit& hit, double tCorr, double& sigScale) const { return true; }
78  virtual bool isAboveThreshold(const digitizerUtility::SimHitInfo* hitInfo, float charge, float thr) const {
79  return true;
80  }
81 
82  // For premixing
83  void loadAccumulator(uint32_t detId, const std::map<int, float>& accumulator);
84 
85 protected:
86  // Accessing Inner Tracker Lorentz angle from DB:
88 
89  // Accessing Outer Tracker Lorentz angle from DB:
91 
92  // Accessing Dead pixel modules from DB:
94 
95  // Accessing Map and Geom:
100  std::vector<double> barrel_efficiencies;
101  std::vector<double> endcap_efficiencies;
102  };
103 
104  // Internal type aliases
105  using signal_map_type = std::map<int, digitizerUtility::Ph2Amplitude, std::less<int> >;
106  using signalMaps = std::map<uint32_t, signal_map_type>;
108  using Parameters = std::vector<edm::ParameterSet>;
109 
110  // Contains the accumulated hit info.
112 
113  const bool makeDigiSimLinks_;
114 
115  const bool use_ineff_from_db_;
116  const bool use_module_killing_; // remove or not the dead pixel modules
117  const bool use_deadmodule_DB_; // if we want to get dead pixel modules from the DataBase.
118  const bool use_LorentzAngle_DB_; // if we want to get Lorentz angle from the DataBase.
119 
121 
122  // Variables
123  // external parameters
124  // go from Geant energy GeV to number of electrons
125  const float GeVperElectron_; // 3.7E-09
126 
127  //-- drift
128  const bool alpha2Order_; // Switch on/off of E.B effect
129  const bool addXtalk_;
130  const float interstripCoupling_;
131  const float Sigma0_; //=0.0007 // Charge diffusion in microns for 300 micron Si
132  const float SigmaCoeff_; // delta in the diffusion across the strip pitch
133 
134  //-- induce_signal
135  const float clusterWidth_; // Gaussian charge cutoff width in sigma units
136 
137  //-- make_digis
138  const int thePhase2ReadoutMode_; // Flag to decide readout mode (digital/Analog dual slope etc.)
139  const float theElectronPerADC_; // Gain, number of electrons per adc count.
140  const int theAdcFullScale_; // Saturation count, 255=8bit.
141  const float theNoiseInElectrons_; // Noise (RMS) in units of electrons.
142  const float theReadoutNoise_; // Noise of the readount chain in elec,
143 
144  // inludes DCOL-Amp,TBM-Amp, Alt, AOH,OptRec.
145  const float theThresholdInE_Endcap_; // threshold in electrons Endcap.
146  const float theThresholdInE_Barrel_; // threshold in electrons Barrel.
147 
150 
153 
154  const float theTofLowerCut_; // Cut on the particle TOF
155  const float theTofUpperCut_; // Cut on the particle TOF
156  const float tanLorentzAnglePerTesla_Endcap_; //FPix Lorentz angle tangent per Tesla
157  const float tanLorentzAnglePerTesla_Barrel_; //BPix Lorentz angle tangent per Tesla
158 
159  // -- add_noise
160  const bool addNoise_;
161  const bool addNoisyPixels_;
162  const bool fluctuateCharge_;
163 
164  //-- pixel efficiency
165  const bool addPixelInefficiency_; // bool to read in inefficiencies
166 
168 
169  // pseudoRadDamage
170  const double pseudoRadDamage_; // Decrease the amount off freed charge that reaches the collector
171  const double pseudoRadDamageRadius_; // Only apply pseudoRadDamage to pixels with radius<=pseudoRadDamageRadius
172 
173  // charge reweighting
175  // access 2D templates from DB. Only gets initialized if useChargeReweighting_ is set to true
176  const std::unique_ptr<SiPixelChargeReweightingAlgorithm> theSiPixelChargeReweightingAlgorithm_;
177 
178  // The PDTable
179  // HepPDTable *particleTable;
180  // ParticleDataTable *particleTable;
181 
182  //-- charge fluctuation
183  const double tMax_; // The delta production cut, should be as in OSCAR = 30keV
184 
185  // Bad Pixels to be killed
187 
188  // The eloss fluctuation class from G4. Is the right place?
189  const std::unique_ptr<SiG4UniversalFluctuation> fluctuate_; // make a pointer
190  const std::unique_ptr<GaussianTailNoiseGenerator> theNoiser_;
191 
192  //-- additional member functions
193  // Private methods
194  virtual std::vector<digitizerUtility::EnergyDepositUnit> primary_ionization(const PSimHit& hit) const;
195  virtual std::vector<digitizerUtility::SignalPoint> drift(
196  const PSimHit& hit,
197  const Phase2TrackerGeomDetUnit* pixdet,
198  const GlobalVector& bfield,
199  const std::vector<digitizerUtility::EnergyDepositUnit>& ionization_points) const;
200  virtual void induce_signal(std::vector<PSimHit>::const_iterator inputBegin,
201  const PSimHit& hit,
202  const size_t hitIndex,
203  const size_t firstHitIndex,
204  const uint32_t tofBin,
205  const Phase2TrackerGeomDetUnit* pixdet,
206  const std::vector<digitizerUtility::SignalPoint>& collection_points);
207  virtual std::vector<float> fluctuateEloss(
208  int particleId, float momentum, float eloss, float length, int NumberOfSegments) const;
209  virtual void add_noise(const Phase2TrackerGeomDetUnit* pixdet);
210  virtual void add_cross_talk(const Phase2TrackerGeomDetUnit* pixdet);
211  virtual void add_noisy_cells(const Phase2TrackerGeomDetUnit* pixdet, float thePixelThreshold);
212  virtual void pixel_inefficiency(const SubdetEfficiencies& eff,
213  const Phase2TrackerGeomDetUnit* pixdet,
214  const TrackerTopology* tTopo);
215 
216  virtual void pixel_inefficiency_db(uint32_t detID);
217 
218  // access to the gain calibration payloads in the db. Only gets initialized if check_dead_pixels_ is set to true.
219  const std::unique_ptr<SiPixelGainCalibrationOfflineSimService> theSiPixelGainCalibrationService_;
220 
222  const GlobalVector& bfield,
223  const DetId& detId) const;
224 
225  // remove dead modules using the list in the configuration file PixelDigi_cfi.py
226  virtual void module_killing_conf(uint32_t detID);
227  // remove dead modules uisng the list in the DB
228  virtual void module_killing_DB(const Phase2TrackerGeomDetUnit* pixdet) = 0;
229 
231  float calcQ(float x);
232 
233  // For random numbers
234  std::unique_ptr<CLHEP::RandGaussQ> gaussDistribution_;
235 
236  // Threshold gaussian smearing:
237  std::unique_ptr<CLHEP::RandGaussQ> smearedThreshold_Endcap_;
238  std::unique_ptr<CLHEP::RandGaussQ> smearedThreshold_Barrel_;
239 
240  //for engine passed into the constructor from Digitizer
241  CLHEP::HepRandomEngine* rengine_;
242 
243  // convert signal in electrons to ADC counts
244  int convertSignalToAdc(uint32_t detID, float signal_in_elec, float threshold);
245 
247 };
248 #endif
virtual std::vector< digitizerUtility::EnergyDepositUnit > primary_ionization(const PSimHit &hit) const
virtual bool select_hit(const PSimHit &hit, double tCorr, double &sigScale) const
void loadAccumulator(uint32_t detId, const std::map< int, float > &accumulator)
constexpr double c_cm_ns
LocalVector driftDirection(const Phase2TrackerGeomDetUnit *pixdet, const GlobalVector &bfield, const DetId &detId) const
virtual void initializeEvent(CLHEP::HepRandomEngine &eng)
virtual void induce_signal(std::vector< PSimHit >::const_iterator inputBegin, const PSimHit &hit, const size_t hitIndex, const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit *pixdet, const std::vector< digitizerUtility::SignalPoint > &collection_points)
virtual void add_cross_talk(const Phase2TrackerGeomDetUnit *pixdet)
const SiPixelLorentzAngle * siPixelLorentzAngle_
const std::unique_ptr< SiG4UniversalFluctuation > fluctuate_
const std::unique_ptr< SiPixelChargeReweightingAlgorithm > theSiPixelChargeReweightingAlgorithm_
std::map< int, digitizerUtility::Ph2Amplitude, std::less< int > > signal_map_type
virtual void add_noise(const Phase2TrackerGeomDetUnit *pixdet)
virtual void module_killing_conf(uint32_t detID)
const std::unique_ptr< SiPixelGainCalibrationOfflineSimService > theSiPixelGainCalibrationService_
virtual void add_noisy_cells(const Phase2TrackerGeomDetUnit *pixdet, float thePixelThreshold)
std::unique_ptr< CLHEP::RandGaussQ > gaussDistribution_
virtual void accumulateSimHits(const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, const size_t inputBeginGlobalIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit *pixdet, const GlobalVector &bfield)
virtual void init(const edm::EventSetup &es)=0
virtual bool isAboveThreshold(const digitizerUtility::SimHitInfo *hitInfo, float charge, float thr) const
Phase2TrackerDigitizerAlgorithm(const edm::ParameterSet &conf_common, const edm::ParameterSet &conf_specific, edm::ConsumesCollector iC)
const std::unique_ptr< GaussianTailNoiseGenerator > theNoiser_
virtual std::vector< float > fluctuateEloss(int particleId, float momentum, float eloss, float length, int NumberOfSegments) const
virtual void pixel_inefficiency_db(uint32_t detID)
std::unique_ptr< CLHEP::RandGaussQ > smearedThreshold_Endcap_
std::vector< edm::ParameterSet > Parameters
constexpr double c_inv
Definition: DetId.h:17
const SiPhase2OuterTrackerLorentzAngle * siPhase2OTLorentzAngle_
virtual void digitize(const Phase2TrackerGeomDetUnit *pixdet, std::map< int, digitizerUtility::DigiSimInfo > &digi_map, const TrackerTopology *tTopo)
std::unique_ptr< CLHEP::RandGaussQ > smearedThreshold_Barrel_
virtual void pixel_inefficiency(const SubdetEfficiencies &eff, const Phase2TrackerGeomDetUnit *pixdet, const TrackerTopology *tTopo)
std::map< uint32_t, signal_map_type > signalMaps
virtual std::vector< digitizerUtility::SignalPoint > drift(const PSimHit &hit, const Phase2TrackerGeomDetUnit *pixdet, const GlobalVector &bfield, const std::vector< digitizerUtility::EnergyDepositUnit > &ionization_points) const
virtual void module_killing_DB(const Phase2TrackerGeomDetUnit *pixdet)=0
int convertSignalToAdc(uint32_t detID, float signal_in_elec, float threshold)