CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ESRecHitSimAlgo Class Reference

#include <ESRecHitSimAlgo.h>

Public Member Functions

EcalRecHit reconstruct (const ESDataFrame &digi) const
 
void setAngleCorrectionFactors (const ESAngleCorrectionFactors *ang)
 
void setChannelStatus (const ESChannelStatus *status)
 
void setESGain (float value)
 
void setIntercalibConstants (const ESIntercalibConstants *mips)
 
void setMIPGeV (float value)
 
void setPedestals (const ESPedestals *peds)
 
void setRatioCuts (const ESRecHitRatioCuts *ratioCuts)
 
void setW0 (float value)
 
void setW1 (float value)
 
void setW2 (float value)
 

Private Member Functions

EcalRecHit::ESFlags evalAmplitude (float *result, const ESDataFrame &digi, float ped) const
 
double * oldEvalAmplitude (const ESDataFrame &digi, const double &ped, const double &w0, const double &w1, const double &w2) const
 
EcalRecHit oldreconstruct (const ESDataFrame &digi) const
 

Private Attributes

const ESAngleCorrectionFactorsang_
 
const ESChannelStatuschannelStatus_
 
int gain_
 
float MIPGeV_
 
const ESIntercalibConstantsmips_
 
const ESPedestalspeds_
 
const ESRecHitRatioCutsratioCuts_
 
float w0_
 
float w1_
 
float w2_
 

Detailed Description

Definition at line 12 of file ESRecHitSimAlgo.h.

Member Function Documentation

EcalRecHit::ESFlags ESRecHitSimAlgo::evalAmplitude ( float *  result,
const ESDataFrame digi,
float  ped 
) const
private

Definition at line 12 of file ESRecHitSimAlgo.cc.

References ecalMGPA::adc(), ESSample::adc(), constexpr, relval_parameters_module::energy, create_public_lumi_plots::exp, f, ESRecHitRatioCuts::getR12High(), ESRecHitRatioCuts::getR23High(), i, EcalRecHit::kESBadRatioFor12, EcalRecHit::kESBadRatioFor23Lower, EcalRecHit::kESBadRatioFor23Upper, EcalRecHit::kESGood, EcalRecHit::kESSaturated, EcalRecHit::kESTS13Sigmas, EcalRecHit::kESTS1Largest, EcalRecHit::kESTS2Saturated, EcalRecHit::kESTS3Largest, EcalRecHit::kESTS3Negative, EcalRecHit::kESTS3Saturated, fff_deleter::log, LogDebug, n, funct::pow(), ratioCuts_, ESDataFrame::sample(), ESDataFrame::size(), ntuplemaker::status, w, w0_, w1_, and w2_.

Referenced by reconstruct().

