/[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.2 - (hide annotations) (download)
Fri Jul 7 12:56:18 2006 UTC (18 years, 5 months ago) by pam-se
Branch: MAIN
CVS Tags: v1r04, v1r4
Changes since 1.1: +863 -1953 lines
quicklook script rewritten

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

  ViewVC Help
Powered by ViewVC 1.1.23