66 double timeCorrection(
float ampli,
const std::vector<float>& amplitudeBins,
const std::vector<float>& shiftBins);
217 if (dataFrame.sample(
i).gainId() == 0)
236 const std::vector<float>& amplitudeBins,
237 const std::vector<float>& shiftBins) {
240 double theCorrection = 0;
243 if (amplitudeBins.empty()) {
244 edm::LogError(
"EcalRecHitError") <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
249 if (amplitudeBins.size() != shiftBins.size()) {
250 edm::LogError(
"EcalRecHitError") <<
"Size of timeCorrAmplitudeBins different from " 251 "timeCorrShiftBins. Forcing no time bias corrections. ";
257 for (
int bin = 0;
bin < (
int)amplitudeBins.size();
bin++) {
258 if (ampli > amplitudeBins.at(
bin)) {
266 theCorrection = shiftBins.at(0);
267 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
268 theCorrection = shiftBins.at(myBin);
269 }
else if (-1 < myBin && myBin < ((
int)amplitudeBins.size() - 1)) {
271 theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
273 (((double)ampli) - amplitudeBins.at(myBin)) / (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
274 theCorrection += shiftBins.at(myBin);
276 edm::LogError(
"EcalRecHitError") <<
"Assigning time correction impossible. Setting it to 0 ";
281 return theCorrection / 25.;
287 DetId detid(itdg->id());
297 float offsetTime = 0;
313 pedVec[0] = aped->mean_x12;
314 pedVec[1] = aped->mean_x6;
315 pedVec[2] = aped->mean_x1;
326 if (it !=
itime_->end()) {
329 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal " << detid.rawId()
330 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
334 int leadingSample = -1;
336 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
338 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
341 if (leadingSample == 4) {
346 }
else if (leadingSample >= 0) {
348 double gainratio = 1.;
370 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
371 wit = wgtsMap.find(std::make_pair(*gid, tdcid));
372 if (wit == wgtsMap.end()) {
374 <<
"No weights found for EcalGroupId: " << gid->
id() <<
" and EcalTDCId: " << tdcid
375 <<
"\n skipping digi with id: " << detid.rawId();
396 float const clockToNsConstant = 25.;
405 uncalibRecHit.
setJitter(crh.timeMax - 5 + theTimeCorrectionEE);
425 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
429 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
430 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < (-1. * sigmat * outOfTimeThreshM))) {
445 uncalibRecHit.
setJitter(crh.timeMax - 5 + theTimeCorrectionEB);
466 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
470 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
471 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < (-1. * sigmat * outOfTimeThreshM))) {
480 double amplitudeOutOfTime = 0.;
481 double jitter = uncalibRecHit.
jitter();
485 (itimeconst + offsetTime),
493 double chi2 = chi2expressEE_.
chi2();
499 bool samplesok =
true;
501 if (!sampleMask_->useSampleEE(
sample)) {
513 double amplitudeOutOfTime = 0.;
514 double jitter = uncalibRecHit.
jitter();
518 (itimeconst + offsetTime),
526 double chi2 = chi2expressEB_.
chi2();
532 bool samplesok =
true;
534 if (!sampleMask_->useSampleEB(
sample)) {
554 result.push_back(uncalibRecHit);
556 result.push_back(uncalibRecHit);
566 "eePulseShape", {5.2e-05, -5.26e-05, 6.66e-05, 0.1168, 0.7575, 1.0, 0.8876, 0.6732, 0.4741, 0.3194},
true) and
568 "EBtimeFitParameters",
569 {-2.015452, 3.130702, -12.3473, 41.88921, -82.83944, 91.01147, -50.35761, 11.05621},
579 "ebPulseShape", {5.2e-05, -5.26e-05, 6.66e-05, 0.1168, 0.7575, 1.0, 0.8876, 0.6732, 0.4741, 0.3194},
true) and
586 "EEtimeFitParameters",
587 {-2.390548, 3.553628, -17.62341, 67.67538, -133.213, 140.7432, -75.41106, 16.20277},
616 "EcalUncalibRecHitWorkerGlobal");
std::pair< double, double > EEtimeFitLimits_
edm::ESHandle< EcalTimeOffsetConstant > offtime_
double amplitudeThreshEE_
double outOfTimeThreshG12pEB_
edm::ESGetToken< EcalTBWeights, EcalTBWeightsRcd > tokenWgts_
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
edm::ESGetToken< EcalTimeCalibConstants, EcalTimeCalibConstantsRcd > tokenItime_
T getParameter(std::string const &) const
double outOfTimeThreshG61pEE_
void computeAmplitude(std::vector< double > &litudeFitParameters)
edm::ESHandle< EcalWeightXtalGroups > grps_
std::vector< float > EBTimeCorrShiftBins
const EcalTBWeightMap & getMap() const
double timeCorrection(float ampli, const std::vector< float > &litudeBins, const std::vector< float > &shiftBins)
void setJitter(float jitter)
int isSaturated(const C &digi)
CalculatedRecHit getCalculatedRecHit()
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &litudeFitParameters)
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > weightsMethod_barrel_
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::vector< double > EBtimeFitParameters_
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
math::Matrix< 3, 10 >::type EcalWeightMatrix
double outOfTimeThreshG12mEE_
Log< level::Error, false > LogError
void set(const edm::EventSetup &es) override
void setJitterError(float jitterErr)
std::vector< double > EEchi2Parameters_
std::vector< double > eePulseShape_
edm::ESGetToken< EcalSampleMask, EcalSampleMaskRcd > tokenSampleMask_
std::vector< double > ebPulseShape_
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
int hashedIndex(int ieta, int iphi)
T const * product() const
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > tokenGains_
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
double outOfTimeThreshG61mEB_
std::vector< float > EETimeCorrAmplitudeBins
double EEtimeConstantTerm_
edm::ESGetToken< EcalTimeBiasCorrections, EcalTimeBiasCorrectionsRcd > tokenTimeCorrBias_
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_
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
double outOfTimeThreshG61mEE_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
double outOfTimeThreshG12mEB_
EcalWeightMatrix & getWeightsAfterGainSwitch()
void setEventSetup(const edm::EventSetup &evtSetup, bool normalize=true)
double outOfTimeThreshG61pEB_
static constexpr int MAXSAMPLES
edm::ESHandle< EcalGainRatios > gains_
edm::ESHandle< EcalPedestals > peds_
std::vector< double > EBamplitudeFitParameters_
float gain12Over6() const
std::vector< double > EBchi2Parameters_
edm::ESHandle< EcalTBWeights > wgts_
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
std::pair< double, double > EBtimeFitLimits_
EcalWeightMatrix & getWeightsBeforeGainSwitch()
const EcalWeightSet::EcalChi2WeightMatrix * chi2mat[2]
bool fixMGPAslew(const C &dataFrame)
std::vector< Item >::const_iterator const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
float EcalTimeCalibConstant
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
int hashedIndex() const
get a compact index for arrays
void setFlagBit(Flags flag)
#define DEFINE_EDM_PLUGIN(factory, type, name)
static constexpr int MAXSAMPLES
edm::ParameterSetDescription getAlgoDescription() override
edm::ESHandle< EcalSampleMask > sampleMaskHand_
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
edm::ESGetToken< EcalWeightXtalGroups, EcalWeightXtalGroupsRcd > tokenGrps_
edm::ESGetToken< EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd > tokenOfftime_
std::vector< double > EEtimeFitParameters_
EcalUncalibRecHitWorkerGlobal()=default
edm::ESHandle< EcalTimeCalibConstants > itime_
Power< A, B >::type pow(const A &a, const B &b)
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > tokenPeds_