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
ESRecHitFitAlgo Class Reference

#include <ESRecHitFitAlgo.h>

Public Member Functions

 ESRecHitFitAlgo ()
 
double * EvalAmplitude (const ESDataFrame &digi, double ped) 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)
 
 ~ESRecHitFitAlgo ()
 

Private Attributes

const ESAngleCorrectionFactorsang_
 
const ESChannelStatuschannelStatus_
 
TF1 * fit_
 
double gain_
 
double MIPGeV_
 
const ESIntercalibConstantsmips_
 
const ESPedestalspeds_
 
const ESRecHitRatioCutsratioCuts_
 

Detailed Description

Definition at line 14 of file ESRecHitFitAlgo.h.

Constructor & Destructor Documentation

ESRecHitFitAlgo::ESRecHitFitAlgo ( )

Definition at line 24 of file ESRecHitFitAlgo.cc.

References fit_, and fitf().

24  {
25 
26  fit_ = new TF1("fit", fitf, -200, 200, 2);
27  fit_->SetParameters(50, 10);
28 
29 }
double fitf(double *x, double *par)
Definition: ESTimingTask.cc:29
ESRecHitFitAlgo::~ESRecHitFitAlgo ( )

Definition at line 31 of file ESRecHitFitAlgo.cc.

References fit_.

31  {
32  delete fit_;
33 }

Member Function Documentation

double * ESRecHitFitAlgo::EvalAmplitude ( const ESDataFrame digi,
double  ped 
) const

Definition at line 35 of file ESRecHitFitAlgo.cc.

References ecalMGPA::adc(), ESSample::adc(), fit_, ESRecHitRatioCuts::getR12High(), ESRecHitRatioCuts::getR23High(), i, ratioCuts_, ESDataFrame::sample(), ESDataFrame::size(), and ntuplemaker::status.

Referenced by reconstruct().

