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