1 |
#include <physics/anticounter/AnticounterEvent.h> |
2 |
#include <PscuHeader.h> |
3 |
#include <EventHeader.h> |
4 |
|
5 |
#include <TFile.h> |
6 |
#include <fstream> |
7 |
#include <vector> |
8 |
#include <iostream> |
9 |
#include <TCanvas.h> |
10 |
#include <TLatex.h> |
11 |
#include <TLegend.h> |
12 |
#include <TLine.h> |
13 |
#include <TTree.h> |
14 |
#include <TStyle.h> |
15 |
#include <TObjString.h> |
16 |
#include <TGraph.h> |
17 |
#include <TH1.h> |
18 |
#include <time.h> |
19 |
#include <sys/stat.h> |
20 |
#include <cstdlib> |
21 |
//#include <utils/yodaUtility.h> |
22 |
|
23 |
#define DEBUG 0 |
24 |
#define VERSION 1.5 |
25 |
#define INTERVAL 100 |
26 |
#define FORMAT "png" |
27 |
|
28 |
using namespace std; |
29 |
|
30 |
UInt_t found; |
31 |
Int_t minevent,maxevent; |
32 |
UShort_t ACheader[2]; |
33 |
TString *cardname = new TString[2]; |
34 |
TString *detector = new TString[16]; |
35 |
|
36 |
|
37 |
int AcQLOOKbasic(TString base,int fromevent=0, int toevent=0, TString outDir = "./", TString format = FORMAT){ |
38 |
|
39 |
ofstream outputFile; |
40 |
stringstream oss; |
41 |
|
42 |
pamela::anticounter::AnticounterEvent *ace = 0; |
43 |
pamela::EventHeader *eh = 0; |
44 |
// pamela::PscuHeader *ph = 0; |
45 |
TFile *rootFile = new TFile(base); |
46 |
if (rootFile->IsZombie()) |
47 |
exit(-1); |
48 |
TString fileName = ((TObjString*)base.Tokenize('\/')->Last())->GetString(); |
49 |
TString filePath = base; |
50 |
filePath.ReplaceAll(fileName, ""); |
51 |
fileName.ReplaceAll(".root", ""); |
52 |
|
53 |
//Takes the tree of the header file |
54 |
TTree *tr = (TTree*)rootFile->Get("Physics"); |
55 |
|
56 |
tr->SetBranchStatus("*",0,&found); //disable all branches |
57 |
|
58 |
tr->SetBranchStatus("header*",1,&found); |
59 |
// printf("header: enabled %i branches \n",found); |
60 |
found = 0; |
61 |
tr->SetBranchStatus("status*",1,&found); |
62 |
// printf("status: enabled %i branches \n",found); |
63 |
found = 0; |
64 |
tr->SetBranchStatus("hitmap*",1,&found); |
65 |
// printf("hitmap: enabled %i branches \n",found); |
66 |
found = 0; |
67 |
tr->SetBranchStatus("regist*",1,&found); |
68 |
// printf("regist: enabled %i branches \n",found); |
69 |
found = 0; |
70 |
tr->SetBranchStatus("shift*",1,&found); |
71 |
// printf("shift: enabled %i branches \n",found); |
72 |
found = 0; |
73 |
tr->SetBranchStatus("counters*",1,&found); |
74 |
// printf("counters: enabled %i branches \n",found); |
75 |
found = 0; |
76 |
tr->SetBranchStatus("coinc*",1,&found); |
77 |
// printf("coinc: enabled %i branches \n",found); |
78 |
found = 0; |
79 |
tr->SetBranchStatus("trigg*",1,&found); |
80 |
// printf("trigg: enabled %i branches \n",found); |
81 |
found = 0; |
82 |
tr->SetBranchStatus("clock*",1,&found); |
83 |
// printf("clock: enabled %i branches \n",found); |
84 |
found = 0; |
85 |
tr->SetBranchStatus("temp*",1,&found); |
86 |
// printf("temp: enabled %i branches \n",found); |
87 |
found = 0; |
88 |
tr->SetBranchStatus("DAC*",1,&found); |
89 |
// printf("DAC: enabled %i branches \n",found); |
90 |
found = 0; |
91 |
tr->SetBranchStatus("CRC*",1,&found); |
92 |
// printf("CRC: enabled %i branches \n",found); |
93 |
|
94 |
found = 0; |
95 |
tr->SetBranchStatus("Pscu*",1,&found); |
96 |
// printf("enabled %i branches \n",found); |
97 |
found = 0; |
98 |
tr->SetBranchStatus("Anticounter*",1,&found); |
99 |
// printf("Ac enabled %i branches \n",found); |
100 |
found = 0; |
101 |
tr->SetBranchStatus("Header*",1,&found); |
102 |
// printf("head enabled %i branches \n",found); |
103 |
|
104 |
tr->SetBranchAddress("Anticounter", &ace); |
105 |
tr->SetBranchAddress("Header", &eh); |
106 |
|
107 |
|
108 |
|
109 |
|
110 |
Int_t nevents = tr->GetEntries(); |
111 |
|
112 |
//check that the selected range of events is ok |
113 |
|
114 |
if ( fromevent > toevent && toevent ){ |
115 |
return -1; |
116 |
}; |
117 |
if ( fromevent > nevents || fromevent < 0 ) { |
118 |
return -1; |
119 |
}; |
120 |
if ( toevent > nevents || toevent < 0 ) { |
121 |
return -1; |
122 |
}; |
123 |
|
124 |
if ( fromevent == 0 ) { |
125 |
minevent = 0; |
126 |
maxevent = nevents; |
127 |
} else { |
128 |
minevent = fromevent - 1; |
129 |
if ( toevent > 0 ){ |
130 |
maxevent = toevent; |
131 |
} else { |
132 |
maxevent = fromevent; |
133 |
}; |
134 |
}; |
135 |
|
136 |
/******************* VARIABLE DECLARATION ***************/ |
137 |
|
138 |
ACheader[0]=0xAC11; |
139 |
ACheader[1]=0xAC22; |
140 |
|
141 |
detector[0]="CARD 4"; |
142 |
detector[1]="CAT 2"; |
143 |
detector[2]="CAS 1"; |
144 |
detector[3]="NC"; |
145 |
detector[4]="CARD 2"; |
146 |
detector[5]="CAT 4"; |
147 |
detector[6]="CAS 4"; |
148 |
detector[7]="NC"; |
149 |
detector[8]="CARD 3"; |
150 |
detector[9]="CAT 3"; |
151 |
detector[10]="CAS 3"; |
152 |
detector[11]="NC"; |
153 |
detector[12]="CARD 1"; |
154 |
detector[13]="CAT 1"; |
155 |
detector[14]="CAS 2"; |
156 |
detector[15]="NC"; |
157 |
|
158 |
|
159 |
/******************** HISTOGRAM DECLARATION *************/ |
160 |
|
161 |
TH1D *hitmap_h[2]; |
162 |
hitmap_h[0] = new TH1D("Hitmap MAIN","Hitmap",16,0.,16.); |
163 |
hitmap_h[1] = new TH1D("Hitmap EXTRA","Hitmap",16,0.,16.); |
164 |
|
165 |
TH1D *status_h = new TH1D("Status","Status",10,0.,10.); |
166 |
|
167 |
/********************* MAIN LOOP **********************/ |
168 |
|
169 |
for (Int_t i = minevent; i < maxevent; i++){ |
170 |
|
171 |
tr->GetEntry(i); |
172 |
// ph = eh->GetPscuHeader(); |
173 |
|
174 |
for(Int_t card=0;card<2;card++) |
175 |
{ |
176 |
//Proceed only if crc is ok |
177 |
if(ace->CRCcheck[card]==1) |
178 |
{ |
179 |
|
180 |
//hitmap |
181 |
for(Int_t ch_cnt=0;ch_cnt<16;ch_cnt++) |
182 |
{ |
183 |
if( (ace->hitmap[card] & (0x1<<ch_cnt)) > 0 ) |
184 |
hitmap_h[card]->Fill(ch_cnt,1.); |
185 |
} |
186 |
//Status |
187 |
if((ace->header[card][0] != 0xACAC) || (ace->header[card][1] != ACheader[card])) |
188 |
status_h->Fill(1.+5.*card,1.); |
189 |
if((ace->status[card] & 0x8000) < 0x8000) //crc |
190 |
status_h->Fill(2.+5.*card,1.); |
191 |
if((ace->status[card] & 0x4000) < 0x4000) //dsp |
192 |
status_h->Fill(3.+5.*card,1.); |
193 |
if((ace->status[card] & 0x01FF) < 0x01FF) //reg |
194 |
status_h->Fill(4.+5*card,1.); |
195 |
|
196 |
}//if(crc check) |
197 |
/******************************************************/ |
198 |
else |
199 |
status_h->Fill(5.*card,1.); //event crc |
200 |
}//for(card) |
201 |
|
202 |
}//for(events) |
203 |
|
204 |
/***************************************** PLOTTING *****************************************/ |
205 |
|
206 |
const char *namn = "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK"; |
207 |
int mposition = 80; |
208 |
int eposition = 80; |
209 |
const char *figsave1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; |
210 |
const char *mystring = "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"; |
211 |
|
212 |
TBox *b1,*b2,*b3,*b4,*b5; |
213 |
gStyle->SetOptDate(0); |
214 |
TString *merr = new TString[5]; |
215 |
merr[0]="Event CRC"; |
216 |
merr[1]="Headers"; |
217 |
merr[2]="CRC"; |
218 |
merr[3]="Dsp"; |
219 |
merr[4]="Reg"; |
220 |
|
221 |
TCanvas *sheet1 = new TCanvas("Sheet 1","Sheet 1"); //base |
222 |
sheet1->Range(0,0,100,100); |
223 |
sheet1->Draw(); |
224 |
b1 = new TBox(10,84.5,90,85.5); |
225 |
b2 = new TBox(49.5,95,50.5,5); |
226 |
b1->SetFillColor(1); |
227 |
b2->SetFillColor(1); |
228 |
b1->Draw(); |
229 |
b2->Draw(); |
230 |
|
231 |
TLatex *t=new TLatex(); |
232 |
t->SetTextFont(40); |
233 |
t->SetTextColor(1); |
234 |
t->SetTextAlign(12); |
235 |
t->SetTextSize(0.04); |
236 |
namn = "AntiCounter MAIN card"; |
237 |
t->DrawLatex(10,90,namn); |
238 |
t->SetTextColor(1); |
239 |
namn = "AntiCounter EXTRA card"; |
240 |
t->DrawLatex(58,90,namn); |
241 |
t->SetTextSize(0.025); |
242 |
|
243 |
for(Int_t ch=1;ch<17;ch++) |
244 |
{ |
245 |
if(ch!=4 && ch!=8 && ch!=12 && ch!=16 && hitmap_h[0]->GetBinContent(ch)==0){ |
246 |
mystring = Form("%s channel empty",detector[ch-1].Data()); |
247 |
t->SetTextColor(2); |
248 |
t->DrawLatex(15,mposition,mystring); |
249 |
mposition -= 4; |
250 |
} |
251 |
if(ch!=4 && ch!=8 && ch!=12 && ch!=16 && hitmap_h[1]->GetBinContent(ch)==0){ |
252 |
mystring = Form("%s channel empty",detector[ch-1].Data()); |
253 |
t->SetTextColor(2); |
254 |
t->DrawLatex(65,eposition,mystring); |
255 |
eposition -= 4; |
256 |
} |
257 |
} |
258 |
for(Int_t ch=0;ch<5;ch++) |
259 |
{ |
260 |
if(status_h->GetBinContent(ch+1)>0){ |
261 |
mposition -= 4; |
262 |
mystring = Form("%d %s errors",(int)status_h->GetBinContent(ch+1),merr[ch].Data()); |
263 |
t->SetTextColor(2); |
264 |
t->DrawLatex(15,mposition,mystring); |
265 |
} |
266 |
if(status_h->GetBinContent(ch+5+1)>0){ |
267 |
eposition -= 4; |
268 |
mystring = Form("%d %s errors",(int)status_h->GetBinContent(ch+5+1),merr[ch].Data()); |
269 |
t->SetTextColor(2); |
270 |
t->DrawLatex(65,eposition,mystring); |
271 |
} |
272 |
} |
273 |
//if no errors |
274 |
if(mposition==80) |
275 |
{ |
276 |
namn = "AC main working"; |
277 |
t->SetTextSize(0.035); |
278 |
t->SetTextColor(1); |
279 |
t->DrawLatex(15,50,namn); |
280 |
} |
281 |
if(eposition==80) |
282 |
{ |
283 |
namn = "AC extra working"; |
284 |
t->SetTextSize(0.035); |
285 |
t->SetTextColor(1); |
286 |
t->DrawLatex(65,50,namn); |
287 |
} |
288 |
if(mposition!=80 || eposition!=80) |
289 |
{ |
290 |
namn = "AC malfunction"; |
291 |
t->SetTextSize(0.035); |
292 |
t->SetTextColor(1); |
293 |
t->DrawLatex(41.5,97.3,namn); |
294 |
b3 = new TBox(10,96,40,98.5); |
295 |
b4 = new TBox(10,1.5,90,4); |
296 |
b5 = new TBox(60,96,90,98.5); |
297 |
b3->SetFillColor(2); |
298 |
b4->SetFillColor(2); |
299 |
b5->SetFillColor(2); |
300 |
b3->Draw(); |
301 |
b4->Draw(); |
302 |
b5->Draw(); |
303 |
} |
304 |
|
305 |
figsave1 = Form("%s/%s_AcQLOOKbasic.%s",outDir.Data(),fileName.Data(),format.Data()); |
306 |
sheet1->SaveAs(figsave1); |
307 |
|
308 |
return 1; |
309 |
|
310 |
} //end AcBasic |
311 |
|
312 |
|
313 |
int AcQLOOKpro(TString base,int fromevent=0, int toevent=0, TString outDir = "./", TString format = FORMAT){ |
314 |
|
315 |
//Float_t startTime,stopTime; |
316 |
//Float_t time1,time2,time3,time4; |
317 |
|
318 |
//startTime = clock(); |
319 |
|
320 |
ofstream outputFile; |
321 |
stringstream oss; |
322 |
|
323 |
pamela::anticounter::AnticounterEvent *ace = 0; |
324 |
pamela::EventHeader *eh = 0; |
325 |
pamela::PscuHeader *ph = 0; |
326 |
TFile *rootFile = new TFile(base); |
327 |
if (rootFile->IsZombie()) |
328 |
exit(-1); |
329 |
TString fileName = ((TObjString*)base.Tokenize('\/')->Last())->GetString(); |
330 |
TString filePath = base; |
331 |
filePath.ReplaceAll(fileName, ""); |
332 |
fileName.ReplaceAll(".root", ""); |
333 |
|
334 |
//Takes the tree of the header file |
335 |
TTree *tr = (TTree*)rootFile->Get("Physics"); |
336 |
|
337 |
tr->SetBranchStatus("*",0,&found); //disable all branches |
338 |
|
339 |
tr->SetBranchStatus("header*",1,&found); |
340 |
// printf("header: enabled %i branches \n",found); |
341 |
found = 0; |
342 |
tr->SetBranchStatus("status*",1,&found); |
343 |
// printf("status: enabled %i branches \n",found); |
344 |
found = 0; |
345 |
tr->SetBranchStatus("hitmap*",1,&found); |
346 |
// printf("hitmap: enabled %i branches \n",found); |
347 |
found = 0; |
348 |
tr->SetBranchStatus("regist*",1,&found); |
349 |
// printf("regist: enabled %i branches \n",found); |
350 |
found = 0; |
351 |
tr->SetBranchStatus("shift*",1,&found); |
352 |
// printf("shift: enabled %i branches \n",found); |
353 |
found = 0; |
354 |
tr->SetBranchStatus("counters*",1,&found); |
355 |
// printf("counters: enabled %i branches \n",found); |
356 |
found = 0; |
357 |
tr->SetBranchStatus("coinc*",1,&found); |
358 |
// printf("coinc: enabled %i branches \n",found); |
359 |
found = 0; |
360 |
tr->SetBranchStatus("trigg*",1,&found); |
361 |
// printf("trigg: enabled %i branches \n",found); |
362 |
found = 0; |
363 |
tr->SetBranchStatus("clock*",1,&found); |
364 |
// printf("clock: enabled %i branches \n",found); |
365 |
found = 0; |
366 |
tr->SetBranchStatus("temp*",1,&found); |
367 |
// printf("temp: enabled %i branches \n",found); |
368 |
found = 0; |
369 |
tr->SetBranchStatus("DAC*",1,&found); |
370 |
// printf("DAC: enabled %i branches \n",found); |
371 |
found = 0; |
372 |
tr->SetBranchStatus("CRC*",1,&found); |
373 |
// printf("CRC: enabled %i branches \n",found); |
374 |
found = 0; |
375 |
|
376 |
tr->SetBranchStatus("Pscu*",1,&found); |
377 |
// printf("enabled %i branches \n",found); |
378 |
found = 0; |
379 |
tr->SetBranchStatus("Anticounter*",1,&found); |
380 |
// printf("Ac enabled %i branches \n",found); |
381 |
found = 0; |
382 |
tr->SetBranchStatus("Header*",1,&found); |
383 |
// printf("head enabled %i branches \n",found); |
384 |
|
385 |
tr->SetBranchAddress("Anticounter", &ace); |
386 |
tr->SetBranchAddress("Header", &eh); |
387 |
|
388 |
/*************************** VARIABLE DECLARATION **************************/ |
389 |
|
390 |
ACheader[0]=0xAC11; |
391 |
ACheader[1]=0xAC22; |
392 |
|
393 |
cardname[0] = "MAIN"; |
394 |
cardname[1] = "EXTRA"; |
395 |
|
396 |
detector[0]="CARD 4"; |
397 |
detector[1]="CAT 2"; |
398 |
detector[2]="CAS 1"; |
399 |
detector[3]="NC"; |
400 |
detector[4]="CARD 2"; |
401 |
detector[5]="CAT 4"; |
402 |
detector[6]="CAS 4"; |
403 |
detector[7]="NC"; |
404 |
detector[8]="CARD 3"; |
405 |
detector[9]="CAT 3"; |
406 |
detector[10]="CAS 3"; |
407 |
detector[11]="NC"; |
408 |
detector[12]="CARD 1"; |
409 |
detector[13]="CAT 1"; |
410 |
detector[14]="CAS 2"; |
411 |
detector[15]="NC"; |
412 |
|
413 |
// ANTICOUNTER VARIABLES |
414 |
|
415 |
Double_t ac_clock_old[2] = {-1., -1.}; |
416 |
Double_t ac_clock_new[2] = {-1., -1.}; |
417 |
Double_t ac_clock100_new[2] = {-1.,-1.}; |
418 |
Double_t ac_clock100_old[2] = {-1.,-1.}; |
419 |
Double_t ac_clock_diff[2]; |
420 |
Double_t ac_clock100_diff[2]; |
421 |
Double_t counter_old[2][16]; |
422 |
Double_t counter_new[2][16]; |
423 |
Double_t counter_diff[2][16]; |
424 |
|
425 |
// MISC VARIABLES |
426 |
|
427 |
// UInt_t obt; |
428 |
Int_t hitsCARD,hitsCAT,hitsCAS; |
429 |
Int_t interval_cnt = 0; |
430 |
Int_t paramEvent = 0; |
431 |
Int_t paramEvents; |
432 |
Int_t minevent,maxevent; |
433 |
const char *figsave = " "; |
434 |
UShort_t ACheader[2]; |
435 |
ACheader[0]=0xAC11; |
436 |
ACheader[1]=0xAC22; |
437 |
|
438 |
vector<int> Err_type(0); |
439 |
vector<float> Err_obt(0); |
440 |
vector<int> Err_evt(0); |
441 |
|
442 |
|
443 |
Int_t *det_map = new Int_t[12]; |
444 |
det_map[0]=2; |
445 |
det_map[1]=14; |
446 |
det_map[2]=10; |
447 |
det_map[3]=6; |
448 |
det_map[4]=13; |
449 |
det_map[5]=1; |
450 |
det_map[6]=9; |
451 |
det_map[7]=5; |
452 |
det_map[8]=12; |
453 |
det_map[9]=4; |
454 |
det_map[10]=8; |
455 |
det_map[11]=0; |
456 |
|
457 |
TString *detector = new TString[16]; |
458 |
detector[0]="CARD 4"; |
459 |
detector[1]="CAT 2"; |
460 |
detector[2]="CAS 1"; |
461 |
detector[3]="NC"; |
462 |
detector[4]="CARD 2"; |
463 |
detector[5]="CAT 4"; |
464 |
detector[6]="CAS 4"; |
465 |
detector[7]="NC"; |
466 |
detector[8]="CARD 3"; |
467 |
detector[9]="CAT 3"; |
468 |
detector[10]="CAS 3"; |
469 |
detector[11]="NC"; |
470 |
detector[12]="CARD 1"; |
471 |
detector[13]="CAT 1"; |
472 |
detector[14]="CAS 2"; |
473 |
detector[15]="NC"; |
474 |
|
475 |
TString *cardname = new TString[2]; |
476 |
cardname[0] = "MAIN"; |
477 |
cardname[1] = "EXTRA"; |
478 |
char histotitel[30]; |
479 |
|
480 |
Int_t nevents = tr->GetEntries(); |
481 |
|
482 |
//check that the selected range of events is ok |
483 |
if ( fromevent > toevent && toevent ){ |
484 |
return -1; |
485 |
}; |
486 |
if ( fromevent > nevents || fromevent < 0 ) { |
487 |
return -1; |
488 |
}; |
489 |
if ( toevent > nevents || toevent < 0 ) { |
490 |
return -1; |
491 |
}; |
492 |
|
493 |
if ( fromevent == 0 ) { |
494 |
minevent = 0; |
495 |
maxevent = nevents; |
496 |
} else { |
497 |
minevent = fromevent - 1; |
498 |
if ( toevent > 0 ){ |
499 |
maxevent = toevent; |
500 |
} else { |
501 |
maxevent = fromevent; |
502 |
}; |
503 |
}; |
504 |
|
505 |
paramEvents = (Int_t)((Float_t)nevents/(Float_t)INTERVAL); |
506 |
|
507 |
/************************* HISTOGRAM and GRAPH DECLARATION *******************************/ |
508 |
|
509 |
TH1D *hitmap_h[2]; |
510 |
TH1D *nmbhitpmtCARD_h = new TH1D("#hit PMTs CARD","#hit PMTs",8,0.5,8.5); |
511 |
TH1D *nmbhitpmtCAT_h = new TH1D("#hit PMTs CAT","#hit PMTs",8,0.5,8.5); |
512 |
TH1D *nmbhitpmtCAS_h = new TH1D("#hit PMTs CAS","#hit PMTs",8,0.5,8.5); |
513 |
TH1D *time_between_trigg_h[2]; |
514 |
TH1D *shiftreg_h[2][16]; |
515 |
|
516 |
for(Int_t card=0;card<2;card++) |
517 |
{ |
518 |
sprintf(histotitel,"Hitmap %s",cardname[card].Data()); |
519 |
hitmap_h[card] = new TH1D(histotitel,"Hitmap",16,0.,16.); |
520 |
|
521 |
hitmap_h[card]->GetXaxis()->SetBinLabel(1,detector[0]); |
522 |
hitmap_h[card]->GetXaxis()->SetBinLabel(2,detector[1]); |
523 |
hitmap_h[card]->GetXaxis()->SetBinLabel(3,detector[2]); |
524 |
hitmap_h[card]->GetXaxis()->SetBinLabel(4,detector[3]); |
525 |
hitmap_h[card]->GetXaxis()->SetBinLabel(5,detector[4]); |
526 |
hitmap_h[card]->GetXaxis()->SetBinLabel(6,detector[5]); |
527 |
hitmap_h[card]->GetXaxis()->SetBinLabel(7,detector[6]); |
528 |
hitmap_h[card]->GetXaxis()->SetBinLabel(8,detector[7]); |
529 |
hitmap_h[card]->GetXaxis()->SetBinLabel(9,detector[8]); |
530 |
hitmap_h[card]->GetXaxis()->SetBinLabel(10,detector[9]); |
531 |
hitmap_h[card]->GetXaxis()->SetBinLabel(11,detector[10]); |
532 |
hitmap_h[card]->GetXaxis()->SetBinLabel(12,detector[11]); |
533 |
hitmap_h[card]->GetXaxis()->SetBinLabel(13,detector[12]); |
534 |
hitmap_h[card]->GetXaxis()->SetBinLabel(14,detector[13]); |
535 |
hitmap_h[card]->GetXaxis()->SetBinLabel(15,detector[14]); |
536 |
hitmap_h[card]->GetXaxis()->SetBinLabel(16,detector[15]); |
537 |
hitmap_h[card]->GetYaxis()->SetTitle("Hits"); |
538 |
|
539 |
sprintf(histotitel,"Time between triggers %s",cardname[card].Data()); |
540 |
time_between_trigg_h[card] = new TH1D(histotitel,"Time between triggers",100,0.,0.01); |
541 |
time_between_trigg_h[card]->SetBit(TH1::kCanRebin); |
542 |
|
543 |
for(Int_t ch = 0; ch < 16; ch++) |
544 |
{ |
545 |
sprintf(histotitel,"Shift Register %s Ch %d",cardname[card].Data(),ch+1); |
546 |
shiftreg_h[card][ch] = new TH1D(histotitel,detector[ch].Data(),16,0.,16.); |
547 |
} |
548 |
} |
549 |
|
550 |
TH1D *status_h = new TH1D("Status","Status",12,0.,12.); |
551 |
status_h->GetXaxis()->SetBinLabel(1,"Headers M"); |
552 |
status_h->GetXaxis()->SetBinLabel(2,"CRC M"); |
553 |
status_h->GetXaxis()->SetBinLabel(3,"Dsp M"); |
554 |
status_h->GetXaxis()->SetBinLabel(4,"Temp M"); |
555 |
status_h->GetXaxis()->SetBinLabel(5,"Reg M"); |
556 |
status_h->GetXaxis()->SetBinLabel(6,"CRC Event M"); |
557 |
status_h->GetXaxis()->SetBinLabel(7,"Headers E"); |
558 |
status_h->GetXaxis()->SetBinLabel(8,"CRC E"); |
559 |
status_h->GetXaxis()->SetBinLabel(9,"Dsp E"); |
560 |
status_h->GetXaxis()->SetBinLabel(10,"Temp E"); |
561 |
status_h->GetXaxis()->SetBinLabel(11,"Reg E"); |
562 |
status_h->GetXaxis()->SetBinLabel(12,"CRC Event E"); |
563 |
status_h->GetYaxis()->SetTitle("# of Errors"); |
564 |
status_h->SetMinimum(0); |
565 |
|
566 |
Double_t *temp_gr[2][4]; |
567 |
for(Int_t i=0;i<2;i++) |
568 |
for(Int_t j=0;j<4;j++) |
569 |
temp_gr[i][j] = new Double_t[paramEvents+1]; |
570 |
|
571 |
for(Int_t i=0;i<2;i++) |
572 |
for(Int_t j=0;j<4;j++) |
573 |
for(Int_t k=0;k<(paramEvents+1);k++) |
574 |
temp_gr[i][j][k] = 0.; |
575 |
|
576 |
Double_t *trigger_gr[2]; |
577 |
trigger_gr[0] = new Double_t[paramEvents+1]; |
578 |
trigger_gr[1] = new Double_t[paramEvents+1]; |
579 |
|
580 |
Double_t *singles_gr[2][16]; |
581 |
for(Int_t i=0;i<2;i++){ |
582 |
for(Int_t j=0;j<16;j++){ |
583 |
singles_gr[i][j] = new Double_t[paramEvents+1]; |
584 |
} |
585 |
} |
586 |
for(Int_t i=0;i<2;i++){ |
587 |
for(Int_t j=0;j<16;j++){ |
588 |
for(Int_t k=0;k<(paramEvents+1);k++){ |
589 |
singles_gr[i][j][k] = 0.; |
590 |
} |
591 |
} |
592 |
} |
593 |
|
594 |
Double_t *event_obt = new Double_t[paramEvents+1]; |
595 |
|
596 |
|
597 |
/**********************************************************************************/ |
598 |
|
599 |
|
600 |
/********************* MAIN LOOP **********************/ |
601 |
|
602 |
//time1 = clock(); |
603 |
//printf("Init time: %f\n",(Double_t) (time1 - startTime) / (Double_t) CLOCKS_PER_SEC); |
604 |
|
605 |
//iterators used in the loop |
606 |
Int_t card, ch, bin; |
607 |
|
608 |
for (Int_t i = minevent; i < maxevent; i++){ |
609 |
|
610 |
interval_cnt++; |
611 |
|
612 |
tr->GetEntry(i); |
613 |
ph = eh->GetPscuHeader(); |
614 |
// obt = ph->GetOrbitalTime(); |
615 |
|
616 |
hitsCARD=hitsCAT=hitsCAS=0; |
617 |
|
618 |
for(card=0;card<2;card++) |
619 |
{ |
620 |
//proceed only if crc of event is ok |
621 |
//printf("CRC: %hx\n",ace->CRCcheck[card]); |
622 |
//printf("Hitmap: %hx\n\n",ace->hitmap[card]); |
623 |
if(ace->CRCcheck[card]==1) |
624 |
{ |
625 |
//clock |
626 |
ac_clock_old[card] = ac_clock_new[card]; |
627 |
ac_clock_new[card] = ace->clock[card][1]*0xFFFF + ace->clock[card][0]; |
628 |
if(ac_clock_new[card] - ac_clock_old[card] < 0.) |
629 |
ac_clock_diff[card] = 0xFFFFFFFF+ac_clock_new[card]-ac_clock_old[card]; |
630 |
else |
631 |
ac_clock_diff[card] = ac_clock_new[card]-ac_clock_old[card]; |
632 |
|
633 |
if(ac_clock_old[card] > 0. && 0.000000025*ac_clock_diff[card]<10.) |
634 |
time_between_trigg_h[card]->Fill( 0.000000025*ac_clock_diff[card] ); |
635 |
|
636 |
//counters, singlesrate & shift reg content |
637 |
for(ch=0;ch<16;ch++) |
638 |
{ |
639 |
counter_old[card][ch] = counter_new[card][ch]; |
640 |
counter_new[card][ch] = ace->counters[card][ch]; |
641 |
if(counter_new[card][ch] - counter_old[card][ch] < 0.) |
642 |
counter_diff[card][ch] = 0xFFFF + counter_new[card][ch] - counter_old[card][ch]; |
643 |
else |
644 |
counter_diff[card][ch] = counter_new[card][ch] - counter_old[card][ch]; |
645 |
|
646 |
singles_gr[card][ch][paramEvent] += (Double_t)counter_diff[card][ch]; |
647 |
|
648 |
for(bin = 0; bin < 16; bin++){ |
649 |
shiftreg_h[card][bin]->Fill(ch,ace->shift[card][ch] & 0x1<<bin); |
650 |
} |
651 |
|
652 |
//hitmap |
653 |
if( (ace->hitmap[card] & (0x1<<ch)) > 0 ){ |
654 |
hitmap_h[card]->Fill(ch,1.); |
655 |
if(ch==0 || ch==4 || ch==8 || ch==12) |
656 |
hitsCARD++; |
657 |
else if(ch==1 || ch==5 || ch==9 || ch==13) |
658 |
hitsCAT++; |
659 |
else if(ch==2 || ch==6 || ch==10 || ch==14) |
660 |
hitsCAS++; |
661 |
} |
662 |
|
663 |
} |
664 |
|
665 |
//Status |
666 |
if((ace->header[card][0] != 0xACAC) || (ace->header[card][1] != ACheader[card])){ |
667 |
status_h->Fill(6.*card,1.); |
668 |
Err_type.push_back(6*card); |
669 |
Err_obt.push_back(ph->GetOrbitalTime()); |
670 |
Err_evt.push_back(i); |
671 |
} |
672 |
if((ace->status[card] & 0x8000) < 0x8000){ //crc |
673 |
status_h->Fill(1.+6.*card,1.); |
674 |
Err_type.push_back(1+6*card); |
675 |
Err_obt.push_back(ph->GetOrbitalTime()); |
676 |
Err_evt.push_back(i); |
677 |
} |
678 |
if((ace->status[card] & 0x6000) < 0x6000){ //dsp |
679 |
status_h->Fill(2.+6.*card,1.); |
680 |
Err_type.push_back(2+6*card); |
681 |
Err_obt.push_back(ph->GetOrbitalTime()); |
682 |
Err_evt.push_back(i); |
683 |
} |
684 |
if((ace->status[card] & 0x0E00) < 0x0E00){ //temp |
685 |
status_h->Fill(3.+6.*card,1.); |
686 |
Err_type.push_back(3+6*card); |
687 |
Err_obt.push_back(ph->GetOrbitalTime()); |
688 |
Err_evt.push_back(i); |
689 |
} |
690 |
if((ace->status[card] & 0x01FF) < 0x01FF){ //reg |
691 |
status_h->Fill(4.+6.*card,1.); |
692 |
Err_type.push_back(4+6*card); |
693 |
Err_obt.push_back(ph->GetOrbitalTime()); |
694 |
Err_evt.push_back(i); |
695 |
} |
696 |
|
697 |
//temperature (left on cards) |
698 |
temp_gr[card][0][paramEvent] += ( ((ace->temp[card][0] & 0x00FF))*2.8 - 273. )/(Float_t)INTERVAL; |
699 |
temp_gr[card][1][paramEvent] += ( ((ace->temp[card][0] & 0xFF00)/256)*2.8 - 273. )/(Float_t)INTERVAL; |
700 |
temp_gr[card][2][paramEvent] += ( ((ace->temp[card][1] & 0x00FF))*2.8 - 273. )/(Float_t)INTERVAL; |
701 |
temp_gr[card][3][paramEvent] += ( ((ace->temp[card][1] & 0xFF00)/256)*2.8 - 273. )/(Float_t)INTERVAL; |
702 |
|
703 |
}//if(crc check) |
704 |
else{ |
705 |
status_h->Fill(5.+6.*card,1.); //event crc |
706 |
Err_type.push_back(5+6*card); |
707 |
Err_obt.push_back(ph->GetOrbitalTime()); |
708 |
Err_evt.push_back(i); |
709 |
} |
710 |
}//for(card) |
711 |
|
712 |
nmbhitpmtCARD_h->Fill(hitsCARD); |
713 |
nmbhitpmtCAS_h->Fill(hitsCAS); |
714 |
nmbhitpmtCAT_h->Fill(hitsCAT); |
715 |
|
716 |
|
717 |
if(interval_cnt==INTERVAL) |
718 |
{ |
719 |
event_obt[paramEvent] = ph->GetOrbitalTime(); |
720 |
|
721 |
for(card=0;card<2;card++) |
722 |
{ |
723 |
ac_clock100_old[card] = ac_clock100_new[card]; |
724 |
ac_clock100_new[card] = (ace->clock[card][1])*0xFFFF + ace->clock[card][0]; |
725 |
if((ac_clock100_new[card]-ac_clock100_old[card]) < 0.) |
726 |
ac_clock100_diff[card] = 0xFFFFFFFF+ac_clock100_new[card]-ac_clock100_old[card]; |
727 |
else |
728 |
ac_clock100_diff[card] = ac_clock100_new[card]-ac_clock100_old[card]; |
729 |
|
730 |
trigger_gr[card][paramEvent] = (Float_t)INTERVAL/(0.000000025*ac_clock100_diff[card]); |
731 |
|
732 |
for(ch=0;ch<16;ch++) |
733 |
singles_gr[card][ch][paramEvent] = singles_gr[card][ch][paramEvent]/(Double_t)(0.000000025*ac_clock100_diff[card]); |
734 |
|
735 |
}//for(card) |
736 |
interval_cnt=0; |
737 |
paramEvent++; |
738 |
}//if(interval_cnt)) |
739 |
|
740 |
} //for(events) |
741 |
|
742 |
//for(Int_t i=0;i<Err_type.size();i++) |
743 |
//printf("%d\t%f\t%d\n\n",Err_type.at(i),Err_obt.at(i),Err_evt.at(i)); |
744 |
|
745 |
//Time2 = clock(); |
746 |
//printf("Loop time: %f\n",(Double_t) (time2 - time1) / (Double_t) CLOCKS_PER_SEC); |
747 |
|
748 |
/****************************** PLOTTING ***************************/ |
749 |
|
750 |
TCanvas *sheet1 = new TCanvas("Sheet 1"); |
751 |
sheet1->Range(0,0,100,100); |
752 |
sheet1->Draw(); |
753 |
sheet1->cd(); |
754 |
|
755 |
TLatex *t=new TLatex(); |
756 |
t->SetTextFont(32); |
757 |
t->SetTextColor(1); |
758 |
t->SetTextAlign(12); |
759 |
t->SetTextSize(0.02); |
760 |
|
761 |
TPad *pd1 = new TPad("pd1","This is pad1",0.02,0.02,0.49,0.49,17); //lower left |
762 |
TPad *pd2 = new TPad("pd2","This is pad2",0.51,0.02,0.98,0.49,17); //lower right |
763 |
TPad *pd4 = new TPad("pd4","This is pad4",0.02,0.51,0.49,0.98,17); //upper left |
764 |
TPad *pd3 = new TPad("pd3","This is pad3",0.51,0.51,0.98,0.98,17); //upper right |
765 |
|
766 |
|
767 |
pd4->Range(0,0,100,100); |
768 |
sheet1->cd(); |
769 |
pd1->Draw(); |
770 |
pd2->Draw(); |
771 |
pd3->Draw(); |
772 |
pd4->Draw(); |
773 |
|
774 |
pd4->cd(); |
775 |
char namn3[30]; |
776 |
char namn4[40]; |
777 |
char namn5[30]; |
778 |
sprintf(namn3,"Anticounter Quicklook v%.1f",VERSION); |
779 |
sprintf(namn4,"File: %s",fileName.Data()); |
780 |
sprintf(namn5,"Events: %d",nevents); |
781 |
t->SetTextSize(0.1); |
782 |
t->DrawLatex(5,90,namn3); |
783 |
t->SetTextSize(0.1); |
784 |
t->DrawLatex(20,50,namn4); |
785 |
t->DrawLatex(20,40,namn5); |
786 |
|
787 |
t->SetTextSize(0.02); |
788 |
|
789 |
pd3->cd(); |
790 |
status_h->SetLineColor(1); |
791 |
status_h->SetStats(kFALSE); |
792 |
status_h->Draw(); |
793 |
|
794 |
pd1->cd(); |
795 |
TGraph *temperatureRIGHT_M_g = new TGraph(paramEvents,event_obt,temp_gr[0][0]); |
796 |
TGraph *temperatureACTEL_M_g = new TGraph(paramEvents,event_obt,temp_gr[0][1]); |
797 |
TGraph *temperatureLEFT_M_g = new TGraph(paramEvents,event_obt,temp_gr[0][2]); |
798 |
TGraph *temperatureDSP_M_g = new TGraph(paramEvents,event_obt,temp_gr[0][3]); |
799 |
temperatureRIGHT_M_g->SetMaximum(50.); |
800 |
temperatureRIGHT_M_g->SetMinimum(0.); |
801 |
temperatureRIGHT_M_g->SetTitle("Temperature MAIN"); |
802 |
temperatureRIGHT_M_g->GetXaxis()->SetTitle("Obt [ms]"); |
803 |
temperatureRIGHT_M_g->GetYaxis()->SetTitle("T [Celsius]"); |
804 |
temperatureRIGHT_M_g->SetMarkerColor(1); |
805 |
temperatureACTEL_M_g->SetMarkerColor(2); |
806 |
temperatureLEFT_M_g->SetMarkerColor(3); |
807 |
temperatureDSP_M_g->SetMarkerColor(4); |
808 |
temperatureRIGHT_M_g->SetLineColor(1); |
809 |
temperatureACTEL_M_g->SetLineColor(2); |
810 |
temperatureLEFT_M_g->SetLineColor(3); |
811 |
temperatureDSP_M_g->SetLineColor(4); |
812 |
temperatureRIGHT_M_g->Draw("AL"); |
813 |
temperatureACTEL_M_g->Draw("LSAME"); |
814 |
temperatureLEFT_M_g->Draw("LSAME"); |
815 |
temperatureDSP_M_g->Draw("LSAME"); |
816 |
|
817 |
TLegend *legTempM = new TLegend(0.72,0.63,0.85,0.8); |
818 |
legTempM->AddEntry(temperatureRIGHT_M_g,"Right","P"); |
819 |
legTempM->AddEntry(temperatureACTEL_M_g,"Actel","P"); |
820 |
legTempM->AddEntry(temperatureLEFT_M_g,"Left","P"); |
821 |
legTempM->AddEntry(temperatureDSP_M_g,"Dsp","P"); |
822 |
legTempM->Draw(); |
823 |
|
824 |
pd2->cd(); |
825 |
TGraph *temperatureRIGHT_E_g = new TGraph(paramEvents,event_obt,temp_gr[1][0]); |
826 |
TGraph *temperatureACTEL_E_g = new TGraph(paramEvents,event_obt,temp_gr[1][1]); |
827 |
TGraph *temperatureLEFT_E_g = new TGraph(paramEvents,event_obt,temp_gr[1][2]); |
828 |
TGraph *temperatureDSP_E_g = new TGraph(paramEvents,event_obt,temp_gr[1][3]); |
829 |
temperatureRIGHT_E_g->SetTitle("Temperature EXTRA"); |
830 |
temperatureRIGHT_E_g->GetXaxis()->SetTitle("Obt [ms]"); |
831 |
temperatureRIGHT_E_g->GetYaxis()->SetTitle("T [Celsius]"); |
832 |
temperatureRIGHT_E_g->SetMarkerColor(1); |
833 |
temperatureACTEL_E_g->SetMarkerColor(2); |
834 |
temperatureLEFT_E_g->SetMarkerColor(3); |
835 |
temperatureDSP_E_g->SetMarkerColor(4); |
836 |
temperatureRIGHT_E_g->SetLineColor(1); |
837 |
temperatureACTEL_E_g->SetLineColor(2); |
838 |
temperatureLEFT_E_g->SetLineColor(3); |
839 |
temperatureDSP_E_g->SetLineColor(4); |
840 |
|
841 |
|
842 |
temperatureRIGHT_E_g->SetMaximum(50.); |
843 |
temperatureRIGHT_E_g->SetMinimum(0.); |
844 |
temperatureRIGHT_E_g->Draw("AL"); |
845 |
temperatureACTEL_E_g->Draw("LSAME"); |
846 |
temperatureLEFT_E_g->Draw("LSAME"); |
847 |
temperatureDSP_E_g->Draw("LSAME"); |
848 |
|
849 |
TLegend *legTempE = new TLegend(0.72,0.63,0.86,0.8); |
850 |
legTempE->AddEntry(temperatureRIGHT_E_g,"Right","L"); |
851 |
legTempE->AddEntry(temperatureACTEL_E_g,"Actel","L"); |
852 |
legTempE->AddEntry(temperatureLEFT_E_g,"Left","L"); |
853 |
legTempE->AddEntry(temperatureDSP_E_g,"Dsp","L"); |
854 |
legTempE->Draw(); |
855 |
|
856 |
/************************/ |
857 |
|
858 |
TCanvas *sheet2 = new TCanvas("Sheet 2"); |
859 |
sheet2->Range(0,0,100,100); |
860 |
sheet2->Draw(); |
861 |
sheet2->cd(); |
862 |
|
863 |
TPad *pd21 = new TPad("pd21","This is pad1",0.02,0.02,0.49,0.49,17); //lower left |
864 |
//TPad *pd22 = new TPad("pd22","This is pad2",0.51,0.02,0.98,0.49,17); //lower right |
865 |
TPad *pd22_1 = new TPad("pd22_1","This is pad22_1",0.51,0.02,0.65,0.49,17); |
866 |
TPad *pd22_2 = new TPad("pd22_3","This is pad22_2",0.67,0.02,0.81,0.49,17); |
867 |
TPad *pd22_3 = new TPad("pd22_4","This is pad22_3",0.83,0.02,0.97,0.49,17); |
868 |
|
869 |
TPad *pd24 = new TPad("pd24","This is pad4",0.02,0.51,0.49,0.98,17); //upper left |
870 |
TPad *pd23 = new TPad("pd23","This is pad3",0.51,0.51,0.98,0.98,17); //upper right |
871 |
sheet2->cd(); |
872 |
pd21->Draw(); |
873 |
pd22_1->Draw(); |
874 |
pd22_2->Draw(); |
875 |
pd22_3->Draw(); |
876 |
pd23->Draw(); |
877 |
pd24->Draw(); |
878 |
|
879 |
t->SetTextColor(1); |
880 |
t->DrawLatex(82,99,cardname[0]); |
881 |
t->SetTextColor(2); |
882 |
t->DrawLatex(89,99,cardname[1]); |
883 |
|
884 |
pd24->cd(); |
885 |
TGraph *triggM_gr = new TGraph(paramEvents,event_obt,trigger_gr[0]); |
886 |
TGraph *triggE_gr = new TGraph(paramEvents,event_obt,trigger_gr[1]); |
887 |
triggM_gr->SetTitle("Trigger Rate"); |
888 |
triggM_gr->GetXaxis()->SetTitle("Obt [ms]"); |
889 |
triggM_gr->GetYaxis()->SetTitle("f [Hz]"); |
890 |
triggM_gr->SetMarkerColor(1); |
891 |
triggE_gr->SetMarkerColor(2); |
892 |
triggM_gr->SetLineColor(1); |
893 |
triggE_gr->SetLineColor(2); |
894 |
triggM_gr->Draw("AL"); |
895 |
triggE_gr->Draw("LSAME"); |
896 |
|
897 |
pd23->cd(); |
898 |
gPad->SetLogy(1); |
899 |
time_between_trigg_h[0]->GetXaxis()->SetTitle("Time [s]"); |
900 |
time_between_trigg_h[0]->SetLineColor(1); |
901 |
time_between_trigg_h[1]->SetLineColor(2); |
902 |
if(time_between_trigg_h[0]->GetMaximum() < time_between_trigg_h[1]->GetMaximum()) |
903 |
time_between_trigg_h[0]->SetMaximum(1.3*time_between_trigg_h[1]->GetMaximum()); |
904 |
//time_between_trigg_h[0]->SetStats(kFALSE); |
905 |
time_between_trigg_h[0]->Draw(); |
906 |
time_between_trigg_h[1]->SetStats(kFALSE); |
907 |
time_between_trigg_h[1]->Draw("SAME"); |
908 |
|
909 |
|
910 |
pd21->cd(); |
911 |
hitmap_h[0]->SetStats(kFALSE); |
912 |
hitmap_h[1]->SetStats(kFALSE); |
913 |
hitmap_h[0]->SetLineColor(1); |
914 |
if(hitmap_h[0]->GetMaximum() < hitmap_h[1]->GetMaximum()) |
915 |
hitmap_h[0]->SetMaximum(1.1*hitmap_h[1]->GetMaximum()); |
916 |
hitmap_h[0]->Draw(); |
917 |
hitmap_h[1]->SetLineColor(2); |
918 |
hitmap_h[1]->Draw("SAME"); |
919 |
|
920 |
|
921 |
pd22_1->cd(); |
922 |
gPad->SetLogy(1); |
923 |
nmbhitpmtCARD_h->SetTitle("CARD"); |
924 |
nmbhitpmtCARD_h->GetXaxis()->SetTitle("Nmb of hits"); |
925 |
nmbhitpmtCARD_h->GetYaxis()->SetTitle("Events"); |
926 |
nmbhitpmtCARD_h->SetStats(kFALSE); |
927 |
nmbhitpmtCARD_h->SetLineColor(1); |
928 |
nmbhitpmtCARD_h->Draw(); |
929 |
|
930 |
pd22_2->cd(); |
931 |
gPad->SetLogy(1); |
932 |
nmbhitpmtCAT_h->SetTitle("CAT"); |
933 |
nmbhitpmtCAT_h->GetXaxis()->SetTitle("Nmb of hits"); |
934 |
nmbhitpmtCAT_h->GetYaxis()->SetTitle("Events"); |
935 |
nmbhitpmtCAT_h->SetStats(kFALSE); |
936 |
nmbhitpmtCAT_h->SetLineColor(1); |
937 |
nmbhitpmtCAT_h->Draw(); |
938 |
|
939 |
pd22_3->cd(); |
940 |
gPad->SetLogy(1); |
941 |
nmbhitpmtCAS_h->SetTitle("CAS"); |
942 |
nmbhitpmtCAS_h->GetXaxis()->SetTitle("Nmb of hits"); |
943 |
nmbhitpmtCAS_h->GetYaxis()->SetTitle("Events"); |
944 |
nmbhitpmtCAS_h->SetStats(kFALSE); |
945 |
nmbhitpmtCAS_h->SetLineColor(1); |
946 |
nmbhitpmtCAS_h->Draw(); |
947 |
|
948 |
/* |
949 |
if(nmbhitpmtCAT_h->GetMaximum() > nmbhitpmtCARD_h->GetMaximum()) |
950 |
{ |
951 |
if(nmbhitpmtCAT_h->GetMaximum() > nmbhitpmtCAS_h->GetMaximum()) |
952 |
nmbhitpmtCARD_h->SetMaximum(1.2*nmbhitpmtCAT_h->GetMaximum()); |
953 |
else |
954 |
nmbhitpmtCARD_h->SetMaximum(1.2*nmbhitpmtCAS_h->GetMaximum()); |
955 |
} |
956 |
nmbhitpmtCARD_h->SetLineColor(1); |
957 |
nmbhitpmtCAT_h->SetLineColor(2); |
958 |
nmbhitpmtCAS_h->SetLineColor(3); |
959 |
nmbhitpmtCARD_h->SetMarkerStyle(20); |
960 |
nmbhitpmtCAT_h->SetMarkerStyle(21); |
961 |
nmbhitpmtCAS_h->SetMarkerStyle(22); |
962 |
nmbhitpmtCARD_h->Draw("P"); |
963 |
nmbhitpmtCAT_h->Draw("PSAME"); |
964 |
nmbhitpmtCAS_h->Draw("PSAME"); |
965 |
|
966 |
TLegend *leghitpmt = new TLegend(0.72,0.63,0.86,0.8); |
967 |
leghitpmt->AddEntry(nmbhitpmtCARD_h,"CARD","P"); |
968 |
leghitpmt->AddEntry(nmbhitpmtCAT_h,"CAT","P"); |
969 |
leghitpmt->AddEntry(nmbhitpmtCAS_h,"CAS","P"); |
970 |
leghitpmt->Draw(); |
971 |
*/ |
972 |
|
973 |
/********** SHEET 3 *********/ |
974 |
|
975 |
TCanvas *sheet3 = new TCanvas("Sheet 3"); |
976 |
//sheet2->Divide(4,4); |
977 |
sheet3->Draw(); |
978 |
sheet3->cd(); |
979 |
|
980 |
sheet3->Range(0,0,100,100); |
981 |
|
982 |
t->SetTextFont(32); |
983 |
t->SetTextColor(1); |
984 |
t->SetTextAlign(12); |
985 |
t->SetTextSize(0.035); |
986 |
const char *namn = " "; |
987 |
|
988 |
namn="Singles Rate"; |
989 |
t->DrawLatex(40.,95,namn); |
990 |
namn="CAS"; |
991 |
t->DrawLatex(4.,95.,namn); |
992 |
namn="CAT"; |
993 |
t->DrawLatex(4.,65.,namn); |
994 |
namn="CARD"; |
995 |
t->DrawLatex(4.,34.,namn); |
996 |
|
997 |
t->SetTextSize(0.02); |
998 |
namn="MAIN"; |
999 |
t->DrawLatex(85,98,namn); |
1000 |
t->SetTextColor(2); |
1001 |
namn="EXTRA"; |
1002 |
t->DrawLatex(85,95,namn); |
1003 |
|
1004 |
Float_t pad_x1[12] = {0.,0.25,0.5,0.75,0.,0.25,0.5,0.75,0.,0.25,0.5,0.75}; |
1005 |
Float_t pad_x2[12] = {0.25,0.5,0.75,1.0,0.25,0.5,0.75,1.,0.25,0.5,0.75,1.}; |
1006 |
Float_t pad_y1[12] = {0.68,0.68,0.68,0.68,0.37,0.37,0.37,0.37,0.06,0.06,0.06,0.06}; |
1007 |
Float_t pad_y2[12] = {0.92,0.92,0.92,0.92,0.62,0.62,0.62,0.62,0.31,0.31,0.31,0.31}; |
1008 |
TPad *singles_Pads[12]; |
1009 |
|
1010 |
char singlesname[30]; |
1011 |
for(Int_t ch=0;ch<12;ch++){ |
1012 |
sprintf(singlesname,"Pad%d",ch+1); |
1013 |
singles_Pads[ch] = new TPad(singlesname,singlesname,pad_x1[ch],pad_y1[ch],pad_x2[ch],pad_y2[ch]); |
1014 |
singles_Pads[ch]->Draw(); |
1015 |
} |
1016 |
|
1017 |
sheet3->cd(); |
1018 |
singles_gr[0][4][0]=0.; |
1019 |
TGraph *singlesrate_g[2][12]; |
1020 |
Int_t k; |
1021 |
for(Int_t card=0;card<2;card++){ |
1022 |
k=0; |
1023 |
for(Int_t ch=0;ch<16;ch++){ |
1024 |
if(ch!=3 && ch!=7 && ch!= 11 && ch!=15){ |
1025 |
//printf("k %d ch %d\n",k,ch); |
1026 |
singles_Pads[k]->cd(); |
1027 |
singles_gr[card][det_map[k]][0]=0.0; |
1028 |
singlesrate_g[card][k] = new TGraph(paramEvents,event_obt,singles_gr[card][det_map[k]]); |
1029 |
singlesrate_g[card][k]->SetLineColor(card+1); |
1030 |
singlesrate_g[card][k]->GetXaxis()->SetTitle("Obt [ms]"); |
1031 |
singlesrate_g[card][k]->GetYaxis()->SetTitle("f [Hz]"); |
1032 |
singlesrate_g[card][k]->SetTitle(detector[det_map[k]].Data()); |
1033 |
if(card==0) |
1034 |
singlesrate_g[card][k]->Draw("AL"); |
1035 |
else |
1036 |
singlesrate_g[card][k]->Draw("LSAME"); |
1037 |
k++; |
1038 |
} |
1039 |
} |
1040 |
} |
1041 |
|
1042 |
/********** SHEET 4 *********/ |
1043 |
|
1044 |
TCanvas *sheet4 = new TCanvas("Sheet 4"); |
1045 |
//sheet2->Divide(4,4); |
1046 |
sheet4->Draw(); |
1047 |
sheet4->cd(); |
1048 |
|
1049 |
sheet4->Range(0,0,100,100); |
1050 |
|
1051 |
t->SetTextFont(32); |
1052 |
t->SetTextColor(1); |
1053 |
t->SetTextAlign(12); |
1054 |
t->SetTextSize(0.035); |
1055 |
|
1056 |
namn="Shift Register Content"; |
1057 |
t->DrawLatex(40.,95,namn); |
1058 |
namn="CAS"; |
1059 |
t->DrawLatex(4.,95.,namn); |
1060 |
namn="CAT"; |
1061 |
t->DrawLatex(4.,65.,namn); |
1062 |
namn="CARD"; |
1063 |
t->DrawLatex(4.,34.,namn); |
1064 |
|
1065 |
t->SetTextSize(0.02); |
1066 |
namn="MAIN"; |
1067 |
t->DrawLatex(85,98,namn); |
1068 |
t->SetTextColor(2); |
1069 |
namn="EXTRA"; |
1070 |
t->DrawLatex(85,95,namn); |
1071 |
|
1072 |
TPad *shift_Pads[12]; |
1073 |
|
1074 |
for(Int_t ch=0;ch<12;ch++){ |
1075 |
sprintf(singlesname,"ShiftPad%d",ch+1); |
1076 |
shift_Pads[ch] = new TPad(singlesname,singlesname,pad_x1[ch],pad_y1[ch],pad_x2[ch],pad_y2[ch]); |
1077 |
shift_Pads[ch]->Draw(); |
1078 |
} |
1079 |
|
1080 |
sheet4->cd(); |
1081 |
for(Int_t card=0;card<2;card++){ |
1082 |
k=0; |
1083 |
for(Int_t ch=0;ch<16;ch++){ |
1084 |
if(ch!=3 && ch!=7 && ch!= 11 && ch!=15){ |
1085 |
//printf("k %d ch %d\n",k,ch); |
1086 |
shift_Pads[k]->cd(); |
1087 |
gPad->SetLogy(1); |
1088 |
shiftreg_h[card][det_map[k]]->SetStats(kFALSE); |
1089 |
shiftreg_h[card][det_map[k]]->SetLineColor(1+card); |
1090 |
shiftreg_h[card][det_map[k]]->SetMinimum(0.); |
1091 |
shiftreg_h[card][det_map[k]]->Scale(1./shiftreg_h[card][det_map[k]]->Integral()); |
1092 |
if(card==0) |
1093 |
shiftreg_h[card][det_map[k]]->Draw(); |
1094 |
else |
1095 |
shiftreg_h[card][det_map[k]]->Draw("SAME"); |
1096 |
k++; |
1097 |
} |
1098 |
} |
1099 |
} |
1100 |
|
1101 |
// Plot error report if any error occurs |
1102 |
|
1103 |
//char *namn6 = "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK"; |
1104 |
int mposition = 80; |
1105 |
int eposition = 80; |
1106 |
const char *mystring = "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"; |
1107 |
TString *merr; |
1108 |
TBox *b1,*b2; |
1109 |
|
1110 |
TCanvas *sheetError; |
1111 |
|
1112 |
if(Err_type.size() > 0) |
1113 |
{ |
1114 |
merr = new TString[12]; |
1115 |
merr[0]="Header"; |
1116 |
merr[1]="CRC"; |
1117 |
merr[2]="Dsp"; |
1118 |
merr[3]="Temp"; |
1119 |
merr[4]="Reg"; |
1120 |
merr[5]="Event CRC"; |
1121 |
merr[6]="Header"; |
1122 |
merr[7]="CRC"; |
1123 |
merr[8]="Dsp"; |
1124 |
merr[9]="Temp"; |
1125 |
merr[10]="Reg"; |
1126 |
merr[11]="Event CRC"; |
1127 |
|
1128 |
sheetError = new TCanvas("Sheet Error","Sheet Error"); //base |
1129 |
sheetError->Range(0,0,100,100); |
1130 |
sheetError->Draw(); |
1131 |
b1 = new TBox(10,83.5,90,84.5); |
1132 |
b2 = new TBox(49.5,90,50.5,5); |
1133 |
b1->SetFillColor(1); |
1134 |
b2->SetFillColor(1); |
1135 |
b1->Draw(); |
1136 |
b2->Draw(); |
1137 |
|
1138 |
t->SetTextFont(40); |
1139 |
t->SetTextColor(1); |
1140 |
t->SetTextAlign(12); |
1141 |
t->SetTextSize(0.04); |
1142 |
namn = "AntiCounter Error Report"; |
1143 |
t->DrawLatex(37,94,namn); |
1144 |
t->SetTextColor(1); |
1145 |
namn = "MAIN card"; |
1146 |
t->DrawLatex(15,87,namn); |
1147 |
t->SetTextColor(1); |
1148 |
namn = "EXTRA card"; |
1149 |
t->DrawLatex(65,87,namn); |
1150 |
t->SetTextSize(0.015); |
1151 |
|
1152 |
|
1153 |
//for(Int_t i=0;i<Err_type.size();i++) |
1154 |
UInt_t iter = 0; |
1155 |
while(iter<Err_type.size()) |
1156 |
{ |
1157 |
mystring = Form("%s error obt %d \t event nmb %d",merr[Err_type.at(iter)].Data(),(int)Err_obt.at(iter),Err_evt.at(iter)); |
1158 |
t->SetTextColor(2); |
1159 |
if(Err_type.at(iter) < 7 && mposition>10){ |
1160 |
mposition -= 2; |
1161 |
t->DrawLatex(15,mposition,mystring); |
1162 |
} |
1163 |
else if(eposition>10){ |
1164 |
eposition -= 2; |
1165 |
t->DrawLatex(65,eposition,mystring); |
1166 |
} |
1167 |
iter++; |
1168 |
} |
1169 |
if(mposition<10) |
1170 |
t->DrawLatex(15,5,"More errors in run!"); |
1171 |
if(eposition<10) |
1172 |
t->DrawLatex(65,5,"More errors in run!"); |
1173 |
|
1174 |
figsave = Form("%s/%s_AcQLOOK_Error.%s",outDir.Data(),fileName.Data(),format.Data()); |
1175 |
sheetError->SaveAs(figsave); |
1176 |
} |
1177 |
|
1178 |
figsave = Form("%s/%s_AcQLOOK_Status.%s",outDir.Data(),fileName.Data(),format.Data()); |
1179 |
sheet1->SaveAs(figsave); |
1180 |
|
1181 |
figsave = Form("%s/%s_AcQLOOK_Trigger.%s",outDir.Data(),fileName.Data(),format.Data()); |
1182 |
sheet2->SaveAs(figsave); |
1183 |
|
1184 |
figsave = Form("%s/%s_AcQLOOK_Singles.%s",outDir.Data(),fileName.Data(),format.Data()); |
1185 |
sheet3->SaveAs(figsave); |
1186 |
|
1187 |
figsave = Form("%s/%s_AcQLOOK_Shift.%s",outDir.Data(),fileName.Data(),format.Data()); |
1188 |
sheet4->SaveAs(figsave); |
1189 |
|
1190 |
delete sheet1; |
1191 |
delete hitmap_h[0]; |
1192 |
delete hitmap_h[1]; |
1193 |
|
1194 |
//stopTime = clock(); |
1195 |
//printf("Draw time: %f\n\n",(Double_t) (stopTime - time2) / (Double_t) CLOCKS_PER_SEC); |
1196 |
//printf("Exc time: %f\n",(Double_t) (stopTime-startTime) / (Double_t) CLOCKS_PER_SEC); |
1197 |
|
1198 |
return 1; |
1199 |
|
1200 |
} |
1201 |
|
1202 |
|
1203 |
int main(int argc, char* argv[]){ |
1204 |
TString outDir = "."; |
1205 |
TString format = FORMAT; |
1206 |
int from = 0; |
1207 |
int to = 0; |
1208 |
int mode = 0; |
1209 |
|
1210 |
if (argc < 2){ |
1211 |
printf("You have to insert at least the file to analyze \n"); |
1212 |
printf("Try '--help' for more information. \n"); |
1213 |
exit(1); |
1214 |
} |
1215 |
|
1216 |
if (!strcmp(argv[1], "--help")){ |
1217 |
printf( "Usage: AcQLOOK FILE [OPTION] \n"); |
1218 |
printf( "\t --help Print this help and exit \n"); |
1219 |
printf( "\t -outDir[path] Path where to put the output [default ./] \n"); |
1220 |
printf( "\t -format[path] Set the format for the output file [default 'jpg']\n"); |
1221 |
printf( "\t -from # Set the starting event [default 0]\n"); |
1222 |
printf( "\t -to # Set the last event [default 0]\n"); |
1223 |
printf( "\t -mode # advanced (1) or dummy (0) mode [default 0]\n"); |
1224 |
exit(1); |
1225 |
} |
1226 |
|
1227 |
if (!strcmp(argv[1], "-v")){ |
1228 |
printf("Version %.2f\n",VERSION); |
1229 |
exit(1); |
1230 |
} |
1231 |
|
1232 |
for (int i = 2; i < argc; i++){ |
1233 |
if (!strcmp(argv[i], "-outDir")){ |
1234 |
if (++i >= argc){ |
1235 |
printf( "-outDir needs arguments. \n"); |
1236 |
printf( "Try '--help' for more information. \n"); |
1237 |
exit(1); |
1238 |
} else { |
1239 |
outDir = argv[i]; |
1240 |
} |
1241 |
} |
1242 |
|
1243 |
if (!strcmp(argv[i], "-format")) { |
1244 |
if (++i >= argc){ |
1245 |
printf( "-format needs arguments. \n"); |
1246 |
printf( "Try '--help' for more information. \n"); |
1247 |
exit(1); |
1248 |
} else { |
1249 |
format = argv[i]; |
1250 |
continue; |
1251 |
} |
1252 |
} |
1253 |
|
1254 |
if (!strcmp(argv[i], "-mode")) { |
1255 |
if (++i >= argc){ |
1256 |
printf( "-mode needs arguments. \n"); |
1257 |
printf( "Try '--help' for more information. \n"); |
1258 |
exit(1); |
1259 |
} else { |
1260 |
mode = atoi(argv[i]); |
1261 |
continue; |
1262 |
} |
1263 |
} |
1264 |
|
1265 |
if (!strcmp(argv[i], "-to")) { |
1266 |
if (++i >= argc){ |
1267 |
printf( "-to needs arguments. \n"); |
1268 |
printf( "Try '--help' for more information. \n"); |
1269 |
exit(1); |
1270 |
} |
1271 |
if (isdigit(*argv[i]) && (atoi(argv[i]) > 0)) { |
1272 |
to = atoi(argv[i]); |
1273 |
} else { |
1274 |
//err << "-to needs a integer value. \n"; |
1275 |
cout << "Try '--help' for more information. \n"; |
1276 |
exit(1); |
1277 |
} |
1278 |
} |
1279 |
|
1280 |
if (!strcmp(argv[i], "-from")) { |
1281 |
if (++i >= argc){ |
1282 |
printf( "-from needs arguments. \n"); |
1283 |
printf( "Try '--help' for more information. \n"); |
1284 |
exit(1); |
1285 |
} |
1286 |
if (isdigit(*argv[i]) && (atoi(argv[i]) > 0)) { |
1287 |
from = atoi(argv[i]); |
1288 |
} else { |
1289 |
//cerr << "-from needs a integer value. \n"; |
1290 |
cout << "Try '--help' for more information. \n"; |
1291 |
exit(1); |
1292 |
} |
1293 |
} |
1294 |
|
1295 |
} |
1296 |
|
1297 |
if(mode==0) |
1298 |
AcQLOOKbasic(argv[1], from, to, outDir, format); |
1299 |
else if(mode==1) |
1300 |
AcQLOOKpro(argv[1], from, to, outDir, format); |
1301 |
else |
1302 |
printf("Wrong mode argument. Try --help for more information\n"); |
1303 |
|
1304 |
} |