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 ) {
324 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
325 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
326 if( wit == wgtsMap.end() ) {
327 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: "
328 << gid->
id() <<
" and EcalTDCId: " << tdcid
329 <<
"\n skipping digi with id: " <<
detid.rawId();
350 float const clockToNsConstant = 25.;
359 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
377 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
381 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
382 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
383 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
397 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
415 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
419 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
420 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
421 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
429 double amplitude = uncalibRecHit.
amplitude();
430 double amplitudeOutOfTime = 0.;
431 double jitter= uncalibRecHit.
jitter();
438 (itimeconst + offsetTime),
447 double chi2 = chi2expressEE_.
chi2();
456 bool samplesok =
true;
458 if (!sampleMask_->useSampleEE(
sample)) {
470 double amplitude = uncalibRecHit.
amplitude();
471 double amplitudeOutOfTime = 0.;
472 double jitter= uncalibRecHit.
jitter();
477 (itimeconst + offsetTime),
486 double chi2 = chi2expressEB_.
chi2();
494 bool samplesok =
true;
496 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_
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_
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
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)
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)