test
CMS 3D CMS Logo

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

Functions

template<class Digi , class RecHit >
bool corrSaturation (RecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const Digi &digi, const int &maxADCvalue, const double &satCorrConst, int ifirst, int n)
 
template<class Digi >
bool isSaturated (const Digi &digi, const int &maxADCvalue, int ifirst, int n)
 
template<class Digi , class RecHit >
RecHit reco (const Digi &digi, const CastorCoder &coder, const CastorCalibrations &calibs, int ifirst, int n, bool slewCorrect, const CastorPulseContainmentCorrection *corr, CastorTimeSlew::BiasSetting slewFlavor)
 

Function Documentation

template<class Digi , class RecHit >
bool CastorSimpleRecAlgoImpl::corrSaturation ( RecHit &  rechit,
const CastorCoder coder,
const CastorCalibrations calibs,
const Digi &  digi,
const int &  maxADCvalue,
const double &  satCorrConst,
int  ifirst,
int  n 
)
inline

Definition at line 103 of file CastorSimpleRecAlgo.cc.

References ecalMGPA::adc(), CastorCoder::adc2fC(), CastorCalibrations::gain(), and CastorCalibrations::pedestal().

105  {
106  // correction works only with 2 used TS
107  if(n != 2) return false;
108 
109  // to avoid segmentation violation
110  if(ifirst+n > digi.size()) return false;
111 
112  // look if first TS is saturated not the second one
113  // in case the second one is saturated do no correction
114  if(digi[ifirst].adc() >= maxADCvalue && digi[ifirst+1].adc() < maxADCvalue) {
115  float ampl = 0;
116 
117  CaloSamples tool;
118  coder.adc2fC(digi,tool);
119 
120  // get energy of first TS
121  int capid = digi[ifirst].capid();
122  float ta = tool[ifirst]-calibs.pedestal(capid); // pedestal subtraction
123  float ta1 = ta*calibs.gain(capid); // fC --> GeV
124 
125  // get energy of second TS
126  capid = digi[ifirst+1].capid();
127  ta = tool[ifirst+1]-calibs.pedestal(capid); // pedestal subtraction
128  float ta2 = ta*calibs.gain(capid); // fC --> GeV
129 
130  // use second TS to calc the first one
131  // check if recalculated TS ampl is
132  // realy greater than the saturated value
133  if(ta2 / satCorrConst <= ta1) return false;
134 
135  // ampl = TS5 + TS4 => TS4 = TS5 / TSratio
136  // ampl = TS5 + TS5 / TSratio
137  ampl = ta2 + ta2 / satCorrConst;
138 
139  // reset energy of rechit
140  rechit.setEnergy(ampl);
141 
142  return true;
143  }
144 
145  return false;
146  }
int adc(sample_type sample)
get the ADC sample (12 bits)
virtual void adc2fC(const CastorDataFrame &df, CaloSamples &lf) const =0
double pedestal(int fCapId) const
get pedestal for capid=0..3
double gain(int fCapId) const
get gain for capid=0..3
template<class Digi >
bool CastorSimpleRecAlgoImpl::isSaturated ( const Digi &  digi,
const int &  maxADCvalue,
int  ifirst,
int  n 
)
inline

Definition at line 92 of file CastorSimpleRecAlgo.cc.

References ecalMGPA::adc(), and i.

Referenced by EcalUncalibRecHitRecChi2Algo< C >::EcalUncalibRecHitRecChi2Algo(), EcalCoder::encode(), EcalUncalibRecHitRecWeightsAlgo< EBDataFrame >::makeRecHit(), EcalUncalibRecHitRecAnalFitAlgo< EBDataFrame >::makeRecHit(), and EcalUncalibRecHitFixedAlphaBetaAlgo< C >::makeRecHit().

92  {
93  for (int i=ifirst; i<digi.size() && i<n+ifirst; i++) {
94  if(digi[i].adc() >= maxADCvalue) return true;
95  }
96 
97  return false;
98  }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
template<class Digi , class RecHit >
RecHit CastorSimpleRecAlgoImpl::reco ( const Digi &  digi,
const CastorCoder coder,
const CastorCalibrations calibs,
int  ifirst,
int  n,
bool  slewCorrect,
const CastorPulseContainmentCorrection corr,
CastorTimeSlew::BiasSetting  slewFlavor 
)
inline

Definition at line 37 of file CastorSimpleRecAlgo.cc.

References CastorCoder::adc2fC(), CastorTimeSlew::delay(), CastorCalibrations::gain(), CastorPulseContainmentCorrection::getCorrection(), i, bookConverter::max, findQualityFiles::maxI, CastorCalibrations::pedestal(), CaloSamples::size(), cond::rpcobgas::time, and timeshift_ns_hf().

38  {
39  CaloSamples tool;
40  coder.adc2fC(digi,tool);
41 
42  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0;
43  double fc_ampl=0;
44  for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
45  int capid=digi[i].capid();
46  ta = (tool[i]-calibs.pedestal(capid)); // pedestal subtraction
47  fc_ampl+=ta;
48  ta*=calibs.gain(capid); // fC --> GeV
49  ampl+=ta;
50  if(ta>maxA){
51  maxA=ta;
52  maxI=i;
53  }
54  }
55 
56  float time=-9999;
58  if(maxI==0 || maxI==(tool.size()-1)) {
59  // supress warning and use dummy time value for 2009 data
60  /*
61  edm::LogWarning("HCAL/CASTOR Pulse") << "CastorSimpleRecAlgo::reconstruct :"
62  << " Invalid max amplitude position, "
63  << " max Amplitude: "<< maxI
64  << " first: "<<ifirst
65  << " last: "<<(tool.size()-1)
66  << std::endl;
67  */
68  } else {
69  maxA=fabs(maxA);
70  int capid=digi[maxI-1].capid();
71  float t0 = fabs((tool[maxI-1]-calibs.pedestal(capid))*calibs.gain(capid));
72  capid=digi[maxI+1].capid();
73  float t2 = fabs((tool[maxI+1]-calibs.pedestal(capid))*calibs.gain(capid));
74  float wpksamp = (t0 + maxA + t2);
75  if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
76  time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);
77 
78  if (corr!=0) {
79  // Apply phase-based amplitude correction:
80  ampl *= corr->getCorrection(fc_ampl);
81  // std::cout << fc_ampl << " --> " << corr->getCorrection(fc_ampl) << std::endl;
82  }
83 
84 
85  if (slewCorrect) time-=CastorTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);
86  }
87  return RecHit(digi.id(),ampl,time);
88  }
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...
int i
Definition: DBlmapReader.cc:9
virtual void adc2fC(const CastorDataFrame &df, CaloSamples &lf) const =0
double pedestal(int fCapId) const
get pedestal for capid=0..3
double gain(int fCapId) const
get gain for capid=0..3
int size() const
get the size
Definition: CaloSamples.h:24
static float timeshift_ns_hf(float wpksamp)
Same as above, but for the HF PMTs.