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
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
T w() const
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 147 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().

147  {
148 
149  double *results = new double[4];
150  float energy = 0;
151  double adc[3];
152  float pw[3];
153  pw[0] = w0;
154  pw[1] = w1;
155  pw[2] = w2;
156 
157  for (int i=0; i<digi.size(); i++) {
158  energy += pw[i]*(digi.sample(i).adc()-ped);
159  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : Digi "<<i<<" ADC counts "<<digi.sample(i).adc()<<" Ped "<<ped;
160  //std::cout<<i<<" "<<digi.sample(i).adc()<<" "<<ped<<" "<<pw[i]<<std::endl;
161  adc[i] = digi.sample(i).adc() - ped;
162  }
163 
164  double status = 0;
165  if (adc[0] > 20) status = 14;
166  if (adc[1] <= 0 || adc[2] <= 0) status = 10;
167  if (adc[0] > adc[1] && adc[0] > adc[2]) status = 8;
168  if (adc[2] > adc[1] && adc[2] > adc[0]) status = 9;
169  double r12 = (adc[1] != 0) ? adc[0]/adc[1] : 99;
170  double r23 = (adc[2] != 0) ? adc[1]/adc[2] : 99;
171  if (r12 > ratioCuts_->getR12High()) status = 5;
172  if (r23 > ratioCuts_->getR23High()) status = 6;
173  if (r23 < ratioCuts_->getR23Low()) status = 7;
174 
175  double A1 = adc[1];
176  double A2 = adc[2];
177 
178  // t0 from analytical formula:
179  double n = 1.798;
180  double w = 0.07291;
181  double DeltaT = 25.;
182  double aaa = (A2 > 0 && A1 > 0) ? log(A2/A1)/n : 20.; // if A1=0, t0=20
183  double bbb = w/n*DeltaT;
184  double ccc= exp(aaa+bbb);
185 
186  double t0 = (2.-ccc)/(1.-ccc) * DeltaT - 5;
187 
188  // A from analytical formula:
189  double t1 = 20.;
190  double A_1 = pow(w/n*(t1),n) * exp(n-w*(t1));
191  double AA1 = (A_1 != 0.) ? A1 / A_1 : 0.;
192 
193  if (adc[1] > 2800 && adc[2] > 2800) status = 11;
194  else if (adc[1] > 2800) status = 12;
195  else if (adc[2] > 2800) status = 13;
196 
197  results[0] = energy; // energy with weight method
198  results[1] = t0; // timing
199  results[2] = status; // hit status
200  results[3] = AA1; // energy with analytic method
201 
202  return results;
203 }
#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
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
T w() const
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 205 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::setEnergyError(), ntuplemaker::status, w0_, w1_, and w2_.

205  {
206 
207  ESPedestals::const_iterator it_ped = peds_->find(digi.id());
208 
211 
213 
214  double* results;
215 
216  results = oldEvalAmplitude(digi, it_ped->getMean(), w0_, w1_, w2_);
217 
218  double energy = results[0];
219  double t0 = results[1];
220  int status = (int) results[2];
221  double otenergy = results[3] * 1000000.; // set out-of-time energy to keV
222  delete[] results;
223 
224  double mipCalib = (fabs(cos(*it_ang)) != 0.) ? (*it_mip)/fabs(cos(*it_ang)) : 0.;
225  energy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
226  otenergy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
227 
228  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : reconstructed energy "<<energy;
229 
230  EcalRecHit rechit(digi.id(), energy, t0);
231  // edm: this is just a placeholder for alternative energy reconstruction,
232  // so put it in the same float, with different name
233  // rechit.setOutOfTimeEnergy(otenergy);
234  rechit.setEnergyError(otenergy);
235 
236  if (it_status->getStatusCode() == 1) {
237  rechit.setFlag(EcalRecHit::kESDead);
238  } else {
239  if (status == 0)
240  rechit.setFlag(EcalRecHit::kESGood);
241  else if (status == 5)
242  rechit.setFlag(EcalRecHit::kESBadRatioFor12);
243  else if (status == 6)
244  rechit.setFlag(EcalRecHit::kESBadRatioFor23Upper);
245  else if (status == 7)
246  rechit.setFlag(EcalRecHit::kESBadRatioFor23Lower);
247  else if (status == 8)
248  rechit.setFlag(EcalRecHit::kESTS1Largest);
249  else if (status == 9)
250  rechit.setFlag(EcalRecHit::kESTS3Largest);
251  else if (status == 10)
252  rechit.setFlag(EcalRecHit::kESTS3Negative);
253  else if (status == 11)
254  rechit.setFlag(EcalRecHit::kESSaturated);
255  else if (status == 12)
256  rechit.setFlag(EcalRecHit::kESTS2Saturated);
257  else if (status == 13)
258  rechit.setFlag(EcalRecHit::kESTS3Saturated);
259  else if (status == 14)
260  rechit.setFlag(EcalRecHit::kESTS13Sigmas);
261  }
262 
263  return rechit;
264 }
#define LogDebug(id)
const ESDetId & id() const
Definition: ESDataFrame.h:21
const self & getMap() const
const ESPedestals * peds_
const ESIntercalibConstants * mips_
void setEnergyError(float energy)
Definition: EcalRecHit.h:136
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
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::setEnergyError(), 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  // edm: this is just a placeholder for alternative energy reconstruction,
96  // so put it in the same float, with different name
97  // rechit.setOutOfTimeEnergy(otenergy);
98  rechit.setEnergyError(otenergy);
99 
100  rechit.setFlag(statusCh.getStatusCode() == 1 ? EcalRecHit::kESDead : status);
101 
102  return rechit;
103 
104 }
#define LogDebug(id)
const ESDetId & id() const
Definition: ESDataFrame.h:21
const self & getMap() const
const ESPedestals * peds_
const ESIntercalibConstants * mips_
void setEnergyError(float energy)
Definition: EcalRecHit.h:136
const ESChannelStatus * channelStatus_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const Item & preshower(size_t hashedIndex) const
const ESAngleCorrectionFactors * ang_
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().