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

#include <EcalUncalibRecHitMultiFitAlgo.h>

Public Member Functions

void disableErrorCalculation ()
 
 EcalUncalibRecHitMultiFitAlgo ()
 
EcalUncalibratedRecHit makeRecHit (const EcalDataFrame &dataFrame, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const SampleMatrix &noisecor, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const BXVector &activeBX)
 compute rechits More...
 
 ~EcalUncalibRecHitMultiFitAlgo ()
 

Private Attributes

bool _computeErrors
 
PulseChiSqSNNLS _pulsefunc
 

Detailed Description

Amplitude reconstucted by the multi-template fit

Author
J.Bendavid, E.Di Marco

Definition at line 21 of file EcalUncalibRecHitMultiFitAlgo.h.

Constructor & Destructor Documentation

EcalUncalibRecHitMultiFitAlgo::EcalUncalibRecHitMultiFitAlgo ( )

Definition at line 8 of file EcalUncalibRecHitMultiFitAlgo.cc.

EcalUncalibRecHitMultiFitAlgo::~EcalUncalibRecHitMultiFitAlgo ( )
inline

Definition at line 27 of file EcalUncalibRecHitMultiFitAlgo.h.

27 { };

Member Function Documentation

void EcalUncalibRecHitMultiFitAlgo::disableErrorCalculation ( )
inline
EcalUncalibratedRecHit EcalUncalibRecHitMultiFitAlgo::makeRecHit ( const EcalDataFrame dataFrame,
const EcalPedestals::Item aped,
const EcalMGPAGainRatio aGain,
const SampleMatrix noisecor,
const FullSampleVector fullpulse,
const FullSampleMatrix fullpulsecov,
const BXVector activeBX 
)

compute rechits

Definition at line 13 of file EcalUncalibRecHitMultiFitAlgo.cc.

References _computeErrors, _pulsefunc, EcalMGPASample::adc(), PulseChiSqSNNLS::BXs(), PulseChiSqSNNLS::ChiSq(), PulseChiSqSNNLS::disableErrorCalculation(), PulseChiSqSNNLS::DoFit(), PulseChiSqSNNLS::Errors(), flags, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), ecalMGPA::gainId(), EcalMGPASample::gainId(), EcalDataFrame::id(), max(), EcalDataFrame::MAXSAMPLES, EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, EcalCondDBWriter_cfi::pedestal, EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, compare_using_db::sample, EcalDataFrame::sample(), EcalUncalibratedRecHit::setAmplitudeError(), ntuplemaker::status, and PulseChiSqSNNLS::X().

Referenced by EcalUncalibRecHitWorkerMultiFit::run().

13  {
14 
15  uint32_t flags = 0;
16 
17  const unsigned int nsample = EcalDataFrame::MAXSAMPLES;
18 
19  double maxamplitude = -std::numeric_limits<double>::max();
20 
21  double pedval = 0.;
22  double pedrms = 0.;
23 
24  SampleVector amplitudes;
25  for(unsigned int iSample = 0; iSample < nsample; iSample++) {
26 
27  const EcalMGPASample &sample = dataFrame.sample(iSample);
28 
29  double amplitude = 0.;
30  int gainId = sample.gainId();
31 
32  double pedestal = 0.;
33  double pederr = 0.;
34  double gainratio = 1.;
35 
36  if (gainId==0 || gainId==3) {
37  pedestal = aped->mean_x1;
38  pederr = aped->rms_x1;
39  gainratio = aGain->gain6Over1()*aGain->gain12Over6();
40  }
41  else if (gainId==1) {
42  pedestal = aped->mean_x12;
43  pederr = aped->rms_x12;
44  gainratio = 1.;
45  }
46  else if (gainId==2) {
47  pedestal = aped->mean_x6;
48  pederr = aped->rms_x6;
49  gainratio = aGain->gain12Over6();
50  }
51 
52  amplitude = ((double)(sample.adc()) - pedestal) * gainratio;
53 
54  if (gainId == 0) {
55  //saturation
56  amplitude = (4095. - pedestal) * gainratio;
57  }
58 
59  amplitudes[iSample] = amplitude;
60 
61  if (amplitude>maxamplitude) {
62  //if (iSample==5) {
63  maxamplitude = amplitude;
64  pedval = pedestal;
65  pedrms = pederr*gainratio;
66  }
67 
68  }
69 
71  bool status = _pulsefunc.DoFit(amplitudes,noisecor,pedrms,activeBX,fullpulse,fullpulsecov);
72  double chisq = _pulsefunc.ChiSq();
73 
74  if (!status) {
75  edm::LogWarning("EcalUncalibRecHitMultiFitAlgo::makeRecHit") << "Failed Fit" << std::endl;
76  }
77 
78  unsigned int ipulseintime = 0;
79  for (unsigned int ipulse=0; ipulse<_pulsefunc.BXs().rows(); ++ipulse) {
80  if (_pulsefunc.BXs().coeff(ipulse)==0) {
81  ipulseintime = ipulse;
82  break;
83  }
84  }
85 
86  double amplitude = status ? _pulsefunc.X()[ipulseintime] : 0.;
87  double amperr = status ? _pulsefunc.Errors()[ipulseintime] : 0.;
88 
89  double jitter = 0.;
90 
91  //printf("status = %i\n",int(status));
92  //printf("amplitude = %5f +- %5f, chisq = %5f\n",amplitude,amperr,chisq);
93 
94  EcalUncalibratedRecHit rh( dataFrame.id(), amplitude , pedval, jitter, chisq, flags );
95  rh.setAmplitudeError(amperr);
96 
97  for (unsigned int ipulse=0; ipulse<_pulsefunc.BXs().rows(); ++ipulse) {
98  int bx = _pulsefunc.BXs().coeff(ipulse);
99  if (bx!=0) {
100  rh.setOutOfTimeAmplitude(bx+5, status ? _pulsefunc.X().coeff(ipulse) : 0.);
101  }
102  }
103 
104  return rh;
105 }
DetId id() const
Definition: EcalDataFrame.h:24
int gainId(sample_type sample)
get the gainId (2 bits)
void disableErrorCalculation()
const PulseVector & Errors() const
Eigen::Matrix< double, 10, 1 > SampleVector
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
int gainId() const
get the gainId (2 bits)
const PulseVector & X() const
const T & max(const T &a, const T &b)
float gain6Over1() const
void setAmplitudeError(float amplitudeerror)
double ChiSq() const
float gain12Over6() const
const BXVector & BXs() const
tuple status
Definition: ntuplemaker.py:245
static const int MAXSAMPLES
Definition: EcalDataFrame.h:48
bool DoFit(const SampleVector &samples, const SampleMatrix &samplecor, double pederr, const BXVector &bxs, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov)
int adc() const
get the ADC sample (12 bits)

Member Data Documentation

bool EcalUncalibRecHitMultiFitAlgo::_computeErrors
private

Definition at line 33 of file EcalUncalibRecHitMultiFitAlgo.h.

Referenced by disableErrorCalculation(), and makeRecHit().

PulseChiSqSNNLS EcalUncalibRecHitMultiFitAlgo::_pulsefunc
private

Definition at line 32 of file EcalUncalibRecHitMultiFitAlgo.h.

Referenced by makeRecHit().