75 const unsigned int csize(ecalSamples.
size());
81 if (ecalSamples[5] > 0.)
82 LogDebug(
"EcalCoder") <<
"Input caloSample" 87 double pedestals[
NGAINS + 1];
91 double trueRMS[
NGAINS + 1];
93 double icalconst = 1.;
96 for (
unsigned int igain(0); igain <=
NGAINS; ++igain) {
98 findPedestal(detId, igain, pedestals[igain], widths[igain]);
101 trueRMS[igain] =
std::sqrt(widths[igain] * widths[igain] - 1. / 12.);
108 LSB[igain] = Emax / (
MAXADC * gains[igain]);
122 noisy[0]->
noisify(noiseframe[0], engine);
123 if (
nullptr == noisy[1])
124 noisy[0]->
noisify(noiseframe[1], engine,
125 &noisy[0]->vecgau());
126 if (
nullptr == noisy[2])
127 noisy[0]->
noisify(noiseframe[2], engine,
128 &noisy[0]->vecgau());
137 for (
unsigned int i(0);
i != csize; ++
i) {
144 int igain(gainId - 1);
153 nullptr != noisy[igain - 1] &&
154 noiseframe[igain - 1].isBlank())
156 noisy[igain - 1]->
noisify(noiseframe[igain - 1], engine, &noisy[0]->vecgau());
164 const double asignal(pedestals[igain] + ecalSamples[
i] / (LSB[igain] * icalconst) +
165 trueRMS[igain] * noiseframe[igain - 1][
i]);
170 const double asignal(ecalSamples[
i] * 1000.);
172 }
else if (igain == 2) {
173 const double asignal(ecalSamples[
i] / (LSB[1] * icalconst));
175 }
else if (igain == 3) {
176 const double asignal(ecalSamples[
i] / (LSB[2] * icalconst));
179 const double asignal(ecalSamples[
i] / (LSB[3] * icalconst));
190 const int isignal(signal);
191 const int tmpadc(signal - (
double)isignal < 0.5 ? isignal : isignal + 1);
197 if (tmpadc <= maxADC[igain]) {
201 }
while (!done && igain < 3);
217 if (gainId == 3 && adc ==
MAXADC) {
231 for (
unsigned int i = 0;
i < ecalSamples.
size(); ++
i) {
233 unsigned int hyst =
i + 1 + 2;
234 for (
unsigned int j =
i + 1; j < hyst && j < ecalSamples.
size(); ++j) {
260 ped = (*itped).mean(gainId);
261 width = (*itped).rms(gainId);
264 edm::LogError(
"EcalCoder") <<
"Could not find pedestal for " << detId.
rawId() <<
" among the " 291 LogDebug(
"EcalCoder") <<
"Pedestals for " << detId.
rawId() <<
" gain range " << gainId <<
" : \n" 292 <<
"Mean = " << ped <<
" rms = " <<
width;
314 Gains[2] = (*grit).gain6Over1();
315 Gains[1] = Gains[2] * ((*grit).gain12Over6());
318 edm::LogError(
"EcalCoder") <<
"Could not find gain ratios for " << detId.
rawId() <<
" among the " 328 if (icalit != icalMap.
end()) {
329 thisconst = (*icalit);
330 if (icalconst == 0.) {
335 <<
"! something wrong with EcalIntercalibConstants in your DB? ";
337 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
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
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
const EcalPedestals * m_peds
void setGainRatios(const EcalGainRatios *gainRatios)
void setFullScaleEnergy(double EBscale, double EEscale)
std::vector< Item >::const_iterator const_iterator
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
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
EcalCoder(bool addNoise, bool PreMix1, Noisifier *ebCorrNoise0, Noisifier *eeCorrNoise0=nullptr, Noisifier *ebCorrNoise1=nullptr, Noisifier *eeCorrNoise1=nullptr, Noisifier *ebCorrNoise2=nullptr, Noisifier *eeCorrNoise2=nullptr)
ctor