21 correctForTimeslew_(correctForTimeslew),
22 correctForPulse_(correctForPulse),
23 phaseNS_(phaseNS), runnum_(0), setLeakCorrection_(
false), puCorrMethod_(0)
60 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
66 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
72 const unsigned lenInfo)
82 static float leakCorr(
double energy);
88 const bool slewCorrect,
double maxA,
float t0,
float t2)
102 if (wpksamp != 0.
f) wpksamp = maxA/wpksamp;
105 if (wpksamp != 0.
f) wpksamp = 1.+(t2/wpksamp);
110 if (slewCorrect && amp_fC > 0.0) {
112 double tslew=
exp(0.337681-5.94689
e-4*amp_fC)+
exp(2.44628-1.34888
e-2*amp_fC);
113 time -= (
float)tslew;
123 const int ifirst,
const int n,
124 const bool pulseCorrect,
127 const BunchXParameter* bxInfo,
const unsigned lenInfo,
128 double* p_maxA,
double* p_ampl,
double* p_uncorr_ampl,
129 double* p_fc_ampl,
int* p_nRead,
int* p_maxI,
130 bool* leakCorrApplied,
float* p_t0,
float* p_t2)
134 const int nRead = cs.
size();
135 const int iStop =
std::min(nRead, n + ifirst);
142 double* correctedEnergy =
nullptr;
143 double fc_ampl = 0.0, corr_fc_ampl = 0.0;
144 bool pulseShapeCorrApplied =
false, readjustTiming =
false;
145 *leakCorrApplied =
false;
147 if (pileupCorrection)
149 correctedEnergy = &buf[0];
154 for (
int i=0;
i<nRead; ++
i)
156 const int capid = digi[
i].capid();
157 correctionInput[
i] = cs[
i] - calibs.
pedestal(capid);
161 for (
int i=ifirst;
i<iStop; ++
i)
162 fc_ampl += correctionInput[
i];
165 for (
int i=0;
i<nRead; ++
i)
167 uncorrectedEnergy[
i] = correctionInput[
i]*gains[
i];
169 correctionInput[
i] = uncorrectedEnergy[
i];
172 pileupCorrection->
apply(digi.id(), correctionInput, nRead,
173 bxInfo, lenInfo, ifirst,
n,
175 &pulseShapeCorrApplied, leakCorrApplied,
181 for (
int i=ifirst;
i<iStop; ++
i)
183 corr_fc_ampl += correctedEnergy[
i]/gains[
i];
187 for (
int i=ifirst;
i<iStop; ++
i)
188 corr_fc_ampl += correctedEnergy[
i];
189 for (
int i=0;
i<nRead; ++
i)
190 correctedEnergy[
i] *= gains[
i];
195 correctedEnergy = &uncorrectedEnergy[0];
198 const int istart =
std::max(ifirst - 1, 0);
199 const int iend =
std::min(n + ifirst + 1, nRead);
200 for (
int i=istart;
i<iend; ++
i)
202 const int capid = digi[
i].capid();
203 float ta = cs[
i] - calibs.
pedestal(capid);
204 if (
i >= ifirst &&
i < iStop)
207 uncorrectedEnergy[
i] = ta;
209 corr_fc_ampl = fc_ampl;
213 double ampl = 0.0, corr_ampl = 0.0;
214 for (
int i=ifirst;
i<iStop; ++
i)
216 ampl += uncorrectedEnergy[
i];
217 corr_ampl += correctedEnergy[
i];
221 if (corr && pulseCorrect)
224 if (pileupCorrection)
226 if (!pulseShapeCorrApplied)
234 const double *etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
235 int maxI = -1;
double maxA = -1.e300;
236 for (
int i=ifirst;
i<iStop; ++
i)
246 *p_uncorr_ampl = ampl;
247 *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
251 if (maxI <= 0 || maxI >= (nRead-1))
253 LogDebug(
"HCAL Pulse") <<
"HcalSimpleRecAlgoImpl::removePileup :" 254 <<
" Invalid max amplitude position, " 255 <<
" max Amplitude: " << maxI
256 <<
" first: " << ifirst
257 <<
" last: " << ifirst + n
264 *p_t0 = etime[maxI - 1];
265 *p_t2 = etime[maxI + 1];
270 template<
class Digi,
class RecHit>
273 const int ifirst,
const int n,
const bool slewCorrect,
276 const int runnum,
const bool useLeak,
278 const BunchXParameter* bxInfo,
const unsigned lenInfo,
279 const int puCorrMethod,
282 double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
283 int nRead = 0,
maxI = -1;
284 bool leakCorrApplied =
false;
293 pulseCorrect, corr, inputAbsOOTpuCorr,
294 bxInfo, lenInfo, &maxA, &l,
295 &uncorr_ampl, &fc_ampl, &nRead, &
maxI,
296 &leakCorrApplied, &t0, &
t2);
302 if (maxA<minA) minA=maxA;
303 if (
t2<minA) minA=
t2;
304 if (minA<0) { maxA-=minA; t0-=minA;
t2-=minA; }
306 float wpksamp = (t0 + maxA +
t2);
307 if (wpksamp!=0) wpksamp=(maxA + 2.0*
t2) / wpksamp;
310 if (slewCorrect) time-=hcalTimeSlew_delay_->
delay(
std::max(1.0,fc_ampl),slewFlavor);
316 if(useLeak && !leakCorrApplied) {
317 uncorr_ampl *=
leakCorr(uncorr_ampl);
318 if (puCorrMethod < 2)
322 RecHit rh(digi.id(),ampl,
time);
330 return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
342 return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
361 double amp_fC, ampl, uncorr_ampl, maxA;
363 bool leakCorrApplied;
369 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
373 if (maxI > 0 && maxI < (nRead - 1))
390 double amp_fC, ampl, uncorr_ampl, maxA;
392 bool leakCorrApplied;
398 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
402 if (maxI > 0 && maxI < (nRead - 1))
417 static const float low32[7] = {0.741,0.721,0.730,0.698,0.708,0.751,0.861};
418 static const float high32[7] = {0.973,0.925,0.900,0.897,0.950,0.935,1};
419 static const float low6[15] = {0.635,0.623,0.670,0.633,0.644,0.648,0.600,
420 0.570,0.595,0.554,0.505,0.513,0.515,0.561,0.579};
421 static const float high6[15] = {0.875,0.937,0.942,0.900,0.922,0.925,0.901,
422 0.850,0.852,0.818,0.731,0.717,0.782,0.853,0.778};
425 double slope, mid, en;
428 if (!(iphi==6 && ieta<0 && ieta>-16) && !(iphi==32 && ieta<0 && ieta>-8))
432 double xeta = (double) ieta;
433 if (energy > 0.) en=energy;
438 mid = 17.14 + 0.7147*xeta;
439 if (en > 100.) corr = high32[
jeta];
442 else if (iphi == 6 && runnum < 216091 ) {
444 mid = 15.96 + 0.3075*xeta;
445 if (en > 100.0) corr = high6[
jeta];
446 else corr = low6[
jeta]+(high6[
jeta]-low6[
jeta])/(1.0+
exp(-(en-mid)*slope));
544 yval = y1 + (y2-y1)*(flx-(
float)
index);
671 yval = y1 + (y2-y1)*(flx-(
float)
index);
static const float actual_ns_hf[num_bins_hf]
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
auto_ptr< ClusterSequence > cs
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
void beginRun(edm::EventSetup const &es)
static const double slope[3]
double delay(double 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...
void setHOPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
edm::DataFrame::id_type id() const
double pedestal(int fCapId) const
get pedestal for capid=0..3
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]
auto const T2 &decltype(t1.eta()) t2
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)
void setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)
int size() const
get the size
double timecorr() const
get time correction factor
HFRecHit reconstructQIE10(const QIE10DataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
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_
const HcalDetId & id() const
void setHFPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
virtual bool inputIsEnergy() const =0
void setAuxEnergy(HcalRecHit &h, float e)