12  {
13 
14  float energy = 0;
15  float adc[3];
16  float pw[3];
17  pw[0] = w0_;
18  pw[1] = w1_;
19  pw[2] = w2_;
20 
21  for (int i=0; i<digi.size(); i++) {
22  energy += pw[i]*(digi.sample(i).adc()-ped);
23  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : Digi "<<i<<" ADC counts "<<digi.sample(i).adc()<<" Ped "<<ped;
24  //std::cout<<i<<" "<<digi.sample(i).adc()<<" "<<ped<<" "<<pw[i]<<std::endl;
25  adc[i] = digi.sample(i).adc() - ped;
26  }
27 
29  if (adc[0] > 20.f) status = EcalRecHit::kESTS13Sigmas; // 14;
30  if (adc[1] <= 0 || adc[2] <= 0) status = EcalRecHit::kESTS3Negative; // 10;
31  if (adc[0] > adc[1] && adc[0] > adc[2]) status = EcalRecHit::kESTS1Largest; // 8;
32  if (adc[2] > adc[1] && adc[2] > adc[0]) status = EcalRecHit::kESTS3Largest; // 9;
33  auto r12 = (adc[1] != 0) ? adc[0]/adc[1] : 99.f;
34  auto r23 = (adc[2] != 0) ? adc[1]/adc[2] : 99.f;
35  if (r12 > ratioCuts_->getR12High()) status = EcalRecHit::kESBadRatioFor12;// 5;
36  if (r23 > ratioCuts_->getR23High()) status = EcalRecHit::kESBadRatioFor23Upper; // 6;
37  if (r23 < ratioCuts_->getR23Low()) status = EcalRecHit::kESBadRatioFor23Lower; // 7
38 
39  auto A1 = adc[1];
40  auto A2 = adc[2];
41 
42  // t0 from analytical formula:
43  constexpr float n = 1.798;
44  constexpr float w = 0.07291;
45  constexpr float DeltaT = 25.;
46  auto aaa = (A2 > 0 && A1 > 0) ? std::log(A2/A1)/n : 20.f; // if A1=0, t0=20
47  constexpr float bbb = w/n*DeltaT;
48  auto ccc= std::exp(aaa+bbb);
49 
50  auto t0 = (2.f-ccc)/(1.f-ccc) * DeltaT - 5.f;
51 
52  // A from analytical formula:
53  constexpr float t1 = 20.;
54  constexpr float A_1 = 1./( std::pow(w/n*(t1),n) * std::exp(n-w*(t1)) );
55  auto AA1 = A1 * A_1 ;
56 
57  if (adc[1] > 2800.f && adc[2] > 2800.f) status = EcalRecHit::kESSaturated;
58  else if (adc[1] > 2800.f) status = EcalRecHit::kESTS2Saturated;
59  else if (adc[2] > 2800.f) status = EcalRecHit::kESTS3Saturated;
60 
61  results[0] = energy; // energy with weight method
62  results[1] = t0; // timing
63  results[2] = AA1; // energy with analytic method
64 
65  return status;
66 
67 }
#define LogDebug(id)
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
const double w
Definition: UKUtility.cc:23
int size() const
Definition: ESDataFrame.h:23
#define constexpr
const ESSample & sample(int i) const
Definition: ESDataFrame.h:26
double f[11][100]
const ESRecHitRatioCuts * ratioCuts_
float getR12High() const
float getR23High() const
int adc() const
get the ADC sample (singed 16 bits)
Definition: ESSample.h:18
tuple status
Definition: ntuplemaker.py:245
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double * ESRecHitSimAlgo::oldEvalAmplitude ( const ESDataFrame digi,
const double &  ped,
const double &  w0,
const double &  w1,
const double &  w2 
) const
private

Definition at line 144 of file ESRecHitSimAlgo.cc.

References ecalMGPA::adc(), ESSample::adc(), relval_parameters_module::energy, create_public_lumi_plots::exp, ESRecHitRatioCuts::getR12High(), ESRecHitRatioCuts::getR23High(), i, fff_deleter::log, LogDebug, n, funct::pow(), ratioCuts_, python.entryComment::results, ESDataFrame::sample(), ESDataFrame::size(), ntuplemaker::status, w, and w2.

Referenced by oldreconstruct().

