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  TFile* file1 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/sig_time.root").c_str());
104  TFile* file2 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/BKG_time.root").c_str());
105  TFile* file3 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/hPOT.root").c_str());
106  TH1D* h1 = (TH1D*) file1->Get("sig_time");
107  TH1D* h2 = (TH1D*) file2->Get("BKG_time");
108  TH2D* hPOT = (TH2D*) file3->Get("hPOT");
109 
110  int POTbins = hPOT->GetNbinsX();
111  double POTmin = hPOT->GetXaxis()->GetBinLowEdge(1);
112  double POTmax = hPOT->GetXaxis()->GetBinLowEdge(POTbins+1);
113 
114  TProfile* POTx = new TProfile("POTx","POTx",POTbins,POTmin,POTmax);
115  hPOT->ProfileX("POTx");
116 
117  unsigned int minBin = h1->FindBin(timestamp - 86400*nDays);
118  unsigned int maxBin = h1->FindBin(timestamp);
119 
120  double minZoom = h2->GetBinLowEdge(minBin);
121  double maxZoom = h2->GetBinLowEdge(maxBin+1);
122 
123  double fSig, fBKG, fSigma, fMCSig, fMCSigma, fErrUp, fErrDown;
124 
125  TF2 funcSig("funcSig","TMath::ErfcInverse(TMath::PoissonI(x,y))*sqrt(2.)",0,100,0,100);
126 
127  TGraphErrors* signal = new TGraphErrors;
128  TGraphErrors* background = new TGraphErrors;
129  TGraphErrors* significance = new TGraphErrors;
130  TGraphErrors* MC = new TGraphErrors;
131  TGraphErrors* MCsignificance = new TGraphErrors;
132  TGraphAsymmErrors *daySignal = new TGraphAsymmErrors;
133  TGraphAsymmErrors *dayBKG = new TGraphAsymmErrors;
134 
135  int kDayPoints = 0;
136  declareSigma();
137 
138  for(unsigned int i=minBin; i<=maxBin; i++)
139  {
140  fSig = h1->Integral(minBin,i);
141  fBKG = h2->Integral(minBin,i);
142  fSigma = funcSig.Eval(fSig, fBKG);
143  fMCSig = MCSignal*POTx->Integral(minBin,i)/POTx->Integral();
144  fMCSigma = funcSig.Eval(fMCSig+fBKG, fBKG);
145 
146  signal->SetPoint(kDayPoints, h1->GetBinCenter(i), fSig);
147  background->SetPoint(kDayPoints, h1->GetBinCenter(i), fBKG);
148  significance->SetPoint(kDayPoints, h1->GetBinCenter(i), fSigma);
149  MC->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSig+fBKG);
150  MCsignificance->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSigma);
151 
152  fSig = h1->GetBinContent(i);
153  fBKG = h2->GetBinContent(i);
154  daySignal->SetPoint(kDayPoints, h1->GetBinCenter(i), fSig);
155  dayBKG->SetPoint(kDayPoints, h1->GetBinCenter(i), fBKG);
156  fErrDown = fSig-jimed[(int)fSig];
157  fErrUp = jimeu[(int)fSig]-fSig;
158  daySignal->SetPointError(kDayPoints, 0, 0, fErrDown, fErrUp);
159 
160  kDayPoints++;
161  }
162 
163  // Signal and background over time
164  TCanvas* c1 = new TCanvas("c1","c1");
165  signal->SetLineColor(kBlack);
166  signal->SetLineWidth(3);
167  signal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(signal->GetN(),signal->GetY())*1.12+4.);
168  signal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
169  signal->GetXaxis()->SetTimeDisplay(1);
170  signal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
171  signal->GetYaxis()->SetTitle("Entries");
172  signal->GetXaxis()->SetTitle("Date");
173  signal->GetXaxis()->SetNdivisions(1);
174  signal->Draw("AL");
175  background->SetLineColor(kBlue);
176  background->SetLineWidth(3);
177  background->Draw("L");
178  MC->SetLineColor(kGray+1);
179  MC->SetLineStyle(9);
180  MC->Draw("L");
181 
182  TLegend* leg = new TLegend(0.15,0.70,0.45,0.89);
183  leg->AddEntry(signal,"Signal","l");
184  leg->AddEntry(MC,"Expectation","l");
185  leg->AddEntry(background,"Background","l");
186  leg->SetFillColor(0);
187  leg->Draw();
188  lastUpdated(timestamp);
189 
190  // Signficance over time
191  TCanvas* c2 = new TCanvas("c2","c2");
192  TGraph* l2 = new TGraph;
193  TGraph* l3 = new TGraph;
194  TGraph* l5 = new TGraph;
195  l2->SetPoint(0,minZoom,2);
196  l2->SetPoint(1,maxZoom,2);
197  l3->SetPoint(0,minZoom,3);
198  l3->SetPoint(1,maxZoom,3);
199  l5->SetPoint(0,minZoom,5);
200  l5->SetPoint(1,maxZoom,5);
201  l2->SetLineStyle(2);
202  l3->SetLineStyle(2);
203  l5->SetLineStyle(2);
204 
205  significance->SetLineColor(kBlue);
206  significance->SetLineWidth(3);
207  significance->GetYaxis()->SetRangeUser(0,TMath::MaxElement(significance->GetN(),significance->GetY())*1.12+4.);
208  significance->GetXaxis()->SetRangeUser(minZoom, maxZoom);
209  significance->GetXaxis()->SetTimeDisplay(1);
210  significance->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
211  significance->GetYaxis()->SetTitle("Significance [ #sigma ]");
212  significance->GetXaxis()->SetTitle("Date");
213  significance->GetXaxis()->SetNdivisions(1);
214  significance->Draw("AL");
215  l2->Draw("L");
216  l3->Draw("L");
217  l5->Draw("L");
218 
219  TLegend* leg2 = new TLegend(0.15,0.70,0.45,0.89);
220  leg2->AddEntry(significance,"Cumulative","l");
221  leg2->SetFillColor(0);
222  leg2->Draw();
223  lastUpdated(timestamp);
224 
225  // Compare with MC
226  TCanvas* c3 = new TCanvas("c3","c3");
227  significance->Draw("AL");
228  l2->Draw("L");
229  l3->Draw("L");
230  l5->Draw("L");
231  MCsignificance->SetLineColor(kRed);
232  MCsignificance->SetLineStyle(9);
233  MCsignificance->Draw("L");
234 
235  TLegend* leg3 = new TLegend(0.15,0.70,0.45,0.89);
236  leg3->AddEntry(significance,"Significance","l");
237  leg3->AddEntry(MCsignificance,"Expectation","l");
238  leg3->SetFillColor(0);
239  leg3->Draw();
240  lastUpdated(timestamp);
241 
242  // Raw daily events
243  TCanvas* c4 = new TCanvas("c4","c4");
244  daySignal->SetLineColor(kBlack);
245  daySignal->SetLineWidth(3);
246  daySignal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(daySignal->GetN(),daySignal->GetY())*1.12+4.);
247  daySignal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
248  daySignal->GetXaxis()->SetTimeDisplay(1);
249  daySignal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
250  daySignal->GetYaxis()->SetTitle("Entries");
251  daySignal->GetXaxis()->SetTitle("Date");
252  daySignal->GetXaxis()->SetNdivisions(1);
253  daySignal->SetMarkerColor(kBlack);
254  daySignal->SetMarkerStyle(20);
255  daySignal->Draw("AP");
256  dayBKG->SetLineColor(kBlue);
257  dayBKG->SetLineWidth(3);
258  dayBKG->SetMarkerColor(kBlue);
259  dayBKG->SetMarkerStyle(24);
260  dayBKG->Draw("P");
261 
262  TLegend* leg4 = new TLegend(0.15,0.70,0.45,0.89);
263  leg4->AddEntry(daySignal,"Daily signal","p");
264  leg4->AddEntry(dayBKG,"Estimated BKG","p");
265  leg4->SetFillColor(0);
266  leg4->Draw();
267  lastUpdated(timestamp);
268 
269 
270  c1->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignalAndBkgOverTime.png").c_str());
271  c2->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignificanceOverTime.png").c_str());
272  c3->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/CumSignificanceOverTime.png").c_str());
273  c4->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/DailySignalAndBkg.png").c_str());
274 
275 
276 } // end getSigmaPlots
277 
278 
279 
280 
281 
282 void getSigmaPlotsAll(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming){
283 
284  gStyle->SetOptStat(0);
285 
286  TFile* file1 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/sig_time.root").c_str());
287  TH1D* h1 = (TH1D*) file1->Get("sig_time");
288  TFile* file2 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/BKG_time.root").c_str());
289  TH1D* h2 = (TH1D*) file2->Get("BKG_time");
290  TFile* file3 = new TFile(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Tools/hPOT.root").c_str());
291  TH2D* hPOT = (TH2D*) file3->Get("hPOT");
292 
293  int POTbins = hPOT->GetNbinsX();
294  double POTmin = hPOT->GetXaxis()->GetBinLowEdge(1);
295  double POTmax = hPOT->GetXaxis()->GetBinLowEdge(POTbins+1);
296 
297  TProfile* POTx = new TProfile("POTx","POTx",POTbins,POTmin,POTmax);
298  hPOT->ProfileX("POTx");
299 
300  unsigned int minBin = h1->FindBin(timestamp - 86400*nDays);
301  unsigned int maxBin = h1->FindBin(timestamp);
302 
303  double minZoom = h2->GetBinLowEdge(minBin);
304  double maxZoom = h2->GetBinLowEdge(maxBin+1);
305 
306  double fSig, fBKG, fSigma, fMCSig, fMCSigma, dSigma, fErrUp, fErrDown;
307 
308  TF2 funcSig("funcSig","TMath::ErfcInverse(TMath::PoissonI(x,y))*sqrt(2.)",0,100,0,100);
309 
310  TGraphErrors* signal = new TGraphErrors;
311  TGraphErrors* background = new TGraphErrors;
312  TGraphErrors* significance = new TGraphErrors;
313  TGraphErrors* MC = new TGraphErrors;
314  TGraphErrors* MCsignificance = new TGraphErrors;
315  TGraphErrors* weekly = new TGraphErrors;
316  TGraphErrors* biweekly = new TGraphErrors;
317  TGraphErrors* monthly = new TGraphErrors;
318  TGraphAsymmErrors *weekSignal = new TGraphAsymmErrors;
319  TGraphAsymmErrors *weekBKG = new TGraphAsymmErrors;
320 
321  int kDayPoints = 0;
322  int kWeekPoints = 0;
323  int kBiweekPoints = 0;
324  int kMonthPoints = 0;
325  declareSigma();
326 
327  for(unsigned int i=minBin; i<=maxBin; i++)
328  {
329  fSig = h1->Integral(minBin,i);
330  fBKG = h2->Integral(minBin,i);
331  fSigma = funcSig.Eval(fSig, fBKG);
332  fMCSig = MCSignal*POTx->Integral(minBin,i)/POTx->Integral();
333  fMCSigma = funcSig.Eval(fMCSig+fBKG, fBKG);
334 
335  signal->SetPoint(kDayPoints, h1->GetBinCenter(i), fSig);
336  background->SetPoint(kDayPoints, h1->GetBinCenter(i), fBKG);
337  significance->SetPoint(kDayPoints, h1->GetBinCenter(i), fSigma);
338  MC->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSig+fBKG);
339  MCsignificance->SetPoint(kDayPoints,h1->GetBinCenter(i), fMCSigma);
340  kDayPoints++;
341  if((i-minBin)>=7 && (i-minBin)%7==0) // weekly plot
342  {
343  fSig = h1->Integral(i-7,i);
344  fBKG = h2->Integral(i-7,i);
345  fSigma = funcSig.Eval(fSig, fBKG);
346  dSigma = TMath::Abs(funcSig.Eval(fSig,fBKG+sqrt(fBKG))-fSigma);
347  weekly->SetPoint(kWeekPoints, h1->GetBinCenter(i), fSigma);
348  weekly->SetPointError(kWeekPoints, 0, dSigma);
349  weekSignal->SetPoint(kWeekPoints, h1->GetBinCenter(i), fSig);
350  weekBKG->SetPoint(kWeekPoints, h1->GetBinCenter(i), fBKG);
351 
352  fErrDown = fSig-jimed[(int)fSig];
353  fErrUp = jimeu[(int)fSig]-fSig;
354  weekSignal->SetPointError(kWeekPoints, 0, 0, fErrDown, fErrUp);
355  kWeekPoints++;
356  }
357 
358  if((i-minBin) >= 14 && (i-minBin)%14==0) // biweekly plot
359  {
360  fSig = h1->Integral(i-14,i);
361  fBKG = h2->Integral(i-14,i);
362  fSigma = funcSig.Eval(fSig, fBKG);
363  dSigma = TMath::Abs(funcSig.Eval(fSig,fBKG+sqrt(fBKG))-fSigma);
364  biweekly->SetPoint(kBiweekPoints, h1->GetBinCenter(i), fSigma);
365  biweekly->SetPointError(kBiweekPoints, 0, dSigma);
366  kBiweekPoints++;
367  }
368 
369  if((i-minBin) >= 30 && (i-minBin)%30==0) // monthly
370  {
371  fSig = h1->Integral(i-30,i);
372  fBKG = h2->Integral(i-30,i);
373  fSigma = funcSig.Eval(fSig, fBKG);
374  dSigma = TMath::Abs(funcSig.Eval(fSig,fBKG+sqrt(fBKG))-fSigma);
375  monthly->SetPoint(kMonthPoints, h1->GetBinCenter(i), fSigma);
376  monthly->SetPointError(kMonthPoints, 0, dSigma);
377  kMonthPoints++;
378  }
379  }
380 
381  // Signal and background over time
382  TCanvas* c1 = new TCanvas("c1","c1");
383  signal->SetLineColor(kBlack);
384  signal->SetLineWidth(3);
385  signal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(signal->GetN(),signal->GetY())*1.12+4.);
386  signal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
387  signal->GetXaxis()->SetTimeDisplay(1);
388  signal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
389  signal->GetYaxis()->SetTitle("Entries");
390  signal->GetXaxis()->SetTitle("Date");
391  signal->GetXaxis()->SetNdivisions(5);
392  signal->Draw("AL");
393  background->SetLineColor(kBlue);
394  background->SetLineWidth(3);
395  background->Draw("L");
396  MC->SetLineColor(kGray+1);
397  MC->SetLineStyle(9);
398  MC->Draw("L");
399 
400  TLegend* leg = new TLegend(0.15,0.70,0.45,0.89);
401  leg->AddEntry(signal,"Signal","l");
402  leg->AddEntry(MC,"Expectation","l");
403  leg->AddEntry(background,"Background","l");
404  leg->SetFillColor(0);
405  leg->Draw();
406  lastUpdated(timestamp);
407 
408  // Signficance over time
409  TCanvas* c2 = new TCanvas("c2","c2");
410  TGraph* l2 = new TGraph;
411  TGraph* l3 = new TGraph;
412  TGraph* l5 = new TGraph;
413  l2->SetPoint(0,minZoom,2);
414  l2->SetPoint(1,maxZoom,2);
415  l3->SetPoint(0,minZoom,3);
416  l3->SetPoint(1,maxZoom,3);
417  l5->SetPoint(0,minZoom,5);
418  l5->SetPoint(1,maxZoom,5);
419  l2->SetLineStyle(2);
420  l3->SetLineStyle(2);
421  l5->SetLineStyle(2);
422 
423  significance->SetLineColor(kBlue);
424  significance->SetLineWidth(3);
425  significance->GetYaxis()->SetRangeUser(0,TMath::MaxElement(significance->GetN(),significance->GetY())*1.12+4.);
426  significance->GetXaxis()->SetRangeUser(minZoom, maxZoom);
427  significance->GetXaxis()->SetTimeDisplay(1);
428  significance->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
429  significance->GetYaxis()->SetTitle("Significance [ #sigma ]");
430  significance->GetXaxis()->SetTitle("Date");
431  significance->GetXaxis()->SetNdivisions(5);
432  significance->Draw("AL");
433  l2->Draw("L");
434  l3->Draw("L");
435  l5->Draw("L");
436 
437  weekly->SetLineColor(kBlack);
438  weekly->SetMarkerColor(kBlack);
439  weekly->SetLineWidth(3);
440  weekly->SetMarkerStyle(20);
441  weekly->Draw("P");
442  biweekly->SetLineColor(kGreen+1);
443  biweekly->SetMarkerColor(kGreen+1);
444  biweekly->SetLineWidth(3);
445  biweekly->SetMarkerStyle(24);
446  biweekly->Draw("P");
447  monthly->SetLineColor(kRed);
448  monthly->SetMarkerColor(kRed);
449  monthly->SetLineWidth(3);
450  monthly->SetMarkerStyle(21);
451  monthly->Draw("P");
452 
453  TLegend* leg2 = new TLegend(0.15,0.70,0.45,0.89);
454  leg2->AddEntry(weekly,"Weekly","pl");
455  leg2->AddEntry(biweekly,"Biweekly","pl");
456  leg2->AddEntry(monthly,"Monthly","pl");
457  leg2->AddEntry(significance,"Cumulative","l");
458  leg2->SetFillColor(0);
459  leg2->Draw();
460  lastUpdated(timestamp);
461 
462  // Compare with MC
463  TCanvas* c3 = new TCanvas("c3","c3");
464  significance->Draw("AL");
465  l2->Draw("L");
466  l3->Draw("L");
467  l5->Draw("L");
468  MCsignificance->SetLineColor(kRed);
469  MCsignificance->SetLineStyle(9);
470  MCsignificance->Draw("L");
471 
472  TLegend* leg3 = new TLegend(0.15,0.70,0.45,0.89);
473  leg3->AddEntry(significance,"Significance","l");
474  leg3->AddEntry(MCsignificance,"Expectation","l");
475  leg3->SetFillColor(0);
476  leg3->Draw();
477  lastUpdated(timestamp);
478 
479  // Raw weekly events
480  TCanvas* c4 = new TCanvas("c4","c4");
481  weekSignal->SetLineColor(kBlack);
482  weekSignal->SetLineWidth(3);
483  weekSignal->GetYaxis()->SetRangeUser(0,TMath::MaxElement(weekSignal->GetN(),weekSignal->GetY())*1.12+4.);
484  weekSignal->GetXaxis()->SetRangeUser(minZoom, maxZoom);
485  weekSignal->GetXaxis()->SetTimeDisplay(1);
486  weekSignal->GetXaxis()->SetTimeFormat("%y-%m-%d%F1970-01-01 00:00:00");
487  weekSignal->GetYaxis()->SetTitle("Entries");
488  weekSignal->GetXaxis()->SetTitle("Date");
489  weekSignal->GetXaxis()->SetNdivisions(5);
490  weekSignal->SetMarkerColor(kBlack);
491  weekSignal->SetMarkerStyle(20);
492  //weekSignal->GetYaxis()->SetNdivisions(0);
493  weekSignal->Draw("AP");
494  weekBKG->SetLineColor(kBlue);
495  weekBKG->SetLineWidth(3);
496  weekBKG->SetMarkerColor(kBlue);
497  weekBKG->SetMarkerStyle(24);
498  weekBKG->Draw("P");
499 
500  TLegend* leg4 = new TLegend(0.15,0.70,0.45,0.89);
501  leg4->AddEntry(weekSignal,"Weekly signal","p");
502  leg4->AddEntry(weekBKG,"Estimated BKG","p");
503  leg4->SetFillColor(0);
504  leg4->Draw();
505  lastUpdated(timestamp);
506 
507  c1->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignalAndBkgOverTime.png").c_str());
508  c2->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/SignificanceOverTime.png").c_str());
509  c3->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/CumSignificanceOverTime.png").c_str());
510  c4->SaveAs(("/nova/ana/users/novadq/TimePeak/Plots/"+naming+"/Plots/WeeklySignalAndBkg.png").c_str());
511 
512 
513 }// end getSigmaPlotsAll
514 
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]
float fSig[xbins]
Definition: MakePlots.C:86
void declareSigma()
TH1F * h2
Definition: plot.C:45
TH1F * h1
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Double_t jimed[51]
void getSigmaPlotsAll(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming)
c1
Definition: demo5.py:24
static constexpr Double_t year
Definition: Munits.h:185