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, int ifirst, int n, bool slewCorrect, bool pulseCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor, bool forData, bool useLeak)
 

Function Documentation

template<class Digi , class RecHit >
RecHit HcalSimpleRecAlgoImpl::reco ( const Digi &  digi,
const HcalCoder coder,
const HcalCalibrations calibs,
int  ifirst,
int  n,
bool  slewCorrect,
bool  pulseCorrect,
const HcalPulseContainmentCorrection corr,
HcalTimeSlew::BiasSetting  slewFlavor,
bool  forData,
bool  useLeak 
)
inline

Definition at line 72 of file HcalSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), HcalTimeSlew::delay(), eCorr(), HcalPulseContainmentCorrection::getCorrection(), i, HcalDetId::ieta(), leakCorr(), LogDebug, max(), findQualityFiles::maxI, HcalCalibrations::pedestal(), HcalCalibrations::respcorrgain(), CaloSamples::size(), cond::rpcobgas::time, HcalCalibrations::timecorr(), and timeshift_ns_hbheho().

74  {
75  CaloSamples tool;
76  coder.adc2fC(digi,tool);
77 
78  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0;
79  double fc_ampl=0;
80  for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
81  int capid=digi[i].capid();
82  ta = (tool[i]-calibs.pedestal(capid)); // pedestal subtraction
83  fc_ampl+=ta;
84  ta*= calibs.respcorrgain(capid) ; // fC --> GeV
85  ampl+=ta;
86  if(ta>maxA){
87  maxA=ta;
88  maxI=i;
89  }
90  }
91 
92  float time = -9999;
94  if(maxI==0 || maxI==(tool.size()-1)) {
95  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :"
96  << " Invalid max amplitude position, "
97  << " max Amplitude: "<< maxI
98  << " first: "<<ifirst
99  << " last: "<<(tool.size()-1)
100  << std::endl;
101  } else {
102  int capid=digi[maxI-1].capid();
103  float t0 = ((tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
104  capid=digi[maxI+1].capid();
105  float t2 = ((tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
106 
107  // Handle negative excursions by moving "zero":
108  float minA=t0;
109  if (maxA<minA) minA=maxA;
110  if (t2<minA) minA=t2;
111  if (minA<0) { maxA-=minA; t0-=minA; t2-=minA; } // positivizes all samples
112 
113  float wpksamp = (t0 + maxA + t2);
114  if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
115  time = (maxI - digi.presamples())*25.0 + timeshift_ns_hbheho(wpksamp);
116  if (corr!=0 && pulseCorrect ) {
117  // Apply phase-based amplitude correction:
118 
119  /*
120  HcalDetId cell(digi.id());
121  int ieta = cell.ieta();
122  int iphi = cell.iphi();
123  int depth = cell.depth();
124  std::cout << "HcalSimpleRecAlgo::reco cell: ieta, iphi, depth = "
125  << ieta << ", " << iphi
126  << ", " << depth
127  << " first, toadd = " << ifirst << ", " << n << std::endl
128  << " ampl, corr, ampl_after_corr = "
129  << ampl << ", " << corr->getCorrection(fc_ampl)
130  << ", "
131  << ampl * corr->getCorrection(fc_ampl) << std::endl;
132  */
133 
134  ampl *= corr->getCorrection(fc_ampl);
135 
136  }
137  if (slewCorrect) time-=HcalTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);
138 
139  time=time-calibs.timecorr(); // time calibration
140  }
141 
142 
143  // Temoprary hack to apply energy-dependent corrections to some HB- cells
144  if(forData) {
145  HcalDetId cell(digi.id());
146  int ieta = cell.ieta();
147  int iphi = cell.iphi();
148  ampl *= eCorr(ieta,iphi,ampl);
149  }
150 
151  // Correction for a leak to pre-sample
152  if(useLeak) {
153  ampl *= leakCorr(ampl);
154  }
155 
156 
157  return RecHit(digi.id(),ampl,time);
158  }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
double getCorrection(double fc_ampl) const
double pedestal(int fCapId) const
get pedestal for capid=0..3
const T & max(const T &a, const T &b)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
static float leakCorr(double energy)
Leak correction.
static float timeshift_ns_hbheho(float wpksamp)
static float eCorr(int ieta, int iphi, double ampl)
Ugly hack to apply energy corrections to some HB- cells.
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
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