CMS 3D CMS Logo

TPNPulse.cc
Go to the documentation of this file.
1 /*
2  * \class TPNPulse
3  *
4  * \author: Julie Malcles - CEA/Saclay
5  */
6 
8 
9 #include <TMath.h>
10 #include <iostream>
11 #include <cassert>
12 using namespace std;
13 
14 //ClassImp(TPNPulse)
15 
16 
17 // Default Constructor...
19 {
20  init(50,6);
21 }
22 
23 // Constructor...
24 TPNPulse::TPNPulse( int nsamples, int presample )
25 {
26  init( nsamples, presample);
27 }
28 
29 // Destructor
31 {
32 }
33 
34 void TPNPulse::init(int nsamples, int presample )
35 {
36  _nsamples=50;
37  assert(nsamples==_nsamples);
38  assert(presample!=0);
39  adc_ = new double[50];
40 
41  _presample=presample;
42 
43  for(int i=0;i<_nsamples;i++){
44  adc_[i]=0.0;
45  }
46 
47  adcMax_=0;
48  iadcMax_=0;
49  pedestal_=0;
50 
51  isMaxFound_=false;
52  isPedCalc_=false;
53 }
54 
55 bool TPNPulse::setPulse(double *adc){
56 
57  bool done=false;
58  adc_=adc;
59  done=true;
60  isMaxFound_=false;
61  isPedCalc_=false;
62  return done;
63 }
65 
66  if(isMaxFound_) return adcMax_;
67 
68  int iadcmax=0;
69  double adcmax=0.0;
70  for(int i=0;i<_nsamples;i++){
71  if(adc_[i]>adcmax){
72  iadcmax=i;
73  adcmax=adc_[i];
74  }
75  }
76  iadcMax_=iadcmax;
77  adcMax_=adcmax;
78  return adcMax_;
79 }
80 
82  if(!isMaxFound_) getMax();
83  return iadcMax_;
84 
85 }
86 
88  if(isPedCalc_) return pedestal_;
89  double ped=0;
90  for(int i=0;i<_presample;i++){
91  ped+=adc_[i];
92  }
93  ped/=double(_presample);
94  pedestal_=ped;
95  isPedCalc_=true;
96  return pedestal_;
97 }
98 
100 
101  double ped;
102  if(!isPedCalc_) ped=getPedestal();
103  else ped=pedestal_;
104 
105  double *adcNoPed= new double[50];
106  for (int i=0;i<_nsamples;i++){
107  adcNoPed[i]=adc_[i]-ped;
108  }
109  return adcNoPed;
110 }
111 
112 void TPNPulse::setPresamples(int presample){
113  isPedCalc_=false;
114  _presample=presample;
115 }
double getPedestal()
Definition: TPNPulse.cc:87
void init(int, int)
Definition: TPNPulse.cc:34
double getMax()
Definition: TPNPulse.cc:64
int init
Definition: HydjetWrapper.h:67
double * getAdcWithoutPedestal()
Definition: TPNPulse.cc:99
bool setPulse(double *)
Definition: TPNPulse.cc:55
~TPNPulse() override
Definition: TPNPulse.cc:30
TPNPulse()
Definition: TPNPulse.cc:18
void setPresamples(int)
Definition: TPNPulse.cc:112
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
int getMaxSample()
Definition: TPNPulse.cc:81