1 | /* ======================================================================== *\!
|
---|
2 | ! Author(s): Javier Rico
|
---|
3 | \* ======================================================================== */
|
---|
4 |
|
---|
5 | void observationTime(
|
---|
6 | Int_t iniRun=0,
|
---|
7 | Int_t finRun=99999,
|
---|
8 | TString filename="/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/AllCrabNebula_3015_kDefault_MispE.root",
|
---|
9 | )
|
---|
10 | {
|
---|
11 | // define files, chains...
|
---|
12 | TChain* t= new TChain("Parameters");
|
---|
13 | t->Add(filename);
|
---|
14 |
|
---|
15 | // define aliases
|
---|
16 | t->SetAlias("run", "MRawRunHeader.fRunNumber");
|
---|
17 | t->SetAlias("runiniT", "MRawRunHeader.fRunStart.fTime.fMilliSec/1000");
|
---|
18 | t->SetAlias("runfinT", "MRawRunHeader.fRunStop.fTime.fMilliSec/1000");
|
---|
19 |
|
---|
20 | TH1I* hrun = new TH1I("hrun","",finRun-iniRun+1,iniRun,finRun+1);
|
---|
21 | TH1I* hent = new TH1I("hent","",finRun-iniRun+1,iniRun,finRun+1);
|
---|
22 |
|
---|
23 | const char varcut[512];
|
---|
24 | const char runcut[512];
|
---|
25 | sprintf(runcut,"(run>=%d && run<=%d)",iniRun,finRun);
|
---|
26 | sprintf(varcut,"%s*(runfinT-runiniT)",runcut);
|
---|
27 |
|
---|
28 | t->Draw("run>>hrun",runcut);
|
---|
29 | t->Draw("run>>hent",varcut);
|
---|
30 |
|
---|
31 | Float_t seconds=0;
|
---|
32 | for(Int_t irun = 1; irun<=finRun-iniRun+1; irun++)
|
---|
33 | {
|
---|
34 | Int_t nev;
|
---|
35 | if(nev=hrun->GetBinContent(irun))
|
---|
36 | {
|
---|
37 | Float_t time = hent->GetBinContent(irun)/nev;
|
---|
38 | seconds += time;
|
---|
39 | cout << "run " << iniRun-1+irun << ", " << time << " seconds" << endl;
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | cout << "Total observation time = " << seconds << " seconds = " << seconds/60. << " minutes = " << seconds/3600. << " hours" << endl;
|
---|
44 | delete hrun;
|
---|
45 | delete hent;
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|