75 double timeCorrection(
float ampli,
const std::vector<float>& amplitudeBins,
const std::vector<float>& shiftBins);
181 for (
unsigned int ibx = 0; ibx <
activeBXs.size(); ++ibx) {
229 if (timeAlgoName ==
"RatioMethod")
231 else if (timeAlgoName ==
"WeightsMethod")
233 else if (timeAlgoName ==
"crossCorrelationMethod") {
236 double stopTime = ps.
getParameter<
double>(
"crossCorrelationStopTime");
239 ps.
getParameter<
double>(
"crossCorrelationTargetTimePrecisionForDelayedPulses");
246 }
else if (timeAlgoName !=
"None")
247 edm::LogError(
"EcalUncalibRecHitError") <<
"No time estimation algorithm defined";
300 int nnoise = SampleVector::RowsAtCompileTime;
308 for (
int i = 0;
i < nnoise; ++
i) {
309 for (
int j = 0;
j < nnoise; ++
j) {
322 unsigned int bunchspacing = 450;
327 bunchspacing = *bunchSpacingH;
333 if (bunchspacing == 25) {
335 activeBX << -5, -4, -3, -2, -1, 0, 1, 2, 3, 4;
354 const std::vector<float>& amplitudeBins,
355 const std::vector<float>& shiftBins) {
358 double theCorrection = 0;
361 if (amplitudeBins.empty()) {
362 edm::LogError(
"EcalRecHitError") <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
367 if (amplitudeBins.size() != shiftBins.size()) {
368 edm::LogError(
"EcalRecHitError") <<
"Size of timeCorrAmplitudeBins different from " 369 "timeCorrShiftBins. Forcing no time bias corrections. ";
376 for (
int bin = 0;
bin < (
int)amplitudeBins.size();
bin++) {
377 if (ampli > amplitudeBins[
bin]) {
385 theCorrection = shiftBins[0];
386 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
387 theCorrection = shiftBins[myBin];
390 theCorrection = (shiftBins[myBin + 1] - shiftBins[myBin]);
391 theCorrection *= (((double)ampli) - amplitudeBins[myBin]) / (amplitudeBins[myBin + 1] - amplitudeBins[myBin]);
392 theCorrection += shiftBins[myBin];
397 return theCorrection * inv25;
433 for (
auto itdg = digis.
begin(); itdg != digis.
end(); ++itdg) {
434 DetId detid(itdg->id());
439 float offsetTime = 0;
465 double pedVec[3] = {aped->mean_x12, aped->mean_x6, aped->mean_x1};
466 double pedRMSVec[3] = {aped->rms_x12, aped->rms_x6, aped->rms_x1};
470 fullpulse(
i + 7) = aPulse->pdfval[
i];
474 fullpulsecov(
i + 7,
j + 7) = aPulseCov->covval[
i][
j];
482 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal " << detid.rawId()
483 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
486 int lastSampleBeforeSaturation = -2;
489 lastSampleBeforeSaturation = iSample - 1;
496 if (lastSampleBeforeSaturation == 4) {
497 result.emplace_back((*itdg).id(), 4095 * 12, 0, 0, 0);
498 auto& uncalibRecHit =
result.back();
501 uncalibRecHit.setChi2(0);
502 }
else if (lastSampleBeforeSaturation >=
508 auto gainratio = gainRatios[
gainId - 1];
511 auto& uncalibRecHit =
result.back();
514 uncalibRecHit.setChi2(0);
520 auto& uncalibRecHit =
result.back();
526 constexpr float invClockToNs = 1. / clockToNsConstant;
536 uncalibRecHit.setJitter(crh.timeMax - 5 + theTimeCorrectionEE);
537 uncalibRecHit.setJitterError(
547 if (uncalibRecHit.amplitude() > 3000.) {
557 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
559 float sigmaped = pedRMSVec[0];
560 float nterm =
EEtimeNconst_ * sigmaped / uncalibRecHit.amplitude();
561 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
562 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < -sigmat * outOfTimeThreshM)) {
578 uncalibRecHit.setJitter(crh.timeMax - 5 + theTimeCorrectionEB);
588 if (uncalibRecHit.amplitude() > 3000.) {
598 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
600 float sigmaped = pedRMSVec[0];
601 float nterm =
EBtimeNconst_ * sigmaped / uncalibRecHit.amplitude();
602 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
603 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < -sigmat * outOfTimeThreshM)) {
610 std::vector<double> amplitudes;
611 for (
unsigned int ibx = 0; ibx <
activeBX.
size(); ++ibx)
612 amplitudes.push_back(uncalibRecHit.outOfTimeAmplitude(ibx));
616 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
617 wit = wgtsMap.find(std::make_pair(*gid, tdcid));
618 if (wit == wgtsMap.end()) {
620 <<
"No weights found for EcalGroupId: " << gid->
id() <<
" and EcalTDCId: " << tdcid
621 <<
"\n skipping digi with id: " << detid.rawId();
639 uncalibRecHit.setJitter(timerh);
640 uncalibRecHit.setJitterError(0.);
644 for (
unsigned int ibx = 0; ibx <
activeBX.
size(); ++ibx)
645 amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx);
647 bool const doSlewCorrection =
653 float noCorrectedJitter =
computeCC_->computeTimeCC(*itdg,
663 uncalibRecHit.setJitter(jitter);
664 uncalibRecHit.setNonCorrectedTime(jitter, noCorrectedJitter);
666 float retreivedNonCorrectedTime = uncalibRecHit.nonCorrectedTime();
668 if (retreivedNonCorrectedTime > -29.0 &&
std::abs(retreivedNonCorrectedTime - noCorrectedTime) > 0.05) {
669 edm::LogError(
"EcalUncalibRecHitError") <<
"Problem with noCorrectedJitter: true value:" << noCorrectedTime
670 <<
"\t received: " << retreivedNonCorrectedTime << std::endl;
683 if (uncalibRecHit.amplitude() > 3000.) {
699 if (uncalibRecHit.amplitude() > 3000.) {
710 if (uncalibRecHit.amplitude() >
threshold) {
712 float sigmaped = pedRMSVec[0];
713 float nterm = timeNconst * sigmaped / uncalibRecHit.amplitude();
714 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
715 if ((correctedTime > sigmat * timeThrP) || (correctedTime < -sigmat * timeThrM))
720 uncalibRecHit.setJitter(0.);
721 uncalibRecHit.setJitterError(0.);
726 auto& uncalibRecHit =
result.back();
736 psd.
addNode(
edm::ParameterDescription<std::vector<int>>(
"activeBXs", {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4},
true) and
817 "EcalUncalibRecHitWorkerMultiFit");
edm::ESGetToken< EcalPulseCovariances, EcalPulseCovariancesRcd > pulseConvariancesToken_
edm::ParameterSetDescription getAlgoDescription() override
bool mitigateBadSamplesEB_
std::array< SampleMatrixGainArray, 2 > noisecors_
EcalPulseShapesMap EcalPulseShapes
T getParameter(std::string const &) const
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
void computeAmplitude(std::vector< double > &litudeFitParameters)
std::vector< float > EBTimeCorrShiftBins
EcalUncalibRecHitMultiFitAlgo multiFitMethod_
const EcalTBWeightMap & getMap() const
bool simplifiedNoiseModelForGainSwitch_
std::array< SampleMatrix, NGains > SampleMatrixGainArray
double CCtargetTimePrecision_
EcalUncalibRecHitTimeWeightsAlgo< EEDataFrame > weightsMethod_endcap_
double EEtimeConstantTerm_
edm::ESGetToken< EcalPulseShapes, EcalPulseShapesRcd > pulseShapesToken_
bool useLumiInfoRunHeader_
bool mitigateBadSamplesEE_
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
double addPedestalUncertaintyEE_
double time(const C &dataFrame, const std::vector< double > &litudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, const EcalWeightSet::EcalWeightMatrix **weights)
Compute time.
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
CalculatedRecHit getCalculatedRecHit()
double outOfTimeThreshG12pEE_
std::vector< double > EBG12SamplesCorrelation
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &litudeFitParameters)
double CCminTimeToBeLateMin_
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > gainsToken_
EcalCondObjectContainer< EcalXtalGroupId > EcalWeightXtalGroups
static const int TEMPLATESAMPLES
edm::ESHandle< EcalWeightXtalGroups > grps
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
double amplitudeThreshEE_
math::Matrix< 3, 10 >::type EcalWeightMatrix
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Log< level::Error, false > LogError
double outOfTimeThreshG61pEE_
constexpr const float clockToNS
edm::ESHandle< EcalGainRatios > gains
bool selectiveBadSampleCriteriaEE_
edm::ESGetToken< EcalSamplesCorrelation, EcalSamplesCorrelationRcd > noiseConvariancesToken_
edm::EDGetTokenT< unsigned int > bunchSpacing_
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
bool gainSwitchUseMaxSampleEE_
std::vector< double > EBG6SamplesCorrelation
const SampleMatrixGainArray & noisecor(bool barrel) const
unsigned size(int bx) const
std::vector< float > EBTimeCorrAmplitudeBins
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedsToken_
std::vector< float > EETimeCorrShiftBins
edm::ESHandle< EcalPedestals > peds
int hashedIndex(int ieta, int iphi)
edm::ESGetToken< EcalTBWeights, EcalTBWeightsRcd > wgtsToken_
void setAddPedestalUncertainty(double x)
T const * product() const
std::vector< double > EBtimeFitParameters_
std::vector< double > ebPulseShape_
std::vector< double > EBamplitudeFitParameters_
EcalGainRatioMap EcalGainRatios
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
std::vector< float > EETimeCorrAmplitudeBins
edm::ESHandle< EcalPulseShapes > pulseshapes
bool crossCorrelationUseSlewCorrectionEB_
void setDynamicPedestals(bool b)
Abs< T >::type abs(const T &t)
double CCTimeShiftWrtRations_
EcalPulseCovariancesMap EcalPulseCovariances
void setMitigateBadSamples(bool b)
edm::ESHandle< EcalTimeCalibConstants > itime
double timeCorrection(float ampli, const std::vector< float > &litudeBins, const std::vector< float > &shiftBins)
double outOfTimeThreshG12mEB_
void disableErrorCalculation()
double outOfTimeThreshG61mEB_
std::unique_ptr< EcalUncalibRecHitTimingCCAlgo > computeCC_
double outOfTimeThreshG12mEE_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG12pEB_
std::vector< double > eePulseShape_
void setSelectiveBadSampleCriteria(bool b)
const SampleMatrix & noisecor(bool barrel, int gain) const
EcalUncalibratedRecHit makeRecHit(const EcalDataFrame &dataFrame, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const SampleMatrixGainArray &noisecors, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const BXVector &activeBX)
compute rechits
const_iterator end() const
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
float gain12Over6() const
EcalPedestalsMap EcalPedestals
double CCminTimeToBeLateMax_
bool ampErrorCalculation_
edm::ESGetToken< EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd > offtimeToken_
void set(const edm::EventSetup &es) override
edm::ESHandle< EcalPulseCovariances > pulsecovariances
void setPrefitMaxChiSq(double x)
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
EcalWeightMatrix & getWeightsBeforeGainSwitch()
EcalTimeCalibConstantMap EcalTimeCalibConstants
std::vector< double > EBG1SamplesCorrelation
bool fixMGPAslew(const C &dataFrame)
double outOfTimeThreshG61mEE_
const_iterator begin() const
The iterator returned can not safely be used across threads.
std::vector< Item >::const_iterator const_iterator
void resize(int bx, unsigned size)
double CCtargetTimePrecisionForDelayedPulses_
edm::ESGetToken< EcalTimeBiasCorrections, EcalTimeBiasCorrectionsRcd > timeCorrBiasToken_
std::pair< double, double > EBtimeFitLimits_
Eigen::Matrix< double, SampleVectorSize, SampleVectorSize > SampleMatrix
EcalUncalibRecHitTimeWeightsAlgo< EBDataFrame > weightsMethod_barrel_
edm::ESHandle< EcalTimeOffsetConstant > offtime
bool selectiveBadSampleCriteriaEB_
std::vector< double > EEG1SamplesCorrelation
bool gainSwitchUseMaxSampleEB_
float EcalTimeCalibConstant
edm::ESGetToken< EcalSampleMask, EcalSampleMaskRcd > sampleMaskToken_
edm::ESGetToken< EcalTimeCalibConstants, EcalTimeCalibConstantsRcd > itimeToken_
int hashedIndex() const
get a compact index for arrays
double outOfTimeThreshG61pEB_
void setGainSwitchUseMaxSample(bool b)
#define DEFINE_EDM_PLUGIN(factory, type, name)
void run(const edm::Event &evt, const EcalDigiCollection &digis, EcalUncalibratedRecHitCollection &result) override
static constexpr int MAXSAMPLES
void setSimplifiedNoiseModelForGainSwitch(bool b)
bool crossCorrelationUseSlewCorrectionEE_
edm::ESHandle< EcalSampleMask > sampleMaskHand_
const EcalWeightSet::EcalWeightMatrix * weights[2]
std::vector< double > EEG12SamplesCorrelation
edm::ESHandle< EcalSamplesCorrelation > noisecovariances
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
std::pair< double, double > EEtimeFitLimits_
double amplitudeThreshEB_
std::vector< double > EEG6SamplesCorrelation
edm::ESHandle< EcalTBWeights > wgts
std::vector< double > EEamplitudeFitParameters_
Power< A, B >::type pow(const A &a, const B &b)
edm::ESGetToken< EcalWeightXtalGroups, EcalWeightXtalGroupsRcd > grpsToken_
double addPedestalUncertaintyEB_
EcalUncalibRecHitWorkerMultiFit()
std::vector< double > EEtimeFitParameters_
double EBtimeConstantTerm_