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 HcalGeometry* geom, const DetId& detid) {
32  //base time samples for each DetId, initialized to 0
33  info.size = 1.0;
34  info.thickness = 1.0;
35  }
36 
37  inline void addCellMetadata(HGCCellInfo& info, const HGCalGeometry* geom, const DetId& detid) {
38  const auto& dddConst = geom->topology().dddConstants();
39  bool isHalf = (((dddConst.geomMode() == HGCalGeometryMode::Hexagon) ||
40  (dddConst.geomMode() == HGCalGeometryMode::HexagonFull))
41  ? dddConst.isHalfCell(HGCalDetId(detid).wafer(), HGCalDetId(detid).cell())
42  : false);
43  //base time samples for each DetId, initialized to 0
44  info.size = (isHalf ? 0.5 : 1.0);
45  info.thickness = 1 + dddConst.waferType(detid);
46  }
47 
48  inline void addCellMetadata(HGCCellInfo& info, const CaloSubdetectorGeometry* geom, const DetId& detid) {
49  if (DetId::Hcal == detid.det()) {
50  const HcalGeometry* hc = static_cast<const HcalGeometry*>(geom);
51  addCellMetadata(info, hc, detid);
52  } else {
53  const HGCalGeometry* hg = static_cast<const HGCalGeometry*>(geom);
54  addCellMetadata(info, hg, detid);
55  }
56  }
57 
58 } // namespace hgc_digi_utils
59 
60 template <class DFr>
62 public:
63  typedef DFr DigiType;
64 
66 
74  void GenerateGaussianNoise(CLHEP::HepRandomEngine* engine, const double NoiseMean, const double NoiseStd);
78  void run(std::unique_ptr<DColl>& digiColl,
80  const CaloSubdetectorGeometry* theGeom,
81  const std::unordered_set<DetId>& validIds,
82  uint32_t digitizationType,
83  CLHEP::HepRandomEngine* engine);
84 
88  float keV2fC() const { return keV2fC_; }
89  bool toaModeByEnergy() const { return (myFEelectronics_->toaMode() == HGCFEElectronics<DFr>::WEIGHTEDBYE); }
90  float tdcOnset() const { return myFEelectronics_->getTDCOnset(); }
91  std::array<float, 3> tdcForToAOnset() const { return myFEelectronics_->getTDCForToAOnset(); }
92 
96  void runSimple(std::unique_ptr<DColl>& coll,
98  const CaloSubdetectorGeometry* theGeom,
99  const std::unordered_set<DetId>& validIds,
100  CLHEP::HepRandomEngine* engine);
101 
105  void updateOutput(std::unique_ptr<DColl>& coll, const DFr& rawDataFrame);
106 
110  virtual void runDigitizer(std::unique_ptr<DColl>& coll,
112  const CaloSubdetectorGeometry* theGeom,
113  const std::unordered_set<DetId>& validIds,
114  uint32_t digitizerType,
115  CLHEP::HepRandomEngine* engine) {
116  throw cms::Exception("HGCDigitizerBaseException") << " Failed to find specialization of runDigitizer";
117  }
118 
122  virtual ~HGCDigitizerBase(){};
123 
124 protected:
125  //baseline configuration
127 
128  //1keV in fC
129  float keV2fC_;
130 
131  //noise level (used if scaleByDose=False)
132  std::vector<float> noise_fC_;
133 
134  //charge collection efficiency (used if scaleByDose=False)
135  std::vector<double> cce_;
136 
137  //determines if the dose map should be used instead
139 
140  //path to dose map
142 
143  //noise maps (used if scaleByDose=True)
145 
146  //front-end electronics model
147  std::unique_ptr<HGCFEElectronics<DFr> > myFEelectronics_;
148 
149  //bunch time
150  double bxTime_;
151 
152  //if true will put both in time and out-of-time samples in the event
154 
155  //if set to true, threshold will be computed based on the expected meap peak/2
157 
158  // New NoiseArray Parameters
159 
160  const double NoiseMean_, NoiseStd_;
161  static const size_t NoiseArrayLength_ = 200000;
162  static const size_t samplesize_ = 15;
163  std::array<std::array<double, samplesize_>, NoiseArrayLength_> GaussianNoiseArray_;
165  // A parameter configurable from python configuration to decide which noise generation model to use
167 };
168 
169 #endif
HGCDigitizerBase::bxTime_
double bxTime_
Definition: HGCDigitizerBase.h:150
DigiToRawDM_cff.digiColl
digiColl
Definition: DigiToRawDM_cff.py:32
HGCDigitizerBase::HGCDigitizerBase
HGCDigitizerBase(const edm::ParameterSet &ps)
CTOR.
Definition: HGCDigitizerBase.cc:9
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:72
HGCDigitizerBase::GaussianNoiseArray_
std::array< std::array< double, samplesize_ >, NoiseArrayLength_ > GaussianNoiseArray_
Definition: HGCDigitizerBase.h:163
HGCalSiNoiseMap.h
HGCDigitizerBase::RandNoiseGenerationFlag_
bool RandNoiseGenerationFlag_
Definition: HGCDigitizerBase.h:164
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
HGCDigitizerBase::NoiseStd_
const double NoiseStd_
Definition: HGCDigitizerBase.h:160
DetId::Hcal
Definition: DetId.h:28
HGCDigitizerBase::NoiseGeneration_Method_
bool NoiseGeneration_Method_
Definition: HGCDigitizerBase.h:166
HGCDigitizerBase::scaleByDose_
bool scaleByDose_
Definition: HGCDigitizerBase.h:138
HGCDigitizerBase::DigiType
DFr DigiType
Definition: HGCDigitizerBase.h:63
edm::SortedCollection
Definition: SortedCollection.h:49
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
hgc_digi_utils
Definition: HGCDigitizerBase.h:28
HcalGeometry.h
hgc_digi
Definition: HGCDigitizerTypes.h:10
HGCDigitizerBase::GenerateGaussianNoise
void GenerateGaussianNoise(CLHEP::HepRandomEngine *engine, const double NoiseMean, const double NoiseStd)
Gaussian Noise Generation Member Function.
Definition: HGCDigitizerBase.cc:61
HGCDigitizerBase::runDigitizer
virtual void runDigitizer(std::unique_ptr< DColl > &coll, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, uint32_t digitizerType, CLHEP::HepRandomEngine *engine)
to be specialized by top class
Definition: HGCDigitizerBase.h:110
EDMException.h
DetId
Definition: DetId.h:17
HGCDigitizerBase::doseMapFile_
std::string doseMapFile_
Definition: HGCDigitizerBase.h:141
HGCDigitizerBase::tdcOnset
float tdcOnset() const
Definition: HGCDigitizerBase.h:90
hgc_digi_utils::addCellMetadata
void addCellMetadata(HGCCellInfo &info, const HcalGeometry *geom, const DetId &detid)
Definition: HGCDigitizerBase.h:31
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
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:179
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 without noise
Definition: HGCDigitizerBase.cc:93
HGCDigitizerBase::noise_fC_
std::vector< float > noise_fC_
Definition: HGCDigitizerBase.h:132
HGCFEElectronics
models the behavior of the front-end electronics
Definition: HGCFEElectronics.h:20
HGCalGeometry
Definition: HGCalGeometry.h:30
HGCDigitizerBase::keV2fC
float keV2fC() const
getters
Definition: HGCDigitizerBase.h:88
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
hgc_digi::HGCCellInfo
Definition: HGCDigitizerTypes.h:31
HGCDigitizerBase::NoiseArrayLength_
static const size_t NoiseArrayLength_
Definition: HGCDigitizerBase.h:161
HGCDigitizerBase::keV2fC_
float keV2fC_
Definition: HGCDigitizerBase.h:129
HGCalSiNoiseMap
derives from HGCalRadiation map to parse fluence parameters, provides Si-specific functions; see DN-1...
Definition: HGCalSiNoiseMap.h:14
CaloSubdetectorGeometry.h
HGCalGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:36
hgcalDigitizer_cfi.digitizationType
digitizationType
Definition: hgcalDigitizer_cfi.py:79
HGCDigitizerBase::doTimeSamples_
bool doTimeSamples_
Definition: HGCDigitizerBase.h:153
HGCDigitizerBase::samplesize_
static const size_t samplesize_
Definition: HGCDigitizerBase.h:162
HGCDigitizerBase::scal_
HGCalSiNoiseMap scal_
Definition: HGCDigitizerBase.h:144
HGCDigiCollections.h
HGCDigitizerBase::tdcForToAOnset
std::array< float, 3 > tdcForToAOnset() const
Definition: HGCDigitizerBase.h:91
hgc_digi::HGCSimHitDataAccumulator
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
Definition: HGCDigitizerTypes.h:38
HGCalGeometryMode::Hexagon
Definition: HGCalGeometryMode.h:25
HGCDigitizerTypes.h
HGCalDetId
Definition: HGCalDetId.h:8
HGCalGeometryMode::HexagonFull
Definition: HGCalGeometryMode.h:25
HGCDigitizerBase
Definition: HGCDigitizerBase.h:61
HGCDigitizerBase::thresholdFollowsMIP_
bool thresholdFollowsMIP_
Definition: HGCDigitizerBase.h:156
Exception
Definition: hltDiff.cc:246
HGCFEElectronics.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
HGCDigitizerBase::NoiseMean_
const double NoiseMean_
Definition: HGCDigitizerBase.h:160
ConsumesCollector.h
ParameterSet.h
HGCDigitizerBase::toaModeByEnergy
bool toaModeByEnergy() const
Definition: HGCDigitizerBase.h:89
HcalGeometry
Definition: HcalGeometry.h:17
HGCDigitizerBase::~HGCDigitizerBase
virtual ~HGCDigitizerBase()
DTOR.
Definition: HGCDigitizerBase.h:122
HGCDigitizerBase::DColl
edm::SortedCollection< DFr > DColl
Definition: HGCDigitizerBase.h:65
HGCDigitizerBase::myCfg_
edm::ParameterSet myCfg_
Definition: HGCDigitizerBase.h:122
HGCDigitizerBase::cce_
std::vector< double > cce_
Definition: HGCDigitizerBase.h:135
HGCDigitizerBase::myFEelectronics_
std::unique_ptr< HGCFEElectronics< DFr > > myFEelectronics_
Definition: HGCDigitizerBase.h:147