144  {
145 
146  double *results = new double[4];
147  float energy = 0;
148  double adc[3];
149  float pw[3];
150  pw[0] = w0;
151  pw[1] = w1;
152  pw[2] = w2;
153 
154  for (int i=0; i<digi.size(); i++) {
155  energy += pw[i]*(digi.sample(i).adc()-ped);
156  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : Digi "<<i<<" ADC counts "<<digi.sample(i).adc()<<" Ped "<<ped;
157  //std::cout<<i<<" "<<digi.sample(i).adc()<<" "<<ped<<" "<<pw[i]<<std::endl;
158  adc[i] = digi.sample(i).adc() - ped;
159  }
160 
161  double status = 0;
162  if (adc[0] > 20) status = 14;
163  if (adc[1] <= 0 || adc[2] <= 0) status = 10;
164  if (adc[0] > adc[1] && adc[0] > adc[2]) status = 8;
165  if (adc[2] > adc[1] && adc[2] > adc[0]) status = 9;
166  double r12 = (adc[1] != 0) ? adc[0]/adc[1] : 99;
167  double r23 = (adc[2] != 0) ? adc[1]/adc[2] : 99;
168  if (r12 > ratioCuts_->getR12High()) status = 5;
169  if (r23 > ratioCuts_->getR23High()) status = 6;
170  if (r23 < ratioCuts_->getR23Low()) status = 7;
171 
172  double A1 = adc[1];
173  double A2 = adc[2];
174 
175  // t0 from analytical formula:
176  double n = 1.798;
177  double w = 0.07291;
178  double DeltaT = 25.;
179  double aaa = (A2 > 0 && A1 > 0) ? log(A2/A1)/n : 20.; // if A1=0, t0=20
180  double bbb = w/n*DeltaT;
181  double ccc= exp(aaa+bbb);
182 
183  double t0 = (2.-ccc)/(1.-ccc) * DeltaT - 5;
184 
185  // A from analytical formula:
186  double t1 = 20.;
187  double A_1 = pow(w/n*(t1),n) * exp(n-w*(t1));
188  double AA1 = (A_1 != 0.) ? A1 / A_1 : 0.;
189 
190  if (adc[1] > 2800 && adc[2] > 2800) status = 11;
191  else if (adc[1] > 2800) status = 12;
192  else if (adc[2] > 2800) status = 13;
193 
194  results[0] = energy; // energy with weight method
195  results[1] = t0; // timing
196  results[2] = status; // hit status
197  results[3] = AA1; // energy with analytic method
198 
199  return results;
200 }
#define LogDebug(id)
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
const double w
Definition: UKUtility.cc:23
int size() const
Definition: ESDataFrame.h:23
const ESSample & sample(int i) const
Definition: ESDataFrame.h:26
const ESRecHitRatioCuts * ratioCuts_
float getR12High() const
float getR23High() const
int adc() const
get the ADC sample (singed 16 bits)
Definition: ESSample.h:18
tuple status
Definition: ntuplemaker.py:245
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
EcalRecHit ESRecHitSimAlgo::oldreconstruct ( const ESDataFrame digi) const
private

Definition at line 202 of file ESRecHitSimAlgo.cc.

References ang_, channelStatus_, funct::cos(), relval_parameters_module::energy, ESCondObjectContainer< T >::find(), ESCondObjectContainer< T >::getMap(), ESDataFrame::id(), EcalRecHit::kESBadRatioFor12, EcalRecHit::kESBadRatioFor23Lower, EcalRecHit::kESBadRatioFor23Upper, EcalRecHit::kESDead, EcalRecHit::kESGood, EcalRecHit::kESSaturated, EcalRecHit::kESTS13Sigmas, EcalRecHit::kESTS1Largest, EcalRecHit::kESTS2Saturated, EcalRecHit::kESTS3Largest, EcalRecHit::kESTS3Negative, EcalRecHit::kESTS3Saturated, LogDebug, MIPGeV_, mips_, oldEvalAmplitude(), peds_, python.entryComment::results, EcalRecHit::setOutOfTimeEnergy(), ntuplemaker::status, w0_, w1_, and w2_.

