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

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

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

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

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

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

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