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 Attributes
ESRecHitSimAlgo Class Reference

#include <ESRecHitSimAlgo.h>

Public Member Functions

 ESRecHitSimAlgo ()
 
double * EvalAmplitude (const ESDataFrame &digi, const double &ped, const double &w0, const double &w1, const double &w2) const
 
EcalRecHit reconstruct (const ESDataFrame &digi) const
 
void setAngleCorrectionFactors (const ESAngleCorrectionFactors *ang)
 
void setChannelStatus (const ESChannelStatus *status)
 
void setESGain (const double &value)
 
void setIntercalibConstants (const ESIntercalibConstants *mips)
 
void setMIPGeV (const double &value)
 
void setPedestals (const ESPedestals *peds)
 
void setRatioCuts (const ESRecHitRatioCuts *ratioCuts)
 
void setW0 (const double &value)
 
void setW1 (const double &value)
 
void setW2 (const double &value)
 
 ~ESRecHitSimAlgo ()
 

Private Attributes

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

Detailed Description

Definition at line 12 of file ESRecHitSimAlgo.h.

Constructor & Destructor Documentation

ESRecHitSimAlgo::ESRecHitSimAlgo ( )

Definition at line 7 of file ESRecHitSimAlgo.cc.

7  {
8 
9 }
ESRecHitSimAlgo::~ESRecHitSimAlgo ( )
inline

Definition at line 17 of file ESRecHitSimAlgo.h.

17 {}

Member Function Documentation

double * ESRecHitSimAlgo::EvalAmplitude ( const ESDataFrame digi,
const double &  ped,
const double &  w0,
const double &  w1,
const double &  w2 
) const

Definition at line 11 of file ESRecHitSimAlgo.cc.

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

Referenced by reconstruct().

11  {
12 
13  double *results = new double[4];
14  float energy = 0;
15  double 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 
28  double status = 0;
29  if (adc[0] > 20) status = 14;
30  if (adc[1] <= 0 || adc[2] <= 0) status = 10;
31  if (adc[0] > adc[1] && adc[0] > adc[2]) status = 8;
32  if (adc[2] > adc[1] && adc[2] > adc[0]) status = 9;
33  double r12 = (adc[1] != 0) ? adc[0]/adc[1] : 99;
34  double r23 = (adc[2] != 0) ? adc[1]/adc[2] : 99;
35  if (r12 > ratioCuts_->getR12High()) status = 5;
36  if (r23 > ratioCuts_->getR23High()) status = 6;
37  if (r23 < ratioCuts_->getR23Low()) status = 7;
38 
39  double A1 = adc[1];
40  double A2 = adc[2];
41 
42  // t0 from analytical formula:
43  double n = 1.798;
44  double w = 0.07291;
45  double DeltaT = 25.;
46  double aaa = (A2 > 0 && A1 > 0) ? log(A2/A1)/n : 20.; // if A1=0, t0=20
47  double bbb = w/n*DeltaT;
48  double ccc= exp(aaa+bbb);
49 
50  double t0 = (2.-ccc)/(1.-ccc) * DeltaT - 5;
51 
52  // A from analytical formula:
53  double t1 = 20.;
54  double A_1 = pow(w/n*(t1),n) * exp(n-w*(t1));
55  double AA1 = (A_1 != 0.) ? A1 / A_1 : 0.;
56 
57  if (adc[1] > 2800 && adc[2] > 2800) status = 11;
58  else if (adc[1] > 2800) status = 12;
59  else if (adc[2] > 2800) status = 13;
60 
61  results[0] = energy; // energy with weight method
62  results[1] = t0; // timing
63  results[2] = status; // hit status
64  results[3] = AA1; // energy with analytic method
65 
66  return results;
67 }
#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
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
int size() const
Definition: ESDataFrame.h:20
const ESSample & sample(int i) const
Definition: ESDataFrame.h:23
Log< T >::type log(const T &t)
Definition: Log.h:22
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::reconstruct ( const ESDataFrame digi) const

Definition at line 69 of file ESRecHitSimAlgo.cc.

References ang_, channelStatus_, funct::cos(), relval_parameters_module::energy, EvalAmplitude(), 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_, peds_, python.entryComment::results, EcalRecHit::setOutOfTimeEnergy(), ntuplemaker::status, w0_, w1_, and w2_.

Referenced by ESRecHitWorker::run().

