19 init(10,3,1,2,2,9,3,8,0.4,0.95,0.8);
23 TAPDPulse::TAPDPulse(
int nsamples,
int presample,
int firstsample,
int lastsample,
int timingcutlow,
int timingcuthigh,
int timingquallow,
int timingqualhigh,
double ratiomincutlow,
double ratiomincuthigh,
double ratiomaxcutlow)
25 init( nsamples, presample, firstsample, lastsample, timingcutlow, timingcuthigh, timingquallow, timingqualhigh,ratiomincutlow,ratiomincuthigh, ratiomaxcutlow );
33 void TAPDPulse::init(
int nsamples,
int presample,
int firstsample,
int lastsample,
int timingcutlow,
int timingcuthigh,
int timingquallow,
int timingqualhigh,
double ratiomincutlow,
double ratiomincuthigh,
double ratiomaxcutlow)
36 assert(nsamples==_nsamples);
38 adc_ =
new double[10];
41 _firstsample=firstsample;
42 _lastsample=lastsample;
44 _timingcutlow=timingcutlow;
45 _timingcuthigh=timingcuthigh;
46 _timingquallow=timingquallow;
47 _timingqualhigh=timingqualhigh;
48 _ratiomincutlow=ratiomincutlow;
49 _ratiomincuthigh=ratiomincuthigh;
50 _ratiomaxcutlow=ratiomaxcutlow;
52 for(
int i=0;
i<_nsamples;
i++){
75 if(isMaxFound_)
return adcMax_;
79 for(
int i=0;
i<_nsamples;
i++){
91 if(!isMaxFound_) getMax();
97 assert (n1<_nsamples && n1>=0);
98 assert (n2<_nsamples && n2>=0);
100 double delta=adc_[n1]-adc_[n2];
105 assert (n1<_nsamples && n1>=0);
106 assert (n2<_nsamples && n2>=0);
109 if(isPedCalc_)ped=pedestal_;
112 double ratio=(adc_[n1]-ped)/(adc_[n2]-ped);
119 if(!isMaxFound_) getMax();
120 if(iadcMax_<=_timingcutlow || iadcMax_>=_timingcuthigh) ok=
false;
126 if(!isMaxFound_) getMax();
127 if(iadcMax_<=_timingquallow || iadcMax_>=_timingqualhigh) ok=
false;
134 if(!isMaxFound_) getMax();
135 if ((iadcMax_-_firstsample)<_presample || (iadcMax_+_lastsample)>_nsamples-1) ok=
false;
141 bool okSamples=areFitSamplesOK();
142 bool okTiming=isTimingOK();
143 bool okPulse=arePulseRatioOK();
145 bool ok=(okSamples && okTiming && okPulse);
153 if(!isMaxFound_) getMax();
154 if(iadcMax_<1 || iadcMax_>=_nsamples-1)
return false;
156 double ratioNm1=getRatio(iadcMax_-1,iadcMax_);
157 double ratioNp1=getRatio(iadcMax_+1,iadcMax_);
158 double ratioMax=
TMath::Max(ratioNm1,ratioNp1);
159 double ratioMin=
TMath::Min(ratioNm1,ratioNp1);
161 if(ratioMax<_ratiomaxcutlow) ok=
false;
162 if(ratioMin<_ratiomincutlow || ratioMin>_ratiomincuthigh) ok=
false;
171 if(!isMaxFound_) getMax();
172 if(iadcMax_<1 || iadcMax_>=_nsamples-1)
return false;
174 double ratioNm1=getRatio(iadcMax_-1,iadcMax_);
175 double ratioNp1=getRatio(iadcMax_+1,iadcMax_);
176 double ratioMax=
TMath::Max(ratioNm1,ratioNp1);
178 if(ratioMax<_ratiomaxcutlow) ok=
false;
186 if(!isMaxFound_) getMax();
187 if(iadcMax_<1 || iadcMax_>=_nsamples-1)
return false;
189 double ratioNm1=getRatio(iadcMax_-1,iadcMax_);
190 double ratioNp1=getRatio(iadcMax_+1,iadcMax_);
191 double ratioMin=
TMath::Min(ratioNm1,ratioNp1);
193 if(ratioMin<_ratiomincutlow || ratioMin>_ratiomincuthigh) ok=
false;
198 if(isPedCalc_)
return pedestal_;
200 for(
int i=0;
i<_presample;
i++){
203 ped/=double(_presample);
212 if(!isPedCalc_) ped=getPedestal();
215 double *adcNoPed=
new double[10];
216 for (
int i=0;
i<_nsamples;
i++){
217 adcNoPed[
i]=adc_[
i]-ped;
224 _presample=presample;
double getRatio(int, int)
double getDelta(int, int)
double * getAdcWithoutPedestal()
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
void init(int, int, int, int, int, int, int, int, double, double, double)