21 correctForTimeslew_(correctForTimeslew),
22 correctForPulse_(correctForPulse),
23 phaseNS_(phaseNS), runnum_(0), setLeakCorrection_(
false), puCorrMethod_(0)
62 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
68 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
74 const unsigned lenInfo)
84 static float leakCorr(
double energy);
90 const bool slewCorrect,
double maxA,
float t0,
float t2)
104 if (wpksamp != 0.
f) wpksamp = maxA/wpksamp;
107 if (wpksamp != 0.
f) wpksamp = 1.+(t2/wpksamp);
112 if (slewCorrect && amp_fC > 0.0) {
114 double tslew=
exp(0.337681-5.94689
e-4*amp_fC)+
exp(2.44628-1.34888
e-2*amp_fC);
115 time -= (
float)tslew;
125 const int ifirst,
const int n,
126 const bool pulseCorrect,
129 const BunchXParameter* bxInfo,
const unsigned lenInfo,
130 double* p_maxA,
double* p_ampl,
double* p_uncorr_ampl,
131 double* p_fc_ampl,
int* p_nRead,
int* p_maxI,
132 bool* leakCorrApplied,
float* p_t0,
float* p_t2)
136 const int nRead = cs.
size();
137 const int iStop =
std::min(nRead, n + ifirst);
144 double* correctedEnergy =
nullptr;
145 double fc_ampl = 0.0, corr_fc_ampl = 0.0;
146 bool pulseShapeCorrApplied =
false, readjustTiming =
false;
147 *leakCorrApplied =
false;
149 if (pileupCorrection)
151 correctedEnergy = &buf[0];
156 for (
int i=0;
i<nRead; ++
i)
158 const int capid = digi[
i].capid();
159 correctionInput[
i] = cs[
i] - calibs.
pedestal(capid);
163 for (
int i=ifirst;
i<iStop; ++
i)
164 fc_ampl += correctionInput[
i];
167 for (
int i=0;
i<nRead; ++
i)
169 uncorrectedEnergy[
i] = correctionInput[
i]*gains[
i];
171 correctionInput[
i] = uncorrectedEnergy[
i];
174 pileupCorrection->
apply(digi.id(), correctionInput, nRead,
175 bxInfo, lenInfo, ifirst,
n,
177 &pulseShapeCorrApplied, leakCorrApplied,
183 for (
int i=ifirst;
i<iStop; ++
i)
185 corr_fc_ampl += correctedEnergy[
i]/gains[
i];
189 for (
int i=ifirst;
i<iStop; ++
i)
190 corr_fc_ampl += correctedEnergy[
i];
191 for (
int i=0;
i<nRead; ++
i)
192 correctedEnergy[
i] *= gains[
i];
197 correctedEnergy = &uncorrectedEnergy[0];
200 const int istart =
std::max(ifirst - 1, 0);
201 const int iend =
std::min(n + ifirst + 1, nRead);
202 for (
int i=istart;
i<iend; ++
i)
204 const int capid = digi[
i].capid();
205 float ta = cs[
i] - calibs.
pedestal(capid);
206 if (
i >= ifirst &&
i < iStop)
209 uncorrectedEnergy[
i] = ta;
211 corr_fc_ampl = fc_ampl;
215 double ampl = 0.0, corr_ampl = 0.0;
216 for (
int i=ifirst;
i<iStop; ++
i)
218 ampl += uncorrectedEnergy[
i];
219 corr_ampl += correctedEnergy[
i];
223 if (corr && pulseCorrect)
226 if (pileupCorrection)
228 if (!pulseShapeCorrApplied)
236 const double *etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
237 int maxI = -1;
double maxA = -1.e300;
238 for (
int i=ifirst;
i<iStop; ++
i)
248 *p_uncorr_ampl = ampl;
249 *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
253 if (maxI <= 0 || maxI >= (nRead-1))
255 LogDebug(
"HCAL Pulse") <<
"HcalSimpleRecAlgoImpl::removePileup :" 256 <<
" Invalid max amplitude position, " 257 <<
" max Amplitude: " << maxI
258 <<
" first: " << ifirst
259 <<
" last: " << ifirst + n
266 *p_t0 = etime[maxI - 1];
267 *p_t2 = etime[maxI + 1];
272 template<
class Digi,
class RecHit>
275 const int ifirst,
const int n,
const bool slewCorrect,
278 const int runnum,
const bool useLeak,
280 const BunchXParameter* bxInfo,
const unsigned lenInfo,
285 double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
286 int nRead = 0,
maxI = -1;
287 bool leakCorrApplied =
false;
296 pulseCorrect, corr, inputAbsOOTpuCorr,
297 bxInfo, lenInfo, &maxA, &l,
298 &uncorr_ampl, &fc_ampl, &nRead, &
maxI,
299 &leakCorrApplied, &t0, &
t2);
305 if (maxA<minA) minA=maxA;
306 if (
t2<minA) minA=
t2;
307 if (minA<0) { maxA-=minA; t0-=minA;
t2-=minA; }
309 float wpksamp = (t0 + maxA +
t2);
310 if (wpksamp!=0) wpksamp=(maxA + 2.0*
t2) / wpksamp;
313 if (slewCorrect) time-=hcalTimeSlew_delay_->
delay(
std::max(1.0,fc_ampl),slewFlavor);
319 if(useLeak && !leakCorrApplied) {
320 uncorr_ampl *=
leakCorr(uncorr_ampl);
321 if (puCorrMethod < 2)
325 RecHit rh(digi.id(),ampl,
time);
333 return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
345 return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
364 double amp_fC, ampl, uncorr_ampl, maxA;
366 bool leakCorrApplied;
372 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
376 if (maxI > 0 && maxI < (nRead - 1))
393 double amp_fC, ampl, uncorr_ampl, maxA;
395 bool leakCorrApplied;
401 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
405 if (maxI > 0 && maxI < (nRead - 1))
420 static const float low32[7] = {0.741,0.721,0.730,0.698,0.708,0.751,0.861};
421 static const float high32[7] = {0.973,0.925,0.900,0.897,0.950,0.935,1};
422 static const float low6[15] = {0.635,0.623,0.670,0.633,0.644,0.648,0.600,
423 0.570,0.595,0.554,0.505,0.513,0.515,0.561,0.579};
424 static const float high6[15] = {0.875,0.937,0.942,0.900,0.922,0.925,0.901,
425 0.850,0.852,0.818,0.731,0.717,0.782,0.853,0.778};
428 double slope, mid, en;
431 if (!(iphi==6 && ieta<0 && ieta>-16) && !(iphi==32 && ieta<0 && ieta>-8))
435 double xeta = (double) ieta;
436 if (energy > 0.) en=energy;
441 mid = 17.14 + 0.7147*xeta;
442 if (en > 100.) corr = high32[
jeta];
445 else if (iphi == 6 && runnum < 216091 ) {
447 mid = 15.96 + 0.3075*xeta;
448 if (en > 100.0) corr = high6[
jeta];
449 else corr = low6[
jeta]+(high6[
jeta]-low6[
jeta])/(1.0+
exp(-(en-mid)*slope));
547 yval = y1 + (y2-y1)*(flx-(
float)
index);
674 yval = y1 + (y2-y1)*(flx-(
float)
index);
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 PulseShapeFitOOTPileupCorrection *psFitOOTpuCorr, HcalDeterministicFit *hltOOTpuCorr, PedestalSub *hltPedSub, const HcalTimeSlew *hcalTimeSlew_delay_)
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.
std::unique_ptr< HcalDeterministicFit > hltOOTpuCorr_
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
std::unique_ptr< PedestalSub > pedSubFxn_
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
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
std::unique_ptr< PulseShapeFitOOTPileupCorrection > psFitOOTpuCorr_
void setHFPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
virtual bool inputIsEnergy() const =0
void setAuxEnergy(HcalRecHit &h, float e)