CMS 3D CMS Logo

Functions
HcalSimpleRecAlgoImpl Namespace Reference

Functions

template<class Digi , class RecHit >
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_)
 
template<class Digi >
float recoHFTime (const Digi &digi, const int maxI, const double amp_fC, const bool slewCorrect, double maxA, float t0, float t2)
 
template<class Digi >
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)
 

Function Documentation

◆ reco()

template<class Digi , class RecHit >
RecHit HcalSimpleRecAlgoImpl::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_ 
)
inline

Definition at line 251 of file HcalSimpleRecAlgo.cc.

266  {
267  double fc_ampl = 0, ampl = 0, uncorr_ampl = 0, m3_ampl = 0, maxA = -1.e300;
268  int nRead = 0, maxI = -1;
269  bool leakCorrApplied = false;
270  float t0 = 0, t2 = 0;
271  float time = -9999;
272 
273  // Disable method 1 inside the removePileup function this way!
274  // Some code in removePileup does NOT do pileup correction & to make sure maximum share of code
275  const AbsOOTPileupCorrection* inputAbsOOTpuCorr = (puCorrMethod == 1 ? pileupCorrection : nullptr);
276 
277  removePileup(digi,
278  coder,
279  calibs,
280  ifirst,
281  n,
282  pulseCorrect,
283  corr,
284  inputAbsOOTpuCorr,
285  bxInfo,
286  lenInfo,
287  &maxA,
288  &ampl,
289  &uncorr_ampl,
290  &fc_ampl,
291  &nRead,
292  &maxI,
293  &leakCorrApplied,
294  &t0,
295  &t2);
296 
297  if (maxI > 0 && maxI < (nRead - 1)) {
298  // Handle negative excursions by moving "zero":
299  float minA = t0;
300  if (maxA < minA)
301  minA = maxA;
302  if (t2 < minA)
303  minA = t2;
304  if (minA < 0) {
305  maxA -= minA;
306  t0 -= minA;
307  t2 -= minA;
308  } // positivizes all samples
309 
310  float wpksamp = (t0 + maxA + t2);
311  if (wpksamp != 0)
312  wpksamp = (maxA + 2.0 * t2) / wpksamp;
313  time = (maxI - digi.presamples()) * 25.0 + timeshift_ns_hbheho(wpksamp);
314 
315  if (slewCorrect)
316  time -= hcalTimeSlew_delay_->delay(std::max(1.0, fc_ampl), slewFlavor);
317 
318  time = time - calibs.timecorr(); // time calibration
319  }
320 
321  // Correction for a leak to pre-sample
322  if (useLeak && !leakCorrApplied) {
323  uncorr_ampl *= leakCorr(uncorr_ampl);
324  if (puCorrMethod < 2)
325  ampl *= leakCorr(ampl);
326  }
327 
328  RecHit rh(digi.id(), ampl, time);
329  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
330  setAuxEnergy(rh, static_cast<float>(m3_ampl));
331  return rh;
332  }

References alignCSCRings::corr, HcalTimeSlew::delay(), leakCorr(), SiStripPI::max, findQualityFiles::maxI, dqmiodumpmetadata::n, removePileup(), setAuxEnergy(), setRawEnergy(), FrontierCondition_GT_autoExpress_cfi::t0, RandomServiceHelper::t2, ntuplemaker::time, HcalCalibrations::timecorr(), and timeshift_ns_hbheho().

◆ recoHFTime()

template<class Digi >
float HcalSimpleRecAlgoImpl::recoHFTime ( const Digi &  digi,
const int  maxI,
const double  amp_fC,
const bool  slewCorrect,
double  maxA,
float  t0,
float  t2 
)
inline

Definition at line 71 of file HcalSimpleRecAlgo.cc.

