File indexing completed on 2024-09-10 02:59:04
0001 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h"
0002
0003 template <>
0004 CaloSamples EcalSignalGenerator<EBDigitizerTraits>::samplesInPE(const DIGI &digi) {
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 DetId detId = digi.id();
0016
0017 double Emax = fullScaleEnergy(detId);
0018 double LSB[NGAINS + 1];
0019
0020
0021
0022 double icalconst = 1.;
0023
0024 const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
0025 EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
0026 if (icalit != icalMap.end()) {
0027 icalconst = (*icalit);
0028 }
0029
0030 double peToA = peToAConversion(detId);
0031
0032 const std::vector<float> gainRatios = GetGainRatios(detId);
0033
0034 for (unsigned int igain(0); igain <= NGAINS; ++igain) {
0035 LSB[igain] = 0.;
0036 if (igain > 0)
0037 LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
0038 }
0039
0040
0041
0042 CaloSamples result(detId, digi.size());
0043
0044
0045 double correction_factor_for_premixed_sample_transparency = 1.0;
0046 double value_LC = 1.;
0047 if (m_timeDependent) {
0048 if (detId.subdetId() != EcalSubdetector::EcalPreshower) {
0049 auto cache = m_valueLCCache_LC.find(detId);
0050 if (cache != m_valueLCCache_LC.end()) {
0051 value_LC = cache->second;
0052 } else {
0053 value_LC = findLaserConstant_LC(detId);
0054 m_valueLCCache_LC.emplace(detId, value_LC);
0055 }
0056 }
0057 }
0058
0059 double value_LC_prime = 1.;
0060
0061 if (m_timeDependent) {
0062 if (detId.subdetId() != EcalSubdetector::EcalPreshower) {
0063 auto cache = m_valueLCCache_LC_prime.find(detId);
0064 if (cache != m_valueLCCache_LC_prime.end()) {
0065 value_LC_prime = cache->second;
0066 } else {
0067 value_LC_prime = findLaserConstant_LC_prime(detId);
0068 m_valueLCCache_LC_prime.emplace(detId, value_LC_prime);
0069 }
0070 }
0071 }
0072
0073 correction_factor_for_premixed_sample_transparency = value_LC_prime / value_LC;
0074
0075
0076
0077
0078 for (int isample = 0; isample < digi.size(); ++isample) {
0079 int gainId = digi[isample].gainId();
0080
0081
0082 if (gainId == 1) {
0083 result[isample] = float(digi[isample].adc()) / 1000. / peToA *
0084 correction_factor_for_premixed_sample_transparency;
0085 } else if (gainId > 1) {
0086 result[isample] =
0087 float(digi[isample].adc()) * LSB[gainId - 1] * icalconst / peToA *
0088 correction_factor_for_premixed_sample_transparency;
0089 }
0090 else {
0091 result[isample] =
0092 float(digi[isample].adc()) * LSB[gainId] * icalconst / peToA *
0093 correction_factor_for_premixed_sample_transparency;
0094
0095 }
0096
0097
0098
0099 }
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 return result;
0110 }
0111
0112 template <>
0113 CaloSamples EcalSignalGenerator<EEDigitizerTraits>::samplesInPE(const DIGI &digi) {
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 DetId detId = digi.id();
0125
0126 double Emax = fullScaleEnergy(detId);
0127 double LSB[NGAINS + 1];
0128
0129 double icalconst = 1.;
0130
0131 const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
0132 EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
0133 if (icalit != icalMap.end()) {
0134 icalconst = (*icalit);
0135 }
0136
0137 double peToA = peToAConversion(detId);
0138
0139 const std::vector<float> gainRatios = GetGainRatios(detId);
0140
0141 for (unsigned int igain(0); igain <= NGAINS; ++igain) {
0142 LSB[igain] = 0.;
0143 if (igain > 0)
0144 LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
0145 }
0146
0147
0148
0149 CaloSamples result(detId, digi.size());
0150
0151
0152 double correction_factor_for_premixed_sample_transparency = 1.0;
0153 double value_LC = 1.;
0154
0155 if (m_timeDependent) {
0156 if (detId.subdetId() != EcalSubdetector::EcalPreshower) {
0157 auto cache = m_valueLCCache_LC.find(detId);
0158 if (cache != m_valueLCCache_LC.end()) {
0159 value_LC = cache->second;
0160 } else {
0161 value_LC = findLaserConstant_LC(detId);
0162 m_valueLCCache_LC.emplace(detId, value_LC);
0163 }
0164 }
0165 }
0166
0167 double value_LC_prime = 1.;
0168 if (m_timeDependent) {
0169 if (detId.subdetId() != EcalSubdetector::EcalPreshower) {
0170 auto cache = m_valueLCCache_LC_prime.find(detId);
0171 if (cache != m_valueLCCache_LC_prime.end()) {
0172 value_LC_prime = cache->second;
0173 } else {
0174 value_LC_prime = findLaserConstant_LC_prime(detId);
0175 m_valueLCCache_LC_prime.emplace(detId, value_LC_prime);
0176 }
0177 }
0178 }
0179
0180 correction_factor_for_premixed_sample_transparency = value_LC_prime / value_LC;
0181
0182
0183
0184
0185 for (int isample = 0; isample < digi.size(); ++isample) {
0186 int gainId = digi[isample].gainId();
0187
0188
0189 if (gainId == 1) {
0190 result[isample] = float(digi[isample].adc()) / 1000. / peToA *
0191 correction_factor_for_premixed_sample_transparency;
0192 } else if (gainId > 1) {
0193 result[isample] = float(digi[isample].adc()) * LSB[gainId - 1] * icalconst / peToA *
0194 correction_factor_for_premixed_sample_transparency;
0195 }
0196 else {
0197 result[isample] = float(digi[isample].adc()) * LSB[gainId] * icalconst / peToA *
0198 correction_factor_for_premixed_sample_transparency;
0199 }
0200
0201
0202
0203 }
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213 return result;
0214 }
0215
0216 template <>
0217 CaloSamples EcalSignalGenerator<ESDigitizerTraits>::samplesInPE(const DIGI &digi) {
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228 DetId detId = digi.id();
0229
0230 double icalconst = 1.;
0231
0232 const ESIntercalibConstantMap &icalMap = esmips->getMap();
0233 ESIntercalibConstantMap::const_iterator icalit = icalMap.find(detId);
0234 if (icalit != icalMap.end()) {
0235 icalconst = double(*icalit);
0236 }
0237
0238 CaloSamples result(detId, digi.size());
0239
0240 for (int isample = 0; isample < digi.size(); ++isample) {
0241 result[isample] = float(digi[isample].adc()) / icalconst * ESMIPToGeV;
0242 }
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 return result;
0253 }