93 for (
int j = 0;
j < C::MAXSAMPLES - 5; ++
j) {
95 for (
int i =
j;
i < (
j + 5) &&
i < C::MAXSAMPLES; ++
i) {
96 if (dataFrame.sample(
i).gainId() == 0)
115 const std::vector<float>& amplitudeBins,
116 const std::vector<float>& shiftBins) {
119 double theCorrection = 0;
122 if (amplitudeBins.empty()) {
123 edm::LogError(
"EcalRecHitError") <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
128 if (amplitudeBins.size() != shiftBins.size()) {
129 edm::LogError(
"EcalRecHitError") <<
"Size of timeCorrAmplitudeBins different from "
130 "timeCorrShiftBins. Forcing no time bias corrections. ";
136 for (
int bin = 0;
bin < (int)amplitudeBins.size();
bin++) {
137 if (ampli > amplitudeBins.at(
bin)) {
145 theCorrection = shiftBins.at(0);
146 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
147 theCorrection = shiftBins.at(myBin);
148 }
else if (-1 < myBin && myBin < ((
int)amplitudeBins.size() - 1)) {
150 theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
152 (((double)ampli) - amplitudeBins.at(myBin)) / (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
153 theCorrection += shiftBins.at(myBin);
155 edm::LogError(
"EcalRecHitError") <<
"Assigning time correction impossible. Setting it to 0 ";
160 return theCorrection / 25.;
166 DetId detid(itdg->id());
176 float offsetTime = 0;
180 aped = &
peds_->endcap(hashedIndex);
181 aGain = &
gains_->endcap(hashedIndex);
182 gid = &
grps_->endcap(hashedIndex);
183 offsetTime =
offtime_->getEEValue();
186 aped = &
peds_->barrel(hashedIndex);
187 aGain = &
gains_->barrel(hashedIndex);
188 gid = &
grps_->barrel(hashedIndex);
189 offsetTime =
offtime_->getEBValue();
192 pedVec[0] = aped->mean_x12;
193 pedVec[1] = aped->mean_x6;
194 pedVec[2] = aped->mean_x1;
205 if (it !=
itime_->end()) {
208 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal " << detid.rawId()
209 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
213 int leadingSample = -1;
215 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
217 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
220 if (leadingSample == 4) {
225 }
else if (leadingSample >= 0) {
227 double gainratio = 1.;
230 if (gainId == 0 || gainId == 3) {
231 pedestal = aped->mean_x1;
233 }
else if (gainId == 1) {
234 pedestal = aped->mean_x12;
236 }
else if (gainId == 2) {
237 pedestal = aped->mean_x6;
240 double amplitude = ((double)(((
EcalDataFrame)(*itdg)).sample(5).adc()) - pedestal) * gainratio;
249 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
250 wit = wgtsMap.find(std::make_pair(*gid, tdcid));
251 if (wit == wgtsMap.end()) {
253 <<
"No weights found for EcalGroupId: " << gid->
id() <<
" and EcalTDCId: " << tdcid
254 <<
"\n skipping digi with id: " << detid.rawId();
275 float const clockToNsConstant = 25.;
284 uncalibRecHit.
setJitter(crh.timeMax - 5 + theTimeCorrectionEE);
304 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
308 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
309 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < (-1. * sigmat * outOfTimeThreshM))) {
324 uncalibRecHit.
setJitter(crh.timeMax - 5 + theTimeCorrectionEB);
345 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
349 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
350 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < (-1. * sigmat * outOfTimeThreshM))) {
358 double amplitude = uncalibRecHit.
amplitude();
359 double amplitudeOutOfTime = 0.;
360 double jitter = uncalibRecHit.
jitter();
364 (itimeconst + offsetTime),
372 double chi2 = chi2expressEE_.
chi2();
378 bool samplesok =
true;
380 if (!sampleMask_->useSampleEE(
sample)) {
391 double amplitude = uncalibRecHit.
amplitude();
392 double amplitudeOutOfTime = 0.;
393 double jitter = uncalibRecHit.
jitter();
397 (itimeconst + offsetTime),
405 double chi2 = chi2expressEB_.
chi2();
411 bool samplesok =
true;
413 if (!sampleMask_->useSampleEB(
sample)) {
445 "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
447 "EBtimeFitParameters",
448 {-2.015452, 3.130702, -12.3473, 41.88921, -82.83944, 91.01147, -50.35761, 11.05621},
458 "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
463 "EEtimeFitParameters",
464 {-2.390548, 3.553628, -17.62341, 67.67538, -133.213, 140.7432, -75.41106, 16.20277},
493 "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_
int hashedIndex() const
get a compact index for arrays
double outOfTimeThreshG61pEE_
const edm::EventSetup & c
void computeAmplitude(std::vector< double > &litudeFitParameters)
edm::ESHandle< EcalWeightXtalGroups > grps_
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)
void push_back(T const &t)
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > weightsMethod_barrel_
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::vector< double > EBtimeFitParameters_
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_
int hashedIndex(int ieta, int iphi)
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > tokenGains_
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
double outOfTimeThreshG61mEB_
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_
double outOfTimeThreshG12mEB_
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG61pEB_
edm::ESHandle< EcalGainRatios > gains_
edm::ESHandle< EcalPedestals > peds_
std::vector< double > EBamplitudeFitParameters_
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()
bool fixMGPAslew(const C &dataFrame)
std::vector< Item >::const_iterator const_iterator
T const * product() const
T getParameter(std::string const &) const
float gain12Over6() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
float EcalTimeCalibConstant
void setEventSetup(const edm::EventSetup &evtSetup)
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
void setFlagBit(Flags flag)
#define DEFINE_EDM_PLUGIN(factory, type, name)
static constexpr int MAXSAMPLES
edm::ParameterSetDescription getAlgoDescription() override
edm::ESHandle< EcalSampleMask > sampleMaskHand_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
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_