CMS 3D CMS Logo

HGCDigitizerBase.h
Go to the documentation of this file.
1 #ifndef SimCalorimetry_HGCSimProducers_hgcdigitizerbase
2 #define SimCalorimetry_HGCSimProducers_hgcdigitizerbase
3 
4 #include <array>
5 #include <iostream>
6 #include <vector>
7 #include <memory>
8 #include <unordered_map>
9 #include <unordered_set>
10 
15 
17 
19 
23 
25 
26 namespace hgc = hgc_digi;
27 
28 namespace hgc_digi_utils {
29  using hgc::HGCCellInfo;
30 
31  inline void addCellMetadata(HGCCellInfo& info, const HGCalGeometry* geom, const DetId& detid) {
32  const auto& dddConst = geom->topology().dddConstants();
33  bool isHalf = (((dddConst.geomMode() == HGCalGeometryMode::Hexagon) ||
34  (dddConst.geomMode() == HGCalGeometryMode::HexagonFull))
35  ? dddConst.isHalfCell(HGCalDetId(detid).wafer(), HGCalDetId(detid).cell())
36  : false);
37  //base time samples for each DetId, initialized to 0
38  info.size = (isHalf ? 0.5 : 1.0);
39  info.thickness = 1 + dddConst.waferType(detid, false);
40  }
41 
43  if (DetId::Hcal == detid.det()) {
44  const HcalGeometry* hc = static_cast<const HcalGeometry*>(geom);
46  } else {
47  const HGCalGeometry* hg = static_cast<const HGCalGeometry*>(geom);
49  }
50  }
51 
52 } // namespace hgc_digi_utils
53 
55 public:
58 
66  void GenerateGaussianNoise(CLHEP::HepRandomEngine* engine, const double NoiseMean, const double NoiseStd);
70  void run(std::unique_ptr<DColl>& digiColl,
72  const CaloSubdetectorGeometry* theGeom,
73  const std::unordered_set<DetId>& validIds,
74  uint32_t digitizationType,
75  CLHEP::HepRandomEngine* engine);
76 
80  float keV2fC() const { return keV2fC_; }
81  bool toaModeByEnergy() const { return (myFEelectronics_->toaMode() == HGCFEElectronics<DFr>::WEIGHTEDBYE); }
82  float tdcOnset() const { return myFEelectronics_->getTDCOnset(); }
83  std::array<float, 3> tdcForToAOnset() const { return myFEelectronics_->getTDCForToAOnset(); }
84  DetId::Detector det() const { return det_; }
85  ForwardSubdetector subdet() const { return subdet_; }
86 
90  void runSimple(std::unique_ptr<DColl>& coll,
92  const CaloSubdetectorGeometry* theGeom,
93  const std::unordered_set<DetId>& validIds,
94  CLHEP::HepRandomEngine* engine);
95 
99  void updateOutput(std::unique_ptr<DColl>& coll, const DFr& rawDataFrame);
100 
104  virtual void runDigitizer(std::unique_ptr<DColl>& coll,
106  const CaloSubdetectorGeometry* theGeom,
107  const std::unordered_set<DetId>& validIds,
108  CLHEP::HepRandomEngine* engine) = 0;
112  virtual ~HGCDigitizerBase() {}
113 
114 protected:
115  //baseline configuration
117 
118  //1keV in fC
119  float keV2fC_;
120 
121  //noise level (used if scaleByDose=False)
122  std::vector<float> noise_fC_;
123 
124  //charge collection efficiency (used if scaleByDose=False)
125  std::vector<double> cce_;
126 
127  //determines if the dose map should be used instead
129 
130  //multiplicative fator to scale fluence map
132 
133  //path to dose map
135 
136  //noise maps (used if scaleByDose=True)
139 
140  //front-end electronics model
141  std::unique_ptr<HGCFEElectronics<DFr> > myFEelectronics_;
142 
143  //bunch time
144  double bxTime_;
145 
146  //if true will put both in time and out-of-time samples in the event
148 
149  //if set to true, threshold will be computed based on the expected meap peak/2
151 
152  // Identify the detector components, i.e. DetIds, that will be managed by
153  // this digitizer. This information will be used to fetch the correct
154  // geometry and the full list of detids for which a digitization is
155  // requested.
157 
158  // Identify the subdetector components that will be managed by this
159  // digitizer. This information will be used to fetch the correct geometry and
160  // the full list of detids for which a digitization is requested.
162 
163  // New NoiseArray Parameters
164 
165  const double NoiseMean_, NoiseStd_;
166  static const size_t NoiseArrayLength_ = 200000;
167  static const size_t samplesize_ = 15;
168  std::array<std::array<double, samplesize_>, NoiseArrayLength_> GaussianNoiseArray_;
170  // A parameter configurable from python configuration to decide which noise generation model to use
172 };
173 
174 #endif
HGCalSiNoiseMap< HGCSiliconDetId > scal_
std::vector< double > cce_
bool toaModeByEnergy() const
static const TGPicture * info(bool iBackgroundIsBlack)
void runSimple(std::unique_ptr< DColl > &coll, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, CLHEP::HepRandomEngine *engine)
a trivial digitization: sum energies and digitize
ForwardSubdetector subdet() const
HGCalSiNoiseMap< HFNoseDetId > scalHFNose_
HGCDigitizerBase(const edm::ParameterSet &ps)
CTOR.
void GenerateGaussianNoise(CLHEP::HepRandomEngine *engine, const double NoiseMean, const double NoiseStd)
Gaussian Noise Generation Member Function.
static const size_t NoiseArrayLength_
void updateOutput(std::unique_ptr< DColl > &coll, const DFr &rawDataFrame)
prepares the output according to the number of time samples to produce
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
ForwardSubdetector subdet_
std::array< float, 3 > tdcForToAOnset() const
std::unique_ptr< HGCFEElectronics< DFr > > myFEelectronics_
ForwardSubdetector
edm::SortedCollection< DFr > DColl
const double NoiseMean_
virtual void runDigitizer(std::unique_ptr< DColl > &coll, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, CLHEP::HepRandomEngine *engine)=0
to be specialized by top class
DetId::Detector det() const
std::vector< float > noise_fC_
HGCalDataFrame DFr
std::string doseMapFile_
void addCellMetadata(HGCCellInfo &info, const HGCalGeometry *geom, const DetId &detid)
virtual ~HGCDigitizerBase()
DTOR.
float tdcOnset() const
static const size_t samplesize_
edm::ParameterSet myCfg_
Definition: DetId.h:17
const double NoiseStd_
Detector
Definition: DetId.h:24
std::array< std::array< double, samplesize_ >, NoiseArrayLength_ > GaussianNoiseArray_
float keV2fC() const
getters
Readout digi for HGC.
Definition: HGCDataFrame.h:14
void run(std::unique_ptr< DColl > &digiColl, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, uint32_t digitizationType, CLHEP::HepRandomEngine *engine)
steer digitization mode
models the behavior of the front-end electronics
DetId::Detector det_