72  {
73  // Handle negative excursions by moving "zero":
74  float zerocorr = std::min(t0, t2);
75  if (zerocorr < 0.f) {
76  t0 -= zerocorr;
77  t2 -= zerocorr;
78  maxA -= zerocorr;
79  }
80 
81  // pair the peak with the larger of the two neighboring time samples
82  float wpksamp = 0.f;
83  if (t0 > t2) {
84  wpksamp = t0 + maxA;
85  if (wpksamp != 0.f)
86  wpksamp = maxA / wpksamp;
87  } else {
88  wpksamp = maxA + t2;
89  if (wpksamp != 0.f)
90  wpksamp = 1. + (t2 / wpksamp);
91  }
92 
93  float time = (maxI - digi.presamples()) * 25.0 + timeshift_ns_hf(wpksamp);
94 
95  if (slewCorrect && amp_fC > 0.0) {
96  // -5.12327 - put in calibs.timecorr()
97  double tslew = exp(0.337681 - 5.94689e-4 * amp_fC) + exp(2.44628 - 1.34888e-2 * amp_fC);
98  time -= (float)tslew;
99  }
100 
101  return time;
102  }

References MillePedeFileConverter_cfg::e, JetChargeProducer_cfi::exp, f, dqmMemoryStats::float, findQualityFiles::maxI, min(), FrontierCondition_GT_autoExpress_cfi::t0, RandomServiceHelper::t2, ntuplemaker::time, and timeshift_ns_hf().

Referenced by HcalSimpleRecAlgo::reconstruct(), and HcalSimpleRecAlgo::reconstructQIE10().

◆ removePileup()

template<class Digi >
void HcalSimpleRecAlgoImpl::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 
)
inline

Definition at line 105 of file HcalSimpleRecAlgo.cc.

123  {
124  CaloSamples cs;
125  coder.adc2fC(digi, cs);
126  const int nRead = cs.size();
127  const int iStop = std::min(nRead, n + ifirst);
128 
129  // Signal energy will be calculated both with
130  // and without OOT pileup corrections. Try to
131  // arrange the calculations so that we do not
132  // repeat them.
133  double uncorrectedEnergy[CaloSamples::MAXSAMPLES]{}, buf[CaloSamples::MAXSAMPLES]{};
134  double* correctedEnergy = nullptr;
135  double fc_ampl = 0.0, corr_fc_ampl = 0.0;
136  bool pulseShapeCorrApplied = false, readjustTiming = false;
137  *leakCorrApplied = false;
138 
139  if (pileupCorrection) {
140  correctedEnergy = &buf[0];
141 
142  double correctionInput[CaloSamples::MAXSAMPLES]{};
143  double gains[CaloSamples::MAXSAMPLES]{};
144 
145  for (int i = 0; i < nRead; ++i) {
146  const int capid = digi[i].capid();
147  correctionInput[i] = cs[i] - calibs.pedestal(capid);
148  gains[i] = calibs.respcorrgain(capid);
149  }
150 
151  for (int i = ifirst; i < iStop; ++i)
152  fc_ampl += correctionInput[i];
153 
154  const bool useGain = pileupCorrection->inputIsEnergy();
155  for (int i = 0; i < nRead; ++i) {
156  uncorrectedEnergy[i] = correctionInput[i] * gains[i];
157  if (useGain)
158  correctionInput[i] = uncorrectedEnergy[i];
159  }
160 
161  pileupCorrection->apply(digi.id(),
162  correctionInput,
163  nRead,
164  bxInfo,
165  lenInfo,
166  ifirst,
167  n,
168  correctedEnergy,
170  &pulseShapeCorrApplied,
171  leakCorrApplied,
172  &readjustTiming);
173  if (useGain) {
174  // Gain factors have been already applied.
175  // Divide by them for accumulating corr_fc_ampl.
176  for (int i = ifirst; i < iStop; ++i)
177  if (gains[i])
178  corr_fc_ampl += correctedEnergy[i] / gains[i];
179  } else {
180  for (int i = ifirst; i < iStop; ++i)
181  corr_fc_ampl += correctedEnergy[i];
182  for (int i = 0; i < nRead; ++i)
183  correctedEnergy[i] *= gains[i];
184  }
185  } else {
186  correctedEnergy = &uncorrectedEnergy[0];
187 
188  // In this situation, we do not need to process all time slices
189  const int istart = std::max(ifirst - 1, 0);
190  const int iend = std::min(n + ifirst + 1, nRead);
191  for (int i = istart; i < iend; ++i) {
192  const int capid = digi[i].capid();
193  float ta = cs[i] - calibs.pedestal(capid);
194  if (i >= ifirst && i < iStop)
195  fc_ampl += ta;
196  ta *= calibs.respcorrgain(capid);
197  uncorrectedEnergy[i] = ta;
198  }
199  corr_fc_ampl = fc_ampl;
200  }
201 
202  // Uncorrected and corrected energies
203  double ampl = 0.0, corr_ampl = 0.0;
204  for (int i = ifirst; i < iStop; ++i) {
205  ampl += uncorrectedEnergy[i];
206  corr_ampl += correctedEnergy[i];
207  }
208 
209  // Apply phase-based amplitude correction:
210  if (corr && pulseCorrect) {
211  ampl *= corr->getCorrection(fc_ampl);
212  if (pileupCorrection) {
213  if (!pulseShapeCorrApplied)
214  corr_ampl *= corr->getCorrection(corr_fc_ampl);
215  } else
216  corr_ampl = ampl;
217  }
218 
219  // Which energies we want to use for timing?
220  const double* etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
221  int maxI = -1;
222  double maxA = -1.e300;
223  for (int i = ifirst; i < iStop; ++i)
224  if (etime[i] > maxA) {
225  maxA = etime[i];
226  maxI = i;
227  }
228 
229  // Fill out the output
230  *p_maxA = maxA;
231  *p_ampl = corr_ampl;
232  *p_uncorr_ampl = ampl;
233  *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
234  *p_nRead = nRead;
235  *p_maxI = maxI;
236 
237  if (maxI <= 0 || maxI >= (nRead - 1)) {
238  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgoImpl::removePileup :"
239  << " Invalid max amplitude position, "
240  << " max Amplitude: " << maxI << " first: " << ifirst << " last: " << ifirst + n
241  << std::endl;
242  *p_t0 = 0.f;
243  *p_t2 = 0.f;
244  } else {
245  *p_t0 = etime[maxI - 1];
246  *p_t2 = etime[maxI + 1];
247  }
248  }

