/[PAMELA software]/quicklook/QLflightS4_ND/S4_QL.cpp
ViewVC logotype

Annotation of /quicklook/QLflightS4_ND/S4_QL.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Mon Mar 12 14:32:46 2007 UTC (17 years, 8 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v2r04, v2r03, HEAD
Changes since 1.6: +24 -20 lines
fixed OBT bug

1 pam-rm2 1.1
2     /*
3     * S4 Quick Look
4     * Author Marcelli-Malvezzi
5     * Version 1.00 - March 2006
6     *
7     * Description - The aim of S4 QL software is to monitor the bahaviour of this detector.
8     * It creates three canvases: the first one contains the histogram of S4 data, the second one
9     * is relative to the time behaviour of collected data while the last shows S4 rate
10     * (information from trigger Packet).
11     * See documentation for a more detailed description of the output.
12     *
13     *
14     * Parameters:
15     * TSTring base - the path to the root directory for the specific Pamela unpack session
16     * There is no default value, without this input the program will not run
17     * TString outDir - the path where to save the output image (Default = ./)
18     * TString format - the format which will be used fo rsave the produced images (Default = "jpg")
19     * Float_t DeltaT - the time interval in minute for calculation of average S4 data for minute,
20     * see S4_QL_2 plot (Default = 1 minute)
21     *
22     *
23     * Version 1.1 - June 2006
24     * Fixed bugs: the vector "trcss" was inizilized to have dimension 10, but for files with large number of events this
25     * is not true; now this vector is inizialized at 100.
26     *
27     * the threshold at which S4 is set and the trigger configuration can change in the file; all these changes are reported
28     * in a pad
29     *
30     * for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms
31 pam-rm2 1.4 *
32     * Version 2.0 - September 2006
33     * Fixed bugs: changed the number of bin in the "rate" histograms and the size of the string vector trcss
34 pam-rm2 1.1 *******/
35    
36    
37     #include <iostream>
38     #include <fstream>
39     #include <sstream>
40     #include <math.h>
41     #include "TStyle.h"
42     #include "TFile.h"
43     #include "TList.h"
44     #include "TTree.h"
45     #include "TLatex.h"
46     #include "TObjString.h"
47     #include "TCanvas.h"
48     #include "TGraph.h"
49     #include "TH1F.h"
50     #include "TF1.h"
51 pam-rm2 1.6 #include "TH2F.h"
52     #include "TF2.h"
53 pam-rm2 1.1 #include "TGaxis.h"
54     #include "TString.h"
55     #include "TPaveText.h"
56     #include "EventHeader.h"
57     #include "PscuHeader.h"
58     #include "TMultiGraph.h"
59     #include "physics/S4/S4Event.h"
60     #include "varDump/VarDumpEvent.h"
61     #include "varDump/VarDumpRecord.h"
62     #include "physics/trigger/TriggerEvent.h"
63    
64     using namespace std;
65    
66     void S4_QL(TString base, TString outDir, TString format, ULong_t DeltaT){ //DeltaT in minute
67 pam-rm2 1.4
68 pam-rm2 1.1 //------ Variables initialization ---------/
69     Int_t tmpSize;
70     ULong_t mintime, maxtime;
71     Int_t adcmax;
72     Int_t j=0;
73     Int_t S4_TRHadc;
74     Int_t S4_TRHmip;
75     TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString();
76     filename = ((TObjString*)filename.Tokenize('.')->First())->GetString();
77     char *trc;
78 pam-rm2 1.6 TString trcs,ciao;
79 pam-rm2 1.1 TString str;
80     TString trcsstot[31];
81     TString trcsstot2;
82 pam-rm2 1.4
83 pam-rm2 1.1 TString trgconf[31]={"TOF1","TOF2","TOF3","TOF4","TOF5","TOF6","TOF7","S4","CALO","CALO-S4","TOF1-S4","TOF2-S4","TOF3-S4","TOF4-S4","TOF5-S4","TOF6-S4","TOF7-S4","TOF1-CALO","TOF2-CALO","TOF3-CALO","TOF4-CALO","TOF5-CALO","TOF6-CALO","TOF7-CALO","TOF1-CALO-S4","TOF2-CALO-S4","TOF3-CALO-S4","TOF4-CALO-S4","TOF5-CALO-S4","TOF6-CALO-S4","TOF7-CALO-S4",};
84     stringstream oss, oss1, oss2, oss3, s4soglia, buffer, conftrig, noentries;
85 pam-rm2 1.7 ULong_t lastime, firstime,obmin,obmax,obt;
86 pam-rm2 1.1 Int_t vardumpentries = 0;
87 pam-rm2 1.4 Int_t channels = 4096;
88 pam-rm2 1.1 char S4_TRH[10];
89     char S4_TRH2[10];
90     Int_t trigconf = 0;
91     Long64_t nevents;
92     string title;
93 pam-rm2 1.7
94 pam-rm2 1.1 double s4rate;
95     //------to open headerfile, s4file, Trigfile and vardumpfile---------------------------/
96     TFile *file =new TFile(base.Data()) ;
97     if (!file){
98     printf("No such file in the directory has been found");
99     return;
100     }
101    
102     TTree *VarDumpTr = (TTree*)file->Get("VarDump");
103     TTree *PhysicsTr = (TTree*)file->Get("Physics");
104 pam-rm2 1.4
105 pam-rm2 1.1 TBranch *S4Br = PhysicsTr->GetBranch("S4");
106     TBranch *TriggerBr = PhysicsTr->GetBranch("Trigger");
107     TBranch *headBr = PhysicsTr->GetBranch("Header");
108     TBranch *VarDumpBr = VarDumpTr->GetBranch("VarDump");
109     TBranch *headVarDumpBr = VarDumpTr->GetBranch("Header");
110 pam-rm2 1.4
111 pam-rm2 1.1 pamela::S4::S4Event *s4e = 0;
112     pamela::EventHeader *eh = 0;
113     pamela::PscuHeader *ph = 0;
114     pamela::trigger::TriggerEvent *trige = 0;
115     pamela::VarDumpEvent *vde = 0;
116     pamela::VarDumpRecord *vdr = 0;
117    
118     PhysicsTr->SetBranchAddress("S4", &s4e);
119     PhysicsTr->SetBranchAddress("Header", &eh);
120     PhysicsTr->SetBranchAddress("Trigger", &trige);
121     VarDumpTr->SetBranchAddress("VarDump", &vde);
122    
123 pam-rm2 1.4 nevents = S4Br->GetEntries();
124 pam-rm2 1.1
125     //----------- If nevents < = 0 ---------------------------------/
126     if (nevents<=0) {
127     printf("nevents = %i \n", nevents);
128     printf(" \n");
129 pam-rm2 1.4
130 pam-rm2 1.1 TCanvas *canvas4 = new TCanvas("No entries", "No entries ", 400, 200);
131     canvas4->SetFillColor(10);
132     canvas4->cd();
133    
134     TLatex *l = new TLatex();
135     l->SetTextAlign(12);
136     l->SetTextSize(0.15);
137     l->SetTextColor(2);
138     noentries.str("");
139     noentries<< "S4_QL:";
140     l->DrawLatex(0.05, 0.7, noentries.str().c_str());
141     noentries.str("");
142     noentries<< "No entries for this files";
143     l->DrawLatex(0.05, 0.5, noentries.str().c_str());
144 pam-rm2 1.4
145 pam-rm2 1.1 if (outDir == "./") {
146     oss.str("");
147     oss << filename.Data() << "_S4_QL." << format.Data();
148     } else {
149     oss.str("");
150     oss << outDir.Data() << filename.Data() << "_S4_QL." << format.Data();
151     }
152 pam-rm2 1.4
153 pam-rm2 1.1 canvas4->Update();
154     canvas4->SaveAs(oss.str().c_str());
155 pam-rm2 1.4
156 pam-rm2 1.1 return;
157     }
158 pam-rm2 1.4 const Int_t ev = nevents;
159     TString trcss[ev];
160     //-------to set trigger configuration---------------------------------//
161     for (Int_t ll = 0; ll < nevents; ll++){
162     TriggerBr->GetEntry(ll);
163 pam-rm2 1.1 trigconf = trige->trigconf;
164     trc = 0;
165     if ( trigconf & (1<<0) ) trc = "TOF1";
166     if ( trigconf & (1<<1) ) {
167     if (trc==0) trc= "TOF2";
168     else trc = Form("%s-TOF2",trc);
169     }
170     if ( trigconf & (1<<2) ) {
171     if (trc==0) trc= "TOF3";
172     else trc = Form("%s-TOF3",trc);
173     }
174     if ( trigconf & (1<<3) ) {
175     if (trc==0) trc= "TOF4";
176     else trc = Form("%s-TOF4",trc);
177 pam-rm2 1.4 }
178 pam-rm2 1.1 if ( trigconf & (1<<4) ) {
179     if (trc==0) trc= "TOF5";
180     else trc = Form("%s-TOF5",trc);
181 pam-rm2 1.4 }
182 pam-rm2 1.1 if ( trigconf & (1<<5) ) {
183     if (trc==0) trc= "TOF6";
184     else trc = Form("%s-TOF6",trc);
185 pam-rm2 1.4 }
186 pam-rm2 1.1 if ( trigconf & (1<<6) ) {
187     if (trc==0) trc= "TOF7";
188     else trc = Form("%s-TOF7",trc);
189     }
190     if ( trigconf & (1<<7) ) {
191     if (trc==0) trc= "S4";
192     else trc = Form("%s-S4",trc);
193     }
194 pam-rm2 1.4 if ( trigconf & (1<<8) ) {
195     if (trc==0) trc= "CALO";
196     else trc = Form("%s-CALO",trc);
197     }
198     if ( trigconf & (1<<9) ) {
199     if (trc==0) trc= "CALIB_ON";
200     else trc = Form("%s-CALIB_ON",trc);
201     }
202     trcs = "";
203     trcs = trc;
204     if (ll==0){
205     trcss[0]=trcs;
206     j=j+1;
207     }
208     if (trcs!=trcss[j-1] && ll>0){
209     trcss[j]=trcs;
210     j=j+1;
211     }
212     //cout<<i<<"\n";
213     //cout<<nevents<<"\n\n";
214 pam-rm2 1.1 }
215 pam-rm2 1.5 //--------------------------//
216 pam-rm2 1.1 for(Int_t k=0; k<31; k++){
217     for(Int_t p=0; p<j ; p++){
218     if(trgconf[k]==trcss[p]){
219     trcsstot[k]=trgconf[k];
220     }
221     }
222     }
223     for(Int_t k=0; k<31; k++){
224     if(trcsstot[k]!= "")
225     trcsstot2=trcsstot2+"/"+ trcsstot[k];
226     }
227 pam-rm2 1.4
228 pam-rm2 1.1 //---------to search S4 threshold and convert it into char (hexadecimal value)--------//
229     vardumpentries = VarDumpBr->GetEntries();
230     if(vardumpentries==0){
231     cout<<"TTree VarDump: Entries = 0"<<"\n"<<" S4 Threshold not defined"<<"\n";
232     str= " Not defined";
233     }
234     else{
235     for(Int_t k=0; k< vardumpentries; k++){
236     VarDumpBr->GetEntry(k);
237     vdr = (pamela::VarDumpRecord*)vde->Records->At(118);
238     S4_TRHadc=((vdr->VAR_VALUE)/256); //trh (number of ADC channels)
239     S4_TRHmip=S4_TRHadc*2;
240    
241     //-----to convert decimal value to TString of S4 threshold value-------//
242     if(k==0){
243     sprintf(S4_TRH, "%d" , S4_TRHmip);
244     str= S4_TRH;
245     }else{
246     sprintf(S4_TRH2, "%d" , S4_TRHmip);
247     if(!strcmp(S4_TRH, S4_TRH2)) continue;
248     str= str+"/"+S4_TRH2;
249     }
250     sprintf(S4_TRH, "%d" , S4_TRHmip);
251     }
252 pam-rm2 1.4 }
253 pam-rm2 1.1
254     //********************** First Histogram ************************************//
255 pam-rm2 1.4 TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, channels, 1, channels);
256     TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, channels, 1, channels);
257 pam-rm2 1.1
258     //********************** Second Histogram ************************************//
259 pam-rm2 1.3 headBr->GetEntry(0);
260     ph = eh->GetPscuHeader();
261     firstime = ph->GetOrbitalTime();
262    
263 pam-rm2 1.6 headBr->GetEntry(nevents);
264     ph = eh->GetPscuHeader();
265     lastime = ph->GetOrbitalTime();
266     headBr->GetEntry(nevents-100);
267     ph = eh->GetPscuHeader();
268 pam-rm2 1.7 obt=ph->GetOrbitalTime();
269     if(lastime-obt> 100000)nevents=nevents-100;
270 pam-rm2 1.6 int iii=0,MaxR=0;
271 pam-rm2 1.4 while(iii < nevents){
272     headBr->GetEntry(iii);
273 pam-rm2 1.2 ph = eh->GetPscuHeader();
274 pam-rm2 1.7 obt=ph->GetOrbitalTime();
275     if(obt<=firstime) firstime=ph->GetOrbitalTime();
276     if(obt>=lastime) lastime=ph->GetOrbitalTime();
277 pam-rm2 1.6 TriggerBr->GetEntry(iii);
278     if(trige->s4calcount[0]>MaxR)MaxR=trige->s4calcount[0];
279 pam-rm2 1.4 iii++;
280 pam-rm2 1.2 }
281 pam-rm2 1.7 MaxR=2*(1.05*MaxR/2);
282 pam-rm2 1.6
283 pam-rm2 1.1 obmin=firstime;
284     obmax=lastime;
285     const ULong_t nint=(((lastime-firstime)/(DeltaT*60000)));
286     const Int_t size = (Int_t)(nint+1);
287    
288     TH1F *Allev = new TH1F("Mean signal from S4-all events", filename+": Mean signal from S4 (all triggered events)", size, obmin, obmax);
289     TH1F *Alltime = new TH1F("Mean signal from S4-all events", filename+": Mean signal from S4 (all triggered events)", size, obmin, obmax);
290     TH1F *S4ev = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax);
291     TH1F *S4time = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax);
292    
293     //********************** Third Histogram ************************************//
294     title="";
295     title=filename+": S4 rate from Trigger Packet";
296    
297 pam-rm2 1.4 const ULong_t nint2=(lastime-firstime)/10000;
298     const Int_t size2 = (Int_t)((nint2+1)); // one bin every 10 second
299     const ULong_t nint3=(lastime-firstime)/1000;
300     const Int_t size3 = (Int_t)((nint3+1)); // one bin every 1 second
301 pam-rm2 1.6 const Int_t Rbin = MaxR/2;
302     TH2I *rate= new TH2I(title.c_str(), title.c_str(), size2,obmin,obmax,Rbin,0,MaxR);
303     TH2I *rateline= new TH2I(filename+". S4 rate from Trigger Packet: mean value over 100 events", filename+". S4 rate from Trigger Packet: mean value over 100 events",size3,obmin,obmax,Rbin,0,MaxR);
304 pam-rm2 1.1
305     //------------------------------------------------------------------------------------------------------------------
306     //------- fill histograms ---------//
307     Int_t n=0, p=0;
308     for (Int_t i = 0; i < nevents; i++){
309     TriggerBr->GetEntry(i);
310     headBr->GetEntry(i);
311     S4Br->GetEntry(i);
312     ph = eh->GetPscuHeader();
313     if (s4e->unpackError == 1 && (s4e->S4_DATA)==0) continue;
314 pam-rm2 1.7 obt=ph->GetOrbitalTime();
315     rate->Fill(obt,trige->s4calcount[0]);
316 pam-rm2 1.1 h1->Fill(s4e->S4_DATA);
317 pam-rm2 1.7 Allev->Fill(obt,s4e->S4_DATA);
318     Alltime->Fill(obt);
319 pam-rm2 1.4 if ((trige->patterntrig[0] == 0)&&(trige->patterntrig[1] != 0)&&(trige->patterntrig[2] == 0)&&(trige->patterntrig[3] == 0)&&(trige->patterntrig[4] == 0)&&(trige->patterntrig[5] == 0)){
320 pam-rm2 1.1 h2->Fill(s4e->S4_DATA);
321 pam-rm2 1.7 S4ev->Fill(obt,s4e->S4_DATA);
322     S4time->Fill(obt);
323 pam-rm2 1.1 p=p+1;
324     }
325     }
326 pam-rm2 1.2 Int_t kk=0;
327 pam-rm2 1.7 ULong_t Aobt=0;
328 pam-rm2 1.2 while (kk < nevents){
329     obt=0;
330     s4rate=0;
331 pam-rm2 1.6 Aobt=0;
332 pam-rm2 1.2 for(Int_t jj=kk; jj< (kk+100); jj++){
333     TriggerBr->GetEntry(jj);
334     headBr->GetEntry(jj);
335 pam-rm2 1.7 obt=ph->GetOrbitalTime();
336 pam-rm2 1.2 s4rate= s4rate+(trige->s4calcount[0]);
337 pam-rm2 1.7 Aobt=Aobt-obmin+obt;
338     //*(trige->s4calcount[0])/1000;
339 pam-rm2 1.2 }
340 pam-rm2 1.7 Aobt=Aobt/100;
341     Aobt=Aobt+obmin;
342     rateline->Fill(Aobt,s4rate/100);
343     //rateline->Fill(ph->GetOrbitalTime(),(s4rate/100));
344 pam-rm2 1.2 kk=kk+100;
345     }
346 pam-rm2 1.1
347     //****************************** Canvases *******************************//
348     //------------------- First Canvas --------------------------------//
349     TCanvas *canvas1 = new TCanvas("S4_QL_1", "S4 HISTO ", 1280, 1024);
350     canvas1->SetFillColor(10);
351     canvas1->Divide(1,2);
352    
353     TPad *all= new TPad ("","", 0, 0, 1, 1);
354     all->SetFillColor(10);
355     TPad *s4 = new TPad ("s4","s4", 0, 1, 1, 0);
356     s4->SetFillColor(10);
357     TPad *pad = new TPad("pad","pad", .30,.80,.78,.90);
358     pad->SetFillColor(10);
359     TPad *pad2 = new TPad("pad2","pad2", .30,.80,.78,.90);
360     pad2->SetFillColor(10);
361     TLatex *l = new TLatex();
362     l->SetTextAlign(12);
363     l->SetTextSize(0.35);
364     l->SetTextColor(8);
365     s4soglia.str("");
366     s4soglia << "S4_THRESHOLD: "<<str.Data()<<" MIP";
367     TLatex *ll = new TLatex();
368     ll->SetTextAlign(12);
369     ll->SetTextSize(0.35);
370     conftrig.str("");
371     conftrig<<"TRIGGER CONF: "<<trcsstot2.Data();
372     if(adcmax<=100) adcmax=120;
373    
374     canvas1->cd(1);
375     all->Draw();
376     all->cd();
377     h1->SetLineColor(kBlack);
378     h1->SetFillColor(kRed);
379     h1->GetXaxis()->SetTitle("ADC");
380     h1->GetXaxis()->CenterTitle();
381     h1->GetYaxis()->SetTitle("Number of Events");
382     h1->GetYaxis()->CenterTitle();
383     h1->Draw();
384     pad->Draw();
385     pad->cd();
386     l->DrawLatex(0.05, 0.65, s4soglia.str().c_str());
387     ll->DrawLatex(0.05, 0.15, conftrig.str().c_str());
388    
389    
390     canvas1->cd(2);
391     s4->Draw();
392     s4->cd();
393     h2->SetLineColor(kBlack);
394     h2->SetFillColor(2);
395     h2->GetXaxis()->SetTitle("ADC");
396     h2->GetXaxis()->CenterTitle();
397     h2->GetYaxis()->SetTitle("Number of Events");
398     h2->GetYaxis()->CenterTitle();
399     h2->Draw();
400     pad2->Draw();
401     pad2->cd();
402     l->DrawLatex(0.05, 0.65, s4soglia.str().c_str());
403     ll->DrawLatex(0.05, 0.15, conftrig.str().c_str());
404    
405     if (h1->GetMaximum()>0){
406     all->SetLogy();
407     all->SetLogx();
408     }
409     if (h2->GetMaximum()>0){
410     s4->SetLogy();
411     s4->SetLogx();
412     }
413     canvas1->Update();
414    
415    
416     if (outDir == "./") {
417     oss1.str("");
418     oss1 << filename.Data() << "_S4_QL_1." << format.Data();
419     } else {
420     oss1.str("");
421     oss1 << outDir.Data() << filename.Data() << "_S4_QL_1." << format.Data();
422     }
423     canvas1->SaveAs(oss1.str().c_str());
424    
425     //------------------- Second Canvas --------------------------------//
426     if (nint==0){
427     cout<<"Number of Time Interval = 0"<<"\n"<<" Set another value for input parameter DeltaTevtime "<<"\n"<<"RETURN"<<"\n";
428    
429     TCanvas *canvas2 = new TCanvas("Number of time interval=0", "Number of time interval=0", 900, 300);
430     canvas2->SetFillColor(10);
431     canvas2->cd();
432    
433     TLatex *l = new TLatex();
434     l->SetTextAlign(12);
435     l->SetTextSize(0.10);
436     l->SetTextColor(2);
437     noentries.str("");
438     noentries<< "S4_QL: Time evolution";
439     l->DrawLatex(0.05, 0.7, noentries.str().c_str());
440     noentries.str("");
441     noentries<< "Number of Time Interval = 0";
442     l->SetTextColor(1);
443     l->DrawLatex(0.05, 0.5, noentries.str().c_str());
444     noentries.str(" Set another value for input parameter DeltaTevtime");
445     noentries<< "";
446     l->DrawLatex(0.05, 0.3, noentries.str().c_str());
447    
448     if (outDir == "./") {
449     oss.str("");
450     oss << filename.Data() << "_S4_QL_2." << format.Data();
451     } else {
452     oss.str("");
453     oss << outDir.Data() << filename.Data() << "_S4_QL_2." << format.Data();
454     }
455     canvas2->Update();
456     canvas2->SaveAs(oss.str().c_str());
457    
458     return;
459     }
460     TCanvas *canvas2 = new TCanvas("S4_QL_2", "S4 - Time evolution", 1280, 1024);
461     canvas2->SetFillColor(10);
462     canvas2->Divide(1,2);
463    
464     TPad *pad3 = new TPad("pad3","pad3", .7,.1,.88,.30);
465     pad3->SetFillColor(10);
466     TPad *pad4 = new TPad("pad4","pad4", .7,.1,.88,.30);
467     pad4->SetFillColor(10);
468    
469     TLatex *l3 = new TLatex();
470     l3->SetTextAlign(12);
471     l3->SetTextSize(.3);
472     l3->SetTextColor(2);
473     buffer.str("");
474     buffer<<"DT : "<<DeltaT<<" min";
475    
476     canvas2->cd(1);
477     Allev->SetStats(kFALSE);
478     Allev->SetMarkerColor(2);
479     Allev->SetMarkerSize(.5);
480     Allev->SetMarkerStyle(21);
481     Allev->GetXaxis()->SetTitle("Time ( OBT in ms )");
482     Allev->GetXaxis()->CenterTitle();
483     Allev->GetYaxis()->SetTitle("Mean signal ( ADC )");
484     Allev->GetYaxis()->CenterTitle();
485 pam-rm2 1.4 //Allev->SetMinimum(20);
486 pam-rm2 1.1 Allev->Divide(Alltime);
487     Allev->Draw("p");
488     pad3->Draw();
489     pad3->cd();
490     l3->DrawLatex(0.05, 0.65, buffer.str().c_str());
491    
492    
493     canvas2->cd(2);
494     if(p != 0){
495     S4ev->SetStats(kFALSE);
496     S4ev->SetMarkerColor(2);
497     S4ev->SetMarkerSize(.5);
498     S4ev->SetMarkerStyle(21);
499     S4ev->GetXaxis()->SetTitle("Time ( OBT in ms )");
500     S4ev->GetXaxis()->CenterTitle();
501     S4ev->GetYaxis()->SetTitle("Mean signal ( ADC )");
502     S4ev->GetYaxis()->CenterTitle();
503     S4ev->SetMinimum(20);
504     S4ev->Divide(S4time);
505     S4ev->Draw("p");
506     pad4->Draw();
507     pad4->cd();
508     l3->DrawLatex(0.05, 0.65, buffer.str().c_str());
509     }else{
510     TLatex *l = new TLatex();
511     l->SetTextAlign(12);
512     l->SetTextSize(0.07);
513     l->SetTextColor(2);
514     noentries.str("");
515     noentries<< "S4_QL: Time evolution";
516     l->DrawLatex(0.06, 0.6, noentries.str().c_str());
517     noentries.str("");
518     noentries<< "No S4 triggered events.";
519     l->SetTextColor(1);
520     l->DrawLatex(0.06, 0.5, noentries.str().c_str());
521     }
522    
523     if (outDir == "./") {
524     oss2.str("");
525     oss2 << filename.Data() << "_S4_QL_2." << format.Data();
526     } else {
527     oss2.str("");
528     oss2 << outDir.Data() << filename.Data() << "_S4_QL_2." << format.Data();
529     }
530     canvas2->SaveAs(oss2.str().c_str());
531    
532     //------------------- Third Canvas --------------------------------//
533     TCanvas *canvas3 = new TCanvas("S4 - Rate", "S4 - Rate", 1280, 1024);
534     canvas3->SetFillColor(10);
535     canvas3->Divide(1,2);
536    
537     canvas3->cd(1);
538     rate->SetStats(kFALSE);
539     rate->SetMarkerColor(2);
540     rate->SetMarkerSize(.5);
541     rate->SetMarkerStyle(21);
542     rate->GetXaxis()->SetTitle("Time ( OBT in ms )");
543     rate->GetXaxis()->CenterTitle();
544     rate->GetYaxis()->SetTitle("S4 rate (Hz)");
545     rate->GetYaxis()->CenterTitle();
546 pam-rm2 1.7 if(MaxR>500) gPad->SetLogy();
547 pam-rm2 1.1 rate->Draw("9p");
548    
549     canvas3->cd(2);
550     rateline->SetStats(kFALSE);
551     rateline->SetMarkerColor(4);
552     rateline->SetMarkerSize(.5);
553     rateline->SetMarkerStyle(21);
554     rateline->GetXaxis()->SetTitle("Time ( OBT in ms )");
555     rateline->GetXaxis()->CenterTitle();
556     rateline->GetYaxis()->SetTitle("S4 rate (Hz)");
557     rateline->GetYaxis()->CenterTitle();
558     rateline->SetMaximum(rate->GetMaximum());
559 pam-rm2 1.7 if(MaxR>500) gPad->SetLogy();
560 pam-rm2 1.1 rateline->Draw("9p");
561    
562    
563     if (outDir == "./") {
564     oss3.str("");
565     oss3 << filename.Data() << "_S4_QL_3." << format.Data();
566     } else {
567     oss3.str("");
568     oss3 << outDir.Data() << filename.Data() << "_S4_QL_3." << format.Data();
569     }
570     canvas3->SaveAs(oss3.str().c_str());
571     file->Close();
572     }
573    
574    
575     int main(int argc, char* argv[]){
576     TString path;
577     TString outDir ="./";
578     TString format ="jpg";
579     ULong_t DeltaT =1;
580    
581    
582     if (argc < 2){
583     printf("You have to insert at least the file to analyze \n");
584     printf("Try '--help' for more information. \n");
585     exit(1);
586     }
587    
588     if (!strcmp(argv[1], "--help")){
589     printf( "Usage: ND_QL FILE [OPTION] \n");
590     printf( "\t --help Print this help and exit \n");
591     printf( "\t -outDir[path] Path where to put the output [default ./] \n");
592     printf( "\t -format[jpg|gif|ps] Format for output files [default 'jpg'] \n");
593     printf( "\t -DeltaT Time interval to control time evolution of acquired data in minute [default = 1 min] \n");
594     exit(1);
595     }
596    
597     path=argv[1];
598    
599     for (int i = 2; i < argc; i++){
600    
601     if (!strcmp(argv[i], "-outDir")){
602     if (++i >= argc){
603     printf( "-outDir needs arguments. \n");
604     printf( "Try '--help' for more information. \n");
605     exit(1);
606     }
607     else{
608     outDir = argv[i];
609     continue;
610     }
611     }
612    
613     if (!strcmp(argv[i], "-format")){
614     if (++i >= argc){
615     printf( "-format needs arguments. \n");
616     printf( "Try '--help' for more information. \n");
617     exit(1);
618     }
619     else{
620     format = argv[i];
621     continue;
622     }
623     }
624    
625     if (!strcmp(argv[i], "-DeltaT")){
626     if (++i >= argc){
627     printf( "-DeltaT needs arguments. \n");
628     printf( "Try '--help' for more information. \n");
629     exit(1);
630     }
631     else{
632     DeltaT = atol(argv[i]);
633     continue;
634     }
635     }
636    
637    
638     }
639    
640     S4_QL(argv[1], outDir, format, DeltaT);
641    
642     }

  ViewVC Help
Powered by ViewVC 1.1.23