202  {
203 
204  ESPedestals::const_iterator it_ped = peds_->find(digi.id());
205 
208 
210 
211  double* results;
212 
213  results = oldEvalAmplitude(digi, it_ped->getMean(), w0_, w1_, w2_);
214 
215  double energy = results[0];
216  double t0 = results[1];
217  int status = (int) results[2];
218  double otenergy = results[3] * 1000000.; // set out-of-time energy to keV
219  delete[] results;
220 
221  double mipCalib = (fabs(cos(*it_ang)) != 0.) ? (*it_mip)/fabs(cos(*it_ang)) : 0.;
222  energy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
223  otenergy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
224 
225  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : reconstructed energy "<<energy;
226 
227  EcalRecHit rechit(digi.id(), energy, t0);
228  rechit.setOutOfTimeEnergy(otenergy);
229 
230  if (it_status->getStatusCode() == 1) {
231  rechit.setFlag(EcalRecHit::kESDead);
232  } else {
233  if (status == 0)
234  rechit.setFlag(EcalRecHit::kESGood);
235  else if (status == 5)
236  rechit.setFlag(EcalRecHit::kESBadRatioFor12);
237  else if (status == 6)
238  rechit.setFlag(EcalRecHit::kESBadRatioFor23Upper);
239  else if (status == 7)
240  rechit.setFlag(EcalRecHit::kESBadRatioFor23Lower);
241  else if (status == 8)
242  rechit.setFlag(EcalRecHit::kESTS1Largest);
243  else if (status == 9)
244  rechit.setFlag(EcalRecHit::kESTS3Largest);
245  else if (status == 10)
246  rechit.setFlag(EcalRecHit::kESTS3Negative);
247  else if (status == 11)
248  rechit.setFlag(EcalRecHit::kESSaturated);
249  else if (status == 12)
250  rechit.setFlag(EcalRecHit::kESTS2Saturated);
251  else if (status == 13)
252  rechit.setFlag(EcalRecHit::kESTS3Saturated);
253  else if (status == 14)
254  rechit.setFlag(EcalRecHit::kESTS13Sigmas);
255  }
256 
257  return rechit;
258 }
#define LogDebug(id)
const ESDetId & id() const
Definition: ESDataFrame.h:21
const self & getMap() const
const ESPedestals * peds_
const ESIntercalibConstants * mips_
const ESChannelStatus * channelStatus_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const_iterator find(uint32_t rawId) const
double * oldEvalAmplitude(const ESDataFrame &digi, const double &ped, const double &w0, const double &w1, const double &w2) const
const ESAngleCorrectionFactors * ang_
std::vector< Item >::const_iterator const_iterator
void setOutOfTimeEnergy(float energy)
Definition: EcalRecHit.h:137
tuple status
Definition: ntuplemaker.py:245
EcalRecHit ESRecHitSimAlgo::reconstruct ( const ESDataFrame digi) const

Definition at line 69 of file ESRecHitSimAlgo.cc.

References funct::abs(), ang_, channelStatus_, relval_parameters_module::energy, evalAmplitude(), ESCondObjectContainer< T >::getMap(), ESDetId::hashedIndex(), ESDataFrame::id(), EcalRecHit::kESDead, LogDebug, MIPGeV_, mips_, peds_, ESCondObjectContainer< T >::preshower(), python.entryComment::results, EcalRecHit::setOutOfTimeEnergy(), and ntuplemaker::status.

Referenced by ESRecHitWorker::run().

69  {
70 
71 
72  auto ind = digi.id().hashedIndex();
73 
74  auto const & ped = peds_->preshower(ind);
75  auto const & mip = mips_->getMap().preshower(ind);
76  auto const & ang = ang_->getMap().preshower(ind);
77  auto const & statusCh = channelStatus_->getMap().preshower(ind);
78 
79  float results[3];
80 
81  auto status = evalAmplitude(results, digi, ped.getMean());
82 
83  auto energy = results[0];
84  auto t0 = results[1];
85  auto otenergy = results[2] * 1000000.f; // set out-of-time energy to keV
86 
87 
88  auto mipCalib = (mip != 0.f) ? MIPGeV_*std::abs(vdt::fast_cosf(ang))/(mip) : 0.f;
89  energy *= mipCalib;
90  otenergy *= mipCalib;
91 
92  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : reconstructed energy "<<energy;
93 
94  EcalRecHit rechit(digi.id(), energy, t0);
95  rechit.setOutOfTimeEnergy(otenergy);
96 
97  rechit.setFlag(statusCh.getStatusCode() == 1 ? EcalRecHit::kESDead : status);
98 
99  return rechit;
100 
101 }
#define LogDebug(id)
const ESDetId & id() const
Definition: ESDataFrame.h:21
const self & getMap() const
const ESPedestals * peds_
const ESIntercalibConstants * mips_
const ESChannelStatus * channelStatus_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const Item & preshower(size_t hashedIndex) const
const ESAngleCorrectionFactors * ang_
void setOutOfTimeEnergy(float energy)
Definition: EcalRecHit.h:137
EcalRecHit::ESFlags evalAmplitude(float *result, const ESDataFrame &digi, float ped) const
tuple status
Definition: ntuplemaker.py:245
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
Definition: ESDetId.cc:69
void ESRecHitSimAlgo::setAngleCorrectionFactors ( const ESAngleCorrectionFactors ang)
inline

Definition at line 22 of file ESRecHitSimAlgo.h.

References ang_.

Referenced by ESRecHitWorker::set().

22 { ang_ = ang; }
const ESAngleCorrectionFactors * ang_
void ESRecHitSimAlgo::setChannelStatus ( const ESChannelStatus status)
inline