References HcalCoder::adc2fC(), AbsOOTPileupCorrection::apply(), visDQMUpload::buf, alignCSCRings::corr, fwrapper::cs, mps_fire::i, AbsOOTPileupCorrection::inputIsEnergy(), LogDebug, SiStripPI::max, findQualityFiles::maxI, CaloSamples::MAXSAMPLES, min(), dqmiodumpmetadata::n, HcalCalibrations::pedestal(), and HcalCalibrations::respcorrgain().

Referenced by reco(), HcalSimpleRecAlgo::reconstruct(), and HcalSimpleRecAlgo::reconstructQIE10().

setAuxEnergy
void setAuxEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:234
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
mps_fire.i
i
Definition: mps_fire.py:355
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HcalCoder::adc2fC
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:45
min
T min(T a, T b)
Definition: MathUtil.h:58
HcalSimpleRecAlgoImpl::removePileup
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)
Definition: HcalSimpleRecAlgo.cc:105
findQualityFiles.maxI
int maxI
Definition: findQualityFiles.py:182
timeshift_ns_hf
static float timeshift_ns_hf(float wpksamp)
Timeshift correction for the HF PMTs.
Definition: HcalSimpleRecAlgo.cc:708
AbsOOTPileupCorrection
Definition: AbsOOTPileupCorrection.h:26
CaloSamples::MAXSAMPLES
static const int MAXSAMPLES
Definition: CaloSamples.h:86
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...
Definition: HcalTimeSlew.cc:20
leakCorr
static float leakCorr(double energy)
Leak correction.
Definition: HcalSimpleRecAlgo.cc:508
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
HcalCalibrations::respcorrgain
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
Definition: HcalCalibrations.h:42
HcalCalibrations::timecorr
constexpr double timecorr() const
get time correction factor
Definition: HcalCalibrations.h:52
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
AbsOOTPileupCorrection::inputIsEnergy
virtual bool inputIsEnergy() const =0
CaloSamples
Definition: CaloSamples.h:14
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
timeshift_ns_hbheho
float timeshift_ns_hbheho(float wpksamp)
Definition: HcalSimpleRecAlgo.cc:582
HcalCalibrations::pedestal
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
Definition: HcalCalibrations.h:46
setRawEnergy
void setRawEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:217
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
ntuplemaker.time
time
Definition: ntuplemaker.py:310
AbsOOTPileupCorrection::apply
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
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37