/[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.4 - (hide annotations) (download)
Tue Jul 11 12:01:17 2006 UTC (18 years, 4 months ago) by pam-se
Branch: MAIN
CVS Tags: v1r7, v1r6
Changes since 1.3: +148 -34 lines
Fixed status mapping, added error report sheet

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

  ViewVC Help
Powered by ViewVC 1.1.23