23 m_maxEneEB ( 1668.3 ) ,
24 m_maxEneEE ( 2859.9 ) ,
25 m_addNoise ( addNoise ) ,
101 CLHEP::HepRandomEngine* engine )
const
105 const unsigned int csize ( ecalSamples.
size() ) ;
108 DetId detId = ecalSamples.
id();
112 if ( ecalSamples[5] > 0. )
LogDebug(
"EcalCoder") <<
"Input caloSample" <<
"\n" << ecalSamples;
115 double pedestals[
NGAINS+1];
121 double icalconst = 1. ;
124 for(
unsigned int igain ( 0 ); igain <=
NGAINS ; ++igain )
133 trueRMS[igain] =
std::sqrt( widths[igain]*widths[igain] - 1./12. ) ;
140 if ( igain > 0 ) LSB[igain]= Emax/(
MAXADC*gains[igain]);
162 noisy[0]->
noisify( noiseframe[0], engine ) ;
163 if( 0 == noisy[1] ) noisy[0]->
noisify( noiseframe[1] ,
165 &noisy[0]->vecgau() ) ;
166 if( 0 == noisy[2] ) noisy[0]->
noisify( noiseframe[2] ,
168 &noisy[0]->vecgau() ) ;
178 for(
unsigned int i ( 0 ) ;
i != csize ; ++
i )
180 bool done (
false ) ;
182 if( 0 == wait ) gainId = 1 ;
185 int igain ( gainId - 1 ) ;
195 0 != noisy[igain-1] &&
196 noiseframe[igain-1].isBlank() )
198 noisy[igain-1]->
noisify( noiseframe[igain-1] ,
200 &noisy[0]->vecgau() ) ;
209 const double asignal ( pedestals[igain] +
210 ecalSamples[
i] /( LSB[igain]*icalconst ) +
211 trueRMS[igain]*noiseframe[igain-1][
i] ) ;
217 const double asignal ( ecalSamples[
i]*1000. );
220 else if( igain == 2) {
221 const double asignal ( ecalSamples[
i]/( LSB[1]*icalconst ));
224 else if( igain == 3) {
225 const double asignal ( ecalSamples[
i]/( LSB[2]*icalconst ) );
229 const double asignal ( ecalSamples[
i]/( LSB[3]*icalconst ) );
241 const int isignal ( signal ) ;
242 const int tmpadc ( signal - (
double)isignal < 0.5 ?
243 isignal : isignal + 1 ) ;
249 if( tmpadc <= maxADC[igain] )
265 if (igain == gainId) --wait ;
276 if ( gainId == 3 && adc ==
MAXADC )
292 for (
unsigned int i = 0 ;
i < ecalSamples.
size() ; ++
i)
296 unsigned int hyst =
i+1+2;
297 for (
unsigned int j =
i+1;
j < hyst &&
j < ecalSamples.
size(); ++
j )
310 double&
width )
const
329 ped = (*itped).mean(gainId);
330 width = (*itped).rms(gainId);
360 LogDebug(
"EcalCoder") <<
"Pedestals for " << detId.
rawId() <<
" gain range " << gainId <<
" : \n" <<
"Mean = " << ped <<
" rms = " <<
width;
366 double Gains[] )
const
386 Gains[2] = (*grit).gain6Over1();
387 Gains[1] = Gains[2]*( (*grit).gain12Over6() );
399 double& icalconst )
const
405 if( icalit!=icalMap.
end() )
407 thisconst = (*icalit);
408 if ( icalconst == 0. ) { thisconst = 1.; }
412 edm::LogError(
"EcalCoder") <<
"No intercalib const found for xtal " << detId.
rawId() <<
"! something wrong with EcalIntercalibConstants in your DB? ";
414 icalconst = thisconst;
int adc(sample_type sample)
get the ADC sample (12 bits)
const EcalGainRatios * m_gainRatios
int gainId(sample_type sample)
get the gainId (2 bits)
const self & getMap() const
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]
uint32_t rawId() const
get the raw id
const Noisifier * m_eeCorrNoise[3]
void setPedestals(const EcalPedestals *pedestals)
can be fetched every event from the EventSetup
void findGains(const DetId &detId, double theGains[]) const
void encode(const EcalSamples &ecalSamples, EcalDataFrame &df, CLHEP::HepRandomEngine *) const
produce the pulse-shape
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const EcalPedestals * m_peds
void setGainRatios(const EcalGainRatios *gainRatios)
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
EcalCoder(bool addNoise, bool PreMix1, Noisifier *ebCorrNoise0, Noisifier *eeCorrNoise0=0, Noisifier *ebCorrNoise1=0, Noisifier *eeCorrNoise1=0, Noisifier *ebCorrNoise2=0, Noisifier *eeCorrNoise2=0)
ctor