20 init(10,3,1,2,2,9,3,8,0.4,0.95,0.8);
24 TAPDPulse::TAPDPulse(
int nsamples,
int presample,
int firstsample,
int lastsample,
int timingcutlow,
int timingcuthigh,
int timingquallow,
int timingqualhigh,
double ratiomincutlow,
double ratiomincuthigh,
double ratiomaxcutlow)
26 init( nsamples, presample, firstsample, lastsample, timingcutlow, timingcuthigh, timingquallow, timingqualhigh,ratiomincutlow,ratiomincuthigh, ratiomaxcutlow );
34 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)
37 assert(nsamples==_nsamples);
39 adc_ =
new double[10];
42 _firstsample=firstsample;
43 _lastsample=lastsample;
45 _timingcutlow=timingcutlow;
46 _timingcuthigh=timingcuthigh;
47 _timingquallow=timingquallow;
48 _timingqualhigh=timingqualhigh;
49 _ratiomincutlow=ratiomincutlow;
50 _ratiomincuthigh=ratiomincuthigh;
51 _ratiomaxcutlow=ratiomaxcutlow;
53 for(
int i=0;
i<_nsamples;
i++){
76 if(isMaxFound_)
return adcMax_;
80 for(
int i=0;
i<_nsamples;
i++){
92 if(!isMaxFound_) getMax();
98 assert (n1<_nsamples && n1>=0);
99 assert (n2<_nsamples && n2>=0);
101 double delta=adc_[n1]-adc_[n2];
106 assert (n1<_nsamples && n1>=0);
107 assert (n2<_nsamples && n2>=0);
110 if(isPedCalc_)ped=pedestal_;
113 double ratio=(adc_[n1]-ped)/(adc_[n2]-ped);
120 if(!isMaxFound_) getMax();
121 if(iadcMax_<=_timingcutlow || iadcMax_>=_timingcuthigh) ok=
false;
127 if(!isMaxFound_) getMax();
128 if(iadcMax_<=_timingquallow || iadcMax_>=_timingqualhigh) ok=
false;
135 if(!isMaxFound_) getMax();
136 if ((iadcMax_-_firstsample)<_presample || (iadcMax_+_lastsample)>_nsamples-1) ok=
false;
142 bool okSamples=areFitSamplesOK();
143 bool okTiming=isTimingOK();
144 bool okPulse=arePulseRatioOK();
146 bool ok=(okSamples && okTiming && okPulse);
154 if(!isMaxFound_) getMax();
155 if(iadcMax_<1 || iadcMax_>=_nsamples-1)
return false;
157 double ratioNm1=getRatio(iadcMax_-1,iadcMax_);
158 double ratioNp1=getRatio(iadcMax_+1,iadcMax_);
159 double ratioMax=
TMath::Max(ratioNm1,ratioNp1);
160 double ratioMin=
TMath::Min(ratioNm1,ratioNp1);
162 if(ratioMax<_ratiomaxcutlow) ok=
false;
163 if(ratioMin<_ratiomincutlow || ratioMin>_ratiomincuthigh) ok=
false;
172 if(!isMaxFound_) getMax();
173 if(iadcMax_<1 || iadcMax_>=_nsamples-1)
return false;
175 double ratioNm1=getRatio(iadcMax_-1,iadcMax_);
176 double ratioNp1=getRatio(iadcMax_+1,iadcMax_);
177 double ratioMax=
TMath::Max(ratioNm1,ratioNp1);
179 if(ratioMax<_ratiomaxcutlow) ok=
false;
187 if(!isMaxFound_) getMax();
188 if(iadcMax_<1 || iadcMax_>=_nsamples-1)
return false;
190 double ratioNm1=getRatio(iadcMax_-1,iadcMax_);
191 double ratioNp1=getRatio(iadcMax_+1,iadcMax_);
192 double ratioMin=
TMath::Min(ratioNm1,ratioNp1);
194 if(ratioMin<_ratiomincutlow || ratioMin>_ratiomincuthigh) ok=
false;
199 if(isPedCalc_)
return pedestal_;
201 for(
int i=0;
i<_presample;
i++){
204 ped/=double(_presample);
213 if(!isPedCalc_) ped=getPedestal();
216 double *adcNoPed=
new double[10];
217 for (
int i=0;
i<_nsamples;
i++){
218 adcNoPed[
i]=adc_[
i]-ped;
225 _presample=presample;
int adc(sample_type sample)
get the ADC sample (12 bits)
double getRatio(int, int)
double getDelta(int, int)
double * getAdcWithoutPedestal()
void init(int, int, int, int, int, int, int, int, double, double, double)