CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 PulseShapeFitOOTPileupCorrection *psFitOOTpuCorr, HcalDeterministicFit *hltOOTpuCorr, PedestalSub *hltPedSub)
 
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 PulseShapeFitOOTPileupCorrection psFitOOTpuCorr,
HcalDeterministicFit hltOOTpuCorr,
PedestalSub hltPedSub 
)
inline

Definition at line 313 of file HcalSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), HcalDeterministicFit::apply(), PulseShapeFitOOTPileupCorrection::apply(), fwrapper::cs, HcalTimeSlew::delay(), eCorr(), HcalBarrel, HcalDetId::ieta(), PedestalSub::init(), HcalDeterministicFit::init(), HcalDetId::iphi(), leakCorr(), bookConverter::max, findQualityFiles::maxI, HcalTimeSlew::Medium, removePileup(), setRawEnergy(), CaloSamples::size(), HcalDetId::subdet(), cond::rpcobgas::time, HcalCalibrations::timecorr(), and timeshift_ns_hbheho().

321  {
322  double fc_ampl =0, ampl =0, uncorr_ampl =0, maxA = -1.e300;
323  int nRead = 0, maxI = -1;
324  bool leakCorrApplied = false;
325  float t0 =0, t2 =0;
326  float time = -9999;
327 
328 // Disable method 1 inside the removePileup function this way!
329 // Some code in removePileup does NOT do pileup correction & to make sure maximum share of code
330  const AbsOOTPileupCorrection * inputAbsOOTpuCorr = ( puCorrMethod == 1 ? pileupCorrection: 0 );
331 
332  removePileup(digi, coder, calibs, ifirst, n,
333  pulseCorrect, corr, inputAbsOOTpuCorr,
334  bxInfo, lenInfo, &maxA, &ampl,
335  &uncorr_ampl, &fc_ampl, &nRead, &maxI,
336  &leakCorrApplied, &t0, &t2);
337 
338  if (maxI > 0 && maxI < (nRead - 1))
339  {
340  // Handle negative excursions by moving "zero":
341  float minA=t0;
342  if (maxA<minA) minA=maxA;
343  if (t2<minA) minA=t2;
344  if (minA<0) { maxA-=minA; t0-=minA; t2-=minA; } // positivizes all samples
345 
346  float wpksamp = (t0 + maxA + t2);
347  if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
348  time = (maxI - digi.presamples())*25.0 + timeshift_ns_hbheho(wpksamp);
349 
350  if (slewCorrect) time-=HcalTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);
351 
352  time=time-calibs.timecorr(); // time calibration
353  }
354 
355 // Note that uncorr_ampl is always set from outside of method 2!
356  if( puCorrMethod == 2 ){
357  std::vector<double> correctedOutput;
358 
359  CaloSamples cs;
360  coder.adc2fC(digi,cs);
361  std::vector<int> capidvec;
362  for(int ip=0; ip<cs.size(); ip++){
363  const int capid = digi[ip].capid();
364  capidvec.push_back(capid);
365  }
366  //if(cs[4]-calibs.pedestal(capidvec[4])+cs[5]-calibs.pedestal(capidvec[4]) > 5){
367  psFitOOTpuCorr->apply(cs, capidvec, calibs, correctedOutput);
368  if( correctedOutput.back() == 0 && correctedOutput.size() >1 ){
369  time = correctedOutput[1]; ampl = correctedOutput[0];
370  }
371  // } else {time = -999; ampl = 0;}
372  }
373 
374  // S. Brandt - Feb 19th : Adding Section for HLT
375  // Turn on HLT here with puCorrMethod = 3
376  if ( puCorrMethod == 3){
377  std::vector<double> hltCorrOutput;
378  hltPedSub->init(((PedestalSub::Method)1), 0, 2.7, 0.0);
380 
381  CaloSamples cs;
382  coder.adc2fC(digi,cs);
383  std::vector<int> capidvec;
384  for(int ip=0; ip<cs.size(); ip++){
385  const int capid = digi[ip].capid();
386  capidvec.push_back(capid);
387  }
388  // if(cs[4]-calibs.pedestal(capidvec[4])+cs[5]-calibs.pedestal(capidvec[4]) > 5){
389  hltOOTpuCorr->apply(cs, capidvec, calibs, hltCorrOutput);
390  if( hltCorrOutput.size() > 1 ){
391  time = hltCorrOutput[1]; ampl = hltCorrOutput[0];
392  }
393  //} else {time = -999; ampl = 0;}
394  }
395 
396  // Temporary hack to apply energy-dependent corrections to some HB- cells
397  if (runnum > 0) {
398  const HcalDetId& cell = digi.id();
399  if (cell.subdet() == HcalBarrel) {
400  const int ieta = cell.ieta();
401  const int iphi = cell.iphi();
402  ampl *= eCorr(ieta, iphi, ampl, runnum);
403  uncorr_ampl *= eCorr(ieta, iphi, uncorr_ampl, runnum);
404  }
405  }
406 
407  // Correction for a leak to pre-sample
408  if(useLeak && !leakCorrApplied) {
409  ampl *= leakCorr(ampl);
410  uncorr_ampl *= leakCorr(uncorr_ampl);
411  }
412 
413  RecHit rh(digi.id(),ampl,time);
414  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
415  return rh;
416  }
auto_ptr< ClusterSequence > cs
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
void setRawEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:139
void apply(const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, std::vector< double > &HLTOutput) const
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
void init(HcalTimeSlew::ParaSource tsParam, HcalTimeSlew::BiasSetting bias, NegStrategy nStrat, PedestalSub pedSubFxn_)
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)
static float timeshift_ns_hbheho(float wpksamp)
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
int size() const
get the size
Definition: CaloSamples.h:24
double timecorr() const
get time correction factor
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
void apply(const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, std::vector< double > &correctedOutput) const
tuple runnum
Definition: summaryLumi.py:210
void init(Method method, int runCond, float threshold, float quantile)
Definition: PedestalSub.cc:14
static float eCorr(int ieta, int iphi, double ampl, int runnum)
Ugly hack to apply energy corrections to some HB- cells.
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...
Definition: HcalTimeSlew.cc:8
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 129 of file HcalSimpleRecAlgo.cc.

