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 253 of file HcalSimpleRecAlgo.cc.

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

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

◆ 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 73 of file HcalSimpleRecAlgo.cc.

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

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

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

◆ 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 107 of file HcalSimpleRecAlgo.cc.

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

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

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