6 #include "CalibFormats/CaloObjects/interface/CaloTSamplesBase.icc"
21 m_gainRatios(nullptr),
76 const unsigned int csize(ecalSamples.
size());
82 if (ecalSamples[5] > 0.)
83 LogDebug(
"EcalCoder") <<
"Input caloSample"
88 double pedestals[
NGAINS + 1];
92 double trueRMS[
NGAINS + 1];
94 double icalconst = 1.;
97 for (
unsigned int igain(0); igain <=
NGAINS; ++igain) {
99 findPedestal(detId, igain, pedestals[igain], widths[igain]);
102 trueRMS[igain] =
std::sqrt(widths[igain] * widths[igain] - 1. / 12.);
109 LSB[igain] = Emax / (
MAXADC * gains[igain]);
123 noisy[0]->
noisify(noiseframe[0], engine);
124 if (
nullptr == noisy[1])
125 noisy[0]->
noisify(noiseframe[1], engine,
126 &noisy[0]->vecgau());
127 if (
nullptr == noisy[2])
128 noisy[0]->
noisify(noiseframe[2], engine,
129 &noisy[0]->vecgau());
138 for (
unsigned int i(0);
i != csize; ++
i) {
145 int igain(gainId - 1);
154 nullptr != noisy[igain - 1] &&
155 noiseframe[igain - 1].isBlank())
157 noisy[igain - 1]->
noisify(noiseframe[igain - 1], engine, &noisy[0]->vecgau());
165 const double asignal(pedestals[igain] + ecalSamples[
i] / (LSB[igain] * icalconst) +
166 trueRMS[igain] * noiseframe[igain - 1][
i]);
171 const double asignal(ecalSamples[
i] * 1000.);
173 }
else if (igain == 2) {
174 const double asignal(ecalSamples[
i] / (LSB[1] * icalconst));
176 }
else if (igain == 3) {
177 const double asignal(ecalSamples[
i] / (LSB[2] * icalconst));
180 const double asignal(ecalSamples[
i] / (LSB[3] * icalconst));
191 const int isignal(signal);
192 const int tmpadc(signal - (
double)isignal < 0.5 ? isignal : isignal + 1);
198 if (tmpadc <= maxADC[igain]) {
202 }
while (!done && igain < 3);
218 if (gainId == 3 && adc ==
MAXADC) {
232 for (
unsigned int i = 0;
i < ecalSamples.
size(); ++
i) {
234 unsigned int hyst =
i + 1 + 2;
235 for (
unsigned int j =
i + 1;
j < hyst &&
j < ecalSamples.
size(); ++
j) {
261 ped = (*itped).mean(gainId);
262 width = (*itped).rms(gainId);
265 edm::LogError(
"EcalCoder") <<
"Could not find pedestal for " << detId.
rawId() <<
" among the "
292 LogDebug(
"EcalCoder") <<
"Pedestals for " << detId.
rawId() <<
" gain range " << gainId <<
" : \n"
293 <<
"Mean = " << ped <<
" rms = " << width;
315 Gains[2] = (*grit).gain6Over1();
316 Gains[1] = Gains[2] * ((*grit).gain12Over6());
319 edm::LogError(
"EcalCoder") <<
"Could not find gain ratios for " << detId.
rawId() <<
" among the "
329 if (icalit != icalMap.
end()) {
330 thisconst = (*icalit);
331 if (icalconst == 0.) {
336 <<
"! something wrong with EcalIntercalibConstants in your DB? ";
338 icalconst = thisconst;
const EcalGainRatios * m_gainRatios
const self & getMap() const
constexpr uint32_t rawId() const
get the raw id
EcalMGPASample sample(int i) const
void setIntercalibConstants(const EcalIntercalibConstantsMC *ical)
virtual void analogToDigital(CLHEP::HepRandomEngine *, const EcalSamples &clf, EcalDataFrame &df) const
from EcalSamples to EcalDataFrame
Log< level::Error, false > LogError
int gainId() const
get the gainId (2 bits)
double fullScaleEnergy(const DetId &did) const
limit on the energy scale due to the electronics range
const EcalIntercalibConstantsMC * m_intercals
const Noisifier * m_ebCorrNoise[3]
const Noisifier * m_eeCorrNoise[3]
void setPedestals(const EcalPedestals *pedestals)
can be fetched every event from the EventSetup
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void findGains(const DetId &detId, double theGains[]) const
void encode(const EcalSamples &ecalSamples, EcalDataFrame &df, CLHEP::HepRandomEngine *) const
produce the pulse-shape
const EcalPedestals * m_peds
void setGainRatios(const EcalGainRatios *gainRatios)
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
void setFullScaleEnergy(double EBscale, double EEscale)
std::vector< Item >::const_iterator const_iterator
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
void setSample(int i, EcalMGPASample sam)
const_iterator find(uint32_t rawId) const
const_iterator end() const
float EcalIntercalibConstantMC
void findIntercalibConstant(const DetId &detId, double &icalconst) const
void findPedestal(const DetId &detId, int gainId, double &pedestal, double &width) const
not yet implemented
uint16_t *__restrict__ uint16_t const *__restrict__ adc
EcalCoder(bool addNoise, bool PreMix1, Noisifier *ebCorrNoise0, Noisifier *eeCorrNoise0=nullptr, Noisifier *ebCorrNoise1=nullptr, Noisifier *eeCorrNoise1=nullptr, Noisifier *ebCorrNoise2=nullptr, Noisifier *eeCorrNoise2=nullptr)
ctor