CMS 3D CMS Logo

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, JetChargeProducer_cfi::exp, f, ESRecHitRatioCuts::getR12High(), ESRecHitRatioCuts::getR23High(), mps_fire::i, EcalRecHit::kESBadRatioFor12, EcalRecHit::kESBadRatioFor23Lower, EcalRecHit::kESBadRatioFor23Upper, EcalRecHit::kESGood, EcalRecHit::kESSaturated, EcalRecHit::kESTS13Sigmas, EcalRecHit::kESTS1Largest, EcalRecHit::kESTS2Saturated, EcalRecHit::kESTS3Largest, EcalRecHit::kESTS3Negative, EcalRecHit::kESTS3Saturated, cmsBatch::log, LogDebug, gen::n, funct::pow(), ratioCuts_, ESDataFrame::sample(), ESDataFrame::size(), mps_update::status, cscNeutronWriter_cfi::t0, w, w0_, w1_, and w2_.

Referenced by reconstruct(), and setW2().

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  #if defined(__clang__) || defined(__INTEL_COMPILER)
55  const float A_1 = 1./( std::pow(w/n*(t1),n) * std::exp(n-w*(t1)) );
56  #else
57  constexpr float A_1 = 1./( std::pow(w/n*(t1),n) * std::exp(n-w*(t1)) );
58  #endif
59  auto AA1 = A1 * A_1 ;
60 
61  if (adc[1] > 2800.f && adc[2] > 2800.f) status = EcalRecHit::kESSaturated;
62  else if (adc[1] > 2800.f) status = EcalRecHit::kESTS2Saturated;
63  else if (adc[2] > 2800.f) status = EcalRecHit::kESTS3Saturated;
64 
65  results[0] = energy; // energy with weight method
66  results[1] = t0; // timing
67  results[2] = AA1; // energy with analytic method
68 
69  return status;
70 
71 }
#define LogDebug(id)
int adc(sample_type sample)
get the ADC sample (12 bits)
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
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 151 of file ESRecHitSimAlgo.cc.

References ecalMGPA::adc(), ESSample::adc(), JetChargeProducer_cfi::exp, ESRecHitRatioCuts::getR12High(), ESRecHitRatioCuts::getR23High(), mps_fire::i, cmsBatch::log, LogDebug, gen::n, funct::pow(), ratioCuts_, mps_update::results, ESDataFrame::sample(), ESDataFrame::size(), mps_update::status, cscNeutronWriter_cfi::t0, w, and w2.

Referenced by oldreconstruct(), and setW2().

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

References ang_, channelStatus_, funct::cos(), ESCondObjectContainer< T >::find(), ESCondObjectContainer< T >::getMap(), ESDataFrame::id(), createfilelist::int, 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_, mps_update::results, EcalRecHit::setEnergyError(), mps_update::status, cscNeutronWriter_cfi::t0, w0_, w1_, and w2_.

Referenced by setW2().

209  {
210 
211  ESPedestals::const_iterator it_ped = peds_->find(digi.id());
212 
215 
217 
218  double* results;
219 
220  results = oldEvalAmplitude(digi, it_ped->getMean(), w0_, w1_, w2_);
221 
222  double energy = results[0];
223  double t0 = results[1];
224  int status = (int) results[2];
225  double otenergy = results[3] * 1000000.; // set out-of-time energy to keV
226  delete[] results;
227 
228  double mipCalib = (fabs(cos(*it_ang)) != 0.) ? (*it_mip)/fabs(cos(*it_ang)) : 0.;
229  energy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
230  otenergy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
231 
232  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : reconstructed energy "<<energy;
233 
234  EcalRecHit rechit(digi.id(), energy, t0);
235  // edm: this is just a placeholder for alternative energy reconstruction,
236  // so put it in the same float, with different name
237  // rechit.setOutOfTimeEnergy(otenergy);
238  rechit.setEnergyError(otenergy);
239 
240  if (it_status->getStatusCode() == 1) {
241  rechit.setFlag(EcalRecHit::kESDead);
242  } else {
243  if (status == 0)
244  rechit.setFlag(EcalRecHit::kESGood);
245  else if (status == 5)
246  rechit.setFlag(EcalRecHit::kESBadRatioFor12);
247  else if (status == 6)
248  rechit.setFlag(EcalRecHit::kESBadRatioFor23Upper);
249  else if (status == 7)
250  rechit.setFlag(EcalRecHit::kESBadRatioFor23Lower);
251  else if (status == 8)
252  rechit.setFlag(EcalRecHit::kESTS1Largest);
253  else if (status == 9)
254  rechit.setFlag(EcalRecHit::kESTS3Largest);
255  else if (status == 10)
256  rechit.setFlag(EcalRecHit::kESTS3Negative);
257  else if (status == 11)
258  rechit.setFlag(EcalRecHit::kESSaturated);
259  else if (status == 12)
260  rechit.setFlag(EcalRecHit::kESTS2Saturated);
261  else if (status == 13)
262  rechit.setFlag(EcalRecHit::kESTS3Saturated);
263  else if (status == 14)
264  rechit.setFlag(EcalRecHit::kESTS13Sigmas);
265  }
266 
267  return rechit;
268 }
#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:144
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
EcalRecHit ESRecHitSimAlgo::reconstruct ( const ESDataFrame digi) const

Definition at line 73 of file ESRecHitSimAlgo.cc.

References funct::abs(), ang_, channelStatus_, evalAmplitude(), ESCondObjectContainer< T >::getMap(), ESDetId::hashedIndex(), ESDataFrame::id(), EcalRecHit::kESDead, LogDebug, MIPGeV_, mips_, peds_, ESCondObjectContainer< T >::preshower(), mps_update::results, EcalRecHit::setEnergyError(), mps_update::status, and cscNeutronWriter_cfi::t0.

Referenced by ESRecHitWorker::run(), and setW2().

73  {
74 
75 
76  auto ind = digi.id().hashedIndex();
77 
78  auto const & ped = peds_->preshower(ind);
79  auto const & mip = mips_->getMap().preshower(ind);
80  auto const & ang = ang_->getMap().preshower(ind);
81  auto const & statusCh = channelStatus_->getMap().preshower(ind);
82 
83  float results[3] {};
84 
85  auto status = evalAmplitude(results, digi, ped.getMean());
86 
87  auto energy = results[0];
88  auto t0 = results[1];
89  auto otenergy = results[2] * 1000000.f; // set out-of-time energy to keV
90 
91 
92  auto mipCalib = (mip != 0.f) ? MIPGeV_*std::abs(vdt::fast_cosf(ang))/(mip) : 0.f;
93  energy *= mipCalib;
94  otenergy *= mipCalib;
95 
96  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : reconstructed energy "<<energy;
97 
98  EcalRecHit rechit(digi.id(), energy, t0);
99  // edm: this is just a placeholder for alternative energy reconstruction,
100  // so put it in the same float, with different name
101  // rechit.setOutOfTimeEnergy(otenergy);
102  rechit.setEnergyError(otenergy);
103 
104  rechit.setFlag(statusCh.getStatusCode() == 1 ? EcalRecHit::kESDead : status);
105 
106  return rechit;
107 
108 }
#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:144
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
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
Definition: ESDetId.cc:44
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 mps_update::status.

Referenced by ESRecHitWorker::set().

const ESChannelStatus * channelStatus_
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

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().