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

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

References HcalTimeSlew::delay(), leakCorr(), SiStripPI::max, findQualityFiles::maxI, nullptr, removePileup(), setAuxEnergy(), setRawEnergy(), genVertex_cff::t0, ntuplemaker::time, HcalCalibrations::timecorr(), and timeshift_ns_hbheho().

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

References MillePedeFileConverter_cfg::e, JetChargeProducer_cfi::exp, f, objects.autophobj::float, min(), ntuplemaker::time, and timeshift_ns_hf().

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

88  {
89  // Handle negative excursions by moving "zero":
90  float zerocorr=std::min(t0,t2);
91  if (zerocorr<0.f) {
92  t0 -= zerocorr;
93  t2 -= zerocorr;
94  maxA -= zerocorr;
95  }
96 
97  // pair the peak with the larger of the two neighboring time samples
98  float wpksamp=0.f;
99  if (t0>t2) {
100  wpksamp = t0+maxA;
101  if (wpksamp != 0.f) wpksamp = maxA/wpksamp;
102  } else {
103  wpksamp = maxA+t2;
104  if (wpksamp != 0.f) wpksamp = 1.+(t2/wpksamp);
105  }
106 
107  float time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);
108 
109  if (slewCorrect && amp_fC > 0.0) {
110  // -5.12327 - put in calibs.timecorr()
111  double tslew=exp(0.337681-5.94689e-4*amp_fC)+exp(2.44628-1.34888e-2*amp_fC);
112  time -= (float)tslew;
113  }
114 
115  return time;
116  }
static float timeshift_ns_hf(float wpksamp)
Timeshift correction for the HF PMTs.
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
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 120 of file HcalSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), AbsOOTPileupCorrection::apply(), fwrapper::cs, HcalPulseContainmentCorrection::getCorrection(), mps_fire::i, AbsOOTPileupCorrection::inputIsEnergy(), LogDebug, SiStripPI::max, findQualityFiles::maxI, CaloSamples::MAXSAMPLES, min(), gen::n, HcalCalibrations::pedestal(), HcalCalibrations::respcorrgain(), and CaloSamples::size().

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

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