Rev 208 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
301 | f9daq | 1 | #include "TFile.h" |
101 | f9daq | 2 | #include "TH1.h" |
3 | #include "TH2.h" |
||
301 | f9daq | 4 | #include "TFile.h" |
101 | f9daq | 5 | #include "TGraph.h" |
6 | #include "TCanvas.h" |
||
7 | #include "TStyle.h" |
||
8 | #include "TLegend.h" |
||
204 | f9daq | 9 | #include "TFile.h" |
101 | f9daq | 10 | //#include "TROOT.h" |
11 | |||
12 | #include <stdio.h> |
||
180 | f9daq | 13 | #include <time.h> |
101 | f9daq | 14 | |
15 | #define DATA_PATH "./data/" |
||
16 | #define CFRAC 0.4 |
||
17 | #define DWIDTH 1024 |
||
180 | f9daq | 18 | #define NCH 4 |
19 | #include "drs.h" |
||
20 | |||
21 | ClassImp (drs) |
||
22 | |||
208 | f9daq | 23 | |
301 | f9daq | 24 | TCanvas *c_wfm; |
25 | TFile *froot; |
||
208 | f9daq | 26 | |
301 | f9daq | 27 | TH1F *h1_chmax[NCH]; |
28 | TH1F *h1_chmaxt[NCH]; |
||
29 | TH1F *h1_chmin[NCH]; |
||
30 | TH1F *h1_chmint[NCH]; |
||
31 | TH1F *h1_letime[NCH]; |
||
32 | TH1F *h1_cftime[NCH]; |
||
33 | TH1F *h1_cftdif[NCH]; |
||
34 | TH1F *h1_qdc[NCH]; |
||
35 | TH2F *h2_dpo[NCH]; |
||
36 | TH2F *h2_tdcadc[NCH]; |
||
37 | TH2F *h2_ctdcadc[NCH]; |
||
38 | TH2F *h2_ctalk; |
||
39 | TH2F *h2_pos; |
||
40 | TH1F *h1_qsumx; |
||
41 | TH1F *h1_qsumy; |
||
42 | TGraph *gr_wfm[NCH]; |
||
43 | TLegend *leg; |
||
208 | f9daq | 44 | |
301 | f9daq | 45 | int drs::histoinit( int nch, DrsChannel* d, int trgch, double ymin, double ymax){ |
208 | f9daq | 46 | char histname[128]; |
301 | f9daq | 47 | c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700); |
48 | |||
49 | c_wfm->Divide(1,1); |
||
50 | c_wfm->cd(1); |
||
51 | const double maxt=1800; |
||
52 | leg = new TLegend(0.8, 0.8, 1, 1); |
||
53 | for (int i=0; i<nch; i++) { |
||
208 | f9daq | 54 | sprintf(histname,"chmax_%02d",i); |
301 | f9daq | 55 | h1_chmax[i]=new TH1F(histname,histname,1500,ymin,ymax); |
208 | f9daq | 56 | sprintf(histname,"chmaxt_%02d",i); |
301 | f9daq | 57 | h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,maxt); |
208 | f9daq | 58 | sprintf(histname,"chmin_%02d",i); |
301 | f9daq | 59 | h1_chmin[i]=new TH1F(histname,histname,1500,ymin,ymax); |
208 | f9daq | 60 | sprintf(histname,"chmint_%02d",i); |
301 | f9daq | 61 | h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,maxt); |
208 | f9daq | 62 | sprintf(histname,"letime_%02d",i); |
63 | h1_letime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
||
64 | sprintf(histname,"cftime_%02d",i); |
||
65 | h1_cftime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
||
66 | sprintf(histname,"cftdif_%02d",i); |
||
301 | f9daq | 67 | h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0]-40,d[i].twin[1]-d[trgch].twin[0]+20); |
208 | f9daq | 68 | sprintf(histname,"qdc_%02d",i); |
301 | f9daq | 69 | h1_qdc[i]=new TH1F(histname,histname,500,-4.5,4.5); |
208 | f9daq | 70 | sprintf(histname,"dpo_%02d",i); |
301 | f9daq | 71 | h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,maxt,1500,ymin,ymax); |
208 | f9daq | 72 | sprintf(histname,"tdcadc_%02d",i); |
301 | f9daq | 73 | h2_tdcadc[i]=new TH2F(histname,histname,250,ymin,ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
208 | f9daq | 74 | sprintf(histname,"ctdcadc_%02d",i); |
301 | f9daq | 75 | h2_ctdcadc[i]=new TH2F(histname,histname,250,ymin,ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
208 | f9daq | 76 | gr_wfm[i]=new TGraph(DWIDTH); |
301 | f9daq | 77 | gr_wfm[i]->SetMinimum(ymin); |
78 | gr_wfm[i]->SetMaximum(ymax); |
||
208 | f9daq | 79 | gr_wfm[i]->SetLineColor(i+1); |
80 | gr_wfm[i]->SetMarkerColor(i+1); |
||
81 | sprintf(histname,"ch %d",i); |
||
82 | leg->AddEntry(gr_wfm[i], histname, "l"); |
||
83 | if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
||
84 | gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
||
301 | f9daq | 85 | gr_wfm[i]->GetHistogram()->SetDirectory(0); |
208 | f9daq | 86 | } |
87 | |||
301 | f9daq | 88 | leg->Draw(); |
208 | f9daq | 89 | h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5); |
301 | f9daq | 90 | h2_pos=new TH2F("cpos","cpos",40,-1,1,40,-1,1); |
91 | h1_qsumx=new TH1F("qsumx","qsumx",100,-1,6); |
||
92 | h1_qsumy=new TH1F("qsumy","qsumy",100,-1,6); |
||
208 | f9daq | 93 | return 0; |
94 | } |
||
95 | |||
301 | f9daq | 96 | drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch,int first, int neve, int updfrq,double ymin, double ymax) |
97 | |||
101 | f9daq | 98 | { |
180 | f9daq | 99 | int debug=0; |
100 | int i,ich,iev; |
||
101 | int stat; |
||
208 | f9daq | 102 | int nev = first + neve; |
101 | f9daq | 103 | // char FileName[300]="./data/n2.dat"; |
180 | f9daq | 104 | FILE *fin; |
101 | f9daq | 105 | |
180 | f9daq | 106 | char recid[5]="SAMO"; |
107 | unsigned short *srecid = (unsigned short *) &recid[0]; |
||
175 | f9daq | 108 | |
180 | f9daq | 109 | struct evrec { |
110 | unsigned long evn; |
||
111 | unsigned short tYear,tMonth,tDay,tHour,tMin,tSec,tmSec,rc; |
||
112 | } evrec; |
||
101 | f9daq | 113 | |
180 | f9daq | 114 | float dtdata[NCH][DWIDTH]; |
115 | float tcdata[NCH][DWIDTH]; |
||
116 | float tccalib[NCH]; |
||
117 | float scaler[NCH]; |
||
118 | float *t; |
||
119 | float *y; |
||
120 | float *ay; |
||
101 | f9daq | 121 | |
180 | f9daq | 122 | short lwfm[NCH]; |
123 | int nwfm[NCH]; |
||
124 | int board; |
||
125 | int version; |
||
175 | f9daq | 126 | |
180 | f9daq | 127 | |
128 | unsigned short ichdat[NCH][DWIDTH]; |
||
129 | float chdat[NCH][DWIDTH]; |
||
130 | float achdat[NCH][DWIDTH]; |
||
131 | float chmax[NCH][2]; |
||
132 | float chmin[NCH][2]; |
||
133 | float letime[NCH],cftime[NCH],qdc[NCH]; |
||
134 | |||
135 | |||
101 | f9daq | 136 | // gROOT->Reset(); |
137 | |||
180 | f9daq | 138 | gStyle->SetOptStat(1111111); |
101 | f9daq | 139 | // gStyle->SetPalette(52); |
208 | f9daq | 140 | |
301 | f9daq | 141 | histoinit(nch, d, trgch, ymin,ymax); |
142 | char rootname[0xff]; |
||
143 | sprintf(rootname, "%s_x%d_y%d.root", FileName, 0, 0); |
||
144 | froot = new TFile(rootname,"RECREATE"); |
||
145 | |||
101 | f9daq | 146 | |
180 | f9daq | 147 | fin=fopen(FileName,"rb"); |
148 | if (fin==NULL) { |
||
149 | printf("Error opening file %s\n",FileName); |
||
150 | return; |
||
151 | } |
||
152 | printf("%s, %lu\n",recid,sizeof(evrec)); |
||
101 | f9daq | 153 | |
154 | |||
180 | f9daq | 155 | for (ich=0; ich<nch; ich++) { |
156 | nwfm[ich]=0; |
||
157 | for (i=0; i<DWIDTH; i++) { |
||
158 | achdat[ich][i]=0; |
||
159 | } |
||
160 | } |
||
161 | unsigned int trgcell = 0; |
||
162 | int event = -1; |
||
163 | |||
164 | iev=0; |
||
165 | time_t t0,told; |
||
166 | time(&t0); |
||
167 | told=t0-1; |
||
206 | f9daq | 168 | int posrec[9]; |
180 | f9daq | 169 | while(!feof(fin)) { |
301 | f9daq | 170 | if (iev==nev) break; |
180 | f9daq | 171 | stat=fread(recid,1,4,fin); |
172 | if (debug) { |
||
173 | if (recid[1]=='#') printf("%c%c%u\n",recid[0],recid[1],srecid[1]); |
||
174 | else printf("%s\n",recid ); |
||
175 | } |
||
176 | switch (recid[0]) { |
||
202 | f9daq | 177 | |
205 | f9daq | 178 | case 'P':{ // position record |
179 | int len; |
||
206 | f9daq | 180 | stat=fread(&len,1,4,fin); |
181 | if (len>0 && len<37) { |
||
182 | stat=fread(posrec,1,len,fin); |
||
208 | f9daq | 183 | if (recid[3]=='R'){ |
184 | if (iev>=first){ |
||
185 | froot->Write(); |
||
186 | froot->Close(); |
||
187 | sprintf(rootname, "%s_x%d_y%d.root", FileName, posrec[3], posrec[4]); |
||
188 | froot = new TFile(rootname,"RECREATE"); |
||
301 | f9daq | 189 | histoinit(nch,d, trgch, ymin,ymax); |
208 | f9daq | 190 | } |
206 | f9daq | 191 | printf("Position len=%d x=%d y=%d ix=%d iy=%d\n", len, posrec[0], posrec[1], posrec[3], posrec[4]); |
208 | f9daq | 192 | } else |
206 | f9daq | 193 | printf("Position record buffer length %d\n", len); |
194 | } else { |
||
195 | printf("Wrong buffer length %d\n", len); |
||
196 | } |
||
202 | f9daq | 197 | break; |
205 | f9daq | 198 | } |
180 | f9daq | 199 | case 'D': // DRS |
200 | version = atoi(&recid[3]); |
||
201 | break; |
||
202 | case 'T': // TIME |
||
203 | switch (recid[1]) { |
||
204 | case 'I': |
||
205 | event=0; |
||
206 | if (version ==0) version++; |
||
207 | break; |
||
208 | case '#': trgcell = srecid[1]; break; |
||
209 | } |
||
210 | break; |
||
211 | case 'B': |
||
212 | board = srecid[1]; |
||
213 | break; |
||
214 | case 'C': |
||
215 | sscanf(recid,"C%d",&ich); |
||
216 | ich=ich-1; |
||
217 | if (event) { |
||
218 | if (version>1) stat=fread(&scaler[ich],1,sizeof(float),fin); |
||
219 | stat=fread(ichdat[ich],1,sizeof(ichdat[ich]),fin); |
||
220 | } else { |
||
221 | |||
222 | stat=fread(dtdata[ich],1,sizeof(float)*DWIDTH,fin); |
||
223 | |||
224 | } |
||
225 | break; |
||
226 | case 'E': |
||
227 | stat=fread(&evrec.evn,1,sizeof(evrec),fin); |
||
228 | iev++; |
||
229 | if (!version) { |
||
230 | stat=fread(dtdata[0],1,sizeof(float)*DWIDTH,fin); |
||
231 | } |
||
232 | event=1; |
||
233 | break; |
||
234 | default: |
||
235 | printf("Unknown header! %s\n", recid); |
||
236 | break; |
||
237 | } |
||
208 | f9daq | 238 | if (iev<first) continue; |
180 | f9daq | 239 | |
240 | if (recid[0] == 'E') { |
||
241 | for ( i=0; i<nch; i++) { |
||
242 | if (!lwfm[i]) continue; |
||
182 | f9daq | 243 | double pulseheight = (d[i].edge)? chmax[i][0]: chmin[i][0]; |
244 | |||
245 | if ((pulseheight >d[i].vcut[0])&& |
||
246 | (pulseheight <d[i].vcut[1]) ) { |
||
247 | |||
248 | h1_cftdif[i]->Fill(cftime[i]-cftime[trgch]); |
||
180 | f9daq | 249 | } |
182 | f9daq | 250 | if (!d[i].edge) pulseheight = - pulseheight; |
251 | h2_tdcadc[i] ->Fill(pulseheight,letime[i]-cftime[trgch]); |
||
252 | h2_ctdcadc[i]->Fill(pulseheight,cftime[i]-cftime[trgch]); |
||
253 | |||
254 | //if (i==1) printf("ph=%f %f\n", pulseheight, letime[i]-cftime[trgch]); |
||
180 | f9daq | 255 | } |
301 | f9daq | 256 | double qsumx=qdc[0]+qdc[1]; |
257 | double qsumy=qdc[2]+qdc[3]; |
||
258 | double x0=(qsumx)?(qdc[0]-qdc[1])/qsumx:-2; |
||
259 | double x1=(qsumy)?(qdc[2]-qdc[3])/qsumy:-2; |
||
260 | h2_pos->Fill(x0,x1); |
||
261 | h1_qsumx->Fill(qsumx); |
||
262 | h1_qsumy->Fill(qsumy); |
||
182 | f9daq | 263 | double ph0 = (d[0].edge)? chmax[0][0]: -chmin[0][0]; |
264 | double ph1 = (d[1].edge)? chmax[1][0]: -chmin[1][0]; |
||
265 | h2_ctalk->Fill(ph0,ph1); |
||
180 | f9daq | 266 | } |
267 | if (event<1) continue; |
||
268 | if (recid[0]!='C') continue; |
||
269 | if (ich>=nch) continue; |
||
101 | f9daq | 270 | |
180 | f9daq | 271 | lwfm[ich]=0; |
301 | f9daq | 272 | qdc[ich]=d[ich].offset; |
180 | f9daq | 273 | chmax[ich][0]=-1; chmax[ich][1]=-1; |
274 | chmin[ich][0]=1; chmin[ich][1]=-1; |
||
275 | letime[ich]=-1.; letime[ich]=-1.; |
||
276 | cftime[ich]=-1.; cftime[ich]=-1.; |
||
101 | f9daq | 277 | |
278 | |||
180 | f9daq | 279 | lwfm[ich]=1; |
280 | nwfm[ich]+=1; |
||
101 | f9daq | 281 | |
282 | |||
180 | f9daq | 283 | |
284 | t = &tcdata[ich][0]; |
||
285 | y = &chdat[ich][0]; |
||
286 | ay = &achdat[ich][0]; |
||
287 | |||
288 | float sum=0; |
||
289 | for (i=0; i<DWIDTH; i++) { |
||
290 | sum+= dtdata[ich][(i+trgcell)%DWIDTH]; |
||
291 | if (version) t[i]=sum; |
||
292 | else t[i]=dtdata[0][i]; // old format |
||
293 | } |
||
294 | tccalib[ich]=t[(DWIDTH-trgcell)%DWIDTH]; |
||
295 | |||
296 | for (i=0; i<DWIDTH; i++) { |
||
297 | if (version) t[i]-=(tccalib[ich]-tccalib[0]); // assume ich 0 is connected and always first in the data |
||
298 | y[i]=-0.5+(float)ichdat[ich][i]/0xFFFF; |
||
192 | f9daq | 299 | if (version) y[i]+=evrec.rc/1000.; |
180 | f9daq | 300 | h2_dpo[ich]->Fill(t[i],y[i]); |
301 | gr_wfm[ich]->SetPoint(i,t[i],y[i]+0.05*(ich-1)); |
||
302 | } |
||
303 | |||
304 | |||
305 | for (i=0; i<DWIDTH; i++) { |
||
306 | // accumulated waveforms |
||
307 | ay[i]+=y[i]; |
||
308 | |||
309 | // signal minumum |
||
310 | if (y[i]>chmax[ich][0]) { |
||
311 | chmax[ich][0]=y[i]; |
||
312 | chmax[ich][1]=t[i]; |
||
313 | } |
||
314 | |||
315 | // signal maximum |
||
316 | if (y[i]<chmin[ich][0]) { |
||
317 | chmin[ich][0]=y[i]; |
||
318 | chmin[ich][1]=t[i]; |
||
319 | } |
||
320 | float t0 = t[i]; |
||
321 | float t0p = t[i+1]; |
||
322 | float t0n = t[i-1]; |
||
323 | // charge in the range |
||
324 | if ((t0>d[ich].adcgate[0])&&(t0<d[ich].adcgate[1])) { |
||
182 | f9daq | 325 | float sign = (d[ich].edge)? 1: -1; |
326 | qdc[ich]+=sign*y[i]*(t0p-t0n)/2.; |
||
180 | f9daq | 327 | } |
328 | } |
||
329 | |||
330 | for (i=1; i<DWIDTH-1; i++) { |
||
331 | float t0 = t[i]; |
||
332 | float t0p = t[i+1]; |
||
333 | float t0n = t[i-1]; |
||
334 | // leading edge in the range |
||
335 | if ((t0>d[ich].twin[0])&&(t0<d[ich].twin[1])) { |
||
336 | if ( ((!d[ich].edge)&&(y[i]<d[ich].threshold) || |
||
337 | ( d[ich].edge)&&(y[i]>d[ich].threshold ) ) |
||
338 | &&(letime[ich]<0.)) { |
||
339 | letime[ich]=t0n+(t0-t0n)*(d[ich].threshold-y[i-1])/(y[i]-y[i-1]); |
||
340 | } |
||
341 | // constant fraction time in the range |
||
204 | f9daq | 342 | if (cftime[ich]<0.){ |
343 | // negative signals |
||
344 | if ((!d[ich].edge) && (chmin[ich][0]<d[ich].threshold)&&(y[i]<chmin[ich][0]*d[ich].cfrac )){ |
||
345 | cftime[ich]=t0n+(t0-t0n)*(chmin[ich][0]*d[ich].cfrac-y[i-1])/(y[i]-y[i-1]); |
||
346 | } |
||
347 | // positive signals |
||
348 | if (( d[ich].edge) && (chmax[ich][0]>d[ich].threshold)&&(y[i]>chmax[ich][0]*d[ich].cfrac)){ |
||
349 | cftime[ich]=t0n+(t0-t0n)*(chmax[ich][0]*d[ich].cfrac-y[i-1])/(y[i]-y[i-1]); |
||
350 | } |
||
351 | } |
||
180 | f9daq | 352 | } |
353 | } |
||
354 | |||
355 | if ((chmax[ich][1]>d[ich].twin[0])&&(chmax[ich][1]<d[ich].twin[1])) { |
||
356 | h1_chmax[ich]->Fill(chmax[ich][0]); |
||
357 | if (chmax[ich][0]>d[ich].threshold) h1_chmaxt[ich]->Fill(chmax[ich][1]); |
||
358 | } |
||
359 | if ((chmin[ich][1]>d[ich].twin[0])&&(chmin[ich][1]<d[ich].twin[1])) { |
||
360 | h1_chmin[ich]->Fill(chmin[ich][0]); |
||
361 | if (chmin[ich][0]<d[ich].threshold) h1_chmint[ich]->Fill(chmin[ich][1]); |
||
362 | } |
||
363 | h1_qdc[ich]->Fill(qdc[ich]); |
||
364 | h1_letime[ich]->Fill(letime[ich]); |
||
365 | h1_cftime[ich]->Fill(cftime[ich]); |
||
366 | time(&t0); |
||
367 | |||
368 | if ((t0!=told) || ((updfrq>0)&&(!(iev%updfrq) ) ) ) { |
||
369 | c_wfm->Update(); |
||
370 | for (i=0; i<DWIDTH; i++) { |
||
371 | ay[i]/=nwfm[ich]; |
||
372 | gr_wfm[ich]->SetPoint(i,t[i],ay[i]+0.00*(ich-1)); |
||
373 | } |
||
374 | printf("processing event %d\n",iev); |
||
375 | told=t0; |
||
376 | } |
||
175 | f9daq | 377 | } |
101 | f9daq | 378 | |
180 | f9daq | 379 | printf("number of events: %d\n",iev); |
380 | fclose(fin); |
||
301 | f9daq | 381 | TString pdfname = Form("%s.pdf",FileName); |
382 | gStyle->SetOptStat(1111111); |
||
180 | f9daq | 383 | TCanvas* c_dpo= new TCanvas("c_dpo","DPO",750,50,700,700); |
384 | c_dpo->Divide(2,2); |
||
101 | f9daq | 385 | |
301 | f9daq | 386 | for (i=0; i<nch; i++) {c_dpo->cd(i+1)->SetLogz(1); h2_dpo[i]->DrawCopy("colz");} |
387 | |||
388 | |||
180 | f9daq | 389 | TCanvas* c_cftdif= new TCanvas("c_cftdif","DPO",750,50,700,700); |
390 | c_cftdif->Divide(2,2); |
||
204 | f9daq | 391 | for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]->DrawCopy();} |
301 | f9daq | 392 | |
393 | TCanvas* c_cftcorr= new TCanvas("c_cftcorr","pulseheight vs timing",750,50,700,700); |
||
394 | c_cftcorr->Divide(2,2); |
||
395 | for (i=0; i<nch; i++) {c_cftcorr->cd(i+1); h2_tdcadc[i]->DrawCopy("colz");} |
||
396 | |||
397 | TCanvas* c_adc= new TCanvas("c_adc","adc",750,50,700,700); |
||
398 | c_adc->Divide(2,2); |
||
399 | for (i=0; i<nch; i++) {c_adc->cd(i+1); h1_qdc[i]->DrawCopy();} |
||
400 | |||
401 | TCanvas* c_qsum= new TCanvas("c_qsum","qsum",750,50,700,700); |
||
402 | c_qsum->Divide(1,2); |
||
403 | c_qsum->cd(1); h1_qsumx->DrawCopy(); |
||
404 | c_qsum->cd(2); h1_qsumy->DrawCopy(); |
||
405 | |||
406 | gStyle->SetOptStat(0); |
||
407 | TCanvas* c_pos= new TCanvas("c_pos","position",750,50,700,700); |
||
408 | |||
409 | c_pos->cd(); |
||
410 | h2_pos->DrawCopy("colz"); |
||
411 | |||
412 | |||
413 | c_pos->Print(pdfname+"(","pdf"); |
||
414 | c_wfm->Print(pdfname,"pdf"); |
||
415 | c_adc->Print(pdfname,"pdf"); |
||
416 | c_qsum->Print(pdfname,"pdf"); |
||
417 | c_dpo->Print(pdfname,"pdf"); |
||
418 | c_cftdif->Print(pdfname + ")","pdf"); |
||
419 | |||
204 | f9daq | 420 | froot->Write(); |
421 | froot->Close(); |
||
301 | f9daq | 422 | |
423 | for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]->DrawCopy();} |
||
424 | froot->Write(); |
||
425 | froot->Close(); |
||
426 | |||
180 | f9daq | 427 | return; |
428 | } |
||
101 | f9daq | 429 | |
180 | f9daq | 430 | |
431 | void drsana(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=0){ |
||
432 | |||
433 | // float threshold[nch][2]={{0.,-0.02},{0.,0.},{0.,0.},{0.,-0.25}}; |
||
434 | // float twin[nch][2]={{120.,130.},{100.,150.},{100.,150.},{70.,90.}}; |
||
435 | // float adcgate[nch][2]={{12nch.,136.},{120.,140.},{120.,140.},{70.,90.}}; |
||
436 | // float threshold[4][2]={{0.,-0.05},{0.,-0.05},{0.,-0.25},{0.,-0.25}}; |
||
437 | // float twin[4][2]={{80.,100.},{80.,100.},{90.,110.},{50.,70.}}; |
||
438 | // float adcgate[4][2]={{80.,110.},{80.,110.},{90.,110.},{50.,70.}}; |
||
182 | f9daq | 439 | double threshold[4][2]={{0.,-0.05},{0.,-0.05},{0.,-0.25},{0.,-0.25}}; |
180 | f9daq | 440 | float twin[4][2]={{100.,120.},{100.,120.},{110.,130.},{60.,80.}}; |
441 | float adcgate[4][2]={{105.,125.},{105.,125.},{110.,130.},{60.,80.}}; |
||
182 | f9daq | 442 | double vcut[4][2]={{-0.49,-0.07},{-1,1},{-1,1},{-1,1}}; |
180 | f9daq | 443 | int edge[4]={1,1,1,1};// 0 -- rising, 1 -- falling |
301 | f9daq | 444 | float offset[4]={0.25,0.25,0.25,0.25};// |
180 | f9daq | 445 | |
446 | DrsChannel c[2]; |
||
447 | |||
448 | c[0].cfrac = CFRAC; |
||
449 | c[0].threshold = threshold[0][0]; |
||
450 | c[0].twin[0] = twin[0][0]; |
||
451 | c[0].twin[1] = twin[0][1]; |
||
452 | |||
453 | c[0].adcgate[0] = adcgate[0][0]; |
||
454 | c[0].adcgate[1] = adcgate[0][1]; |
||
455 | |||
456 | c[0].vcut[0] = vcut[0][0]; |
||
457 | c[0].vcut[1] = vcut[0][1]; |
||
458 | |||
459 | c[0].edge = edge[0]; |
||
301 | f9daq | 460 | c[0].edge = offset[0]; |
180 | f9daq | 461 | |
462 | c[1].cfrac = CFRAC; |
||
463 | c[1].threshold = threshold[1][0]; |
||
464 | c[1].twin[0] = twin[1][0]; |
||
465 | c[1].twin[1] = twin[1][1]; |
||
466 | |||
467 | c[1].adcgate[0] = adcgate[1][0]; |
||
468 | c[1].adcgate[1] = adcgate[1][1]; |
||
469 | |||
470 | c[1].vcut[0] = vcut[1][0]; |
||
471 | c[1].vcut[1] = vcut[1][1]; |
||
472 | |||
473 | c[1].edge = edge[1]; |
||
301 | f9daq | 474 | c[1].offset = offset[1]; |
475 | drs * d = new drs(FileName, 2, c, trgch, nev, updfrq, -0.55,0.55 ); |
||
101 | f9daq | 476 | } |
301 | f9daq | 477 | |
478 | |||
479 | |||
480 | void sensl(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=0){ |
||
481 | // nev = -1 all events |
||
482 | double threshold[4]={-0.005,-0.005,-0.005,-0.005}; // threshold for determination of timing |
||
483 | float twin[4][2]={{980.,1150.},{980.,1150.},{980.,1150.},{980,1150.}}; // window for calculation of the timing |
||
484 | float adcgate[4][2]={{980.,1150.},{980.,1150.},{980.,1150.},{980.,1150.}}; //integration window |
||
485 | double vcut[4][2]={{-1,1},{-1,1},{-1,1},{-1,1}}; // cut on the pulseheight for filling the timing histograms |
||
486 | int edge[4]={0,0,0,0};// 1 -- rising edge, 0 -- falling edge |
||
487 | float offset[4]={0.25,0.25,0.25,0.25};// qdc offset |
||
488 | |||
489 | DrsChannel c[NCH]; |
||
490 | for (int k=0;k<NCH;k++){ |
||
491 | c[k].cfrac = CFRAC; |
||
492 | c[k].threshold = threshold[k]; |
||
493 | for (int j=0;j<2;j++){ |
||
494 | c[k].twin[j] = twin[k][j]; |
||
495 | c[k].adcgate[j] = adcgate[k][j]; |
||
496 | c[k].vcut[j] = vcut[k][j]; |
||
497 | c[k].edge = edge[k]; |
||
498 | c[k].offset = offset[k]; |
||
499 | } |
||
500 | } |
||
501 | drs * d = new drs(FileName, NCH, c, trgch, nev, updfrq , -0.1,0.12); |
||
502 | } |