File indexing completed on 2023-03-17 11:23:55
0001 #ifndef simcalorimetry_hgcalsimalgos_hgcalsinoisemap
0002 #define simcalorimetry_hgcalsimalgos_hgcalsinoisemap
0003
0004 #include "SimCalorimetry/HGCalSimAlgos/interface/HGCalRadiationMap.h"
0005 #include "SimCalorimetry/HGCalSimProducers/interface/HGCFEElectronics.h"
0006 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0007 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0008 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0009 #include <string>
0010 #include <array>
0011 #include <unordered_map>
0012
0013
0014
0015
0016
0017 template <typename T>
0018 class HGCalSiNoiseMap : public HGCalRadiationMap {
0019 public:
0020 enum GainRange_t { q80fC, q160fC, q320fC, AUTO };
0021 enum NoiseMapAlgoBits_t { FLUENCE, CCE, NOISE, PULSEPERGAIN, CACHEDOP };
0022
0023 struct SiCellOpCharacteristicsCore {
0024 SiCellOpCharacteristicsCore() : cce(0.), noise(0.), gain(0), thrADC(0) {}
0025 float cce, noise;
0026 unsigned short gain, thrADC;
0027 };
0028
0029 struct SiCellOpCharacteristics {
0030 SiCellOpCharacteristics() : lnfluence(0.), fluence(0.), ileak(0.), enc_s(0.), enc_p(0.), mipfC(0), mipADC(0) {}
0031 SiCellOpCharacteristicsCore core;
0032 double lnfluence, fluence, ileak, enc_s, enc_p, mipfC;
0033 unsigned int mipADC;
0034 };
0035
0036 HGCalSiNoiseMap();
0037 ~HGCalSiNoiseMap(){};
0038
0039
0040
0041
0042 void setIleakParam(const std::vector<double> &pars) { ileakParam_ = pars; }
0043
0044
0045
0046
0047 void setCceParam(const std::vector<double> &parsFine,
0048 const std::vector<double> &parsThin,
0049 const std::vector<double> &parsThick) {
0050 cceParam_.push_back(parsFine);
0051 cceParam_.push_back(parsThin);
0052 cceParam_.push_back(parsThick);
0053 }
0054
0055
0056
0057
0058 void setDoseMap(const std::string &, const unsigned int &);
0059
0060
0061
0062
0063
0064
0065 void setGeometry(const CaloSubdetectorGeometry *, GainRange_t gain = GainRange_t::AUTO, int aimMIPtoADC = 10);
0066
0067
0068
0069
0070
0071 const SiCellOpCharacteristicsCore getSiCellOpCharacteristicsCore(const T &did, GainRange_t gain, int aimMIPtoADC);
0072 const SiCellOpCharacteristicsCore getSiCellOpCharacteristicsCore(const T &did) {
0073 return getSiCellOpCharacteristicsCore(did, defaultGain_, defaultAimMIPtoADC_);
0074 }
0075
0076 SiCellOpCharacteristics getSiCellOpCharacteristics(const T &did,
0077 GainRange_t gain = GainRange_t::AUTO,
0078 int aimMIPtoADC = 10);
0079 SiCellOpCharacteristics getSiCellOpCharacteristics(double &cellCap,
0080 double &cellVol,
0081 double &mipEqfC,
0082 std::vector<double> &cceParam,
0083 int &subdet,
0084 int &layer,
0085 double &radius,
0086 GainRange_t &gain,
0087 int &aimMIPtoADC);
0088
0089 std::array<double, 3> &getMipEqfC() { return mipEqfC_; }
0090 std::array<double, 3> &getCellCapacitance() { return cellCapacitance_; }
0091 std::array<double, 3> &getCellVolume() { return cellVolume_; }
0092 std::vector<std::vector<double> > &getCCEParam() { return cceParam_; }
0093 std::vector<double> &getIleakParam() { return ileakParam_; }
0094 std::vector<std::vector<double> > &getENCsParam() { return encsParam_; }
0095 std::vector<double> &getLSBPerGain() { return lsbPerGain_; }
0096 void setDefaultADCPulseShape(const hgc_digi::FEADCPulseShape &adcPulse) { defaultADCPulse_ = adcPulse; };
0097 const hgc_digi::FEADCPulseShape &adcPulseForGain(GainRange_t gain) {
0098 if (ignoreGainDependentPulse_)
0099 return defaultADCPulse_;
0100 return adcPulses_[gain];
0101 };
0102 std::vector<double> &getMaxADCPerGain() { return chargeAtFullScaleADCPerGain_; }
0103 double getENCpad(double ileak);
0104 void setCachedOp(bool flag) { activateCachedOp_ = flag; }
0105 double getTDCOnsetAuto(uint32_t gainIdx);
0106
0107 inline void setENCCommonNoiseSubScale(double val) { encCommonNoiseSub_ = val; }
0108
0109 private:
0110 GainRange_t defaultGain_;
0111 int defaultAimMIPtoADC_;
0112
0113
0114 std::map<uint32_t, SiCellOpCharacteristicsCore> siopCache_;
0115
0116
0117 std::array<double, 3> mipEqfC_, cellCapacitance_, cellVolume_;
0118 std::vector<std::vector<double> > cceParam_;
0119
0120
0121 std::vector<double> ileakParam_;
0122
0123
0124 double encCommonNoiseSub_;
0125
0126
0127 const double qe2fc_;
0128
0129
0130 std::vector<std::vector<double> > encsParam_;
0131 hgc_digi::FEADCPulseShape defaultADCPulse_;
0132 std::vector<hgc_digi::FEADCPulseShape> adcPulses_;
0133
0134
0135 std::vector<double> lsbPerGain_, chargeAtFullScaleADCPerGain_;
0136
0137
0138 const double unitToMicro_ = 1.e6;
0139 const double unitToMicroLog_ = log(unitToMicro_);
0140
0141
0142 bool ignoreFluence_, ignoreCCE_, ignoreNoise_, ignoreGainDependentPulse_, activateCachedOp_;
0143 };
0144
0145 #include "HGCalSiNoiseMap.icc"
0146
0147 template class HGCalSiNoiseMap<HGCSiliconDetId>;
0148 template class HGCalSiNoiseMap<HFNoseDetId>;
0149
0150 #endif