TB_Nearline_Watchdog_Plots.C
Go to the documentation of this file.
1 void TB_Nearline_Watchdog_Plots(int TBRunL,int TBRunH)
2 
3 {
4 
5  gStyle->SetOptStat(" ");
6  gStyle->SetLabelSize(0.025);
7  gStyle->SetLegendBorderSize(1);
8 
9  //===============================================
10  // Time Stamp for Far Detector
11  //================================================
12 
13  TDatime *TNowGMT = new TDatime; // current GMT time
14  TDatime *TNow = new TDatime; // current local time
15  TDatime *SRtime = new TDatime;
16 
17  int XNowGMT = TNowGMT->Convert(kTRUE);
18  int XNow = TNow ->Convert(kFALSE);
19 
20  int GMToffset = XNowGMT - XNow;
21  XNow = XNow - GMToffset;
22 
23  int XDayAgo = XNow - 60 * 60 * 24;
24  int XWeekAgo = XNow - 60 * 60 * 24 * 7;
25  int XMonthAgo = XNow - 60 * 60 * 24 * 30;
26  int Xsrtime = 0;
27  int time_ago = 0;
28 
29  unsigned int year = 0;
30  unsigned short int month = 0;
31  unsigned short int day = 0;
32  double Hour = 0.0;
33  double Min = 0.0;
34  int hour = 0;
35  int min = 0;
36  int sec = 0;
37 
38  unsigned int run = 0;
39  unsigned int subrun = 0;
40  UInt_t par = 0;
41 
42  unsigned int LastRun = 0;
43  unsigned int LastSR = 0;
44 
45  unsigned int yearEnd = 0;
46  unsigned short int monthEnd = 0;
47  unsigned short int dayEnd = 0;
48  double HourEnd = 0.0;
49  double SRdur = 0;
50 
51  // Root is stupid and you have to make it think that it is in a different time zone so that it will draw any
52  // plots with time on the X-axis correctly.
53  gSystem->Setenv("TZ","UTC");
54  gStyle->SetTimeOffset(0);
55 
56  //======================================
57  // Make time/date stamp for each plot
58  //======================================
59 
60  TDatime *Ttemp = new TDatime; // finish time
61  int Xfin = Ttemp->Convert();
62  TDatime *Tfinish = new TDatime(Xfin); // finish time
63  TPaveText *UpdateTextTB = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
64  UpdateTextTB->SetLineColor(0);
65  UpdateTextTB->SetFillColor(0);
66  UpdateTextTB->SetBorderSize(1);
67  UpdateTextTB->SetMargin(0.0);
68  UpdateTextTB->SetTextAlign(11);
69  // UpdateTextTB->SetTextSize(22);
70 
71  char buff1[256];
72  sprintf(buff1, "Last updated on: %s (central time)", Tfinish->AsString());
73  UpdateTextTB->AddText(buff1);
74  char buff2TB[256];
75  sprintf(buff2TB, "Last run: %d", TBRunH);
76  UpdateTextTB->AddText(buff2TB);
77 
78  //Opening a text file
79 
80  ifstream in;
81  in.open("TBNearline.txt");
82  int Runnum,RawBeamlinelarge,OnMonBeamline,OnMonBeamlineSmall,RecoBeamline,RecoBeamlineSMALL,RawDDActivity1bigfile,OnMonDDActivity1,OnMonDDActivity1small,recoDDActivity1files,recoDDActivity1SMALLfiles,TBSubrun;
83 
84  int tbrun1=TBRunL;
85  int tbrun2=TBRunH+1;
86  int nbin=TBRunH-TBRunL;
87 
88  THStack *BeamlineLarplusSmall = new THStack ("BeamlineLarplusSmall",";Run Number; Number of Subruns");
89 
90  THStack *BeamlineOnMonLarplusSmall = new THStack ("BeamlineOnMonLarplusSmall",";Run Number; Number of Subruns");
91 
92  THStack *DDALarplusSmall = new THStack ("DDALarplusSmall",";Run Number; Number of Subruns");
93 
94  THStack *DDAOnMonLarplusSmall = new THStack ("DDAOnMonLarplusSmall",";Run Number; Number of Subruns");
95 
96  TH1F *BeamlineRecofiles = new TH1F("BeamlineRecofiles","Nearline TestBeam Beamline Trigger: Last 7 days",nbin,tbrun1,tbrun2);
97 
98  TH1F *DBtbsubrun = new TH1F("DBtbsubrun","", nbin,tbrun1, tbrun2);
99 
100  TH1F *BeamlineRecoSMALLfiles = new TH1F("BeamlineRecoSMALLfiles","", nbin,tbrun1, tbrun2);
101 
102  TH1F *BeamlineOnMonfiles = new TH1F("BeamlineOnMonfiles",";Run Number; Number of Subruns", nbin , tbrun1 , tbrun2);
103 
104  TH1F *BeamlineOnMonsmallfiles = new TH1F("BeamlineOnMonsmallfiles",";Run Number; Number of Subruns", nbin , tbrun1 , tbrun2);
105 
106  TH1F *BeamlineRawlargefiles = new TH1F("BeamlineRawlargefiles","", nbin , tbrun1 , tbrun2);
107 
108  TH1F *DDARecofiles = new TH1F("DDARecofiles","Nearline TestBeam DDActitivy1 Trigger: Last 7 day", nbin , tbrun1 , tbrun2);
109 
110  TH1F *DDARecoSMALLfiles = new TH1F("DDARecoSMALLfiles","", nbin , tbrun1 , tbrun2);
111 
112  TH1F *DDARawlargefiles = new TH1F("DDARawlargefiles","", nbin , tbrun1 , tbrun2);
113 
114  TH1F *TBDDAOnMon = new TH1F("TBDDAOnMOn",";Run Number;Number of Subruns", nbin , tbrun1 , tbrun2);
115 
116  TH1F *TBDDAOnMonsmall = new TH1F("TBDDAOnMOnsmall",";Run Number;Number of Subruns", nbin , tbrun1 , tbrun2);
117 
118  TH1F *DBtbsubrun1 = new TH1F("DBtbsubrun1","", nbin,tbrun1, tbrun2);
119 
120 
121  //Reading the text file
122 
123  while(1)
124  {
125 
126  in>>Runnum>>RawBeamlinelarge>>OnMonBeamline>>OnMonBeamlineSmall>>RecoBeamline>>RecoBeamlineSMALL>>RawDDActivity1bigfile>>OnMonDDActivity1>>OnMonDDActivity1small>>recoDDActivity1files>>recoDDActivity1SMALLfiles>>TBSubrun;
127 
128 
129 
130  if(!in.good())break;
131 
132  //========================================
133  //Filling the histogram by SetBinContent !
134  //========================================
135 
136  BeamlineRecofiles->SetBinContent(BeamlineRecofiles->FindBin(Runnum),RecoBeamline);
137 
138 
139  BeamlineRecoSMALLfiles->SetBinContent(BeamlineRecoSMALLfiles->FindBin(Runnum),RecoBeamlineSMALL);
140 
141 
142  BeamlineOnMonfiles->SetBinContent(BeamlineOnMonfiles->FindBin(Runnum),OnMonBeamline);
143 
144  BeamlineOnMonsmallfiles->SetBinContent(BeamlineOnMonsmallfiles->FindBin(Runnum),OnMonBeamlineSmall);
145 
146 
147  BeamlineRawlargefiles->SetBinContent(BeamlineRawlargefiles->FindBin(Runnum),RawBeamlinelarge);
148 
149 
150  DBtbsubrun->SetBinContent(DBtbsubrun->FindBin(Runnum),TBSubrun);
151 
152  DDARecofiles->SetBinContent(DDARecofiles->FindBin(Runnum),recoDDActivity1files);
153 
154  TBDDAOnMon->SetBinContent(TBDDAOnMon->FindBin(Runnum),OnMonDDActivity1);
155 
156  TBDDAOnMonsmall->SetBinContent(TBDDAOnMonsmall->FindBin(Runnum),OnMonDDActivity1small);
157 
158  DDARecoSMALLfiles->SetBinContent(DDARecoSMALLfiles->FindBin(Runnum),recoDDActivity1SMALLfiles);
159 
160 
161  DDARawlargefiles->SetBinContent(DDARawlargefiles->FindBin(Runnum),RawDDActivity1bigfile);
162 
163 
164  DBtbsubrun1->SetBinContent(DBtbsubrun1->FindBin(Runnum),TBSubrun);
165 
166 
167 
168  }
169 
170  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171  //Making Canvas for BeamlineReco files
172  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173 
174  TCanvas *beamreco = new TCanvas ("beamreco","",700,700);
175 
176  BeamlineRecofiles->SetFillColor(kAzure+1);
177  BeamlineRecofiles->SetLineColor(kAzure+1);
178 
179  BeamlineRecoSMALLfiles->SetFillStyle(3001);
180  BeamlineRecoSMALLfiles->SetFillColor(kAzure+1);
181  BeamlineRecoSMALLfiles->SetLineColor(kAzure+1);
182 
183 
184 
185  DBtbsubrun->SetLineColor(kBlack);
186  DBtbsubrun->SetLineWidth(3);
187 
188  BeamlineRawlargefiles->SetLineColor(kRed);
189  BeamlineRawlargefiles->SetLineWidth(3);
190 
191 
192  BeamlineLarplusSmall->Add(BeamlineRecofiles);
193  BeamlineLarplusSmall->Add(BeamlineRecoSMALLfiles);
194 
195  BeamlineLarplusSmall->Draw();
196  BeamlineLarplusSmall->GetYaxis()->SetTitleOffset(1.4);
197  BeamlineLarplusSmall->SetMaximum(120);
198  BeamlineLarplusSmall->SetMinimum(0);
199 
200  BeamlineRawlargefiles->Draw("SAME");
201  DBtbsubrun->Draw("SAME");
202 
203 
204  auto leg = new TLegend(0.12,0.75,0.45,0.9);
205  leg->SetTextFont(62);
206  leg->SetLineColor(1);
207  leg->SetLineStyle(1);
208  leg->SetLineWidth(3);
209  leg->SetFillColor(0);
210  leg->SetFillStyle(1001);
211  leg->SetShadowColor(0);
212  leg->SetDrawOption(0);
213  leg->SetBorderSize(0);
214  leg->SetTextSize(0.02);
215  leg->SetHeader("");
216  leg->AddEntry("BeamlineRecofiles","Beamline Reco Files","f");
217  leg->AddEntry("BeamlineRecoSMALLfiles","Beamline Reco SMALL files","f");
218  leg->AddEntry("BeamlineRawlargefiles","Beamline Raw files","l");
219  leg->AddEntry("DBtbsubrun","DB Subrun","l");
220  leg->Draw();
221  UpdateTextTB->Draw();
222 
223  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224  //Making Canvas and Drawing for TestBeam Beamline OnMon files
225  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226 
227  TCanvas *TBBeamlineOnMon = new TCanvas("TBBeamlineOnMon","",700,700);
228 
229  BeamlineOnMonfiles->SetFillColor(kOrange-2);
230  BeamlineOnMonfiles->SetLineColor(kOrange-2);
231 
232  BeamlineOnMonsmallfiles->SetFillStyle(3001);
233  BeamlineOnMonsmallfiles->SetFillColor(kOrange-2);
234  BeamlineOnMonsmallfiles->SetLineColor(kOrange-2);
235 
236  DBtbsubrun->SetLineColor(kBlack);
237  DBtbsubrun->SetLineWidth(3);
238 
239  BeamlineRawlargefiles->SetLineColor(kRed);
240  BeamlineRawlargefiles->SetLineWidth(3);
241 
242  BeamlineOnMonLarplusSmall->Add(BeamlineOnMonfiles);
243  BeamlineOnMonLarplusSmall->Add(BeamlineOnMonsmallfiles);
244  BeamlineOnMonLarplusSmall->Draw();
245  BeamlineOnMonLarplusSmall->GetYaxis()->SetTitleOffset(1.4);
246  BeamlineOnMonLarplusSmall->SetMaximum(120);
247  BeamlineOnMonLarplusSmall->SetMinimum(0);
248  BeamlineRawlargefiles->Draw("same");
249  DBtbsubrun->Draw("same");
250 
251 
252  auto leg5 = new TLegend(0.12,0.75,0.45,0.9);
253  leg5->SetTextFont(62);
254  leg5->SetLineColor(1);
255  leg5->SetLineStyle(1);
256  leg5->SetLineWidth(3);
257  leg5->SetFillColor(0);
258  leg5->SetFillStyle(1001);
259  leg5->SetShadowColor(0);
260  leg5->SetDrawOption(0);
261  leg5->SetBorderSize(0);
262  leg5->SetTextSize(0.02);
263  leg5->SetHeader("");
264  leg5->AddEntry("BeamlineOnMonfiles","Beamline OnMon files","f");
265  leg5->AddEntry("BeamlineOnMonsmallfiles","Beamline OnMon SMALL files","f");
266  leg5->AddEntry("BeamlineRawlargefiles","Beamline Raw files","l");
267  leg5->AddEntry("DBtbsubrun","DB Subrun","l");
268  leg5->Draw();
269 
270  UpdateTextTB->Draw();
271 
272  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273 
274  //Making Canvas and Drawing for TestBeam DDAct Reco files
275 
276  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277 
278  TCanvas *ddareco = new TCanvas ("ddareco","",700,700);
279 
280 
281  DDARecofiles->SetFillColor(kAzure+1);
282  DDARecofiles->SetLineColor(kAzure+1);
283 
284  DDARecoSMALLfiles->SetFillStyle(3001);
285  DDARecoSMALLfiles->SetFillColor(kAzure+1);
286  DDARecoSMALLfiles->SetLineColor(kAzure+1);
287 
288 
289  DBtbsubrun1->SetLineColor(kBlack);
290  DBtbsubrun1->SetLineWidth(3);
291 
292  DDARawlargefiles->SetLineColor(kRed);
293  DDARawlargefiles->SetLineWidth(3);
294 
295 
296  DDALarplusSmall->Add(DDARecofiles);
297  DDALarplusSmall->Add(DDARecoSMALLfiles);
298  DDALarplusSmall->Draw();
299  DDALarplusSmall->SetMaximum(90);
300  DDALarplusSmall->SetMinimum(0);
301  DDARawlargefiles->Draw("SAME");
302  DBtbsubrun1->Draw("SAME");
303 
304  auto leg1 = new TLegend(0.12,0.75,0.45,0.9);
305  leg1->SetTextFont(62);
306  leg1->SetLineColor(1);
307  leg1->SetLineStyle(1);
308  leg1->SetLineWidth(3);
309  leg1->SetFillColor(0);
310  leg1->SetFillStyle(1001);
311  leg1->SetShadowColor(0);
312  leg1->SetDrawOption(0);
313  leg1->SetBorderSize(0);
314  leg1->SetTextSize(0.02);
315  leg1->AddEntry("DDARecofiles","DDActivity1 Reco files","f");
316  leg1->AddEntry("DDARecoSMALLfiles","DDActivity1 Reco SMALL files","f");
317  leg1->AddEntry("DDARawlargefiles","DDActivity1 Raw files","l");
318  leg1->AddEntry("DBtbsubrun1","DB Subrun","l");
319  leg1->Draw();
320 
321  UpdateTextTB->Draw();
322 
323  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324 
325  //Making Canvas and Drawing for TestBeam DDAct OnMon files
326 
327  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328 
329 
330  TCanvas *TBddaOnmon = new TCanvas("TBddaOnmon","",700,700);
331 
332 
333  TBDDAOnMon->SetFillColor(kOrange-2);
334  TBDDAOnMon->SetLineColor(kOrange-2);
335 
336  TBDDAOnMonsmall->SetFillStyle(3001);
337  TBDDAOnMonsmall->SetFillColor(kOrange-2);
338  TBDDAOnMonsmall->SetLineColor(kOrange-2);
339 
340 
341  DBtbsubrun1->SetLineColor(kBlack);
342  DBtbsubrun1->SetLineWidth(3);
343 
344  DDARawlargefiles->SetLineColor(kRed);
345  DDARawlargefiles->SetLineWidth(3);
346 
347  DDAOnMonLarplusSmall->Add(TBDDAOnMon);
348  DDAOnMonLarplusSmall->Add(TBDDAOnMonsmall);
349  DDAOnMonLarplusSmall->Draw();
350  DDAOnMonLarplusSmall->SetMaximum(90);
351  DDAOnMonLarplusSmall->SetMinimum(0);
352  DDARawlargefiles->Draw("SAME");
353  DBtbsubrun1->Draw("SAME");
354 
355 
356  auto leg4 = new TLegend(0.12,0.75,0.45,0.9);
357  leg4->SetTextFont(62);
358  leg4->SetLineColor(1);
359  leg4->SetLineStyle(1);
360  leg4->SetLineWidth(3);
361  leg4->SetFillColor(0);
362  leg4->SetFillStyle(1001);
363  leg4->SetShadowColor(0);
364  leg4->SetDrawOption(0);
365  leg4->SetBorderSize(0);
366  leg4->SetTextSize(0.02);
367  leg4->AddEntry(TBDDAOnMon,"DDActivity1 OnMon files","f");
368  leg4->AddEntry(TBDDAOnMonsmall,"DDActivity1 OnMon SMALL files","f");
369  leg4->AddEntry("DDARawlargefiles","DDActivity1 Raw files","l");
370  leg4->AddEntry("DBtbsubrun1","DB Subrun","l");
371  leg4->Draw("same");
372 
373  // When you generate your plot, make sure you add the following line \
374  //before saving the png file
375  UpdateTextTB->Draw();
376 
377  //~~~~~~~~~~~~~~~~~~~~~~~~
378  // Making .png plots
379  //~~~~~~~~~~~~~~~~~~~~~~~~
380 
381  TBBeamlineOnMon->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/TestBeam-Beamline-P1NearlineOnMonFilesDay.png");
382  TBddaOnmon->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/TestBeam-Act-P1NearlineOnMonFilesDay.png");
383  beamreco->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/TestBeam-Beamline-P1NearlineRecoFilesDay.png");
384  ddareco->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/TestBeam-Act-P1NearlineRecoFilesDay.png");
385 
386  in.close();
387 
388 }
389 
390 
enum BeamMode kOrange
UInt_t LastSR
Definition: AnaPlotMaker.h:50
enum BeamMode kRed
void TB_Nearline_Watchdog_Plots(int TBRunL, int TBRunH)
TDatime * TNow
Definition: AnaPlotMaker.h:41
Int_t par
Definition: SimpleIterate.C:24
TLegend * leg1
Definition: plot_hist.C:105
TDatime * SRtime
Definition: AnaPlotMaker.h:42
UInt_t LastRun
Definition: AnaPlotMaker.h:49
Definition: run.py:1
TDatime * TNowGMT
Definition: AnaPlotMaker.h:40
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
ifstream in
Definition: comparison.C:7
Int_t GMToffset
Definition: AnaPlotMaker.h:43
static constexpr Double_t year
Definition: Munits.h:185