144 for (
int j = 0;
j < C::MAXSAMPLES - 5; ++
j) {
146 for (
int i =
j;
i < (
j + 5) &&
i < C::MAXSAMPLES; ++
i) {
147 if ( dataFrame.sample(
i).gainId() == 0 ) ++cnt;
149 if ( cnt == 5 )
return j-1 ;
165 const std::vector<float>& amplitudeBins,
166 const std::vector<float>& shiftBins) {
170 double theCorrection = 0;
173 if (amplitudeBins.size() == 0) {
175 <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
180 if (amplitudeBins.size() != shiftBins.size()) {
182 <<
"Size of timeCorrAmplitudeBins different from "
183 "timeCorrShiftBins. Forcing no time bias corrections. ";
189 for (
int bin = 0;
bin < (int) amplitudeBins.size();
bin++) {
190 if (ampli > amplitudeBins.at(
bin)) {
198 theCorrection = shiftBins.at(0);
199 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
200 theCorrection = shiftBins.at(myBin);
201 }
else if (-1 < myBin && myBin < ((
int) amplitudeBins.size() - 1)) {
203 theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
204 theCorrection *= (((double) ampli) - amplitudeBins.at(myBin)) /
205 (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
206 theCorrection += shiftBins.at(myBin);
209 <<
"Assigning time correction impossible. Setting it to 0 ";
214 return theCorrection / 25.;
235 float offsetTime = 0;
239 aped = &
peds->endcap(hashedIndex);
240 aGain = &
gains->endcap(hashedIndex);
241 gid = &
grps->endcap(hashedIndex);
242 offsetTime =
offtime->getEEValue();
245 aped = &
peds->barrel(hashedIndex);
246 aGain = &
gains->barrel(hashedIndex);
247 gid = &
grps->barrel(hashedIndex);
248 offsetTime =
offtime->getEBValue();
264 if( it !=
itime->end() ) {
267 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal "
269 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
274 int leadingSample = -1;
276 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
278 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
281 if ( leadingSample >= 0 ) {
282 if ( leadingSample != 4 ) {
325 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
326 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
327 if( wit == wgtsMap.end() ) {
328 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: "
329 << gid->
id() <<
" and EcalTDCId: " << tdcid
330 <<
"\n skipping digi with id: " <<
detid.rawId();
351 float const clockToNsConstant = 25.;
360 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
379 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
383 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
384 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
385 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
399 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
418 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
422 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
423 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
424 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
432 double amplitude = uncalibRecHit.
amplitude();
434 double jitter= uncalibRecHit.
jitter();
441 (itimeconst + offsetTime),
450 double chi2 = chi2expressEE_.
chi2();
461 bool samplesok =
true;
463 if (!sampleMask_->useSampleEE(
sample)) {
475 double amplitude = uncalibRecHit.
amplitude();
477 double jitter= uncalibRecHit.
jitter();
482 (itimeconst + offsetTime),
491 double chi2 = chi2expressEB_.
chi2();
501 bool samplesok =
true;
503 if (!sampleMask_->useSampleEB(
sample)) {
edm::ESHandle< EcalTimeOffsetConstant > offtime
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
T getParameter(std::string const &) const
double amplitudeThreshEE_
double outOfTimeThreshG12pEB_
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
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
double timeCorrection(float ampli, const std::vector< float > &litudeBins, const std::vector< float > &shiftBins)
void setJitter(float jitter)
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)
void push_back(T const &t)
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > weightsMethod_barrel_
std::vector< double > EBtimeFitParameters_
double outOfTimeThreshG12mEE_
void setJitterError(float jitterErr)
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_
void setOutOfTimeChi2(float chi2)
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
edm::ESHandle< EcalWeightXtalGroups > grps
double outOfTimeThreshG61mEE_
EcalUncalibRecHitWorkerGlobal(const edm::ParameterSet &, edm::ConsumesCollector &c)
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)
std::vector< Item >::const_iterator const_iterator
T const * product() const
float gain12Over6() const
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
float EcalTimeCalibConstant
float outOfTimeEnergy() const
void set(const edm::EventSetup &es)
edm::ESHandle< EcalTimeCalibConstants > itime
void setLeadingEdgeSample(int isample)
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
math::Matrix< 3, 10 >::type EcalWeightMatrix
void setFlagBit(Flags flag)
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setOutOfTimeEnergy(float energy)
edm::ESHandle< EcalSampleMask > sampleMaskHand_
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
std::vector< double > EEtimeFitParameters_
static const int MAXSAMPLES
Power< A, B >::type pow(const A &a, const B &b)