References alignCSCRings::e, create_public_lumi_plots::exp, f, min(), cond::rpcobgas::time, and timeshift_ns_hf().

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

131  {
132  // Handle negative excursions by moving "zero":
133  float zerocorr=std::min(t0,t2);
134  if (zerocorr<0.f) {
135  t0 -= zerocorr;
136  t2 -= zerocorr;
137  maxA -= zerocorr;
138  }
139 
140  // pair the peak with the larger of the two neighboring time samples
141  float wpksamp=0.f;
142  if (t0>t2) {
143  wpksamp = t0+maxA;
144  if (wpksamp != 0.f) wpksamp = maxA/wpksamp;
145  } else {
146  wpksamp = maxA+t2;
147  if (wpksamp != 0.f) wpksamp = 1.+(t2/wpksamp);
148  }
149 
150  float time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);
151 
152  if (slewCorrect && amp_fC > 0.0) {
153  // -5.12327 - put in calibs.timecorr()
154  double tslew=exp(0.337681-5.94689e-4*amp_fC)+exp(2.44628-1.34888e-2*amp_fC);
155  time -= (float)tslew;
156  }
157 
158  return time;
159  }
static float timeshift_ns_hf(float wpksamp)
Same as above, but 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 163 of file HcalSimpleRecAlgo.cc.

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

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