Definition at line 20 of file ESRecHitSimAlgo.h.

References channelStatus_, and ntuplemaker::status.

Referenced by ESRecHitWorker::set().

const ESChannelStatus * channelStatus_
tuple status
Definition: ntuplemaker.py:245
void ESRecHitSimAlgo::setESGain ( float  value)
inline

Definition at line 16 of file ESRecHitSimAlgo.h.

References gain_, and relativeConstraints::value.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setIntercalibConstants ( const ESIntercalibConstants mips)
inline

Definition at line 19 of file ESRecHitSimAlgo.h.

References mips_.

Referenced by ESRecHitWorker::set().

19 { mips_ = mips; }
const ESIntercalibConstants * mips_
void ESRecHitSimAlgo::setMIPGeV ( float  value)
inline

Definition at line 17 of file ESRecHitSimAlgo.h.

References MIPGeV_, and relativeConstraints::value.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setPedestals ( const ESPedestals peds)
inline

Definition at line 18 of file ESRecHitSimAlgo.h.

References peds_.

Referenced by ESRecHitWorker::set().

18 { peds_ = peds; }
const ESPedestals * peds_
void ESRecHitSimAlgo::setRatioCuts ( const ESRecHitRatioCuts ratioCuts)
inline

Definition at line 21 of file ESRecHitSimAlgo.h.

References ratioCuts_.

Referenced by ESRecHitWorker::set().

21 { ratioCuts_ = ratioCuts; }
const ESRecHitRatioCuts * ratioCuts_
void ESRecHitSimAlgo::setW0 ( float  value)
inline

Definition at line 23 of file ESRecHitSimAlgo.h.

References relativeConstraints::value, and w0_.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setW1 ( float  value)
inline

Definition at line 24 of file ESRecHitSimAlgo.h.

References relativeConstraints::value, and w1_.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setW2 ( float  value)
inline

Definition at line 25 of file ESRecHitSimAlgo.h.

References relativeConstraints::value, and w2_.

Referenced by ESRecHitWorker::set().

Member Data Documentation

const ESAngleCorrectionFactors* ESRecHitSimAlgo::ang_
private

Definition at line 43 of file ESRecHitSimAlgo.h.

Referenced by oldreconstruct(), reconstruct(), and setAngleCorrectionFactors().

const ESChannelStatus* ESRecHitSimAlgo::channelStatus_
private

Definition at line 41 of file ESRecHitSimAlgo.h.

Referenced by oldreconstruct(), reconstruct(), and setChannelStatus().

int ESRecHitSimAlgo::gain_
private

Definition at line 38 of file ESRecHitSimAlgo.h.

Referenced by setESGain().

float ESRecHitSimAlgo::MIPGeV_
private

Definition at line 47 of file ESRecHitSimAlgo.h.

Referenced by oldreconstruct(), reconstruct(), and setMIPGeV().

const ESIntercalibConstants* ESRecHitSimAlgo::mips_
private

Definition at line 40 of file ESRecHitSimAlgo.h.

Referenced by oldreconstruct(), reconstruct(), and setIntercalibConstants().

const ESPedestals* ESRecHitSimAlgo::peds_
private

Definition at line 39 of file ESRecHitSimAlgo.h.

Referenced by oldreconstruct(), reconstruct(), and setPedestals().

const ESRecHitRatioCuts* ESRecHitSimAlgo::ratioCuts_
private

Definition at line 42 of file ESRecHitSimAlgo.h.

Referenced by evalAmplitude(), oldEvalAmplitude(), and setRatioCuts().

float ESRecHitSimAlgo::w0_
private

Definition at line 44 of file ESRecHitSimAlgo.h.

Referenced by evalAmplitude(), oldreconstruct(), and setW0().

float ESRecHitSimAlgo::w1_
private

Definition at line 45 of file ESRecHitSimAlgo.h.

Referenced by evalAmplitude(), oldreconstruct(), and setW1().

float ESRecHitSimAlgo::w2_
private

Definition at line 46 of file ESRecHitSimAlgo.h.

Referenced by evalAmplitude(), oldreconstruct(), and setW2().