CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
ZdcSimpleRecAlgoImpl Namespace Reference

Functions

template<class Digi , class RecHit >
RecHit reco1 (const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, int ifirst, int n, bool slewCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor)
 
template<class Digi , class RecHit >
RecHit reco2 (const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, int ifirst, int n, bool slewCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor)
 

Function Documentation

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

Definition at line 32 of file ZdcSimpleRecAlgo.cc.

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

33  {
34  CaloSamples tool;
35  coder.adc2fC(digi,tool);
36  double ampl=0; int maxI = -1; double maxA = -1e10; double ta=0;
37  double fc_ampl=0;
38  for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
39  int capid=digi[i].capid();
40  ta = (tool[i]-calibs.pedestal(capid)); // pedestal subtraction
41  fc_ampl+=ta;
42  ta*= calibs.respcorrgain(capid) ; // fC --> GeV
43  ampl+=ta;
44  if(ta>maxA){
45  maxA=ta;
46  maxI=i;
47  }
48  }
49 
50  double time=-9999;
52  if(maxI==0 || maxI==(tool.size()-1)) {
53  LogDebug("HCAL Pulse") << "ZdcSimpleRecAlgo::reconstruct :"
54  << " Invalid max amplitude position, "
55  << " max Amplitude: "<< maxI
56  << " first: "<<ifirst
57  << " last: "<<(tool.size()-1)
58  << std::endl;
59  } else {
60  maxA=fabs(maxA);
61  int capid=digi[maxI-1].capid();
62  double t0 = fabs((tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
63  capid=digi[maxI+1].capid();
64  double t2 = fabs((tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
65  double wpksamp = (t0 + maxA + t2);
66  if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
67  time = (maxI - digi.presamples())*25.0 + timeshift_ns_zdc(wpksamp);
68  if (corr!=0) {
69  // Apply phase-based amplitude correction:
70  ampl *= corr->getCorrection(fc_ampl);
71  // std::cout << fc_ampl << " --> " << corr->getCorrection(fc_ampl) << std::endl;
72  }
73 
74  if (slewCorrect) time-=HcalTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);
75  }
76 
77  time=time-calibs.timecorr(); // time calibration
78  return RecHit(digi.id(),ampl,time);
79  }
#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
static float timeshift_ns_zdc(float wpksamp)
const T & max(const T &a, const T &b)
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
template<class Digi , class RecHit >
RecHit ZdcSimpleRecAlgoImpl::reco2 ( const Digi &  digi,
const HcalCoder coder,
const HcalCalibrations calibs,
int  ifirst,
int  n,
bool  slewCorrect,
const HcalPulseContainmentCorrection corr,
HcalTimeSlew::BiasSetting  slewFlavor 
)
inline

Definition at line 85 of file ZdcSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), HcalPulseContainmentCorrection::getCorrection(), i, gen::k, LogDebug, findQualityFiles::maxI, HcalCalibrations::respcorrgain(), CaloSamples::size(), and cond::rpcobgas::time.

86  {
87  CaloSamples tool;
88  coder.adc2fC(digi,tool);
89  double ampl=0; int maxI = -1; double maxA = -1e10; double ta=0;
90  double prenoise = 0; double postnoise = 0;
91  int noiseslices = 0;
92  double noise = 0;
93  double fc_ampl=0;
94 
95  for(int k = 0 ; k < tool.size() && k < ifirst; k++){
96  prenoise += tool[k];
97  noiseslices++;
98  }
99 // for(int j = (n + ifirst + 1); j <tool.size(); j++){
100 // postnoise += tool[j];
101 // noiseslices++;
102 // }
103 // removed postnoise due to significant signal seen in TS 7,8,9 (Heavy Ion run 2010)
104 // Future ZdcSimpleRecAlgo will have better configurable noise calculation
105  postnoise=0;
106  if(noiseslices != 0) {
107  noise = (prenoise+postnoise)/double(noiseslices);
108  } else {
109  noise = 0;
110  }
111  // factor to multiply by noise to make 0 or 1 to handle negative noise situations
112  double noisefactor=1.;
113  for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
114  int capid=digi[i].capid();
115  if(noise<0){
116  // flag hit as having negative noise, and don't subtract anything, because
117  // it will falsely increase the energy
118  noisefactor=0.;
119  }
120  ta = tool[i]-noisefactor*noise;
121  fc_ampl+=ta;
122  ta*= calibs.respcorrgain(capid) ; // fC --> GeV
123  ampl+=ta;
124  if(ta>maxA){
125  maxA=ta;
126  maxI=i;
127  }
128  }
129 // if(ta<0){
130 // // flag hits that have negative energy
131 // }
132 
133  double time=-9999;
135  if(maxI==0 || maxI==(tool.size()-1)) {
136  LogDebug("HCAL Pulse") << "ZdcSimpleRecAlgo::reco2 :"
137  << " Invalid max amplitude position, "
138  << " max Amplitude: "<< maxI
139  << " first: "<<ifirst
140  << " last: "<<(tool.size()-1)
141  << std::endl;
142  } else {
143  int capid=digi[maxI-1].capid();
144  double Energy0 = ((tool[maxI-1])*calibs.respcorrgain(capid) );
145 // if any of the energies used in the weight are negative, make them 0 instead
146 // these are actually QIE values, not energy
147  if(Energy0<0){Energy0=0.;}
148  capid=digi[maxI].capid();
149  double Energy1 = ((tool[maxI])*calibs.respcorrgain(capid) ) ;
150  if(Energy1<0){Energy1=0.;}
151  capid=digi[maxI+1].capid();
152  double Energy2 = ((tool[maxI+1])*calibs.respcorrgain(capid) );
153  if(Energy2<0){Energy2=0.;}
154 //
155  double TSWeightEnergy = ((maxI-1)*Energy0 + maxI*Energy1 + (maxI+1)*Energy2);
156  double EnergySum=Energy0+Energy1+Energy2;
157  double AvgTSPos=0.;
158  if (EnergySum!=0) AvgTSPos=TSWeightEnergy/ EnergySum;
159 // If time is zero, set it to the "nonsensical" -99
160 // Time should be between 75ns and 175ns (Timeslices 3-7)
161  if(AvgTSPos==0){
162  time=-99;
163  } else {
164  time = (AvgTSPos*25.0);
165  }
166  if (corr!=0) {
167  // Apply phase-based amplitude correction:
168  ampl *= corr->getCorrection(fc_ampl);
169  }
170  }
171  return RecHit(digi.id(),ampl,time);
172  }
#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
int k[5][pyjets_maxn]
int size() const
get the size
Definition: CaloSamples.h:24
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0