/[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.3 - (hide annotations) (download)
Mon Jul 10 14:39:32 2006 UTC (18 years, 4 months ago) by pam-se
Branch: MAIN
CVS Tags: v1r5
Changes since 1.2: +195 -89 lines
Unnecessary physics branches removed

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

  ViewVC Help
Powered by ViewVC 1.1.23