21 correctForTimeslew_(correctForTimeslew),
22 correctForPulse_(correctForPulse),
23 phaseNS_(phaseNS), runnum_(0), setLeakCorrection_(
false), puCorrMethod_(0)
59 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
65 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
71 const unsigned lenInfo)
81 static float leakCorr(
double energy);
87 const bool slewCorrect,
double maxA,
float t0,
float t2)
101 if (wpksamp != 0.
f) wpksamp = maxA/wpksamp;
104 if (wpksamp != 0.
f) wpksamp = 1.+(t2/wpksamp);
109 if (slewCorrect && amp_fC > 0.0) {
111 double tslew=
exp(0.337681-5.94689
e-4*amp_fC)+
exp(2.44628-1.34888
e-2*amp_fC);
112 time -= (
float)tslew;
122 const int ifirst,
const int n,
123 const bool pulseCorrect,
126 const BunchXParameter* bxInfo,
const unsigned lenInfo,
127 double* p_maxA,
double* p_ampl,
double* p_uncorr_ampl,
128 double* p_fc_ampl,
int* p_nRead,
int* p_maxI,
129 bool* leakCorrApplied,
float* p_t0,
float* p_t2)
133 const int nRead = cs.
size();
134 const int iStop =
std::min(nRead, n + ifirst);
141 double* correctedEnergy =
nullptr;
142 double fc_ampl = 0.0, corr_fc_ampl = 0.0;
143 bool pulseShapeCorrApplied =
false, readjustTiming =
false;
144 *leakCorrApplied =
false;
146 if (pileupCorrection)
148 correctedEnergy = &buf[0];
153 for (
int i=0;
i<nRead; ++
i)
155 const int capid = digi[
i].capid();
156 correctionInput[
i] = cs[
i] - calibs.
pedestal(capid);
160 for (
int i=ifirst;
i<iStop; ++
i)
161 fc_ampl += correctionInput[
i];
164 for (
int i=0;
i<nRead; ++
i)
166 uncorrectedEnergy[
i] = correctionInput[
i]*gains[
i];
168 correctionInput[
i] = uncorrectedEnergy[
i];
171 pileupCorrection->
apply(digi.id(), correctionInput, nRead,
172 bxInfo, lenInfo, ifirst,
n,
174 &pulseShapeCorrApplied, leakCorrApplied,
180 for (
int i=ifirst;
i<iStop; ++
i)
182 corr_fc_ampl += correctedEnergy[
i]/gains[
i];
186 for (
int i=ifirst;
i<iStop; ++
i)
187 corr_fc_ampl += correctedEnergy[
i];
188 for (
int i=0;
i<nRead; ++
i)
189 correctedEnergy[
i] *= gains[
i];
194 correctedEnergy = &uncorrectedEnergy[0];
197 const int istart =
std::max(ifirst - 1, 0);
198 const int iend =
std::min(n + ifirst + 1, nRead);
199 for (
int i=istart;
i<iend; ++
i)
201 const int capid = digi[
i].capid();
202 float ta = cs[
i] - calibs.
pedestal(capid);
203 if (
i >= ifirst &&
i < iStop)
206 uncorrectedEnergy[
i] = ta;
208 corr_fc_ampl = fc_ampl;
212 double ampl = 0.0, corr_ampl = 0.0;
213 for (
int i=ifirst;
i<iStop; ++
i)
215 ampl += uncorrectedEnergy[
i];
216 corr_ampl += correctedEnergy[
i];
220 if (corr && pulseCorrect)
223 if (pileupCorrection)
225 if (!pulseShapeCorrApplied)
233 const double *etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
234 int maxI = -1;
double maxA = -1.e300;
235 for (
int i=ifirst;
i<iStop; ++
i)
245 *p_uncorr_ampl = ampl;
246 *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
250 if (maxI <= 0 || maxI >= (nRead-1))
252 LogDebug(
"HCAL Pulse") <<
"HcalSimpleRecAlgoImpl::removePileup :" 253 <<
" Invalid max amplitude position, " 254 <<
" max Amplitude: " << maxI
255 <<
" first: " << ifirst
256 <<
" last: " << ifirst + n
263 *p_t0 = etime[maxI - 1];
264 *p_t2 = etime[maxI + 1];
269 template<
class Digi,
class RecHit>
272 const int ifirst,
const int n,
const bool slewCorrect,
275 const int runnum,
const bool useLeak,
277 const BunchXParameter* bxInfo,
const unsigned lenInfo,
278 const int puCorrMethod,
281 double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
282 int nRead = 0,
maxI = -1;
283 bool leakCorrApplied =
false;
292 pulseCorrect, corr, inputAbsOOTpuCorr,
293 bxInfo, lenInfo, &maxA, &l,
294 &uncorr_ampl, &fc_ampl, &nRead, &
maxI,
295 &leakCorrApplied, &t0, &t2);
301 if (maxA<minA) minA=maxA;
302 if (t2<minA) minA=t2;
303 if (minA<0) { maxA-=minA; t0-=minA; t2-=minA; }
305 float wpksamp = (t0 + maxA + t2);
306 if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
309 if (slewCorrect) time-=hcalTimeSlew_delay_->
delay(
std::max(1.0,fc_ampl),slewFlavor);
315 if(useLeak && !leakCorrApplied) {
316 uncorr_ampl *=
leakCorr(uncorr_ampl);
317 if (puCorrMethod < 2)
321 RecHit rh(digi.id(),ampl,
time);
329 return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
341 return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
360 double amp_fC, ampl, uncorr_ampl, maxA;
362 bool leakCorrApplied;
368 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
369 &
maxI, &leakCorrApplied, &
t0, &t2);
372 if (maxI > 0 && maxI < (nRead - 1))
389 double amp_fC, ampl, uncorr_ampl, maxA;
391 bool leakCorrApplied;
397 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
398 &
maxI, &leakCorrApplied, &
t0, &t2);
401 if (maxI > 0 && maxI < (nRead - 1))
416 static const float low32[7] = {0.741,0.721,0.730,0.698,0.708,0.751,0.861};
417 static const float high32[7] = {0.973,0.925,0.900,0.897,0.950,0.935,1};
418 static const float low6[15] = {0.635,0.623,0.670,0.633,0.644,0.648,0.600,
419 0.570,0.595,0.554,0.505,0.513,0.515,0.561,0.579};
420 static const float high6[15] = {0.875,0.937,0.942,0.900,0.922,0.925,0.901,
421 0.850,0.852,0.818,0.731,0.717,0.782,0.853,0.778};
424 double slope, mid, en;
427 if (!(iphi==6 && ieta<0 && ieta>-16) && !(iphi==32 && ieta<0 && ieta>-8))
431 double xeta = (double) ieta;
432 if (energy > 0.) en=energy;
437 mid = 17.14 + 0.7147*xeta;
438 if (en > 100.) corr = high32[
jeta];
441 else if (iphi == 6 && runnum < 216091 ) {
443 mid = 15.96 + 0.3075*xeta;
444 if (en > 100.0) corr = high6[
jeta];
445 else corr = low6[
jeta]+(high6[
jeta]-low6[
jeta])/(1.0+
exp(-(en-mid)*slope));
543 yval = y1 + (y2-y1)*(flx-(
float)
index);
670 yval = y1 + (y2-y1)*(flx-(
float)
index);
static const float actual_ns_hf[num_bins_hf]
static float timeshift_ns_hf(float wpksamp)
Timeshift correction for the HF PMTs.
static const int MAXSAMPLES
virtual void apply(const HcalDetId &id, const double *inputCharge, unsigned lenInputCharge, const BunchXParameter *bcParams, unsigned lenBcParams, unsigned firstTimeSlice, unsigned nTimeSlices, double *correctedCharge, unsigned lenCorrectedCharge, bool *pulseShapeCorrApplied, bool *leakCorrApplied, bool *readjustTiming) const =0
double getCorrection(double fc_ampl) const
unique_ptr< ClusterSequence > cs
void beginRun(edm::EventSetup const &es)
static const double slope[3]
void setHOPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
edm::DataFrame::id_type id() const
std::tuple< unsigned int, int, int, DigiType, int, int, int, float > Digi
const BunchXParameter * bunchCrossingInfo_
boost::shared_ptr< AbsOOTPileupCorrection > hoPileupCorr_
std::unique_ptr< HcalPulseContainmentManager > pulseCorr_
static const float wpksamp0_hbheho
void setBXInfo(const BunchXParameter *info, unsigned lenInfo)
static const float wpksamp0_hf
void setRawEnergy(HcalRecHit &h, float e)
static const float actual_ns_hbheho[num_bins_hbheho]
HcalDetId const & id() const
unsigned lenBunchCrossingInfo_
double MaximumFractionalError
void initPulseCorr(int toadd)
HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs)
static float leakCorr(double energy)
Leak correction.
HFRecHit reconstruct(const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void removePileup(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const int ifirst, const int n, const bool pulseCorrect, const HcalPulseContainmentCorrection *corr, const AbsOOTPileupCorrection *pileupCorrection, const BunchXParameter *bxInfo, const unsigned lenInfo, double *p_maxA, double *p_ampl, double *p_uncorr_ampl, double *p_fc_ampl, int *p_nRead, int *p_maxI, bool *leakCorrApplied, float *p_t0, float *p_t2)
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
float timeshift_ns_hbheho(float wpksamp)
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
void setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)
int size() const
get the size
HFRecHit reconstructQIE10(const QIE10DataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
constexpr double timecorr() const
get time correction factor
static const int num_bins_hf
boost::shared_ptr< AbsOOTPileupCorrection > hfPileupCorr_
static const int num_bins_hbheho
RecHit reco(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const int ifirst, const int n, const bool slewCorrect, const bool pulseCorrect, const HcalPulseContainmentCorrection *corr, const HcalTimeSlew::BiasSetting slewFlavor, const int runnum, const bool useLeak, const AbsOOTPileupCorrection *pileupCorrection, const BunchXParameter *bxInfo, const unsigned lenInfo, const int puCorrMethod, const HcalTimeSlew *hcalTimeSlew_delay_)
float hbminus_special_ecorr(int ieta, int iphi, double energy, int runnum)
Ugly hack to apply energy corrections to some HB- cells.
float recoHFTime(const Digi &digi, const int maxI, const double amp_fC, const bool slewCorrect, double maxA, float t0, float t2)
const HcalTimeSlew * hcalTimeSlew_delay_
float delay(float fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
void setHFPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
virtual bool inputIsEnergy() const =0
void setAuxEnergy(HcalRecHit &h, float e)