69  {
70 
71  ESPedestals::const_iterator it_ped = peds_->find(digi.id());
72 
75 
77 
78  double* results;
79 
80  results = EvalAmplitude(digi, it_ped->getMean(), w0_, w1_, w2_);
81 
82  double energy = results[0];
83  double t0 = results[1];
84  int status = (int) results[2];
85  double otenergy = results[3] * 1000000.; // set out-of-time energy to keV
86  delete[] results;
87 
88  double mipCalib = (fabs(cos(*it_ang)) != 0.) ? (*it_mip)/fabs(cos(*it_ang)) : 0.;
89  energy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
90  otenergy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
91 
92  DetId detId = digi.id();
93 
94  LogDebug("ESRecHitSimAlgo") << "ESRecHitSimAlgo : reconstructed energy "<<energy;
95 
96  EcalRecHit rechit(digi.id(), energy, t0);
97  rechit.setOutOfTimeEnergy(otenergy);
98 
99  if (it_status->getStatusCode() == 1) {
100  rechit.setRecoFlag(EcalRecHit::kESDead);
101  } else {
102  if (status == 0)
103  rechit.setRecoFlag(EcalRecHit::kESGood);
104  else if (status == 5)
105  rechit.setRecoFlag(EcalRecHit::kESBadRatioFor12);
106  else if (status == 6)
107  rechit.setRecoFlag(EcalRecHit::kESBadRatioFor23Upper);
108  else if (status == 7)
109  rechit.setRecoFlag(EcalRecHit::kESBadRatioFor23Lower);
110  else if (status == 8)
111  rechit.setRecoFlag(EcalRecHit::kESTS1Largest);
112  else if (status == 9)
113  rechit.setRecoFlag(EcalRecHit::kESTS3Largest);
114  else if (status == 10)
115  rechit.setRecoFlag(EcalRecHit::kESTS3Negative);
116  else if (status == 11)
117  rechit.setRecoFlag(EcalRecHit::kESSaturated);
118  else if (status == 12)
119  rechit.setRecoFlag(EcalRecHit::kESTS2Saturated);
120  else if (status == 13)
121  rechit.setRecoFlag(EcalRecHit::kESTS3Saturated);
122  else if (status == 14)
123  rechit.setRecoFlag(EcalRecHit::kESTS13Sigmas);
124  }
125 
126  return rechit;
127 }
#define LogDebug(id)
const ESDetId & id() const
Definition: ESDataFrame.h:18
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
Definition: DetId.h:20
const ESAngleCorrectionFactors * ang_
std::vector< Item >::const_iterator const_iterator
void setOutOfTimeEnergy(float energy)
Definition: EcalRecHit.cc:107
tuple status
Definition: ntuplemaker.py:245
double * EvalAmplitude(const ESDataFrame &digi, const double &ped, const double &w0, const double &w1, const double &w2) const
void ESRecHitSimAlgo::setAngleCorrectionFactors ( const ESAngleCorrectionFactors ang)
inline

Definition at line 25 of file ESRecHitSimAlgo.h.

References ang_.

Referenced by ESRecHitWorker::set().

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

Definition at line 23 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 ( const double &  value)
inline

Definition at line 19 of file ESRecHitSimAlgo.h.

References gain_, and relativeConstraints::value.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setIntercalibConstants ( const ESIntercalibConstants mips)
inline

Definition at line 22 of file ESRecHitSimAlgo.h.

References mips_.

Referenced by ESRecHitWorker::set().

22 { mips_ = mips; }
const ESIntercalibConstants * mips_
void ESRecHitSimAlgo::setMIPGeV ( const double &  value)
inline

Definition at line 20 of file ESRecHitSimAlgo.h.

References MIPGeV_, and relativeConstraints::value.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setPedestals ( const ESPedestals peds)
inline

Definition at line 21 of file ESRecHitSimAlgo.h.

References peds_.

Referenced by ESRecHitWorker::set().

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

Definition at line 24 of file ESRecHitSimAlgo.h.

References ratioCuts_.

Referenced by ESRecHitWorker::set().

24 { ratioCuts_ = ratioCuts; }
const ESRecHitRatioCuts * ratioCuts_
void ESRecHitSimAlgo::setW0 ( const double &  value)
inline

Definition at line 26 of file ESRecHitSimAlgo.h.

References relativeConstraints::value, and w0_.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setW1 ( const double &  value)
inline

Definition at line 27 of file ESRecHitSimAlgo.h.

References relativeConstraints::value, and w1_.

Referenced by ESRecHitWorker::set().

void ESRecHitSimAlgo::setW2 ( const double &  value)
inline

Definition at line 28 of file ESRecHitSimAlgo.h.

References relativeConstraints::value, and w2_.

Referenced by ESRecHitWorker::set().

Member Data Documentation

const ESAngleCorrectionFactors* ESRecHitSimAlgo::ang_
private

Definition at line 40 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setAngleCorrectionFactors().

const ESChannelStatus* ESRecHitSimAlgo::channelStatus_
private

Definition at line 38 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setChannelStatus().

int ESRecHitSimAlgo::gain_
private

Definition at line 35 of file ESRecHitSimAlgo.h.

Referenced by setESGain().

double ESRecHitSimAlgo::MIPGeV_
private

Definition at line 44 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setMIPGeV().

const ESIntercalibConstants* ESRecHitSimAlgo::mips_
private

Definition at line 37 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setIntercalibConstants().

const ESPedestals* ESRecHitSimAlgo::peds_
private

Definition at line 36 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setPedestals().

const ESRecHitRatioCuts* ESRecHitSimAlgo::ratioCuts_
private

Definition at line 39 of file ESRecHitSimAlgo.h.

Referenced by EvalAmplitude(), and setRatioCuts().

double ESRecHitSimAlgo::w0_
private

Definition at line 41 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setW0().

double ESRecHitSimAlgo::w1_
private

Definition at line 42 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setW1().

double ESRecHitSimAlgo::w2_
private

Definition at line 43 of file ESRecHitSimAlgo.h.

Referenced by reconstruct(), and setW2().