35  {
36 
37  double *fitresults = new double[3];
38  double adc[3];
39  double tx[3];
40  tx[0] = -5.;
41  tx[1] = 20.;
42  tx[2] = 45.;
43 
44  for (int i=0; i<digi.size(); i++)
45  adc[i] = digi.sample(i).adc() - ped;
46 
47  double status = 0;
48  if (adc[0] > 20) status = 14;
49  if (adc[1] < 0 || adc[2] < 0) status = 10;
50  if (adc[0] > adc[1] && adc[0] > adc[2]) status = 8;
51  if (adc[2] > adc[1] && adc[2] > adc[0]) status = 9;
52  double r12 = (adc[1] != 0) ? adc[0]/adc[1] : 99999;
53  double r23 = (adc[2] != 0) ? adc[1]/adc[2] : 99999;
54  if (r12 > ratioCuts_->getR12High()) status = 5;
55  if (r23 > ratioCuts_->getR23High()) status = 6;
56  if (r23 < ratioCuts_->getR23Low()) status = 7;
57 
58  if (int(status) == 0) {
59  double para[10];
60  TGraph *gr = new TGraph(3, tx, adc);
61  fit_->SetParameters(50, 10);
62  gr->Fit("fit", "MQ");
63  fit_->GetParameters(para);
64  fitresults[0] = para[0];
65  fitresults[1] = para[1];
66  delete gr;
67 
68  if (adc[1] > 2800 && adc[2] > 2800) status = 11;
69  else if (adc[1] > 2800) status = 12;
70  else if (adc[2] > 2800) status = 13;
71 
72  } else {
73  fitresults[0] = 0;
74  fitresults[1] = -999;
75  }
76 
77  fitresults[2] = status;
78 
79  return fitresults;
80 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
int size() const
Definition: ESDataFrame.h:23
const ESRecHitRatioCuts * ratioCuts_
const ESSample & sample(int i) const
Definition: ESDataFrame.h:26
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
EcalRecHit ESRecHitFitAlgo::reconstruct ( const ESDataFrame digi) const

Definition at line 82 of file ESRecHitFitAlgo.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::setFlag(), and ntuplemaker::status.

Referenced by ESRecHitWorker::run().

82  {
83 
84  ESPedestals::const_iterator it_ped = peds_->find(digi.id());
85 
88 
90 
91  double* results;
92 
93  results = EvalAmplitude(digi, it_ped->getMean());
94 
95  double energy = results[0];
96  double t0 = results[1];
97  int status = (int) results[2];
98  delete[] results;
99 
100  double mipCalib = (std::fabs(cos(*it_ang)) != 0.) ? (*it_mip)/fabs(cos(*it_ang)) : 0.;
101  energy *= (mipCalib != 0.) ? MIPGeV_/mipCalib : 0.;
102 
103  LogDebug("ESRecHitFitAlgo") << "ESRecHitFitAlgo : reconstructed energy "<<energy<<" T0 "<<t0;
104 
105  EcalRecHit rechit(digi.id(), energy, t0);
106 
107  if (it_status->getStatusCode() == 1) {
109  } else {
110  if (status == 0)
111  rechit.setFlag(EcalRecHit::kESGood);
112  else if (status == 5)
113  rechit.setFlag(EcalRecHit::kESBadRatioFor12);
114  else if (status == 6)
115  rechit.setFlag(EcalRecHit::kESBadRatioFor23Upper);
116  else if (status == 7)
117  rechit.setFlag(EcalRecHit::kESBadRatioFor23Lower);
118  else if (status == 8)
119  rechit.setFlag(EcalRecHit::kESTS1Largest);
120  else if (status == 9)
121  rechit.setFlag(EcalRecHit::kESTS3Largest);
122  else if (status == 10)
123  rechit.setFlag(EcalRecHit::kESTS3Negative);
124  else if (status == 11)
125  rechit.setFlag(EcalRecHit::kESSaturated);
126  else if (status == 12)
127  rechit.setFlag(EcalRecHit::kESTS2Saturated);
128  else if (status == 13)
129  rechit.setFlag(EcalRecHit::kESTS3Saturated);
130  else if (status == 14)
131  rechit.setFlag(EcalRecHit::kESTS13Sigmas);
132  }
133 
134  return rechit;
135 }
#define LogDebug(id)
const ESChannelStatus * channelStatus_
const ESDetId & id() const
Definition: ESDataFrame.h:21
const self & getMap() const
void setFlag(int flag)
set the flags (from Flags or ESFlags)
Definition: EcalRecHit.h:102
const ESAngleCorrectionFactors * ang_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const_iterator find(uint32_t rawId) const
std::vector< Item >::const_iterator const_iterator
double * EvalAmplitude(const ESDataFrame &digi, double ped) const
tuple status
Definition: ntuplemaker.py:245
const ESIntercalibConstants * mips_
const ESPedestals * peds_
void ESRecHitFitAlgo::setAngleCorrectionFactors ( const ESAngleCorrectionFactors ang)
inline

Definition at line 27 of file ESRecHitFitAlgo.h.

References ang_.

Referenced by ESRecHitWorker::set().

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

Definition at line 25 of file ESRecHitFitAlgo.h.

References channelStatus_, and ntuplemaker::status.

Referenced by ESRecHitWorker::set().

const ESChannelStatus * channelStatus_
tuple status
Definition: ntuplemaker.py:245
void ESRecHitFitAlgo::setESGain ( const double &  value)
inline

Definition at line 21 of file ESRecHitFitAlgo.h.

References gain_, and relativeConstraints::value.

Referenced by ESRecHitWorker::set().

void ESRecHitFitAlgo::setIntercalibConstants ( const ESIntercalibConstants mips)
inline

Definition at line 24 of file ESRecHitFitAlgo.h.

References mips_.

Referenced by ESRecHitWorker::set().

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

Definition at line 22 of file ESRecHitFitAlgo.h.

References MIPGeV_, and relativeConstraints::value.

Referenced by ESRecHitWorker::set().

void ESRecHitFitAlgo::setPedestals ( const ESPedestals peds)
inline

Definition at line 23 of file ESRecHitFitAlgo.h.

References peds_.

Referenced by ESRecHitWorker::set().

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

Definition at line 26 of file ESRecHitFitAlgo.h.

References ratioCuts_.

Referenced by ESRecHitWorker::set().

26 { ratioCuts_ = ratioCuts; }
const ESRecHitRatioCuts * ratioCuts_

Member Data Documentation

const ESAngleCorrectionFactors* ESRecHitFitAlgo::ang_
private

Definition at line 39 of file ESRecHitFitAlgo.h.

Referenced by reconstruct(), and setAngleCorrectionFactors().

const ESChannelStatus* ESRecHitFitAlgo::channelStatus_
private

Definition at line 37 of file ESRecHitFitAlgo.h.

Referenced by reconstruct(), and setChannelStatus().

TF1* ESRecHitFitAlgo::fit_
private

Definition at line 33 of file ESRecHitFitAlgo.h.

Referenced by ESRecHitFitAlgo(), EvalAmplitude(), and ~ESRecHitFitAlgo().

double ESRecHitFitAlgo::gain_
private

Definition at line 34 of file ESRecHitFitAlgo.h.

Referenced by setESGain().

double ESRecHitFitAlgo::MIPGeV_
private

Definition at line 40 of file ESRecHitFitAlgo.h.

Referenced by reconstruct(), and setMIPGeV().

const ESIntercalibConstants* ESRecHitFitAlgo::mips_
private

Definition at line 36 of file ESRecHitFitAlgo.h.

Referenced by reconstruct(), and setIntercalibConstants().

const ESPedestals* ESRecHitFitAlgo::peds_
private

Definition at line 35 of file ESRecHitFitAlgo.h.

Referenced by reconstruct(), and setPedestals().

const ESRecHitRatioCuts* ESRecHitFitAlgo::ratioCuts_
private

Definition at line 38 of file ESRecHitFitAlgo.h.

Referenced by EvalAmplitude(), and setRatioCuts().