/[PAMELA software]/quicklook/anticounter/src/AcQLOOK.cpp
ViewVC logotype

Annotation of /quicklook/anticounter/src/AcQLOOK.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Sun Mar 18 14:24:31 2007 UTC (17 years, 8 months ago) by pamela
Branch: MAIN
Changes since 1.4: +6 -5 lines
Obt problem fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23