CustomFunctions.h
Go to the documentation of this file.
1 void lastUpdated(unsigned int timestamp){
2  TTimeStamp refreshTime(timestamp + 86400*7);
3  TTimeStamp includedTime(timestamp);
4  unsigned int year, month, day, hour, minute, second;
5 
6  refreshTime.GetDate(kFALSE, 0, &year, &month, &day);
7  refreshTime.GetTime(kFALSE, 0, &hour, &minute, &second);
8 
9  TPaveLabel* pl = new TPaveLabel;
10  pl->SetX1NDC(0.50);
11  pl->SetX2NDC(0.98);
12  pl->SetY1NDC(0.95);
13  pl->SetY2NDC(1.00);
14  pl->SetFillColor(0);
15  pl->SetShadowColor(0);
16  pl->SetLineColor(0);
17  pl->SetLabel(Form("Last refreshed: %u-%02u-%02u-%02u:%02u:%02u",year,month,day,hour,minute,second));
18  pl->SetTextSize(0);
19  pl->Draw();
20 
21  includedTime.GetDate(kFALSE, 0, &year, &month, &day);
22  includedTime.GetTime(kFALSE, 0, &hour, &minute, &second);
23 
24  TPaveLabel* pl2 = new TPaveLabel;
25  pl2->SetX1NDC(0.10);
26  pl2->SetX2NDC(0.35);
27  pl2->SetY1NDC(0.95);
28  pl2->SetY2NDC(1.00);
29  pl2->SetFillColor(0);
30  pl2->SetShadowColor(0);
31  pl2->SetLineColor(0);
32  pl2->SetLabel(Form("Data up to %u-%02u-%02u-%02u:%02u:%02u",year,month,day,hour,minute,second));
33  pl2->SetTextSize(0);
34  pl2->Draw();
35 }
36 
37 
38 
39 Double_t jimeu[51];
40 Double_t jimed[51];
41 
42 void declareSigma(){
43 
44  jimeu[0]= 1.841; jimed[0]= 0.000;
45  jimeu[1]= 3.3 ; jimed[1]= 0.173;
46  jimeu[2]= 4.638; jimed[2]= 0.708;
47  jimeu[3]= 5.918; jimed[3]= 1.367;
48  jimeu[4]= 7.163; jimed[4]= 2.086;
49  jimeu[5]= 8.382; jimed[5]= 2.84 ;
50  jimeu[6]= 9.584; jimed[6]= 3.62 ;
51  jimeu[7]= 10.77; jimed[7]= 4.419;
52  jimeu[8]= 11.95; jimed[8]= 5.232;
53  jimeu[9]= 13.11; jimed[9]= 6.057;
54  jimeu[10]= 14.27; jimed[10]=6.891;
55  jimeu[11]= 15.42; jimed[11]=7.734;
56  jimeu[12]= 16.56; jimed[12]=8.585;
57  jimeu[13]= 17.7 ; jimed[13]=9.441;
58  jimeu[14]= 18.83; jimed[14]=10.3 ;
59  jimeu[15]= 19.96; jimed[15]=11.17;
60  jimeu[16]= 21.08; jimed[16]=12.04;
61  jimeu[17]= 22.2 ; jimed[17]=12.92;
62  jimeu[18]= 23.32; jimed[18]=13.8 ;
63  jimeu[19]= 24.44; jimed[19]=14.68;
64  jimeu[20]= 25.55; jimed[20]=15.57;
65  jimeu[21]= 26.66; jimed[21]=16.45;
66  jimeu[22]= 27.76; jimed[22]=17.35;
67  jimeu[23]= 28.87; jimed[23]=18.24;
68  jimeu[24]= 29.97; jimed[24]=19.14;
69  jimeu[25]= 31.07; jimed[25]=20.03;
70  jimeu[26]= 32.16; jimed[26]=20.93;
71  jimeu[27]= 33.26; jimed[27]=21.84;
72  jimeu[28]= 34.35; jimed[28]=22.74;
73  jimeu[29]= 35.45; jimed[29]=23.65;
74  jimeu[30]= 36.54; jimed[30]=24.55;
75  jimeu[31]= 37.63; jimed[31]=25.46;
76  jimeu[32]= 38.72; jimed[32]=26.37;
77  jimeu[33]= 39.80; jimed[33]=27.28;
78  jimeu[34]= 40.89; jimed[34]=28.20;
79  jimeu[35]= 41.97; jimed[35]=29.11;
80  jimeu[36]= 43.06; jimed[36]=30.03;
81  jimeu[37]= 44.14; jimed[37]=30.94;
82  jimeu[38]= 45.22; jimed[38]=31.86;
83  jimeu[39]= 46.30; jimed[39]=32.78;
84  jimeu[40]= 47.32; jimed[40]=33.70;
85  jimeu[41]= 48.36; jimed[41]=34.62;
86  jimeu[42]= 49.53; jimed[42]=35.55;
87  jimeu[43]= 50.61; jimed[43]=36.47;
88  jimeu[44]= 51.68; jimed[44]=37.39;
89  jimeu[45]= 52.76; jimed[45]=38.32;
90  jimeu[46]= 53.83; jimed[46]=39.24;
91  jimeu[47]= 54.90; jimed[47]=40.17;
92  jimeu[48]= 55.98; jimed[48]=41.10;
93  jimeu[49]= 57.05; jimed[49]=42.02;
94  jimeu[50]= 58.12; jimed[50]=42.95;
95 
96 }// end declareSigma
97 
98 
99 
100 void getSigmaPlots(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming){
101  gStyle->SetOptStat(0);
102 
103 
104  //TFile* file1 = new TFile((naming+"/Tools/sig_time.root").c_str());
105  //TFile* file2 = new TFile((naming+"/Tools/BKG_time.root").c_str());
106  //TFile* file3 = new TFile((naming+"/Tools/hPOT.root").c_str());
107  TFile* file1 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/sig_time.root").c_str());
108  TFile* file2 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/BKG_time.root").c_str());
109  TFile* file3 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/hPOT.root").c_str());
110  TH1D* h1 = (TH1D*) file1->Get("sig_time");
111  TH1D* h2 = (TH1D*) file2->Get("BKG_time");
112  TH2D* hPOT = (TH2D*) file3->Get("hPOT");
113 
114  int POTbins = hPOT->GetNbinsX();
115  double POTmin = hPOT->GetXaxis()->GetBinLowEdge(1);
116  double POTmax = hPOT->GetXaxis()->GetBinLowEdge(POTbins+1);
117 
118  TProfile* POTx = new TProfile("POTx","POTx",POTbins,POTmin,POTmax);
119  hPOT->ProfileX("POTx");
120 
121  unsigned int minBin = h1->FindBin(timestamp - 86400*nDays);
122  unsigned int maxBin = h1->FindBin(timestamp);
123 
124  double minZoom = h2->GetBinLowEdge(minBin);
125  double maxZoom = h2->GetBinLowEdge(maxBin+1);
126 
127  double fSig, fBKG, fSigma, fMCSig, fMCSigma, fErrUp, fErrDown;
128 
129  TF2 funcSig("funcSig","TMath::ErfcInverse(TMath::PoissonI(x,y))*sqrt(2.)",0,100,0,100);
130 
131  TGraphErrors* signal = new TGraphErrors;
132  TGraphErrors* background = new TGraphErrors;
133  TGraphErrors* significance = new TGraphErrors;
134  TGraphErrors* MC = new TGraphErrors;
135  TGraphErrors* MCsignificance = new TGraphErrors;
136  TGraphAsymmErrors *daySignal = new TGraphAsymmErrors;
137  TGraphAsymmErrors *dayBKG = new TGraphAsymmErrors;
138 
139  int kDayPoints = 0;
140  declareSigma();
141 
142  for(unsigned int i=minBin; i<=maxBin; i++)
143  {
144  fSig = h1->Integral(minBin,i);
145  fBKG = h2->Integral(minBin,i);
146  fSigma = funcSig.Eval(fSig, fBKG);
147  fMCSig = MCSignal*POTx->Integral(minBin,i)/POTx->Integral();
148  fMCSigma = funcSig.Eval(fMCSig+fBKG, fBKG);
149 
150  signal->SetPoint(kDayPoints, h1->GetBinCenter(i), fSig);
151  background->SetPoint(kDayPoints, h1->GetBinCenter(i), fBKG);
152  significance->SetPoint(kDayPoints, h1->GetBinCenter(i), fSigma);
153  MC->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSig+fBKG);
154  MCsignificance->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSigma);
155 
156  fSig = h1->GetBinContent(i);
157  fBKG = h2->GetBinContent(i);
158  daySignal->SetPoint(kDayPoints, h1->GetBinCenter(i), fSig);
159  dayBKG->SetPoint(kDayPoints, h1->GetBinCenter(i), fBKG);
160  fErrDown = fSig-jimed[(int)fSig];
161  fErrUp = jimeu[(int)fSig]-fSig;
162  daySignal->SetPointError(kDayPoints, 0, 0, fErrDown, fErrUp);
163 
164  kDayPoints++;
165  }
166 
167  // Signal and background over time
168  TCanvas* c1 = new TCanvas("c1","c1");
169  signal->SetLineColor(kBlack);
170  signal->SetLineWidth(3);
171  signal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(signal->GetN(),signal->GetY())*1.12+4.);
172  signal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
173  signal->GetXaxis()->SetTimeDisplay(1);
174  signal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
175  signal->GetYaxis()->SetTitle("Entries");
176  signal->GetXaxis()->SetTitle("Date");
177  signal->GetXaxis()->SetNdivisions(1);
178  signal->Draw("AL");
179  background->SetLineColor(kBlue);
180  background->SetLineWidth(3);
181  background->Draw("L");
182  MC->SetLineColor(kGray+1);
183  MC->SetLineStyle(9);
184  MC->Draw("L");
185 
186  TLegend* leg = new TLegend(0.15,0.70,0.45,0.89);
187  leg->AddEntry(signal,"Signal","l");
188  leg->AddEntry(MC,"Expectation","l");
189  leg->AddEntry(background,"Background","l");
190  leg->SetFillColor(0);
191  leg->Draw();
192  lastUpdated(timestamp);
193 
194  // Signficance over time
195  TCanvas* c2 = new TCanvas("c2","c2");
196  TGraph* l2 = new TGraph;
197  TGraph* l3 = new TGraph;
198  TGraph* l5 = new TGraph;
199  l2->SetPoint(0,minZoom,2);
200  l2->SetPoint(1,maxZoom,2);
201  l3->SetPoint(0,minZoom,3);
202  l3->SetPoint(1,maxZoom,3);
203  l5->SetPoint(0,minZoom,5);
204  l5->SetPoint(1,maxZoom,5);
205  l2->SetLineStyle(2);
206  l3->SetLineStyle(2);
207  l5->SetLineStyle(2);
208 
209  significance->SetLineColor(kBlue);
210  significance->SetLineWidth(3);
211  significance->GetYaxis()->SetRangeUser(0,TMath::MaxElement(significance->GetN(),significance->GetY())*1.12+4.);
212  significance->GetXaxis()->SetRangeUser(minZoom, maxZoom);
213  significance->GetXaxis()->SetTimeDisplay(1);
214  significance->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
215  significance->GetYaxis()->SetTitle("Significance [ #sigma ]");
216  significance->GetXaxis()->SetTitle("Date");
217  significance->GetXaxis()->SetNdivisions(1);
218  significance->Draw("AL");
219  l2->Draw("L");
220  l3->Draw("L");
221  l5->Draw("L");
222 
223  TLegend* leg2 = new TLegend(0.15,0.70,0.45,0.89);
224  leg2->AddEntry(significance,"Cumulative","l");
225  leg2->SetFillColor(0);
226  leg2->Draw();
227  lastUpdated(timestamp);
228 
229  // Compare with MC
230  TCanvas* c3 = new TCanvas("c3","c3");
231  significance->Draw("AL");
232  l2->Draw("L");
233  l3->Draw("L");
234  l5->Draw("L");
235  MCsignificance->SetLineColor(kRed);
236  MCsignificance->SetLineStyle(9);
237  MCsignificance->Draw("L");
238 
239  TLegend* leg3 = new TLegend(0.15,0.70,0.45,0.89);
240  leg3->AddEntry(significance,"Significance","l");
241  leg3->AddEntry(MCsignificance,"Expectation","l");
242  leg3->SetFillColor(0);
243  leg3->Draw();
244  lastUpdated(timestamp);
245 
246  // Raw daily events
247  TCanvas* c4 = new TCanvas("c4","c4");
248  daySignal->SetLineColor(kBlack);
249  daySignal->SetLineWidth(3);
250  daySignal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(daySignal->GetN(),daySignal->GetY())*1.12+4.);
251  daySignal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
252  daySignal->GetXaxis()->SetTimeDisplay(1);
253  daySignal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
254  daySignal->GetYaxis()->SetTitle("Entries");
255  daySignal->GetXaxis()->SetTitle("Date");
256  daySignal->GetXaxis()->SetNdivisions(1);
257  daySignal->SetMarkerColor(kBlack);
258  daySignal->SetMarkerStyle(20);
259  daySignal->Draw("AP");
260  dayBKG->SetLineColor(kBlue);
261  dayBKG->SetLineWidth(3);
262  dayBKG->SetMarkerColor(kBlue);
263  dayBKG->SetMarkerStyle(24);
264  dayBKG->Draw("P");
265 
266  TLegend* leg4 = new TLegend(0.15,0.70,0.45,0.89);
267  leg4->AddEntry(daySignal,"Daily signal","p");
268  leg4->AddEntry(dayBKG,"Estimated BKG","p");
269  leg4->SetFillColor(0);
270  leg4->Draw();
271  lastUpdated(timestamp);
272 
273  //c1->SaveAs((naming+"/Plots/SignalAndBkgOverTime.png").c_str());
274  //c2->SaveAs((naming+"/Plots/SignificanceOverTime.png").c_str());
275  //c3->SaveAs((naming+"/Plots/CumSignificanceOverTime.png").c_str());
276  //c4->SaveAs((naming+"/Plots/DailySignalAndBkg.png").c_str());
277  c1->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignalAndBkgOverTime.png").c_str());
278  c2->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignificanceOverTime.png").c_str());
279  c3->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/CumSignificanceOverTime.png").c_str());
280  c4->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/DailySignalAndBkg.png").c_str());
281 
282 
283 } // end getSigmaPlots
284 
285 
286 
287 
288 
289 void getSigmaPlotsAll(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming){
290 
291  gStyle->SetOptStat(0);
292 
293  TFile* file1 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/sig_time.root").c_str());
294  TH1D* h1 = (TH1D*) file1->Get("sig_time");
295  TFile* file2 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/BKG_time.root").c_str());
296  TH1D* h2 = (TH1D*) file2->Get("BKG_time");
297  TFile* file3 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/hPOT.root").c_str());
298  TH2D* hPOT = (TH2D*) file3->Get("hPOT");
299 
300  int POTbins = hPOT->GetNbinsX();
301  double POTmin = hPOT->GetXaxis()->GetBinLowEdge(1);
302  double POTmax = hPOT->GetXaxis()->GetBinLowEdge(POTbins+1);
303 
304  TProfile* POTx = new TProfile("POTx","POTx",POTbins,POTmin,POTmax);
305  hPOT->ProfileX("POTx");
306 
307  unsigned int minBin = h1->FindBin(timestamp - 86400*nDays);
308  unsigned int maxBin = h1->FindBin(timestamp);
309 
310  double minZoom = h2->GetBinLowEdge(minBin);
311  double maxZoom = h2->GetBinLowEdge(maxBin+1);
312 
313  double fSig, fBKG, fSigma, fMCSig, fMCSigma, dSigma, fErrUp, fErrDown;
314 
315  TF2 funcSig("funcSig","TMath::ErfcInverse(TMath::PoissonI(x,y))*sqrt(2.)",0,100,0,100);
316 
317  TGraphErrors* signal = new TGraphErrors;
318  TGraphErrors* background = new TGraphErrors;
319  TGraphErrors* significance = new TGraphErrors;
320  TGraphErrors* MC = new TGraphErrors;
321  TGraphErrors* MCsignificance = new TGraphErrors;
322  TGraphErrors* weekly = new TGraphErrors;
323  TGraphErrors* biweekly = new TGraphErrors;
324  TGraphErrors* monthly = new TGraphErrors;
325  TGraphAsymmErrors *weekSignal = new TGraphAsymmErrors;
326  TGraphAsymmErrors *weekBKG = new TGraphAsymmErrors;
327 
328  int kDayPoints = 0;
329  int kWeekPoints = 0;
330  int kBiweekPoints = 0;
331  int kMonthPoints = 0;
332  declareSigma();
333 
334  for(unsigned int i=minBin; i<=maxBin; i++)
335  {
336  fSig = h1->Integral(minBin,i);
337  fBKG = h2->Integral(minBin,i);
338  fSigma = funcSig.Eval(fSig, fBKG);
339  fMCSig = MCSignal*POTx->Integral(minBin,i)/POTx->Integral();
340  fMCSigma = funcSig.Eval(fMCSig+fBKG, fBKG);
341 
342  signal->SetPoint(kDayPoints, h1->GetBinCenter(i), fSig);
343  background->SetPoint(kDayPoints, h1->GetBinCenter(i), fBKG);
344  significance->SetPoint(kDayPoints, h1->GetBinCenter(i), fSigma);
345  MC->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSig+fBKG);
346  MCsignificance->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSigma);
347  kDayPoints++;
348  if((i-minBin)>=7 && (i-minBin)%7==0) // weekly plot
349  {
350  fSig = h1->Integral(i-7,i);
351  fBKG = h2->Integral(i-7,i);
352  fSigma = funcSig.Eval(fSig, fBKG);
353  dSigma = TMath::Abs(funcSig.Eval(fSig,fBKG+sqrt(fBKG))-fSigma);
354  weekly->SetPoint(kWeekPoints, h1->GetBinCenter(i), fSigma);
355  weekly->SetPointError(kWeekPoints, 0, dSigma);
356  weekSignal->SetPoint(kWeekPoints, h1->GetBinCenter(i), fSig);
357  weekBKG->SetPoint(kWeekPoints, h1->GetBinCenter(i), fBKG);
358 
359  fErrDown = fSig-jimed[(int)fSig];
360  fErrUp = jimeu[(int)fSig]-fSig;
361  weekSignal->SetPointError(kWeekPoints, 0, 0, fErrDown, fErrUp);
362  kWeekPoints++;
363  }
364 
365  if((i-minBin) >= 14 && (i-minBin)%14==0) // biweekly plot
366  {
367  fSig = h1->Integral(i-14,i);
368  fBKG = h2->Integral(i-14,i);
369  fSigma = funcSig.Eval(fSig, fBKG);
370  dSigma = TMath::Abs(funcSig.Eval(fSig,fBKG+sqrt(fBKG))-fSigma);
371  biweekly->SetPoint(kBiweekPoints, h1->GetBinCenter(i), fSigma);
372  biweekly->SetPointError(kBiweekPoints, 0, dSigma);
373  kBiweekPoints++;
374  }
375 
376  if((i-minBin) >= 30 && (i-minBin)%30==0) // monthly
377  {
378  fSig = h1->Integral(i-30,i);
379  fBKG = h2->Integral(i-30,i);
380  fSigma = funcSig.Eval(fSig, fBKG);
381  dSigma = TMath::Abs(funcSig.Eval(fSig,fBKG+sqrt(fBKG))-fSigma);
382  monthly->SetPoint(kMonthPoints, h1->GetBinCenter(i), fSigma);
383  monthly->SetPointError(kMonthPoints, 0, dSigma);
384  kMonthPoints++;
385  }
386  }
387 
388  // Signal and background over time
389  TCanvas* c1 = new TCanvas("c1","c1");
390  signal->SetLineColor(kBlack);
391  signal->SetLineWidth(3);
392  signal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(signal->GetN(),signal->GetY())*1.12+4.);
393  signal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
394  signal->GetXaxis()->SetTimeDisplay(1);
395  signal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
396  signal->GetYaxis()->SetTitle("Entries");
397  signal->GetXaxis()->SetTitle("Date");
398  signal->GetXaxis()->SetNdivisions(5);
399  signal->Draw("AL");
400  background->SetLineColor(kBlue);
401  background->SetLineWidth(3);
402  background->Draw("L");
403  MC->SetLineColor(kGray+1);
404  MC->SetLineStyle(9);
405  MC->Draw("L");
406 
407  TLegend* leg = new TLegend(0.15,0.70,0.45,0.89);
408  leg->AddEntry(signal,"Signal","l");
409  leg->AddEntry(MC,"Expectation","l");
410  leg->AddEntry(background,"Background","l");
411  leg->SetFillColor(0);
412  leg->Draw();
413  lastUpdated(timestamp);
414 
415  // Signficance over time
416  TCanvas* c2 = new TCanvas("c2","c2");
417  TGraph* l2 = new TGraph;
418  TGraph* l3 = new TGraph;
419  TGraph* l5 = new TGraph;
420  l2->SetPoint(0,minZoom,2);
421  l2->SetPoint(1,maxZoom,2);
422  l3->SetPoint(0,minZoom,3);
423  l3->SetPoint(1,maxZoom,3);
424  l5->SetPoint(0,minZoom,5);
425  l5->SetPoint(1,maxZoom,5);
426  l2->SetLineStyle(2);
427  l3->SetLineStyle(2);
428  l5->SetLineStyle(2);
429 
430  significance->SetLineColor(kBlue);
431  significance->SetLineWidth(3);
432  significance->GetYaxis()->SetRangeUser(0,TMath::MaxElement(significance->GetN(),significance->GetY())*1.12+4.);
433  significance->GetXaxis()->SetRangeUser(minZoom, maxZoom);
434  significance->GetXaxis()->SetTimeDisplay(1);
435  significance->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
436  significance->GetYaxis()->SetTitle("Significance [ #sigma ]");
437  significance->GetXaxis()->SetTitle("Date");
438  significance->GetXaxis()->SetNdivisions(5);
439  significance->Draw("AL");
440  l2->Draw("L");
441  l3->Draw("L");
442  l5->Draw("L");
443 
444  weekly->SetLineColor(kBlack);
445  weekly->SetMarkerColor(kBlack);
446  weekly->SetLineWidth(3);
447  weekly->SetMarkerStyle(20);
448  weekly->Draw("P");
449  biweekly->SetLineColor(kGreen+1);
450  biweekly->SetMarkerColor(kGreen+1);
451  biweekly->SetLineWidth(3);
452  biweekly->SetMarkerStyle(24);
453  biweekly->Draw("P");
454  monthly->SetLineColor(kRed);
455  monthly->SetMarkerColor(kRed);
456  monthly->SetLineWidth(3);
457  monthly->SetMarkerStyle(21);
458  monthly->Draw("P");
459 
460  TLegend* leg2 = new TLegend(0.15,0.70,0.45,0.89);
461  leg2->AddEntry(weekly,"Weekly","pl");
462  leg2->AddEntry(biweekly,"Biweekly","pl");
463  leg2->AddEntry(monthly,"Monthly","pl");
464  leg2->AddEntry(significance,"Cumulative","l");
465  leg2->SetFillColor(0);
466  leg2->Draw();
467  lastUpdated(timestamp);
468 
469  // Compare with MC
470  TCanvas* c3 = new TCanvas("c3","c3");
471  significance->Draw("AL");
472  l2->Draw("L");
473  l3->Draw("L");
474  l5->Draw("L");
475  MCsignificance->SetLineColor(kRed);
476  MCsignificance->SetLineStyle(9);
477  MCsignificance->Draw("L");
478 
479  TLegend* leg3 = new TLegend(0.15,0.70,0.45,0.89);
480  leg3->AddEntry(significance,"Significance","l");
481  leg3->AddEntry(MCsignificance,"Expectation","l");
482  leg3->SetFillColor(0);
483  leg3->Draw();
484  lastUpdated(timestamp);
485 
486  // Raw weekly events
487  TCanvas* c4 = new TCanvas("c4","c4");
488  weekSignal->SetLineColor(kBlack);
489  weekSignal->SetLineWidth(3);
490  weekSignal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(weekSignal->GetN(),weekSignal->GetY())*1.12+4.);
491  weekSignal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
492  weekSignal->GetXaxis()->SetTimeDisplay(1);
493  weekSignal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
494  weekSignal->GetYaxis()->SetTitle("Entries");
495  weekSignal->GetXaxis()->SetTitle("Date");
496  weekSignal->GetXaxis()->SetNdivisions(5);
497  weekSignal->SetMarkerColor(kBlack);
498  weekSignal->SetMarkerStyle(20);
499  //weekSignal->GetYaxis()->SetNdivisions(0);
500  weekSignal->Draw("AP");
501  weekBKG->SetLineColor(kBlue);
502  weekBKG->SetLineWidth(3);
503  weekBKG->SetMarkerColor(kBlue);
504  weekBKG->SetMarkerStyle(24);
505  weekBKG->Draw("P");
506 
507  TLegend* leg4 = new TLegend(0.15,0.70,0.45,0.89);
508  leg4->AddEntry(weekSignal,"Weekly signal","p");
509  leg4->AddEntry(weekBKG,"Estimated BKG","p");
510  leg4->SetFillColor(0);
511  leg4->Draw();
512  lastUpdated(timestamp);
513 
514  c1->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignalAndBkgOverTime.png").c_str());
515  c2->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignificanceOverTime.png").c_str());
516  c3->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/CumSignificanceOverTime.png").c_str());
517  c4->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/WeeklySignalAndBkg.png").c_str());
518 
519 
520 }// end getSigmaPlotsAll
521 
enum BeamMode kRed
T sqrt(T number)
Definition: d0nt_math.hpp:156
void getSigmaPlots(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming)
c2
Definition: demo5.py:33
void lastUpdated(unsigned int timestamp)
Double_t jimeu[51]
void declareSigma()
TH1F * h2
Definition: plot.C:45
TH1F * h1
Double_t jimed[51]
void getSigmaPlotsAll(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming)
c1
Definition: demo5.py:24
float fSig[xbins]
Definition: MakePlots.C:86
enum BeamMode kGreen
enum BeamMode kBlue
static constexpr Double_t year
Definition: Munits.h:185
enum BeamMode string