133 for (
int j = 0;
j < C::MAXSAMPLES - 5; ++
j) {
135 for (
int i =
j;
i < (
j + 5) &&
i < C::MAXSAMPLES; ++
i) {
136 if (dataFrame.sample(
i).gainId() == 0)
155 const std::vector<float>& amplitudeBins,
156 const std::vector<float>& shiftBins) {
159 double theCorrection = 0;
162 if (amplitudeBins.empty()) {
163 edm::LogError(
"EcalRecHitError") <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
168 if (amplitudeBins.size() != shiftBins.size()) {
169 edm::LogError(
"EcalRecHitError") <<
"Size of timeCorrAmplitudeBins different from " 170 "timeCorrShiftBins. Forcing no time bias corrections. ";
176 for (
int bin = 0;
bin < (
int)amplitudeBins.size();
bin++) {
177 if (ampli > amplitudeBins.at(
bin)) {
185 theCorrection = shiftBins.at(0);
186 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
187 theCorrection = shiftBins.at(myBin);
188 }
else if (-1 < myBin && myBin < ((
int)amplitudeBins.size() - 1)) {
190 theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
192 (((double)ampli) - amplitudeBins.at(myBin)) / (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
193 theCorrection += shiftBins.at(myBin);
195 edm::LogError(
"EcalRecHitError") <<
"Assigning time correction impossible. Setting it to 0 ";
200 return theCorrection / 25.;
206 DetId detid(itdg->id());
216 float offsetTime = 0;
220 aped = &
peds->endcap(hashedIndex);
221 aGain = &
gains->endcap(hashedIndex);
222 gid = &
grps->endcap(hashedIndex);
226 aped = &
peds->barrel(hashedIndex);
227 aGain = &
gains->barrel(hashedIndex);
228 gid = &
grps->barrel(hashedIndex);
245 if (it !=
itime->end()) {
248 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal " << detid.rawId()
249 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
253 int leadingSample = -1;
255 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
257 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
260 if (leadingSample == 4) {
265 }
else if (leadingSample >= 0) {
267 double gainratio = 1.;
270 if (gainId == 0 || gainId == 3) {
273 }
else if (gainId == 1) {
276 }
else if (gainId == 2) {
289 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
290 wit = wgtsMap.find(std::make_pair(*gid, tdcid));
291 if (wit == wgtsMap.end()) {
293 <<
"No weights found for EcalGroupId: " << gid->
id() <<
" and EcalTDCId: " << tdcid
294 <<
"\n skipping digi with id: " << detid.rawId();
315 float const clockToNsConstant = 25.;
324 uncalibRecHit.
setJitter(crh.timeMax - 5 + theTimeCorrectionEE);
344 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
348 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
349 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < (-1. * sigmat * outOfTimeThreshM))) {
364 uncalibRecHit.
setJitter(crh.timeMax - 5 + theTimeCorrectionEB);
385 float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
389 float sigmat =
std::sqrt(nterm * nterm + cterm * cterm);
390 if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < (-1. * sigmat * outOfTimeThreshM))) {
399 double amplitudeOutOfTime = 0.;
400 double jitter = uncalibRecHit.
jitter();
404 (itimeconst + offsetTime),
412 double chi2 = chi2expressEE_.
chi2();
418 bool samplesok =
true;
420 if (!sampleMask_->useSampleEE(
sample)) {
432 double amplitudeOutOfTime = 0.;
433 double jitter = uncalibRecHit.
jitter();
437 (itimeconst + offsetTime),
445 double chi2 = chi2expressEB_.
chi2();
451 bool samplesok =
true;
453 if (!sampleMask_->useSampleEB(
sample)) {
485 "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
487 "EBtimeFitParameters",
488 {-2.015452, 3.130702, -12.3473, 41.88921, -82.83944, 91.01147, -50.35761, 11.05621},
498 "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
503 "EEtimeFitParameters",
504 {-2.390548, 3.553628, -17.62341, 67.67538, -133.213, 140.7432, -75.41106, 16.20277},
533 "EcalUncalibRecHitWorkerGlobal");
edm::ESHandle< EcalTimeOffsetConstant > offtime
std::pair< double, double > EEtimeFitLimits_
T getParameter(std::string const &) const
double amplitudeThreshEE_
double outOfTimeThreshG12pEB_
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
int hashedIndex() const
get a compact index for arrays
double outOfTimeThreshG61pEE_
void computeAmplitude(std::vector< double > &litudeFitParameters)
std::vector< float > EBTimeCorrShiftBins
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_
void set(const edm::EventSetup &es) override
void setJitterError(float jitterErr)
std::vector< double > EEchi2Parameters_
std::vector< double > eePulseShape_
std::vector< double > ebPulseShape_
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
const unsigned int id() const
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
int hashedIndex(int ieta, int iphi)
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
double outOfTimeThreshG61mEB_
edm::ESHandle< EcalGainRatios > gains
std::vector< float > EETimeCorrAmplitudeBins
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
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
double outOfTimeThreshG61mEE_
double outOfTimeThreshG12mEB_
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG61pEB_
std::vector< double > EBamplitudeFitParameters_
std::vector< double > EBchi2Parameters_
std::pair< double, double > EBtimeFitLimits_
EcalWeightMatrix & getWeightsBeforeGainSwitch()
bool fixMGPAslew(const C &dataFrame)
std::vector< Item >::const_iterator const_iterator
float gain12Over6() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalUncalibRecHitWorkerGlobal()
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
float EcalTimeCalibConstant
edm::ESHandle< EcalTimeCalibConstants > itime
void setEventSetup(const edm::EventSetup &evtSetup)
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
const EcalTBWeightMap & getMap() const
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)
T const * product() const
std::vector< double > EEtimeFitParameters_
Power< A, B >::type pow(const A &a, const B &b)