173  {
174  CaloSamples cs;
175  coder.adc2fC(digi,cs);
176  const int nRead = cs.size();
177  const int iStop = std::min(nRead, n + ifirst);
178 
179  // Signal energy will be calculated both with
180  // and without OOT pileup corrections. Try to
181  // arrange the calculations so that we do not
182  // repeat them.
183  double uncorrectedEnergy[CaloSamples::MAXSAMPLES], buf[CaloSamples::MAXSAMPLES];
184  double* correctedEnergy = 0;
185  double fc_ampl = 0.0, corr_fc_ampl = 0.0;
186  bool pulseShapeCorrApplied = false, readjustTiming = false;
187  *leakCorrApplied = false;
188 
189  if (pileupCorrection)
190  {
191  correctedEnergy = &buf[0];
192 
193  double correctionInput[CaloSamples::MAXSAMPLES];
194  double gains[CaloSamples::MAXSAMPLES];
195 
196  for (int i=0; i<nRead; ++i)
197  {
198  const int capid = digi[i].capid();
199  correctionInput[i] = cs[i] - calibs.pedestal(capid);
200  gains[i] = calibs.respcorrgain(capid);
201  }
202 
203  for (int i=ifirst; i<iStop; ++i)
204  fc_ampl += correctionInput[i];
205 
206  const bool useGain = pileupCorrection->inputIsEnergy();
207  for (int i=0; i<nRead; ++i)
208  {
209  uncorrectedEnergy[i] = correctionInput[i]*gains[i];
210  if (useGain)
211  correctionInput[i] = uncorrectedEnergy[i];
212  }
213 
214  pileupCorrection->apply(digi.id(), correctionInput, nRead,
215  bxInfo, lenInfo, ifirst, n,
216  correctedEnergy, CaloSamples::MAXSAMPLES,
217  &pulseShapeCorrApplied, leakCorrApplied,
218  &readjustTiming);
219  if (useGain)
220  {
221  // Gain factors have been already applied.
222  // Divide by them for accumulating corr_fc_ampl.
223  for (int i=ifirst; i<iStop; ++i)
224  if (gains[i])
225  corr_fc_ampl += correctedEnergy[i]/gains[i];
226  }
227  else
228  {
229  for (int i=ifirst; i<iStop; ++i)
230  corr_fc_ampl += correctedEnergy[i];
231  for (int i=0; i<nRead; ++i)
232  correctedEnergy[i] *= gains[i];
233  }
234  }
235  else
236  {
237  correctedEnergy = &uncorrectedEnergy[0];
238 
239  // In this situation, we do not need to process all time slices
240  const int istart = std::max(ifirst - 1, 0);
241  const int iend = std::min(n + ifirst + 1, nRead);
242  for (int i=istart; i<iend; ++i)
243  {
244  const int capid = digi[i].capid();
245  float ta = cs[i] - calibs.pedestal(capid);
246  if (i >= ifirst && i < iStop)
247  fc_ampl += ta;
248  ta *= calibs.respcorrgain(capid);
249  uncorrectedEnergy[i] = ta;
250  }
251  corr_fc_ampl = fc_ampl;
252  }
253 
254  // Uncorrected and corrected energies
255  double ampl = 0.0, corr_ampl = 0.0;
256  for (int i=ifirst; i<iStop; ++i)
257  {
258  ampl += uncorrectedEnergy[i];
259  corr_ampl += correctedEnergy[i];
260  }
261 
262  // Apply phase-based amplitude correction:
263  if (corr && pulseCorrect)
264  {
265  ampl *= corr->getCorrection(fc_ampl);
266  if (pileupCorrection)
267  {
268  if (!pulseShapeCorrApplied)
269  corr_ampl *= corr->getCorrection(corr_fc_ampl);
270  }
271  else
272  corr_ampl = ampl;
273  }
274 
275  // Which energies we want to use for timing?
276  const double *etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
277  int maxI = -1; double maxA = -1.e300;
278  for (int i=ifirst; i<iStop; ++i)
279  if (etime[i] > maxA)
280  {
281  maxA = etime[i];
282  maxI = i;
283  }
284 
285  // Fill out the output
286  *p_maxA = maxA;
287  *p_ampl = corr_ampl;
288  *p_uncorr_ampl = ampl;
289  *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
290  *p_nRead = nRead;
291  *p_maxI = maxI;
292 
293  if (maxI <= 0 || maxI >= (nRead-1))
294  {
295  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgoImpl::removePileup :"
296  << " Invalid max amplitude position, "
297  << " max Amplitude: " << maxI
298  << " first: " << ifirst
299  << " last: " << ifirst + n
300  << std::endl;
301  *p_t0 = 0.f;
302  *p_t2 = 0.f;
303  }
304  else
305  {
306  *p_t0 = etime[maxI - 1];
307  *p_t2 = etime[maxI + 1];
308  }
309  }
#define LogDebug(id)
virtual bool inputIsEnergy() const =0
int i
Definition: DBlmapReader.cc:9
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
auto_ptr< ClusterSequence > cs
static const int MAXSAMPLES
Definition: CaloSamples.h:73
double getCorrection(double fc_ampl) const
double pedestal(int fCapId) const
get pedestal for capid=0..3
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
T min(T a, T b)
Definition: MathUtil.h:58
int size() const
get the size
Definition: CaloSamples.h:24
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0