/[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.6 - (hide annotations) (download)
Fri Jan 5 16:16:09 2007 UTC (17 years, 11 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v2r02
Changes since 1.5: +22 -8 lines
change histogram of canvas 3 of S4_QL from TH1 to TH2

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.3 ULong_t lastime, firstime;
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     double obmin=0.;
94     double obmax=0.;
95     double obt;
96     double s4rate;
97     //------to open headerfile, s4file, Trigfile and vardumpfile---------------------------/
98     TFile *file =new TFile(base.Data()) ;
99     if (!file){
100     printf("No such file in the directory has been found");
101     return;
102     }
103    
104     TTree *VarDumpTr = (TTree*)file->Get("VarDump");
105     TTree *PhysicsTr = (TTree*)file->Get("Physics");
106 pam-rm2 1.4
107 pam-rm2 1.1 TBranch *S4Br = PhysicsTr->GetBranch("S4");
108     TBranch *TriggerBr = PhysicsTr->GetBranch("Trigger");
109     TBranch *headBr = PhysicsTr->GetBranch("Header");
110     TBranch *VarDumpBr = VarDumpTr->GetBranch("VarDump");
111     TBranch *headVarDumpBr = VarDumpTr->GetBranch("Header");
112 pam-rm2 1.4
113 pam-rm2 1.1 pamela::S4::S4Event *s4e = 0;
114     pamela::EventHeader *eh = 0;
115     pamela::PscuHeader *ph = 0;
116     pamela::trigger::TriggerEvent *trige = 0;
117     pamela::VarDumpEvent *vde = 0;
118     pamela::VarDumpRecord *vdr = 0;
119    
120     PhysicsTr->SetBranchAddress("S4", &s4e);
121     PhysicsTr->SetBranchAddress("Header", &eh);
122     PhysicsTr->SetBranchAddress("Trigger", &trige);
123     VarDumpTr->SetBranchAddress("VarDump", &vde);
124    
125 pam-rm2 1.4 nevents = S4Br->GetEntries();
126 pam-rm2 1.1
127     //----------- If nevents < = 0 ---------------------------------/
128     if (nevents<=0) {
129     printf("nevents = %i \n", nevents);
130     printf(" \n");
131 pam-rm2 1.4
132 pam-rm2 1.1 TCanvas *canvas4 = new TCanvas("No entries", "No entries ", 400, 200);
133     canvas4->SetFillColor(10);
134     canvas4->cd();
135    
136     TLatex *l = new TLatex();
137     l->SetTextAlign(12);
138     l->SetTextSize(0.15);
139     l->SetTextColor(2);
140     noentries.str("");
141     noentries<< "S4_QL:";
142     l->DrawLatex(0.05, 0.7, noentries.str().c_str());
143     noentries.str("");
144     noentries<< "No entries for this files";
145     l->DrawLatex(0.05, 0.5, noentries.str().c_str());
146 pam-rm2 1.4
147 pam-rm2 1.1 if (outDir == "./") {
148     oss.str("");
149     oss << filename.Data() << "_S4_QL." << format.Data();
150     } else {
151     oss.str("");
152     oss << outDir.Data() << filename.Data() << "_S4_QL." << format.Data();
153     }
154 pam-rm2 1.4
155 pam-rm2 1.1 canvas4->Update();
156     canvas4->SaveAs(oss.str().c_str());
157 pam-rm2 1.4
158 pam-rm2 1.1 return;
159     }
160 pam-rm2 1.4 const Int_t ev = nevents;
161     TString trcss[ev];
162     //-------to set trigger configuration---------------------------------//
163     for (Int_t ll = 0; ll < nevents; ll++){
164     TriggerBr->GetEntry(ll);
165 pam-rm2 1.1 trigconf = trige->trigconf;
166     trc = 0;
167     if ( trigconf & (1<<0) ) trc = "TOF1";
168     if ( trigconf & (1<<1) ) {
169     if (trc==0) trc= "TOF2";
170     else trc = Form("%s-TOF2",trc);
171     }
172     if ( trigconf & (1<<2) ) {
173     if (trc==0) trc= "TOF3";
174     else trc = Form("%s-TOF3",trc);
175     }
176     if ( trigconf & (1<<3) ) {
177     if (trc==0) trc= "TOF4";
178     else trc = Form("%s-TOF4",trc);
179 pam-rm2 1.4 }
180 pam-rm2 1.1 if ( trigconf & (1<<4) ) {
181     if (trc==0) trc= "TOF5";
182     else trc = Form("%s-TOF5",trc);
183 pam-rm2 1.4 }
184 pam-rm2 1.1 if ( trigconf & (1<<5) ) {
185     if (trc==0) trc= "TOF6";
186     else trc = Form("%s-TOF6",trc);
187 pam-rm2 1.4 }
188 pam-rm2 1.1 if ( trigconf & (1<<6) ) {
189     if (trc==0) trc= "TOF7";
190     else trc = Form("%s-TOF7",trc);
191     }
192     if ( trigconf & (1<<7) ) {
193     if (trc==0) trc= "S4";
194     else trc = Form("%s-S4",trc);
195     }
196 pam-rm2 1.4 if ( trigconf & (1<<8) ) {
197     if (trc==0) trc= "CALO";
198     else trc = Form("%s-CALO",trc);
199     }
200     if ( trigconf & (1<<9) ) {
201     if (trc==0) trc= "CALIB_ON";
202     else trc = Form("%s-CALIB_ON",trc);
203     }
204     trcs = "";
205     trcs = trc;
206     if (ll==0){
207     trcss[0]=trcs;
208     j=j+1;
209     }
210     if (trcs!=trcss[j-1] && ll>0){
211     trcss[j]=trcs;
212     j=j+1;
213     }
214     //cout<<i<<"\n";
215     //cout<<nevents<<"\n\n";
216 pam-rm2 1.1 }
217 pam-rm2 1.5 //--------------------------//
218 pam-rm2 1.1 for(Int_t k=0; k<31; k++){
219     for(Int_t p=0; p<j ; p++){
220     if(trgconf[k]==trcss[p]){
221     trcsstot[k]=trgconf[k];
222     }
223     }
224     }
225     for(Int_t k=0; k<31; k++){
226     if(trcsstot[k]!= "")
227     trcsstot2=trcsstot2+"/"+ trcsstot[k];
228     }
229 pam-rm2 1.4
230 pam-rm2 1.1 //---------to search S4 threshold and convert it into char (hexadecimal value)--------//
231     vardumpentries = VarDumpBr->GetEntries();
232     if(vardumpentries==0){
233     cout<<"TTree VarDump: Entries = 0"<<"\n"<<" S4 Threshold not defined"<<"\n";
234     str= " Not defined";
235     }
236     else{
237     for(Int_t k=0; k< vardumpentries; k++){
238     VarDumpBr->GetEntry(k);
239     vdr = (pamela::VarDumpRecord*)vde->Records->At(118);
240     S4_TRHadc=((vdr->VAR_VALUE)/256); //trh (number of ADC channels)
241     S4_TRHmip=S4_TRHadc*2;
242    
243     //-----to convert decimal value to TString of S4 threshold value-------//
244     if(k==0){
245     sprintf(S4_TRH, "%d" , S4_TRHmip);
246     str= S4_TRH;
247     }else{
248     sprintf(S4_TRH2, "%d" , S4_TRHmip);
249     if(!strcmp(S4_TRH, S4_TRH2)) continue;
250     str= str+"/"+S4_TRH2;
251     }
252     sprintf(S4_TRH, "%d" , S4_TRHmip);
253     }
254 pam-rm2 1.4 }
255 pam-rm2 1.1
256     //********************** First Histogram ************************************//
257 pam-rm2 1.4 TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, channels, 1, channels);
258     TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, channels, 1, channels);
259 pam-rm2 1.1
260     //********************** Second Histogram ************************************//
261 pam-rm2 1.3 headBr->GetEntry(0);
262     ph = eh->GetPscuHeader();
263     firstime = ph->GetOrbitalTime();
264    
265 pam-rm2 1.6 headBr->GetEntry(nevents);
266     ph = eh->GetPscuHeader();
267     lastime = ph->GetOrbitalTime();
268     headBr->GetEntry(nevents-100);
269     ph = eh->GetPscuHeader();
270     if(lastime-ph->GetOrbitalTime()> 100000) nevents=nevents-100;
271     int iii=0,MaxR=0;
272 pam-rm2 1.4 while(iii < nevents){
273     headBr->GetEntry(iii);
274 pam-rm2 1.2 ph = eh->GetPscuHeader();
275 pam-rm2 1.3 if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime();
276     if((ph->GetOrbitalTime()) >= 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.6 MaxR=10+2*(MaxR/2);
282    
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.6 rate->Fill(ph->GetOrbitalTime(),trige->s4calcount[0]);
315 pam-rm2 1.1 h1->Fill(s4e->S4_DATA);
316 pam-rm2 1.4 Allev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA);
317     Alltime->Fill(ph->GetOrbitalTime());
318     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)){
319 pam-rm2 1.1 h2->Fill(s4e->S4_DATA);
320 pam-rm2 1.4 S4ev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA);
321     S4time->Fill(ph->GetOrbitalTime());
322 pam-rm2 1.1 p=p+1;
323     }
324     }
325 pam-rm2 1.2 Int_t kk=0;
326 pam-rm2 1.6 Double_t Aobt=0;
327 pam-rm2 1.2 while (kk < nevents){
328     obt=0;
329     s4rate=0;
330 pam-rm2 1.6 Aobt=0;
331 pam-rm2 1.2 for(Int_t jj=kk; jj< (kk+100); jj++){
332     TriggerBr->GetEntry(jj);
333     headBr->GetEntry(jj);
334     obt = obt+(ph->GetOrbitalTime());
335     s4rate= s4rate+(trige->s4calcount[0]);
336 pam-rm2 1.6 Aobt=Aobt+((ph->GetOrbitalTime())-obmin)*(trige->s4calcount[0]);
337 pam-rm2 1.2 }
338 pam-rm2 1.6 rateline->Fill((Aobt/s4rate)+obmin,(s4rate/100));
339 pam-rm2 1.2 kk=kk+100;
340     }
341 pam-rm2 1.1
342     //****************************** Canvases *******************************//
343     //------------------- First Canvas --------------------------------//
344     TCanvas *canvas1 = new TCanvas("S4_QL_1", "S4 HISTO ", 1280, 1024);
345     canvas1->SetFillColor(10);
346     canvas1->Divide(1,2);
347    
348     TPad *all= new TPad ("","", 0, 0, 1, 1);
349     all->SetFillColor(10);
350     TPad *s4 = new TPad ("s4","s4", 0, 1, 1, 0);
351     s4->SetFillColor(10);
352     TPad *pad = new TPad("pad","pad", .30,.80,.78,.90);
353     pad->SetFillColor(10);
354     TPad *pad2 = new TPad("pad2","pad2", .30,.80,.78,.90);
355     pad2->SetFillColor(10);
356     TLatex *l = new TLatex();
357     l->SetTextAlign(12);
358     l->SetTextSize(0.35);
359     l->SetTextColor(8);
360     s4soglia.str("");
361     s4soglia << "S4_THRESHOLD: "<<str.Data()<<" MIP";
362     TLatex *ll = new TLatex();
363     ll->SetTextAlign(12);
364     ll->SetTextSize(0.35);
365     conftrig.str("");
366     conftrig<<"TRIGGER CONF: "<<trcsstot2.Data();
367     if(adcmax<=100) adcmax=120;
368    
369     canvas1->cd(1);
370     all->Draw();
371     all->cd();
372     h1->SetLineColor(kBlack);
373     h1->SetFillColor(kRed);
374     h1->GetXaxis()->SetTitle("ADC");
375     h1->GetXaxis()->CenterTitle();
376     h1->GetYaxis()->SetTitle("Number of Events");
377     h1->GetYaxis()->CenterTitle();
378     h1->Draw();
379     pad->Draw();
380     pad->cd();
381     l->DrawLatex(0.05, 0.65, s4soglia.str().c_str());
382     ll->DrawLatex(0.05, 0.15, conftrig.str().c_str());
383    
384    
385     canvas1->cd(2);
386     s4->Draw();
387     s4->cd();
388     h2->SetLineColor(kBlack);
389     h2->SetFillColor(2);
390     h2->GetXaxis()->SetTitle("ADC");
391     h2->GetXaxis()->CenterTitle();
392     h2->GetYaxis()->SetTitle("Number of Events");
393     h2->GetYaxis()->CenterTitle();
394     h2->Draw();
395     pad2->Draw();
396     pad2->cd();
397     l->DrawLatex(0.05, 0.65, s4soglia.str().c_str());
398     ll->DrawLatex(0.05, 0.15, conftrig.str().c_str());
399    
400     if (h1->GetMaximum()>0){
401     all->SetLogy();
402     all->SetLogx();
403     }
404     if (h2->GetMaximum()>0){
405     s4->SetLogy();
406     s4->SetLogx();
407     }
408     canvas1->Update();
409    
410    
411     if (outDir == "./") {
412     oss1.str("");
413     oss1 << filename.Data() << "_S4_QL_1." << format.Data();
414     } else {
415     oss1.str("");
416     oss1 << outDir.Data() << filename.Data() << "_S4_QL_1." << format.Data();
417     }
418     canvas1->SaveAs(oss1.str().c_str());
419    
420     //------------------- Second Canvas --------------------------------//
421     if (nint==0){
422     cout<<"Number of Time Interval = 0"<<"\n"<<" Set another value for input parameter DeltaTevtime "<<"\n"<<"RETURN"<<"\n";
423    
424     TCanvas *canvas2 = new TCanvas("Number of time interval=0", "Number of time interval=0", 900, 300);
425     canvas2->SetFillColor(10);
426     canvas2->cd();
427    
428     TLatex *l = new TLatex();
429     l->SetTextAlign(12);
430     l->SetTextSize(0.10);
431     l->SetTextColor(2);
432     noentries.str("");
433     noentries<< "S4_QL: Time evolution";
434     l->DrawLatex(0.05, 0.7, noentries.str().c_str());
435     noentries.str("");
436     noentries<< "Number of Time Interval = 0";
437     l->SetTextColor(1);
438     l->DrawLatex(0.05, 0.5, noentries.str().c_str());
439     noentries.str(" Set another value for input parameter DeltaTevtime");
440     noentries<< "";
441     l->DrawLatex(0.05, 0.3, noentries.str().c_str());
442    
443     if (outDir == "./") {
444     oss.str("");
445     oss << filename.Data() << "_S4_QL_2." << format.Data();
446     } else {
447     oss.str("");
448     oss << outDir.Data() << filename.Data() << "_S4_QL_2." << format.Data();
449     }
450     canvas2->Update();
451     canvas2->SaveAs(oss.str().c_str());
452    
453     return;
454     }
455     TCanvas *canvas2 = new TCanvas("S4_QL_2", "S4 - Time evolution", 1280, 1024);
456     canvas2->SetFillColor(10);
457     canvas2->Divide(1,2);
458    
459     TPad *pad3 = new TPad("pad3","pad3", .7,.1,.88,.30);
460     pad3->SetFillColor(10);
461     TPad *pad4 = new TPad("pad4","pad4", .7,.1,.88,.30);
462     pad4->SetFillColor(10);
463    
464     TLatex *l3 = new TLatex();
465     l3->SetTextAlign(12);
466     l3->SetTextSize(.3);
467     l3->SetTextColor(2);
468     buffer.str("");
469     buffer<<"DT : "<<DeltaT<<" min";
470    
471     canvas2->cd(1);
472     Allev->SetStats(kFALSE);
473     Allev->SetMarkerColor(2);
474     Allev->SetMarkerSize(.5);
475     Allev->SetMarkerStyle(21);
476     Allev->GetXaxis()->SetTitle("Time ( OBT in ms )");
477     Allev->GetXaxis()->CenterTitle();
478     Allev->GetYaxis()->SetTitle("Mean signal ( ADC )");
479     Allev->GetYaxis()->CenterTitle();
480 pam-rm2 1.4 //Allev->SetMinimum(20);
481 pam-rm2 1.1 Allev->Divide(Alltime);
482     Allev->Draw("p");
483     pad3->Draw();
484     pad3->cd();
485     l3->DrawLatex(0.05, 0.65, buffer.str().c_str());
486    
487    
488     canvas2->cd(2);
489     if(p != 0){
490     S4ev->SetStats(kFALSE);
491     S4ev->SetMarkerColor(2);
492     S4ev->SetMarkerSize(.5);
493     S4ev->SetMarkerStyle(21);
494     S4ev->GetXaxis()->SetTitle("Time ( OBT in ms )");
495     S4ev->GetXaxis()->CenterTitle();
496     S4ev->GetYaxis()->SetTitle("Mean signal ( ADC )");
497     S4ev->GetYaxis()->CenterTitle();
498     S4ev->SetMinimum(20);
499     S4ev->Divide(S4time);
500     S4ev->Draw("p");
501     pad4->Draw();
502     pad4->cd();
503     l3->DrawLatex(0.05, 0.65, buffer.str().c_str());
504     }else{
505     TLatex *l = new TLatex();
506     l->SetTextAlign(12);
507     l->SetTextSize(0.07);
508     l->SetTextColor(2);
509     noentries.str("");
510     noentries<< "S4_QL: Time evolution";
511     l->DrawLatex(0.06, 0.6, noentries.str().c_str());
512     noentries.str("");
513     noentries<< "No S4 triggered events.";
514     l->SetTextColor(1);
515     l->DrawLatex(0.06, 0.5, noentries.str().c_str());
516     }
517    
518     if (outDir == "./") {
519     oss2.str("");
520     oss2 << filename.Data() << "_S4_QL_2." << format.Data();
521     } else {
522     oss2.str("");
523     oss2 << outDir.Data() << filename.Data() << "_S4_QL_2." << format.Data();
524     }
525     canvas2->SaveAs(oss2.str().c_str());
526    
527     //------------------- Third Canvas --------------------------------//
528     TCanvas *canvas3 = new TCanvas("S4 - Rate", "S4 - Rate", 1280, 1024);
529     canvas3->SetFillColor(10);
530     canvas3->Divide(1,2);
531    
532     canvas3->cd(1);
533     rate->SetStats(kFALSE);
534     rate->SetMarkerColor(2);
535     rate->SetMarkerSize(.5);
536     rate->SetMarkerStyle(21);
537     rate->GetXaxis()->SetTitle("Time ( OBT in ms )");
538     rate->GetXaxis()->CenterTitle();
539     rate->GetYaxis()->SetTitle("S4 rate (Hz)");
540     rate->GetYaxis()->CenterTitle();
541     if(rate->GetMaximum() > 1000) gPad->SetLogy();
542     rate->Draw("9p");
543    
544     canvas3->cd(2);
545     rateline->SetStats(kFALSE);
546     rateline->SetMarkerColor(4);
547     rateline->SetMarkerSize(.5);
548     rateline->SetMarkerStyle(21);
549     rateline->GetXaxis()->SetTitle("Time ( OBT in ms )");
550     rateline->GetXaxis()->CenterTitle();
551     rateline->GetYaxis()->SetTitle("S4 rate (Hz)");
552     rateline->GetYaxis()->CenterTitle();
553     rateline->SetMaximum(rate->GetMaximum());
554     if(rateline->GetMaximum() > 1000) gPad->SetLogy();
555     rateline->Draw("9p");
556    
557    
558     if (outDir == "./") {
559     oss3.str("");
560     oss3 << filename.Data() << "_S4_QL_3." << format.Data();
561     } else {
562     oss3.str("");
563     oss3 << outDir.Data() << filename.Data() << "_S4_QL_3." << format.Data();
564     }
565     canvas3->SaveAs(oss3.str().c_str());
566     file->Close();
567     }
568    
569    
570     int main(int argc, char* argv[]){
571     TString path;
572     TString outDir ="./";
573     TString format ="jpg";
574     ULong_t DeltaT =1;
575    
576    
577     if (argc < 2){
578     printf("You have to insert at least the file to analyze \n");
579     printf("Try '--help' for more information. \n");
580     exit(1);
581     }
582    
583     if (!strcmp(argv[1], "--help")){
584     printf( "Usage: ND_QL FILE [OPTION] \n");
585     printf( "\t --help Print this help and exit \n");
586     printf( "\t -outDir[path] Path where to put the output [default ./] \n");
587     printf( "\t -format[jpg|gif|ps] Format for output files [default 'jpg'] \n");
588     printf( "\t -DeltaT Time interval to control time evolution of acquired data in minute [default = 1 min] \n");
589     exit(1);
590     }
591    
592     path=argv[1];
593    
594     for (int i = 2; i < argc; i++){
595    
596     if (!strcmp(argv[i], "-outDir")){
597     if (++i >= argc){
598     printf( "-outDir needs arguments. \n");
599     printf( "Try '--help' for more information. \n");
600     exit(1);
601     }
602     else{
603     outDir = argv[i];
604     continue;
605     }
606     }
607    
608     if (!strcmp(argv[i], "-format")){
609     if (++i >= argc){
610     printf( "-format needs arguments. \n");
611     printf( "Try '--help' for more information. \n");
612     exit(1);
613     }
614     else{
615     format = argv[i];
616     continue;
617     }
618     }
619    
620     if (!strcmp(argv[i], "-DeltaT")){
621     if (++i >= argc){
622     printf( "-DeltaT needs arguments. \n");
623     printf( "Try '--help' for more information. \n");
624     exit(1);
625     }
626     else{
627     DeltaT = atol(argv[i]);
628     continue;
629     }
630     }
631    
632    
633     }
634    
635     S4_QL(argv[1], outDir, format, DeltaT);
636    
637     }
638    

  ViewVC Help
Powered by ViewVC 1.1.23