47 if(EBtimeCorrAmplitudeBins_.size() != EBtimeCorrShiftBins_.size()) {
48 doEBtimeCorrection_ =
false;
49 edm::LogError(
"EcalRecHitError") <<
"Size of EBtimeCorrAmplitudeBins different from EBtimeCorrShiftBins. Forcing no time corrections for EB. ";
51 if(EEtimeCorrAmplitudeBins_.size() != EEtimeCorrShiftBins_.size()) {
52 doEEtimeCorrection_ =
false;
53 edm::LogError(
"EcalRecHitError") <<
"Size of EEtimeCorrAmplitudeBins different from EEtimeCorrShiftBins. Forcing no time corrections for EE. ";
94 for (
int j = 0;
j < C::MAXSAMPLES - 5; ++
j) {
96 for (
int i =
j;
i < (
j + 5) &&
i < C::MAXSAMPLES; ++
i) {
97 if ( dataFrame.sample(
i).gainId() == 0 ) ++cnt;
99 if ( cnt == 5 )
return j-1 ;
107 double theCorrection=0;
134 edm::LogError(
"EcalRecHitError") <<
"Assigning time correction impossible. Setting it to 0 ";
139 return theCorrection/25.;
145 double theCorrection=0;
171 edm::LogError(
"EcalRecHitError") <<
"Assigning time correction impossible. Setting it to 0 ";
176 return theCorrection/25.;
199 aped = &
peds->endcap(hashedIndex);
200 aGain = &
gains->endcap(hashedIndex);
201 gid = &
grps->endcap(hashedIndex);
204 aped = &
peds->barrel(hashedIndex);
205 aGain = &
gains->barrel(hashedIndex);
206 gid = &
grps->barrel(hashedIndex);
209 pedVec[0] = aped->mean_x12;
210 pedVec[1] = aped->mean_x6;
211 pedVec[2] = aped->mean_x1;
222 if( it !=
itime->end() ) {
225 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal "
227 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
232 int leadingSample = -1;
234 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
236 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
239 if ( leadingSample >= 0 ) {
240 if ( leadingSample != 4 ) {
277 uncalibRecHit.setChi2(0);
278 uncalibRecHit.setOutOfTimeChi2(0);
283 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
284 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
285 if( wit == wgtsMap.end() ) {
286 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: "
287 << gid->
id() <<
" and EcalTDCId: " << tdcid
288 <<
"\n skipping digi with id: " <<
detid.rawId();
309 float const clockToNsConstant = 25.;
315 double theTimeCorrectionEE=0;
317 uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
319 uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
327 if (uncalibRecHit.amplitude() > 3000.){
329 int GainId = ((
EcalDataFrame)(*itdg)).sample(iSample).gainId();
335 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst;
338 float nterm =
EEtimeNconst_*sigmaped/uncalibRecHit.amplitude();
339 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
340 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
341 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
351 double theTimeCorrectionEB=0;
360 uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
363 uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
371 if (uncalibRecHit.amplitude() > 3000.){
373 int GainId = ((
EcalDataFrame)(*itdg)).sample(iSample).gainId();
379 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst;
382 float nterm =
EBtimeNconst_*sigmaped/uncalibRecHit.amplitude();
383 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
384 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
385 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
393 double amplitude = uncalibRecHit.amplitude();
394 double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
395 double jitter= uncalibRecHit.jitter();
411 double chi2 = chi2expressEE_.
chi2();
412 uncalibRecHit.setChi2(chi2);
414 uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);
422 double amplitude = uncalibRecHit.amplitude();
423 double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
424 double jitter= uncalibRecHit.jitter();
438 double chi2 = chi2expressEB_.
chi2();
439 uncalibRecHit.setChi2(chi2);
441 uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
T getParameter(std::string const &) const
double amplitudeThreshEE_
double outOfTimeThreshG12pEB_
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
int hashedIndex() const
get a compact index for arrays
double outOfTimeThreshG61pEE_
void computeAmplitude(std::vector< double > &litudeFitParameters)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalUncalibRecHitWorkerGlobal(const edm::ParameterSet &)
void setRecoFlag(uint32_t flags)
const EEShape testbeamEEShape
int isSaturated(const C &digi)
std::pair< double, double > EBtimeFitLimits_
CalculatedRecHit getCalculatedRecHit()
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &litudeFitParameters)
std::vector< double > EBtimeCorrShiftBins_
void push_back(T const &t)
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > weightsMethod_barrel_
std::vector< double > EBtimeFitParameters_
double outOfTimeThreshG12mEE_
std::vector< double > EEchi2Parameters_
std::vector< double > eePulseShape_
std::vector< double > ebPulseShape_
std::pair< double, double > EEtimeFitLimits_
void setPulseShape(std::vector< double > &shape)
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
const unsigned int id() const
const EBShape testbeamEBShape
EcalUncalibRecHitLeadingEdgeAlgo< EBDataFrame > leadingEdgeMethod_barrel_
int hashedIndex(int ieta, int iphi)
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
double outOfTimeThreshG61mEB_
edm::ESHandle< EcalGainRatios > gains
EcalUncalibRecHitLeadingEdgeAlgo< EEDataFrame > leadingEdgeMethod_endcap_
edm::ESHandle< EcalPedestals > peds
double EEtimeConstantTerm_
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
double outOfTimeThreshG12pEE_
double amplitudeThreshEB_
double EBtimeConstantTerm_
edm::ESHandle< EcalTBWeights > wgts
std::vector< double > EEtimeCorrShiftBins_
edm::ESHandle< EcalWeightXtalGroups > grps
double outOfTimeThreshG61mEE_
double outOfTimeThreshG12mEB_
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG61pEB_
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix)
Compute parameters.
std::vector< double > EBamplitudeFitParameters_
std::vector< double > EBchi2Parameters_
virtual double chi2OutOfTime()
EcalWeightMatrix & getWeightsBeforeGainSwitch()
bool fixMGPAslew(const C &dataFrame)
void init(const C &dataFrame, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
std::vector< Item >::const_iterator const_iterator
float gain12Over6() const
std::vector< double > EBtimeCorrAmplitudeBins_
double timeCorrectionEE(float ampliEE)
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
float EcalTimeCalibConstant
void set(const edm::EventSetup &es)
edm::ESHandle< EcalTimeCalibConstants > itime
double timeCorrectionEB(float ampliEB)
void setLeadingEdgeSample(int isample)
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
math::Matrix< 3, 10 >::type EcalWeightMatrix
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< double > EEtimeCorrAmplitudeBins_
std::vector< double > EEtimeFitParameters_
static const int MAXSAMPLES
Power< A, B >::type pow(const A &a, const B &b)