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 73 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(), reco::t2, cond::rpcobgas::time, HcalCalibrations::timecorr(), and timeshift_ns_hbheho().

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