25 correctForPulse_(correctForPulse),
29 setLeakCorrection_(
false),
46 bool correctForTimeslew,
bool correctForPulse,
bool setLeakCorrection,
int pileupCleaningID,
float phaseNS) {
74 const Digi& digi,
const int maxI,
const double amp_fC,
const bool slewCorrect,
double maxA,
float t0,
float t2) {
88 wpksamp = maxA / wpksamp;
92 wpksamp = 1. + (
t2 / wpksamp);
97 if (slewCorrect && amp_fC > 0.0) {
99 double tslew =
exp(0.337681 - 5.94689
e-4 * amp_fC) +
exp(2.44628 - 1.34888
e-2 * amp_fC);
106 template <
class Digi>
112 const bool pulseCorrect,
115 const BunchXParameter* bxInfo,
116 const unsigned lenInfo,
119 double* p_uncorr_ampl,
123 bool* leakCorrApplied,
128 const int nRead =
cs.size();
129 const int iStop =
std::min(nRead,
n + ifirst);
136 double* correctedEnergy =
nullptr;
137 double fc_ampl = 0.0, corr_fc_ampl = 0.0;
138 bool pulseShapeCorrApplied =
false, readjustTiming =
false;
139 *leakCorrApplied =
false;
141 if (pileupCorrection) {
142 correctedEnergy = &
buf[0];
147 for (
int i = 0;
i < nRead; ++
i) {
148 const int capid = digi[
i].capid();
153 for (
int i = ifirst;
i < iStop; ++
i)
154 fc_ampl += correctionInput[
i];
157 for (
int i = 0;
i < nRead; ++
i) {
158 uncorrectedEnergy[
i] = correctionInput[
i] *
gains[
i];
160 correctionInput[
i] = uncorrectedEnergy[
i];
163 pileupCorrection->
apply(digi.id(),
172 &pulseShapeCorrApplied,
178 for (
int i = ifirst;
i < iStop; ++
i)
180 corr_fc_ampl += correctedEnergy[
i] /
gains[
i];
182 for (
int i = ifirst;
i < iStop; ++
i)
183 corr_fc_ampl += correctedEnergy[
i];
184 for (
int i = 0;
i < nRead; ++
i)
185 correctedEnergy[
i] *=
gains[
i];
188 correctedEnergy = &uncorrectedEnergy[0];
191 const int istart =
std::max(ifirst - 1, 0);
192 const int iend =
std::min(
n + ifirst + 1, nRead);
193 for (
int i = istart;
i < iend; ++
i) {
194 const int capid = digi[
i].capid();
196 if (
i >= ifirst &&
i < iStop)
199 uncorrectedEnergy[
i] = ta;
201 corr_fc_ampl = fc_ampl;
205 double ampl = 0.0, corr_ampl = 0.0;
206 for (
int i = ifirst;
i < iStop; ++
i) {
207 ampl += uncorrectedEnergy[
i];
208 corr_ampl += correctedEnergy[
i];
212 if (
corr && pulseCorrect) {
213 ampl *=
corr->getCorrection(fc_ampl);
214 if (pileupCorrection) {
215 if (!pulseShapeCorrApplied)
216 corr_ampl *=
corr->getCorrection(corr_fc_ampl);
222 const double* etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
224 double maxA = -1.e300;
225 for (
int i = ifirst;
i < iStop; ++
i)
226 if (etime[
i] > maxA) {
234 *p_uncorr_ampl = ampl;
235 *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
239 if (maxI <= 0 || maxI >= (nRead - 1)) {
240 LogDebug(
"HCAL Pulse") <<
"HcalSimpleRecAlgoImpl::removePileup :" 241 <<
" Invalid max amplitude position, " 242 <<
" max Amplitude: " <<
maxI <<
" first: " << ifirst <<
" last: " << ifirst +
n 247 *p_t0 = etime[
maxI - 1];
248 *p_t2 = etime[
maxI + 1];
252 template <
class Digi,
class RecHit>
258 const bool slewCorrect,
259 const bool pulseCorrect,
265 const BunchXParameter* bxInfo,
266 const unsigned lenInfo,
267 const int puCorrMethod,
269 double fc_ampl = 0, ampl = 0, uncorr_ampl = 0, m3_ampl = 0, maxA = -1.e300;
270 int nRead = 0,
maxI = -1;
271 bool leakCorrApplied =
false;
272 float t0 = 0,
t2 = 0;
299 if (
maxI > 0 &&
maxI < (nRead - 1)) {
312 float wpksamp = (
t0 + maxA +
t2);
314 wpksamp = (maxA + 2.0 *
t2) / wpksamp;
324 if (useLeak && !leakCorrApplied) {
325 uncorr_ampl *=
leakCorr(uncorr_ampl);
326 if (puCorrMethod < 2)
330 RecHit rh(digi.id(), ampl,
time);
339 return HcalSimpleRecAlgoImpl::reco<HODataFrame, HORecHit>(digi,
362 return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame, HcalCalibRecHit>(digi,
387 double amp_fC, ampl, uncorr_ampl, maxA;
389 bool leakCorrApplied;
412 float time = -9999.f;
428 double amp_fC, ampl, uncorr_ampl, maxA;
430 bool leakCorrApplied;
453 float time = -9999.f;
467 static const float low32[7] = {0.741, 0.721, 0.730, 0.698, 0.708, 0.751, 0.861};
468 static const float high32[7] = {0.973, 0.925, 0.900, 0.897, 0.950, 0.935, 1};
469 static const float low6[15] = {
470 0.635, 0.623, 0.670, 0.633, 0.644, 0.648, 0.600, 0.570, 0.595, 0.554, 0.505, 0.513, 0.515, 0.561, 0.579};
471 static const float high6[15] = {
472 0.875, 0.937, 0.942, 0.900, 0.922, 0.925, 0.901, 0.850, 0.852, 0.818, 0.731, 0.717, 0.782, 0.853, 0.778};
474 double slope, mid, en;
477 if (!(
iphi == 6 && ieta < 0 && ieta > -16) && !(
iphi == 32 && ieta < 0 && ieta > -8))
481 double xeta = (double)
ieta;
489 mid = 17.14 + 0.7147 * xeta;
496 mid = 15.96 + 0.3075 * xeta;
virtual bool inputIsEnergy() const =0
static const float actual_ns_hf[num_bins_hf]
constexpr HcalDetId const & id() const
const edm::ESGetToken< HcalTimeSlew, HcalTimeSlewRecord > delayToken_
static float timeshift_ns_hf(float wpksamp)
Timeshift correction for the HF PMTs.
constexpr edm::DataFrame::id_type id() const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
static const int MAXSAMPLES
void setHFPileupCorrection(std::shared_ptr< AbsOOTPileupCorrection > corr)
void beginRun(edm::EventSetup const &es)
static const double slope[3]
const BunchXParameter * bunchCrossingInfo_
std::unique_ptr< HcalPulseContainmentManager > pulseCorr_
static const float wpksamp0_hbheho
void setBXInfo(const BunchXParameter *info, unsigned lenInfo)
static const float wpksamp0_hf
constexpr double timecorr() const
get time correction factor
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
void setRawEnergy(HcalRecHit &h, float e)
static const float actual_ns_hbheho[num_bins_hbheho]
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...
HFRecHit reconstructQIE10(const QIE10DataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
unsigned lenBunchCrossingInfo_
constexpr double MaximumFractionalError
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
void initPulseCorr(int toadd)
static float leakCorr(double energy)
Leak correction.
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)
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
float timeshift_ns_hbheho(float wpksamp)
constexpr float gains[NGAINS]
void setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)
static const int num_bins_hf
static const int num_bins_hbheho
std::shared_ptr< AbsOOTPileupCorrection > hfPileupCorr_
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_)
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
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_
HFRecHit reconstruct(const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
std::shared_ptr< AbsOOTPileupCorrection > hoPileupCorr_
HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs, edm::ConsumesCollector iC)
void setHOPileupCorrection(std::shared_ptr< AbsOOTPileupCorrection > corr)
void setAuxEnergy(HcalRecHit &h, float e)