| 1 | void runlivetime(TString filename)
|
|---|
| 2 | {
|
|---|
| 3 |
|
|---|
| 4 | gROOT->Reset();
|
|---|
| 5 | gStyle->SetCanvasColor(0);
|
|---|
| 6 | gStyle->SetCanvasBorderMode(0);
|
|---|
| 7 | gStyle->SetPadBorderMode(0);
|
|---|
| 8 | gStyle->SetFrameBorderMode(0);
|
|---|
| 9 |
|
|---|
| 10 | //
|
|---|
| 11 | // Make a loop only for the ON data:
|
|---|
| 12 | //
|
|---|
| 13 |
|
|---|
| 14 | MParList plist;
|
|---|
| 15 | MTaskList tlist;
|
|---|
| 16 | plist.AddToList(&tlist);
|
|---|
| 17 |
|
|---|
| 18 | //Containers
|
|---|
| 19 |
|
|---|
| 20 | MLiveTime livetime;
|
|---|
| 21 |
|
|---|
| 22 | plist.AddToList(&livetime);
|
|---|
| 23 |
|
|---|
| 24 | //
|
|---|
| 25 | //tasks
|
|---|
| 26 | //
|
|---|
| 27 |
|
|---|
| 28 | MReadTree read("Parameters");
|
|---|
| 29 | read.DisableAutoScheme();
|
|---|
| 30 |
|
|---|
| 31 | TString tmpfile = "./runlivetime.ls.tmp";
|
|---|
| 32 | TString cmd = "ls " + filename + " > " + tmpfile;
|
|---|
| 33 | gSystem->Exec(cmd);
|
|---|
| 34 | TString tmpline;
|
|---|
| 35 | ifstream in(tmpfile);
|
|---|
| 36 | while(1)
|
|---|
| 37 | {
|
|---|
| 38 | in >> tmpline;
|
|---|
| 39 | if(in.eof())
|
|---|
| 40 | break;
|
|---|
| 41 | read.AddFile(tmpline);
|
|---|
| 42 | }
|
|---|
| 43 | TString cmd = "rm " + tmpfile;
|
|---|
| 44 | gSystem->Exec(cmd);
|
|---|
| 45 |
|
|---|
| 46 | Double_t timebin = 500.; //[sec]
|
|---|
| 47 | MLiveTimeCalc livetimecalc;
|
|---|
| 48 | livetimecalc.SetRealTimeBinSize(timebin);
|
|---|
| 49 |
|
|---|
| 50 | tlist.AddToList(&read);
|
|---|
| 51 | tlist.AddToList(&livetimecalc);
|
|---|
| 52 |
|
|---|
| 53 | //
|
|---|
| 54 | // Create and setup the eventloop
|
|---|
| 55 | //
|
|---|
| 56 | MEvtLoop loop;
|
|---|
| 57 | loop.SetParList(&plist);
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | if (!loop.Eventloop())
|
|---|
| 61 | return;
|
|---|
| 62 |
|
|---|
| 63 | // if (!loop.PreProcess())
|
|---|
| 64 | // return;
|
|---|
| 65 |
|
|---|
| 66 | // while(loop.Process())
|
|---|
| 67 | // {}
|
|---|
| 68 |
|
|---|
| 69 | // loop.PostProcess();
|
|---|
| 70 |
|
|---|
| 71 | tlist.PrintStatistics();
|
|---|
| 72 |
|
|---|
| 73 | UInt_t numbertimebins = livetime.GetNumberTimeBins();
|
|---|
| 74 | TArrayD y(numbertimebins);
|
|---|
| 75 | TArrayD erry(numbertimebins);
|
|---|
| 76 |
|
|---|
| 77 | for (UInt_t bin=0; bin<numbertimebins; bin++)
|
|---|
| 78 | {
|
|---|
| 79 | y[bin] = bin+1.;
|
|---|
| 80 | erry[bin] = 0.;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | TCanvas *c0 = new TCanvas;
|
|---|
| 84 | c0->cd(1);
|
|---|
| 85 | TGraphErrors *graph = new TGraphErrors(numbertimebins,livetime.GetMeanRealTimeArray(),y.GetArray(),livetime.GetWidthRealTimeArray(),erry.GetArray());
|
|---|
| 86 | graph->SetTitle("");
|
|---|
| 87 | graph->SetMinimum(0.);
|
|---|
| 88 | graph->SetMarkerStyle(21);
|
|---|
| 89 | graph->SetMarkerSize(0.03);
|
|---|
| 90 | graph->Draw("AP");
|
|---|
| 91 | graph->GetXaxis()->SetLabelSize(0.03);
|
|---|
| 92 | graph->GetXaxis()->SetTitle("Time [MJD]");
|
|---|
| 93 | // lightcurvegraph->GetXaxis()->SetTimeDisplay(1);
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | }
|
|---|