5 #include "ERNeuRadPixelSignal.h" 11 const Double_t ERNeuRadPixelSignal::cdT = 0.1;
18 fStartTime(99999999.),
29 fStartTime(99999999.),
34 fPEAmplitudes.Set(pe_count);
35 fPEAnodeTimes.Set(pe_count);
36 fPETimes.Set(pe_count);
39 ERNeuRadPixelSignal::~ERNeuRadPixelSignal()
46 fPEAmplitudes[fCurFPoint] = pe->Amplitude();
47 fPEAnodeTimes[fCurFPoint] = pe->AnodeTime();
49 fPETimes[fCurFPoint] = 40.;
51 if (pe->AnodeTime() < fStartTime) {
52 fStartTime = pe->AnodeTime();
55 if (pe->AnodeTime()+fPETimes[fCurFPoint]*cdT > fFinishTime) {
56 fFinishTime = pe->AnodeTime()+fPETimes[fCurFPoint]*cdT;
59 fPEAmplitudesSum+=pe->Amplitude();
64 void ERNeuRadPixelSignal::Generate()
68 Int_t gdTCount = (fFinishTime - fStartTime)/cdT+1;
69 fResFunction =
new Float_t[gdTCount];
71 for (Int_t i = 0; i < gdTCount; i++) {
75 for (Int_t iPE = 0; iPE < fPECount; iPE++) {
77 Float_t *sig_func =
new Float_t[fPETimes[iPE]];
78 for (Int_t idT = 0; idT < fPETimes[iPE]; idT++) {
79 sig_func[idT] = OnePEFunction(idT*cdT, fPEAmplitudes[iPE]);
84 Int_t shift = (Int_t) ((fPEAnodeTimes[iPE]-fStartTime)/cdT);
86 Float_t *cur_f = fResFunction + shift;
88 for (Int_t idT = 0; idT < fPETimes[iPE]; idT++) {
89 cur_f[idT] += sig_func[idT];
93 fResFunctionRoot.Adopt(gdTCount,fResFunction);
96 Double_t ERNeuRadPixelSignal::OnePEFunction(Double_t time, Double_t amplitude){
99 if(time>0)
return 8.*amplitude*pow((time+0.22),5)*TMath::Exp(-pow((time+0.22),1.5)/0.4);
104 Int_t ERNeuRadPixelSignal::OnePETime(Double_t amplitude)
108 Bool_t find = kFALSE;
109 Double_t threshold = 0.001;
111 Double_t val = OnePEFunction((counts++)*cdT, amplitude);
112 if (!find && val>threshold) {
116 if (find && val<threshold) {
127 std::vector<Double_t> ERNeuRadPixelSignal::Intersections(Double_t discriminatorThreshold)
129 std::vector<Double_t> intersections;
131 Bool_t startIntersect = kFALSE;
132 for (Int_t i = 0; i < fResFunctionRoot.GetSize(); i++) {
133 if (!startIntersect && fResFunctionRoot[i] > discriminatorThreshold) {
134 intersections.push_back(fStartTime + cdT*i);
135 startIntersect = kTRUE;
137 if (startIntersect && fResFunctionRoot[i] < discriminatorThreshold) {
138 intersections.push_back(fStartTime + cdT*i);
139 startIntersect = kFALSE;
143 return intersections;
147 Double_t ERNeuRadPixelSignal::Integ(
const Double_t start,
const Double_t finish)
149 if (finish<fStartTime) {
155 Int_t st = (Int_t)((start-fStartTime)/cdT) + 1;
156 Int_t fn = (Int_t)((finish - fStartTime)/cdT);
159 if ((fStartTime+fn*cdT) > fFinishTime) {
160 fn = (Int_t)(fFinishTime- fStartTime)/cdT;
164 for(Int_t i = st; i < fResFunctionRoot.GetSize()-1; i++) {
165 res += 0.5*(fResFunctionRoot[i] + fResFunctionRoot[i+1])*cdT;
172 Double_t ERNeuRadPixelSignal::FirstInteg(
const Double_t window)
174 if ((fStartTime + window) > fFinishTime ) {
175 return Integ(fStartTime, fFinishTime);
177 return Integ(fStartTime, fStartTime+window);
182 Float_t ERNeuRadPixelSignal::ThresholdTime(Float_t peThreshold)
185 while((fResFunctionRoot[i] < peThreshold*OnePEIntegral()) && i < (fResFunctionRoot.GetSize()-1)) {
191 Float_t prevT = fStartTime + prevI*cdT;
192 Float_t lastT = fStartTime + lastI*cdT;
193 if (i==fResFunctionRoot.GetSize()-1) {
196 return (peThreshold*OnePEIntegral()-fResFunctionRoot[prevI])/(fResFunctionRoot[lastI]-fResFunctionRoot[prevI])*(lastT-prevT)+prevT;
199 Double_t ERNeuRadPixelSignal::OnePEIntegral()
202 for (Int_t i=0; i<39; i++) {
203 res += 0.5*(OnePEFunction(i*cdT,8.) + OnePEFunction((i+1)*cdT,8.))*cdT;