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, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, bool slewCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor)
 
template<class Digi , class RecHit >
RecHit reco2 (const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, 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,
const std::vector< unsigned int > &  myNoiseTS,
const std::vector< unsigned int > &  mySignalTS,
bool  slewCorrect,
const HcalPulseContainmentCorrection corr,
HcalTimeSlew::BiasSetting  slewFlavor 
)
inline

Definition at line 31 of file ZdcSimpleRecAlgo.cc.

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

32  {
33  CaloSamples tool;
34  coder.adc2fC(digi,tool);
35  int ifirst = mySignalTS[0];
36  int n = mySignalTS.size();
37  double ampl=0; int maxI = -1; double maxA = -1e10; double ta=0;
38  double fc_ampl=0;
39  for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
40  int capid=digi[i].capid();
41  ta = (tool[i]-calibs.pedestal(capid)); // pedestal subtraction
42  fc_ampl+=ta;
43  ta*= calibs.respcorrgain(capid) ; // fC --> GeV
44  ampl+=ta;
45  if(ta>maxA){
46  maxA=ta;
47  maxI=i;
48  }
49  }
50 
51  double time=-9999;
53  if(maxI==0 || maxI==(tool.size()-1)) {
54  LogDebug("HCAL Pulse") << "ZdcSimpleRecAlgo::reconstruct :"
55  << " Invalid max amplitude position, "
56  << " max Amplitude: "<< maxI
57  << " first: "<<ifirst
58  << " last: "<<(tool.size()-1)
59  << std::endl;
60  } else {
61  maxA=fabs(maxA);
62  int capid=digi[maxI-1].capid();
63  double t0 = fabs((tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
64  capid=digi[maxI+1].capid();
65  double t2 = fabs((tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
66  double wpksamp = (t0 + maxA + t2);
67  if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
68  time = (maxI - digi.presamples())*25.0 + timeshift_ns_zdc(wpksamp);
69  if (corr!=0) {
70  // Apply phase-based amplitude correction:
71  ampl *= corr->getCorrection(fc_ampl);
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,
const std::vector< unsigned int > &  myNoiseTS,
const std::vector< unsigned int > &  mySignalTS,
bool  slewCorrect,
const HcalPulseContainmentCorrection corr,
HcalTimeSlew::BiasSetting  slewFlavor 
)
inline

Definition at line 84 of file ZdcSimpleRecAlgo.cc.

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

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