20 correctForTimeslew_(correctForTimeslew),
21 correctForPulse_(correctForPulse),
22 phaseNS_(phaseNS), runnum_(0), setLeakCorrection_(
false), puCorrMethod_(0)
54 bool iApplyTimeSlew,
double iTS4Min,
const std::vector<double> & iTS4Max,
56 double iTimeMean,
double iTimeSig,
double iTimeSigSiPM,
57 double iPedMean,
double iPedSig,
double iPedSigSiPM,
58 double iNoise,
double iNoiseSiPM,
59 double iTMin,
double iTMax,
60 const std::vector<double> & its4Chi2,
int iFitTimes) {
61 if( iPedestalConstraint ) assert ( iPedSig );
62 if( iTimeConstraint ) assert( iTimeSig );
63 psFitOOTpuCorr_->setPUParams(iPedestalConstraint,iTimeConstraint,iAddPulseJitter,iApplyTimeSlew,
64 iTS4Min, iTS4Max, iPulseJitter,iTimeMean,iTimeSig,iTimeSigSiPM,iPedMean,iPedSig,iPedSigSiPM,iNoise,iNoiseSiPM,iTMin,iTMax,its4Chi2,
95 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
101 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
107 boost::shared_ptr<AbsOOTPileupCorrection>
corr)
113 const unsigned lenInfo)
123 static float leakCorr(
double energy);
129 const bool slewCorrect,
double maxA,
float t0,
float t2)
143 if (wpksamp != 0.
f) wpksamp = maxA/wpksamp;
146 if (wpksamp != 0.
f) wpksamp = 1.+(t2/wpksamp);
151 if (slewCorrect && amp_fC > 0.0) {
153 double tslew=
exp(0.337681-5.94689
e-4*amp_fC)+
exp(2.44628-1.34888
e-2*amp_fC);
154 time -= (
float)tslew;
164 const int ifirst,
const int n,
165 const bool pulseCorrect,
168 const BunchXParameter* bxInfo,
const unsigned lenInfo,
169 double* p_maxA,
double* p_ampl,
double* p_uncorr_ampl,
170 double* p_fc_ampl,
int* p_nRead,
int* p_maxI,
171 bool* leakCorrApplied,
float* p_t0,
float* p_t2)
175 const int nRead = cs.
size();
176 const int iStop =
std::min(nRead, n + ifirst);
183 double* correctedEnergy = 0;
184 double fc_ampl = 0.0, corr_fc_ampl = 0.0;
185 bool pulseShapeCorrApplied =
false, readjustTiming =
false;
186 *leakCorrApplied =
false;
188 if (pileupCorrection)
190 correctedEnergy = &buf[0];
195 for (
int i=0;
i<nRead; ++
i)
197 const int capid = digi[
i].capid();
198 correctionInput[
i] = cs[
i] - calibs.
pedestal(capid);
202 for (
int i=ifirst;
i<iStop; ++
i)
203 fc_ampl += correctionInput[
i];
206 for (
int i=0;
i<nRead; ++
i)
208 uncorrectedEnergy[
i] = correctionInput[
i]*gains[
i];
210 correctionInput[
i] = uncorrectedEnergy[
i];
213 pileupCorrection->
apply(digi.id(), correctionInput, nRead,
214 bxInfo, lenInfo, ifirst,
n,
216 &pulseShapeCorrApplied, leakCorrApplied,
222 for (
int i=ifirst;
i<iStop; ++
i)
224 corr_fc_ampl += correctedEnergy[
i]/gains[
i];
228 for (
int i=ifirst;
i<iStop; ++
i)
229 corr_fc_ampl += correctedEnergy[
i];
230 for (
int i=0;
i<nRead; ++
i)
231 correctedEnergy[
i] *= gains[
i];
236 correctedEnergy = &uncorrectedEnergy[0];
239 const int istart =
std::max(ifirst - 1, 0);
240 const int iend =
std::min(n + ifirst + 1, nRead);
241 for (
int i=istart;
i<iend; ++
i)
243 const int capid = digi[
i].capid();
244 float ta = cs[
i] - calibs.
pedestal(capid);
245 if (
i >= ifirst &&
i < iStop)
248 uncorrectedEnergy[
i] = ta;
250 corr_fc_ampl = fc_ampl;
254 double ampl = 0.0, corr_ampl = 0.0;
255 for (
int i=ifirst;
i<iStop; ++
i)
257 ampl += uncorrectedEnergy[
i];
258 corr_ampl += correctedEnergy[
i];
262 if (corr && pulseCorrect)
265 if (pileupCorrection)
267 if (!pulseShapeCorrApplied)
275 const double *etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
276 int maxI = -1;
double maxA = -1.e300;
277 for (
int i=ifirst;
i<iStop; ++
i)
287 *p_uncorr_ampl = ampl;
288 *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
292 if (maxI <= 0 || maxI >= (nRead-1))
294 LogDebug(
"HCAL Pulse") <<
"HcalSimpleRecAlgoImpl::removePileup :" 295 <<
" Invalid max amplitude position, " 296 <<
" max Amplitude: " << maxI
297 <<
" first: " << ifirst
298 <<
" last: " << ifirst + n
305 *p_t0 = etime[maxI - 1];
306 *p_t2 = etime[maxI + 1];
311 template<
class Digi,
class RecHit>
314 const int ifirst,
const int n,
const bool slewCorrect,
317 const int runnum,
const bool useLeak,
321 double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
322 int nRead = 0,
maxI = -1;
323 bool leakCorrApplied =
false;
326 float m3_time = -9999;
333 pulseCorrect, corr, inputAbsOOTpuCorr,
334 bxInfo, lenInfo, &maxA, &l,
335 &uncorr_ampl, &fc_ampl, &nRead, &
maxI,
336 &leakCorrApplied, &t0, &
t2);
342 if (maxA<minA) minA=maxA;
343 if (
t2<minA) minA=
t2;
344 if (minA<0) { maxA-=minA; t0-=minA;
t2-=minA; }
346 float wpksamp = (t0 + maxA +
t2);
347 if (wpksamp!=0) wpksamp=(maxA + 2.0*
t2) / wpksamp;
356 if( puCorrMethod == 2 ){
358 bool useTriple=
false;
363 std::vector<int> capidvec;
364 for(
int ip=0; ip<cs.
size(); ip++){
365 const int capid = digi[ip].capid();
366 capidvec.push_back(capid);
368 psFitOOTpuCorr->
apply(cs, capidvec, calibs, ampl, time, useTriple,chi2);
377 std::vector<int> capidvec;
378 for(
int ip=0; ip<cs.
size(); ip++){
379 const int capid = digi[ip].capid();
380 capidvec.push_back(capid);
382 hltOOTpuCorr->
apply(cs, capidvec, calibs, digi, m3_ampl,m3_time);
383 if (puCorrMethod == 3) {ampl = m3_ampl; time=m3_time;}
390 const int ieta = cell.
ieta();
391 const int iphi = cell.
iphi();
399 if(useLeak && !leakCorrApplied) {
400 uncorr_ampl *=
leakCorr(uncorr_ampl);
401 if (puCorrMethod < 2)
405 RecHit rh(digi.id(),ampl,
time);
411 template<
class Digi,
class RecHit>
414 const int ifirst,
const int n,
const bool slewCorrect,
417 const int runnum,
const bool useLeak,
421 double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
422 int nRead = 0,
maxI = -1;
423 bool leakCorrApplied =
false;
426 bool useTriple =
false;
434 pulseCorrect, corr, inputAbsOOTpuCorr,
435 bxInfo, lenInfo, &maxA, &l,
436 &uncorr_ampl, &fc_ampl, &nRead, &
maxI,
437 &leakCorrApplied, &t0, &
t2);
443 if (maxA<minA) minA=maxA;
444 if (
t2<minA) minA=
t2;
445 if (minA<0) { maxA-=minA; t0-=minA;
t2-=minA; }
447 float wpksamp = (t0 + maxA +
t2);
448 if (wpksamp!=0) wpksamp=(maxA + 2.0*
t2) / wpksamp;
457 if( puCorrMethod == 2 ){
461 std::vector<int> capidvec;
462 for(
int ip=0; ip<cs.
size(); ip++){
463 const int capid = digi[ip].capid();
464 capidvec.push_back(capid);
466 psFitOOTpuCorr->
apply(cs, capidvec, calibs, ampl, time, useTriple,chi2);
475 std::vector<int> capidvec;
476 for(
int ip=0; ip<cs.
size(); ip++){
477 const int capid = digi[ip].capid();
478 capidvec.push_back(capid);
483 hltOOTpuCorr->
apply(cs, capidvec, calibs, digi, m3_ampl, m3_time);
484 if (puCorrMethod == 3) { ampl = m3_ampl; time = m3_time; }
492 const int ieta = cell.
ieta();
493 const int iphi = cell.
iphi();
501 if(useLeak && !leakCorrApplied) {
502 uncorr_ampl *=
leakCorr(uncorr_ampl);
503 if (puCorrMethod < 2)
512 rh.setChiSquared(chi2);
521 return HcalSimpleRecAlgoImpl::recoHBHE<HBHEDataFrame,HBHERecHit>(digi,coder,calibs,
532 return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
542 return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
559 double amp_fC, ampl, uncorr_ampl, maxA;
561 bool leakCorrApplied;
567 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
571 if (maxI > 0 && maxI < (nRead - 1))
588 double amp_fC, ampl, uncorr_ampl, maxA;
590 bool leakCorrApplied;
596 &maxA, &l, &uncorr_ampl, &_fC, &nRead,
600 if (maxI > 0 && maxI < (nRead - 1))
615 static const float low32[7] = {0.741,0.721,0.730,0.698,0.708,0.751,0.861};
616 static const float high32[7] = {0.973,0.925,0.900,0.897,0.950,0.935,1};
617 static const float low6[15] = {0.635,0.623,0.670,0.633,0.644,0.648,0.600,
618 0.570,0.595,0.554,0.505,0.513,0.515,0.561,0.579};
619 static const float high6[15] = {0.875,0.937,0.942,0.900,0.922,0.925,0.901,
620 0.850,0.852,0.818,0.731,0.717,0.782,0.853,0.778};
623 double slope, mid, en;
626 if (!(iphi==6 && ieta<0 && ieta>-16) && !(iphi==32 && ieta<0 && ieta>-8))
630 double xeta = (double) ieta;
631 if (energy > 0.) en=energy;
636 mid = 17.14 + 0.7147*xeta;
637 if (en > 100.) corr = high32[
jeta];
640 else if (iphi == 6 && runnum < 216091 ) {
642 mid = 15.96 + 0.3075*xeta;
643 if (en > 100.0) corr = high6[
jeta];
644 else corr = low6[
jeta]+(high6[
jeta]-low6[
jeta])/(1.0+
exp(-(en-mid)*slope));
742 yval = y1 + (y2-y1)*(flx-(
float)
index);
869 yval = y1 + (y2-y1)*(flx-(
float)
index);
const Shape & getShape(int shapeType) const
static const float actual_ns_hf[num_bins_hf]
HBHERecHit reconstruct(const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void apply(const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, double &reconstructedEnergy, float &reconstructedTime, bool &useTriple, float &chi2) const
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.
void setMeth3Params(bool iApplyTimeSlew, float iPedSubThreshold, int iTimeSlewParsType, std::vector< double > iTimeSlewPars, double irespCorrM3)
std::unique_ptr< HcalDeterministicFit > hltOOTpuCorr_
HcalSubdetector subdet() const
get the subdetector
static const int MAXSAMPLES
void setpuCorrParams(bool iPedestalConstraint, bool iTimeConstraint, bool iAddPulseJitter, bool iApplyTimeSlew, double iTS4Min, const std::vector< double > &iTS4Max, double iPulseJitter, double iTimeMean, double iTimeSig, double iTimeSigSiPM, double iPedMean, double iPedSig, double iPedSigSiPM, double iNoise, double iNoiseSiPM, double iTMin, double iTMax, const std::vector< double > &its4Chi2, int iFitTimes)
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]
void setFlagField(uint32_t value, int base, int width=1)
void setHOPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
edm::DataFrame::id_type id() const
double pedestal(int fCapId) const
get pedestal for capid=0..3
HcalPulseShapes theHcalPulseShapes_
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)
boost::shared_ptr< AbsOOTPileupCorrection > hbhePileupCorr_
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
int ieta() const
get the cell ieta
std::unique_ptr< PedestalSub > pedSubFxn_
void initPulseCorr(int toadd)
HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs)
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)
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
float timeshift_ns_hbheho(float wpksamp)
int iphi() const
get the cell iphi
void apply(const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, const Digi &digi, double &l, float &time) const
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
void setHBHEPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
HFRecHit reconstructQIE10(const QIE10DataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void setForData(int runnum)
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.
RecHit recoHBHE(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)
float recoHFTime(const Digi &digi, const int maxI, const double amp_fC, const bool slewCorrect, double maxA, float t0, float t2)
const HcalDetId & id() const
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)
std::unique_ptr< PulseShapeFitOOTPileupCorrection > psFitOOTpuCorr_
void setHFPileupCorrection(boost::shared_ptr< AbsOOTPileupCorrection > corr)
virtual bool inputIsEnergy() const =0
void setAuxEnergy(HcalRecHit &h, float e)
static double delay(double fC, BiasSetting bias=Medium)
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...