Rev 29 | Rev 37 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 29 | Rev 35 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | // Data to root conversion root script |
2 | // Data to root conversion root script |
3 | // |
3 | // |
4 | // Contributors: Rok Pestotnik, Rok Dolenec, Dino Tahirovic |
4 | // Contributors: Rok Pestotnik, Rok Dolenec, Dino Tahirovic |
5 | // |
5 | // |
6 | // 3/1/2014 TDC cut relative to tdc offset |
6 | // 3/1/2014 TDC cut relative to tdc offset |
7 | // |
- | |
- | 7 | // 5/3/2014 TH3F h_correctedTDC; commented 'delete' commands |
|
- | 8 | // 12/3/2014 declarations of all histos before while{} |
|
8 | 9 | ||
9 | #include "stdio.h" |
10 | #include "stdio.h" |
10 | #include "TROOT.h" |
11 | #include "TROOT.h" |
11 | #include "TFile.h" |
12 | #include "TFile.h" |
12 | #include "TNtuple.h" |
13 | #include "TNtuple.h" |
13 | #include "TH1F.h" |
14 | #include "TH1F.h" |
14 | #include "TH2F.h" |
15 | #include "TH2F.h" |
- | 16 | #include "TH3F.h" |
|
15 | #include "TF1.h" |
17 | #include "TF1.h" |
16 | #include "TMath.h" |
18 | #include "TMath.h" |
17 | #include "TStyle.h" |
19 | #include "TStyle.h" |
18 | #include "TCanvas.h" |
20 | #include "TCanvas.h" |
19 | #include "TLine.h" |
21 | #include "TLine.h" |
Line 28... | Line 30... | ||
28 | // data format |
30 | // data format |
29 | #define MAXDATA 16 |
31 | #define MAXDATA 16 |
30 | #define NCH 64 |
32 | #define NCH 64 |
31 | #define TDC_BIN 1.0416 // 1 TDC bin in ns |
33 | #define TDC_BIN 1.0416 // 1 TDC bin in ns |
32 | #define MIKRO_BIN 0.49609/1000. //1 mikro step in mm; stage MM3MF |
34 | #define MIKRO_BIN 0.49609/1000. //1 mikro step in mm; stage MM3MF |
33 | #define OFFSETX |
35 | #define OFFSETX 5200 // Right edge of SiPM+Lightguide |
34 | #define OFFSETY |
36 | #define OFFSETY 5400 // Lower edge of SiPM+Lightguide |
35 | 37 | ||
36 | #define RUNREC_ID 1 |
38 | #define RUNREC_ID 1 |
37 | #define ENDREC_ID 2 |
39 | #define ENDREC_ID 2 |
38 | #define POSREC_ID 3 |
40 | #define POSREC_ID 3 |
39 | #define EVTREC_ID 4 |
41 | #define EVTREC_ID 4 |
Line 89... | Line 91... | ||
89 | 91 | ||
90 | // ------------------------------------------------------------------------------ |
92 | // ------------------------------------------------------------------------------ |
91 | 93 | ||
92 | int d2r(char* dfile0="test", int dbg=0, double tdcCut=5.0) |
94 | int d2r(char* dfile0="test", int dbg=0, double tdcCut=5.0) |
93 | { |
95 | { |
94 | - | ||
95 | const double c_tdcOffset = |
96 | const double c_tdcOffset = 1; // ns |
96 | 97 | ||
97 | printf(" Data to root conversion program\nUsage:\nd2r(input file name <without |
98 | printf(" Data to root conversion program\nUsage:\nd2r(input file name <without.dat>, debug on/off, TDC cut +-[ns])\n\n"); |
98 | 99 | ||
99 | char fullname[256]; |
100 | char fullname[256]; |
100 | char sbuff[256]; |
101 | char sbuff[256]; |
101 | FILE *fp; |
102 | FILE *fp; |
102 | 103 | ||
103 | //Chanel information |
104 | //Chanel information |
104 | 105 | ||
105 | double tdcOffset[NCH]; |
106 | double tdcOffset[NCH]; |
106 | sprintf(fullname, "d2r.ini"); |
107 | sprintf(fullname, "d2r.ini"); |
107 | if( (fp=fopen(fullname, "rt")) == NULL ) |
108 | if( (fp=fopen(fullname, "rt")) == NULL ) |
108 | printf("Cannot open pad centers file %s !!!\n", fullname); |
109 | printf("Cannot open pad centers file %s !!!\n", fullname); |
109 | else { |
110 | else { |
Line 120... | Line 121... | ||
120 | } |
121 | } |
121 | for(int i=0; i<NCH; i++) { |
122 | for(int i=0; i<NCH; i++) { |
122 | tdcOffset[i] += c_tdcOffset; |
123 | tdcOffset[i] += c_tdcOffset; |
123 | printf("%.2lf %.2lf %.2lf\n", padCenter[i][0], padCenter[i][1], tdcOffset[i]); |
124 | printf("%.2lf %.2lf %.2lf\n", padCenter[i][0], padCenter[i][1], tdcOffset[i]); |
124 | } |
125 | } |
125 | - | ||
126 | //TDC correction parameters |
- | |
127 | /* |
- | |
128 | double corpar[NCH][3]={ {-0.8, 25, 0}, |
- | |
129 | {-0.8, 25, 0}, |
- | |
130 | {-0.8, 25, 0}, |
- | |
131 | {-0.8, 25, 0}, |
- | |
132 | {-0.8, 25, 0}, |
- | |
133 | {-0.8, 25, 0}, |
- | |
134 | {-0.8, 25, 0}, |
- | |
135 | {-0.8, 25, 0} }; |
- | |
136 | sprintf(fullname, "data/%s_cor.txt", dfile0); |
- | |
137 | if( (fp=fopen(fullname, "rt")) == NULL ) |
- | |
138 | printf("Cannot open parameter file %s !!!\n", fullname); |
- | |
139 | else { |
- | |
140 | printf("Opened parameter file %s\n", fullname); |
- | |
141 | for(int i=0; i<NCH; i++) { |
- | |
142 | fscanf(fp, "%lf %lf %lf\n", &corpar[i][0], &corpar[i][1], &corpar[i][2]);*/ |
- | |
143 | /*// check if parameters make sense |
- | |
144 | if( (corpar[i][0] < (tdcmi-0.2*tdcmi)) || ((tdcma+0.2*tdcma) < corpar[i][0]) || |
- | |
145 | (corpar[i][1] < 0) || (1e4*TDC_BIN < corpar[i][1]) || |
- | |
146 | (1e4 < TMath::Abs(corpar[i][2])) ) { |
- | |
147 | printf("Warning: parameters for ch%d out of limits -> using default!\n", i); |
- | |
148 | corpar[i][0]=2200*TDC_BIN; corpar[i][1]=1000*TDC_BIN; corpar[i][2]=-100*TDC_BIN; |
- | |
149 | }*/ |
- | |
150 | /* } |
- | |
151 | fclose(fp); |
- | |
152 | }*/ |
- | |
153 | //for(int i=0; i<NCH; i++) printf("%.2lf %.2lf %.2lf\n", corpar[i][0], corpar[i][1], corpar[i][2]); |
- | |
154 | - | ||
155 | 126 | ||
156 | //histograms |
- | |
157 | char hname[256]; |
- | |
158 | //double tdc; |
- | |
159 | TH2F *htdc; |
- | |
160 | TH2F* h_correctedTDC; |
- | |
161 | TH1F *hnhitsx[NCH], *hnhitsy[NCH]; |
- | |
162 | TH2F *h2d[NCH]; |
- | |
163 | TH2F *h_threshold; |
- | |
164 | TH2F *h_ch33; |
- | |
165 | - | ||
166 | TNtuple *nt; |
- | |
167 | - | ||
168 | //data buffer |
127 | //data buffer |
169 | unsigned int readbuf[READBUFFERLENGTH]; |
128 | unsigned int readbuf[READBUFFERLENGTH]; |
170 | unsigned int buf[READBUFFERLENGTH]; |
129 | unsigned int buf[READBUFFERLENGTH]; |
171 | - | ||
172 | - | ||
173 | - | ||
174 | - | ||
175 | 130 | ||
176 | //data file |
131 | //data file |
177 | gzFile dfp; |
132 | gzFile dfp; |
178 | char dfile[256]; |
133 | char dfile[256]; |
179 | int ftype=0; |
134 | int ftype=0; |
Line 195... | Line 150... | ||
195 | } |
150 | } |
196 | dfp=gzopen(dfile,"rb"); |
151 | dfp=gzopen(dfile,"rb"); |
197 | } while(!dfp); |
152 | } while(!dfp); |
198 | printf("Opened data file %s\n", dfile); |
153 | printf("Opened data file %s\n", dfile); |
199 | 154 | ||
200 | //opens ROOT file |
155 | //opens ROOT file |
201 | //TFile *rootfile; |
- | |
202 | char fnameroot[256]; |
156 | char fnameroot[256]; |
203 | sprintf(fnameroot, "root/%s.root", dfile0); |
157 | sprintf(fnameroot, "root/%s.root", dfile0); |
204 |
|
158 | TFile rootfile(fnameroot,"RECREATE",dfile0); |
205 |
|
159 | if (rootfile.IsZombie()) { |
206 |
|
160 | std::cout << "Error opening file" << std::endl; |
207 |
|
161 | exit(-1); |
- | 162 | } |
|
208 |
|
163 | if (rootfile.IsOpen()) std::cout << "ROOT file opened for writing." << std::endl; |
209 | 164 | ||
210 | // ----------------------------------------------- |
165 | // ----------------------------------------------- |
211 | // loop trough records |
166 | // loop trough records |
212 | unsigned int rec_id, rec_len; |
167 | unsigned int rec_id, rec_len; |
213 | unsigned int ulsize = sizeof(unsigned int); |
168 | unsigned int ulsize = sizeof(unsigned int); |
214 | //unsigned int ulsize = 4; |
169 | //unsigned int ulsize = 4; |
215 | if (dbg) printf("Size of unsigned int: %lu\n", sizeof(unsigned int)); |
170 | if (dbg) printf("Size of unsigned int: %lu\n", sizeof(unsigned int)); |
Line 217... | Line 172... | ||
217 | int end_of_file = 0; |
172 | int end_of_file = 0; |
218 | 173 | ||
219 | int ii; |
174 | int ii; |
220 | int nint; |
175 | int nint; |
221 | int nb; |
176 | int nb; |
222 | int nSteps; |
- | |
223 | int status; |
177 | int status; |
- | 178 | char hname[256]; |
|
- | 179 | TH2F* htdc = new TH2F("htdc",";TDC channel;SiPM channel",512,-0.5,511.5,NCH,-0.5,NCH-0.5); |
|
- | 180 | TH3F* h_correctedTDC = new TH3F("h_correctedTDC",";SiPM channel; ASD threshold [V]; t [ns]", |
|
- | 181 | NCH, -0.5, NCH-0.5, |
|
- | 182 | 101, 1.0, 2.0, |
|
- | 183 | 33, -16.5*TDC_BIN, 16.5*TDC_BIN); |
|
- | 184 | TH1F* hnhitsx[NCH]; // move to 2d with (channel, position) |
|
- | 185 | TH1F* hnhitsy[NCH]; //-||- |
|
- | 186 | TH2F* h2d[NCH]; //-||- |
|
- | 187 | TH2F* h_threshold = new TH2F("h_threshold",";SiPM ch;Threshold[V]", |
|
- | 188 | 64,-0.5,63.5, |
|
- | 189 | 101, 1.0, 2.0); |
|
- | 190 | TH2F* h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000); |
|
- | 191 | TNtuple* nt = new TNtuple("nt", "nt", "ch:x:y:tdc"); |
|
224 | 192 | ||
225 | while(1) { |
193 | while(1) { |
226 | if(gzeof(dfp)) end_of_file = 1; |
194 | if(gzeof(dfp)) end_of_file = 1; |
227 | 195 | ||
228 | gzread(dfp, (voidp)&readbuf, 2*ulsize); |
196 | gzread(dfp, (voidp)&readbuf, 2*ulsize); |
Line 230... | Line 198... | ||
230 | rec_len=readbuf[1]; |
198 | rec_len=readbuf[1]; |
231 | 199 | ||
232 | 200 | ||
233 | if(dbg) printf("-----------------------------------------------\n"); |
201 | if(dbg) printf("-----------------------------------------------\n"); |
234 | if(dbg) printf("[%d] rec_id = %d | rec_len = %u\n", ceve, rec_id, rec_len); |
202 | if(dbg) printf("[%d] rec_id = %d | rec_len = %u\n", ceve, rec_id, rec_len); |
235 | 203 | ||
- | 204 | double nSteps = 0; |
|
236 | switch(rec_id) |
205 | switch(rec_id) |
237 | { |
206 | { |
238 | case RUNREC_ID: |
207 | case RUNREC_ID: |
- | 208 | if (dbg) printf("RUNREC\n"); |
|
239 | gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize)); |
209 | gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize)); |
240 | runrec = (RUNREC*) readbuf; |
210 | runrec = (RUNREC *) readbuf; |
241 | run |
211 | run=*runrec; |
242 | 212 | ||
243 | if(dbg) { |
213 | if(dbg) { |
244 | printf("RUNREC_ID\n"); |
214 | printf("RUNREC_ID\n"); |
245 | printf("id = %d, len = %d, time = %d\n", run.id, run.len, run.time); |
215 | printf("id = %d, len = %d, time = %d\n", run.id, run.len, run.time); |
246 | printf("nev = %d, nch = %d\n", run.nev, run.nch); |
216 | printf("nev = %d, nch = %d\n", run.nev, run.nch); |
247 | printf("nx = %d, x0 = %d, dx = %d\n", run.nx, run.x0, run.dx); |
217 | printf("nx = %d, x0 = %d, dx = %d\n", run.nx, run.x0, run.dx); |
248 | printf("ny = %d, y0 = %d, dy = %d\n", run.ny, run.y0, run.dy); |
218 | printf("ny = %d, y0 = %d, dy = %d\n", run.ny, run.y0, run.dy); |
249 | printf("thLow = %d, thUp = %d, thStep = %d\n", run.thLow, run.thUp, run.thStep); |
219 | printf("thLow = %d, thUp = %d, thStep = %d\n", run.thLow, run.thUp, run.thStep); |
250 | } |
220 | } |
251 | 221 | ||
252 | //create histograms |
222 | //create histograms |
253 | nt |
223 | //nt = (TNtuple*) gROOT->FindObject("nt"); |
- | 224 | //if (nt) delete nt; |
|
- | 225 | ||
254 |
|
226 | //sprintf(hname, "htdc"); |
255 | htdc |
227 | //htdc = (TH2F*) gROOT->FindObject(hname); |
256 |
|
228 | //if (htdc) delete htdc; |
257 | htdc |
229 | //htdc = new TH2F("htdc",";TDC channel;SiPM channel",512,0,512,NCH,0,NCH); |
258 | h_correctedTDC = ( |
230 | h_correctedTDC = (TH3F*) gROOT->FindObject("h_correctedTDC"); |
259 | if (h_correctedTDC) delete h_correctedTDC; |
231 | if (h_correctedTDC) delete h_correctedTDC; |
- | 232 | nSteps = (run.thUp - run.thLow)/double(run.thStep) + 1; |
|
- | 233 | if (dbg) printf("nSteps %d\n", nSteps); |
|
260 | h_correctedTDC = new |
234 | h_correctedTDC = new TH3F("h_correctedTDC",";SiPM channel; ASD threshold [V]; t [ns]", |
- | 235 | NCH, |
|
- | 236 | -0.5, |
|
- | 237 | NCH-0.5, |
|
- | 238 | nSteps, |
|
- | 239 | (run.thLow - 0.5*run.thStep)/1000.0, |
|
- | 240 | (run.thUp + 0.5*run.thStep)/1000.0, |
|
- | 241 | 2*tdcCut*TDC_BIN, |
|
- | 242 | -tdcCut*TDC_BIN, |
|
- | 243 | tdcCut*TDC_BIN); |
|
261 | //TH1F* gsumV673A[NCH/16] = new TH1F(hn,hname,256,-0.5,255.5); |
244 | //TH1F* gsumV673A[NCH/16] = new TH1F(hn,hname,256,-0.5,255.5); |
262 | for(int i=0; i<NCH; i++) { |
245 | for(int i=0; i<NCH; i++) { |
263 | /* |
246 | /* |
264 | sprintf(hname, "htdcpos%d", i); |
247 | sprintf(hname, "htdcpos%d", i); |
265 | htdcpos[i] = (TH1F*)gROOT->FindObject(hname); |
248 | htdcpos[i] = (TH1F*)gROOT->FindObject(hname); |
Line 269... | Line 252... | ||
269 | sprintf(hname, "htdc%d", i); |
252 | sprintf(hname, "htdc%d", i); |
270 | htdc[i] = (TH1F*)gROOT->FindObject(hname); |
253 | htdc[i] = (TH1F*)gROOT->FindObject(hname); |
271 | if(htdc[i]) delete htdc[i]; |
254 | if(htdc[i]) delete htdc[i]; |
272 | htdc[i] = new TH1F(hname, hname, 512, 0*TDC_BIN, 512*TDC_BIN); |
255 | htdc[i] = new TH1F(hname, hname, 512, 0*TDC_BIN, 512*TDC_BIN); |
273 | */ |
256 | */ |
274 | - | ||
275 | 257 | ||
276 | sprintf(hname, "hnhitsx%d", i); |
258 | sprintf(hname, "hnhitsx%d", i); |
277 | hnhitsx[i] = (TH1F*)gROOT->FindObject(hname); |
259 | hnhitsx[i] = (TH1F*)gROOT->FindObject(hname); |
278 | if(hnhitsx[i]) delete hnhitsx[i]; |
260 | if(hnhitsx[i]) delete hnhitsx[i]; |
279 | hnhitsx[i] = new TH1F(hname, hname, run.nx, |
261 | hnhitsx[i] = new TH1F(hname, hname, run.nx, |
280 | (run.x0 - OFFSETX - 0.5*run.dx)*MIKRO_BIN, |
262 | (run.x0 - OFFSETX - 0.5*run.dx)*MIKRO_BIN, |
281 | (run.x0 - OFFSETX + (run.nx-0.5)*run.dx)*MIKRO_BIN); |
263 | (run.x0 - OFFSETX + (run.nx-0.5)*run.dx)*MIKRO_BIN); |
282 | 264 | ||
283 | sprintf(hname, "hnhitsy%d", i); |
265 | sprintf(hname, "hnhitsy%d", i); |
284 | hnhitsy[i] = (TH1F*)gROOT->FindObject(hname); |
266 | hnhitsy[i] = (TH1F*)gROOT->FindObject(hname); |
285 | if(hnhitsy[i]) delete hnhitsy[i]; |
267 | if(hnhitsy[i]) delete hnhitsy[i]; |
286 | //hnhitsy[i] = new TH1F(hname, hname, run.ny, (run.y0-0.5*run.dy)*MIKRO_BIN, (run.y0+(run.ny-0.5)*run.dy)*MIKRO_BIN); |
268 | //hnhitsy[i] = new TH1F(hname, hname, run.ny, (run.y0-0.5*run.dy)*MIKRO_BIN, (run.y0+(run.ny-0.5)*run.dy)*MIKRO_BIN); |
287 | hnhitsy[i] = new TH1F(hname, hname, run.ny, |
269 | hnhitsy[i] = new TH1F(hname, hname, run.ny, |
Line 299... | Line 281... | ||
299 | (run.y0 - OFFSETY - 0.5*run.dy)*MIKRO_BIN, |
281 | (run.y0 - OFFSETY - 0.5*run.dy)*MIKRO_BIN, |
300 | (run.y0 - OFFSETY + (run.ny-0.5)*run.dy)*MIKRO_BIN); |
282 | (run.y0 - OFFSETY + (run.ny-0.5)*run.dy)*MIKRO_BIN); |
301 | } |
283 | } |
302 | 284 | ||
303 | if (h_threshold) delete h_threshold; |
285 | if (h_threshold) delete h_threshold; |
304 | nSteps = (run.thUp - run.thLow)/double(run.thStep) + 1; |
- | |
305 | if (dbg) printf("nSteps %d\n", nSteps); |
- | |
306 | h_threshold = new TH2F("h_threshold"," |
286 | h_threshold = new TH2F("h_threshold",";SiPM ch;Threshold[V]",64,-0.5,63.5, |
307 | nSteps, |
287 | nSteps, |
308 |
|
288 | (run.thLow - 0.5*run.thStep)/1000.0, |
309 |
|
289 | (run.thUp + 0.5*run.thStep)/1000.0); |
310 | 290 | ||
311 | //h_threshold = new TH2F("h_threshold","Threshold scan;SiPM ch;Threshold[mV]",64,-0.5,63.5, |
291 | //h_threshold = new TH2F("h_threshold","Threshold scan;SiPM ch;Threshold[mV]",64,-0.5,63.5, |
312 | // 101,995,2005); |
292 | // 101,995,2005); |
313 | 293 | ||
314 | if (h_ch33) delete h_ch33; |
294 | if (h_ch33) delete h_ch33; |
315 | h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000); |
295 | h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000); |
316 | 296 | ||
- | 297 | if (dbg) printf("RUNREC: all histos created.\n"); |
|
317 | break; |
298 | break; |
318 | 299 | ||
319 | case POSREC_ID: |
300 | case POSREC_ID: |
- | 301 | if (dbg) printf("POSREC\n"); |
|
320 | gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize)); |
302 | gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize)); |
321 | posrec = (POSREC *) readbuf; |
303 | posrec = (POSREC *) readbuf; |
322 | pos=*posrec; |
304 | pos=*posrec; |
323 | 305 | ||
324 | if(dbg) { |
306 | if(dbg) { |
Line 335... | Line 317... | ||
335 | evtrec = (EVTREC *) readbuf; |
317 | evtrec = (EVTREC *) readbuf; |
336 | //evtrec->nev = buf[0]; |
318 | //evtrec->nev = buf[0]; |
337 | //if (rec_len < 0 || rec_len > 10000) { |
319 | //if (rec_len < 0 || rec_len > 10000) { |
338 | if (rec_len > READBUFFERLENGTH) { |
320 | if (rec_len > READBUFFERLENGTH) { |
339 | printf("Len %u\n", rec_len); |
321 | printf("Len %u\n", rec_len); |
340 | return( |
322 | return(1); |
341 | } |
323 | } |
342 | nb = rec_len - 3*ulsize; // no. of bytes to read |
324 | nb = rec_len - 3*ulsize; // no. of bytes to read |
343 | gzread(dfp, (voidp)&buf, nb); |
325 | gzread(dfp, (voidp)&buf, nb); |
344 | 326 | ||
345 | if(dbg) { |
327 | if(dbg) { |
Line 376... | Line 358... | ||
376 | int nval_dat = (dbuf[i]>>31)&0x1 ; |
358 | int nval_dat = (dbuf[i]>>31)&0x1 ; |
377 | if (dbg){ |
359 | if (dbg){ |
378 | if (ev_dat) printf("Event %d\n",data); |
360 | if (ev_dat) printf("Event %d\n",data); |
379 | else printf("ch=%d edge=%d ev=%d data=%d last=%d nval=%d\n", |
361 | else printf("ch=%d edge=%d ev=%d data=%d last=%d nval=%d\n", |
380 | channel, edge_type,ev_dat,data,last_dat,nval_dat); |
362 | channel, edge_type,ev_dat,data,last_dat,nval_dat); |
381 | } |
363 | } |
382 | if (!ev_dat){ |
364 | if (!ev_dat){ |
383 | if (!edge_type && !overflow) { |
365 | if (!edge_type && !overflow) { |
384 | htdc->Fill(data, channel); |
366 | htdc->Fill(data, channel); |
385 | if(dbg) printf("ch: %d tdc: %d\n", channel, data); |
367 | if (dbg) printf("ch: %d tdc: %d\n", channel, data); |
386 | if (dbg) nt->Fill(channel, pos.ix, pos.iy, data); |
368 | if (dbg) nt->Fill(channel, pos.ix, pos.iy, data); |
387 | double tdcmin=tdcOffset[channel] - tdcCut; |
369 | double tdcmin = tdcOffset[channel] - tdcCut; |
388 | double tdcmax=tdcOffset[channel] + tdcCut; |
370 | double tdcmax = tdcOffset[channel] + tdcCut; |
389 | double time = data*TDC_BIN; |
371 | double time = data*TDC_BIN - tdcOffset[channel]; |
390 | if(time >= |
372 | if(time >= -tdcCut and time <= tdcCut) { |
391 | h_correctedTDC->Fill( |
373 | h_correctedTDC->Fill(channel, thr.threshold/1000.0, time); |
392 | hnhitsx[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN); |
374 | hnhitsx[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN); |
393 | hnhitsy[channel]->Fill((pos.yset - OFFSETY) * MIKRO_BIN); |
375 | hnhitsy[channel]->Fill((pos.yset - OFFSETY) * MIKRO_BIN); |
394 | h2d[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN); |
376 | h2d[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN); |
395 | //h_threshold->Fill(channel, thr.threshold); |
- | |
- | 377 | ||
396 | if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) { |
378 | if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) { |
397 | h_ch33->Fill(pos.xset-OFFSETX, pos.yset-OFFSETY); |
379 | h_ch33->Fill(pos.xset-OFFSETX, pos.yset-OFFSETY); |
398 | h_threshold->Fill(channel, thr.threshold); |
380 | h_threshold->Fill(channel, thr.threshold/1000.0); |
399 | } |
381 | } |
400 | } |
382 | } |
401 | //gV673A->Fill(data,channel); |
383 | //gV673A->Fill(data,channel); |
402 | //gsumV673A[channel/16]->Fill(data); |
384 | //gsumV673A[channel/16]->Fill(data); |
403 | } |
385 | } |
Line 406... | Line 388... | ||
406 | } |
388 | } |
407 | } // if (recid== 0x140 || recid== 0x141) |
389 | } // if (recid== 0x140 || recid== 0x141) |
408 | ii += len; |
390 | ii += len; |
409 | } //while |
391 | } //while |
410 | 392 | ||
411 | // events ------------------------------------------------------------------------------------------ |
- | |
412 | // fill histograms |
- | |
413 | /* |
- | |
414 | for(int i=0; i<NCH; i++) { |
- | |
415 | //tdc=((double)evtrec->data[i])*TDC_BIN - tdcoffset[i]; |
- | |
416 | //adc=(double)evtrec->data[i+NCH]-adcoffset[i]; |
- | |
417 | if (gNtWrite) nt->Fill(i,pos.ix,pos.iy,tdc); |
- | |
418 | //if( (qdcmi < adc) && (adc < qdcma) ) { |
- | |
419 | htdc[i]->Fill(tdc); |
- | |
420 | //} |
- | |
421 | //hadc[i]->Fill(adc); |
- | |
422 | //hcor[i]->Fill(adc,tdc); |
- | |
423 | //if(adc > corpar[i][2]) |
- | |
424 | //hctdc[i]->Fill( tdc - (corpar[i][0] + corpar[i][1]/TMath::Sqrt(adc - corpar[i][2])) ); |
- | |
425 | - | ||
426 | if( (abs(padcenter[i][0] - pos.xset) < POSMARG) && (abs(padcenter[i][1] - pos.yset) < POSMARG) ) { |
- | |
427 | htdcpos[i]->Fill(tdc); |
- | |
428 | //hadcpos[i]->Fill(adc); |
- | |
429 | //hcorpos[i]->Fill(adc,tdc); |
- | |
430 | //if(adc > corpar[i][2]) |
- | |
431 | //hctdcpos[i]->Fill( tdc - (corpar[i][0] + corpar[i][1]/TMath::Sqrt(adc - corpar[i][2])) ); |
- | |
432 | } |
- | |
433 | |
- | |
434 | if((tdcmi < tdc) && (tdc < tdcma)) { |
- | |
435 | //hadc_cut[i]->Fill(adc); |
- | |
436 | hnhitsx[i]->Fill((pos.xset - OFFSETX) * MIKRO_BIN); |
- | |
437 | hnhitsy[i]->Fill((pos.yset - OFFSETY) * MIKRO_BIN); |
- | |
438 | h2d[i]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN); |
- | |
439 | |
- | |
440 | //if(i==4) adc1=adc; |
- | |
441 | //if(i==5) adc2=adc; |
- | |
442 | } |
- | |
443 | } */ |
- | |
444 | break; |
393 | break; |
445 | 394 | ||
446 | case THRREC_ID: |
395 | case THRREC_ID: |
447 | status = gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize)); |
396 | status = gzread(dfp, (voidp)&readbuf[2], (rec_len-2*ulsize)); |
448 | thrrec = (THRREC*) readbuf; |
397 | thrrec = (THRREC*) readbuf; |
Line 491... | Line 440... | ||
491 | end_of_file = 1; |
440 | end_of_file = 1; |
492 | break; |
441 | break; |
493 | } |
442 | } |
494 | 443 | ||
495 | ceve++; |
444 | ceve++; |
496 | if |
445 | if ( (ceve%50000) == 0) printf(" Current event = %d\n", ceve); |
497 | //if(dbg) if( ceve>dbg ) break; |
446 | //if(dbg) if( ceve>dbg ) break; |
498 | if(end_of_file) break; |
447 | if (end_of_file) break; |
499 |
|
448 | } |
500 | 449 | ||
501 | if(dfp) { |
450 | if(dfp) { |
502 | gzclose(dfp); |
451 | gzclose(dfp); |
503 |
|
452 | //delete dfp; |
504 | } |
453 | } |
505 |
|
454 | //if(dbg) return 0; |
506 | if(rootfile) { |
455 | if(rootfile.IsOpen()) { |
507 | nt->Write(); |
456 | nt->Write(); |
508 | rootfile |
457 | rootfile.Write(); |
509 | printf("Saved to %s\n", fnameroot); |
458 | printf("Saved to %s\n", fnameroot); |
510 | rootfile |
459 | rootfile.Close(); |
511 |
|
460 | //delete rootfile; |
512 | } |
461 | } |
513 | 462 | ||
514 | return |
463 | return 0; |
515 | } |
464 | } |
516 | 465 | ||
517 | int position(int x, int y, int channel) |
466 | int position(int x, int y, int channel) |
518 | { |
467 | { |
519 | int flag = 0; |
468 | int flag = 0; |
520 | if ( (x > (padCenter[channel][0] - 5000)) |
469 | if ( (x > (padCenter[channel][0] - 5000)) and (x < (padCenter[channel][0] + 5000)) and |
521 | (y > (padCenter[channel][1] - 5000)) |
470 | (y > (padCenter[channel][1] - 5000)) and (y < (padCenter[channel][1] + 5000)) ) flag = 1; |
522 | return flag; |
471 | return flag; |
523 | } |
472 | } |