CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibRecHitMultiFitAlgo.cc
Go to the documentation of this file.
2 
4 
7 
9  _computeErrors(true) {
10 }
11 
13 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) {
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 }
106 
DetId id() const
Definition: EcalDataFrame.h:24
int gainId(sample_type sample)
get the gainId (2 bits)
void disableErrorCalculation()
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
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
Eigen::Matrix< double, 19, 19 > FullSampleMatrix
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)
Eigen::Matrix< double, 19, 1 > FullSampleVector
double ChiSq() const
float gain12Over6() const
const BXVector & BXs() const
Eigen::Matrix< double, 10, 10 > SampleMatrix
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)