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);
40  }
41 
42  inline void addCellMetadata(HGCCellInfo& info, const CaloSubdetectorGeometry* geom, const DetId& detid) {
43  if (DetId::Hcal == detid.det()) {
44  const HcalGeometry* hc = static_cast<const HcalGeometry*>(geom);
45  addCellMetadata(info, hc, detid);
46  } else {
47  const HGCalGeometry* hg = static_cast<const HGCalGeometry*>(geom);
48  addCellMetadata(info, hg, detid);
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
DigiToRawDM_cff.digiColl
digiColl
Definition: DigiToRawDM_cff.py:32
HGCDigitizerBase::DFr
HGCalDataFrame DFr
Definition: HGCDigitizerBase.h:56
HGCDigitizerBase::samplesize_
static const size_t samplesize_
Definition: HGCDigitizerBase.h:167
HGCDigitizerBase::keV2fC
float keV2fC() const
getters
Definition: HGCDigitizerBase.h:80
HGCDigitizerBase::GaussianNoiseArray_
std::array< std::array< double, samplesize_ >, NoiseArrayLength_ > GaussianNoiseArray_
Definition: HGCDigitizerBase.h:168
HGCDigitizerBase::doTimeSamples_
bool doTimeSamples_
Definition: HGCDigitizerBase.h:147
ForwardSubdetector
ForwardSubdetector
Definition: ForwardSubdetector.h:4
HGCDigitizerBase::scaleByDoseFactor_
double scaleByDoseFactor_
Definition: HGCDigitizerBase.h:131
HGCDigitizerBase::NoiseStd_
const double NoiseStd_
Definition: HGCDigitizerBase.h:165
HGCalSiNoiseMap.h
HGCDigitizerBase::tdcOnset
float tdcOnset() const
Definition: HGCDigitizerBase.h:82
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
DetId::Hcal
Definition: DetId.h:28
HGCDigitizerBase::doseMapFile_
std::string doseMapFile_
Definition: HGCDigitizerBase.h:134
HGCDigitizerBase::~HGCDigitizerBase
virtual ~HGCDigitizerBase()
DTOR.
Definition: HGCDigitizerBase.h:112
edm::SortedCollection
Definition: SortedCollection.h:49
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
HGCDigitizerBase::run
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
Definition: HGCDigitizerBase.cc:90
hgc_digi_utils
Definition: HGCDigitizerBase.h:28
HGCDigitizerBase::det_
DetId::Detector det_
Definition: HGCDigitizerBase.h:156
HGCDigitizerBase::thresholdFollowsMIP_
bool thresholdFollowsMIP_
Definition: HGCDigitizerBase.h:150
HcalGeometry.h
HGCDigitizerBase::NoiseGeneration_Method_
bool NoiseGeneration_Method_
Definition: HGCDigitizerBase.h:171
hgc_digi
Definition: HGCDigitizerTypes.h:10
EDMException.h
DetId
Definition: DetId.h:17
HGCDigitizerBase::bxTime_
double bxTime_
Definition: HGCDigitizerBase.h:144
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
HGCDigitizerBase::scal_
HGCalSiNoiseMap< HGCSiliconDetId > scal_
Definition: HGCDigitizerBase.h:137
HGCFEElectronics
models the behavior of the front-end electronics
Definition: HGCFEElectronics.h:24
HGCalGeometry
Definition: HGCalGeometry.h:29
hgc_digi::HGCCellInfo
Definition: HGCDigitizerTypes.h:31
HGCDigitizerBase::GenerateGaussianNoise
void GenerateGaussianNoise(CLHEP::HepRandomEngine *engine, const double NoiseMean, const double NoiseStd)
Gaussian Noise Generation Member Function.
Definition: HGCDigitizerBase.cc:80
HGCDigitizerBase::keV2fC_
float keV2fC_
Definition: HGCDigitizerBase.h:119
HGCalSiNoiseMap< HGCSiliconDetId >
CaloSubdetectorGeometry.h
HGCalGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
hgcalDigitizer_cfi.digitizationType
digitizationType
Definition: hgcalDigitizer_cfi.py:86
HGCDigitizerBase::toaModeByEnergy
bool toaModeByEnergy() const
Definition: HGCDigitizerBase.h:81
HGCDataFrame
Readout digi for HGC.
Definition: HGCDataFrame.h:14
HGCDigitizerBase::runSimple
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
Definition: HGCDigitizerBase.cc:112
HGCDigiCollections.h
HGCDigitizerBase::subdet
ForwardSubdetector subdet() const
Definition: HGCDigitizerBase.h:85
HGCDigitizerBase::scalHFNose_
HGCalSiNoiseMap< HFNoseDetId > scalHFNose_
Definition: HGCDigitizerBase.h:138
DetId::Detector
Detector
Definition: DetId.h:24
hgc_digi::HGCSimHitDataAccumulator
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
Definition: HGCDigitizerTypes.h:38
HGCDigitizerBase::cce_
std::vector< double > cce_
Definition: HGCDigitizerBase.h:125
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalGeometryMode::Hexagon
Definition: HGCalGeometryMode.h:27
HGCDigitizerTypes.h
HGCalDetId
Definition: HGCalDetId.h:8
HGCalGeometryMode::HexagonFull
Definition: HGCalGeometryMode.h:28
HGCDigitizerBase::runDigitizer
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
HGCDigitizerBase
Definition: HGCDigitizerBase.h:54
HGCDigitizerBase::DColl
edm::SortedCollection< DFr > DColl
Definition: HGCDigitizerBase.h:57
HGCDigitizerBase::HGCDigitizerBase
HGCDigitizerBase(const edm::ParameterSet &ps)
CTOR.
Definition: HGCDigitizerBase.cc:9
hgc_digi_utils::addCellMetadata
void addCellMetadata(HGCCellInfo &info, const HGCalGeometry *geom, const DetId &detid)
Definition: HGCDigitizerBase.h:31
HGCDigitizerBase::tdcForToAOnset
std::array< float, 3 > tdcForToAOnset() const
Definition: HGCDigitizerBase.h:83
HGCFEElectronics.h
HGCDigitizerBase::updateOutput
void updateOutput(std::unique_ptr< DColl > &coll, const DFr &rawDataFrame)
prepares the output according to the number of time samples to produce
Definition: HGCDigitizerBase.cc:218
HGCDigitizerBase::noise_fC_
std::vector< float > noise_fC_
Definition: HGCDigitizerBase.h:122
HGCDigitizerBase::myFEelectronics_
std::unique_ptr< HGCFEElectronics< DFr > > myFEelectronics_
Definition: HGCDigitizerBase.h:141
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
HGCDigitizerBase::NoiseArrayLength_
static const size_t NoiseArrayLength_
Definition: HGCDigitizerBase.h:166
HGCDigitizerBase::RandNoiseGenerationFlag_
bool RandNoiseGenerationFlag_
Definition: HGCDigitizerBase.h:169
HGCDigitizerBase::NoiseMean_
const double NoiseMean_
Definition: HGCDigitizerBase.h:165
ConsumesCollector.h
HGCDigitizerBase::subdet_
ForwardSubdetector subdet_
Definition: HGCDigitizerBase.h:161
ParameterSet.h
HcalGeometry
Definition: HcalGeometry.h:17
HGCDigitizerBase::scaleByDose_
bool scaleByDose_
Definition: HGCDigitizerBase.h:128
HGCDigitizerBase::det
DetId::Detector det() const
Definition: HGCDigitizerBase.h:84
HGCDigitizerBase::myCfg_
edm::ParameterSet myCfg_
Definition: HGCDigitizerBase.h:112