179 TFile* covmxFile =
new TFile(
"/pnfs/nova/persistent/analysis/nux/nus20/cmf_covmx/2020-02-14/covariance_matrix_hist_all.root",
182 TH2D* covmx = (TH2D*)covmxFile->Get(
"covar/covarianceMatrix");
183 std::vector<float> fracUncertainty;
185 for (
int i = 93;
i < 93+38; ++
i){
187 if (
i > 93+0 &&
i < 93+20)
189 fracUncertainty.push_back(
std::sqrt(covmx->GetBinContent(
i,
i))*mod);
192 std::vector< std::string > cutLevels = {
196 "QualityVtxFiducial",
201 std::vector< std::string > histNames1D = {
223 std::vector< std::string > histTitles1D = {
224 ";Hits Per Plane;Events;",
225 ";Number Hits in Slice;Events",
226 ";Beam-Transverse Momentum Fraction; Events",
227 ";Number of Elastic Vertices;Events",
228 ";Number of Fuzzy Prongs;Events",
229 ";Number of Continuous Planes;Events",
230 ";Vertex x (cm);Events",
231 ";Vertex y (cm);Events",
232 ";Vertex z (cm);Events",
233 ";Minimum Distance To Top;Events",
234 ";Minimum Distance To Bottom;Events",
235 ";Minimum Distance To East;Events",
236 ";Minimum Distance To West;Events",
237 ";Minimum Distance To Front;Events",
238 ";Minimum Distance To Back;Events",
239 ";CVNnc Score;Events",
240 ";CVNnc Score (looseptp);Events",
241 ";CVNnc Score (oldpresel);Events",
242 ";Calorimetric Energy (GeV);Events" 245 std::vector< CutSide > histCutSide = {
267 std::vector< bool > plotFOM = {
289 std::vector< std::vector< double > > currentCuts = {
311 std::vector< std::string > histNames2D = {
312 "kHitsPerPlaneNSliceHitsHist",
313 "kHitsPerPlanePartPtpHist",
314 "kNSliceHitsPartPtpHist" 317 std::vector< std::string > histTitles2D = {
318 ";Hits Per Plane; Number of Hits in Slice",
319 ";Hits Per Plane; kPartPtp",
320 ";Number of Hits in Slice; kPartPtp" 326 for (
int iH = 0; iH < histNames1D.size(); iH++){
328 TCanvas* c1Ratio =
new TCanvas(
"c1Ratio",
"c1Ratio", 600, 600);
329 TPad *
topPad =
new TPad(
"topPad",
"", 0.005, 0.3, 0.995, 0.995);
330 TPad *bottomPad =
new TPad(
"bottomPad",
"", 0.005, 0.005, 0.995, 0.3);
331 topPad ->SetTopMargin(0.1);
332 topPad ->SetBottomMargin(0.005);
333 bottomPad->SetTopMargin(0.005);
334 bottomPad->SetBottomMargin(0.35);
335 bottomPad->SetGridy();
339 TCanvas*
c1 =
new TCanvas(
"c1",
"c1", 600, 500);
340 TPad *
thisPad =
new TPad(
"topPad",
"", 0.005, 0.005, 0.995, 0.995);
341 thisPad ->SetTopMargin(0.1);
342 thisPad ->SetBottomMargin(0.15);
346 for (
int icl = 0; icl < cutLevels.size(); ++icl){
348 TH1D* histSim = (TH1D*)_file0->Get((
"sim"+histNames1D.at(iH)+
"Hist"+cutLevels.at(icl)).c_str());
349 TH1D* histSimTrueNC = (TH1D*)_file0->Get((
"sim"+histNames1D.at(iH)+
"Hist"+cutLevels.at(icl)+
"TrueNC").c_str());
350 TH1D* histSimTrueNCNoCut = (TH1D*)_file0->Get((
"sim"+histNames1D.at(iH)+
"Hist"+
"NoCutTrueNC").c_str());
351 TH1D* histDatNoCut = (TH1D*)_file0->Get((
"dat"+histNames1D.at(iH)+
"Hist"+cutLevels.at(icl)).c_str());
355 std::string simEnergyString =
"sim"+name+
"CaloEHist"+cutLevels.at(icl);
356 TH2D* histSimEnergy = (TH2D*)_file0->Get(simEnergyString.c_str());
359 if (histDatNoCut !=
nullptr)
360 scalef = (double)histDatNoCut->Integral()/histSim->Integral();
363 histSim ->
Scale(scalef);
364 histSimTrueNC -> Sumw2();
365 histSimTrueNC ->
Scale(scalef);
366 histSimTrueNCNoCut -> Sumw2();
367 histSimTrueNCNoCut ->
Scale(scalef);
369 histSim ->SetLineColor(kGray+1);
370 histSimTrueNC->SetFillColor(kAzure+1);
371 histSimTrueNC->SetLineColor(kAzure+1);
372 histSimTrueNC->SetMarkerColor(kAzure+1);
374 histSim ->SetLineWidth(2);
375 histSim ->GetYaxis()->SetRangeUser(0.0001, histSim->GetMaximum()*maxVal);
376 histSim ->SetTitle(histTitles1D.at(iH).c_str());
377 histSim ->GetYaxis()->SetTitleOffset(1.25);
378 histSim ->GetYaxis()->SetMaxDigits(3);
379 histSim ->GetYaxis()->SetNdivisions(515);
380 histSim ->GetXaxis()->SetTitleFont(43);
381 histSim ->GetXaxis()->SetTitleSize(textSize);
382 histSim ->GetXaxis()->CenterTitle();
383 histSim ->GetYaxis()->SetTitleFont(43);
384 histSim ->GetYaxis()->SetTitleSize(textSize);
385 histSim ->GetYaxis()->CenterTitle();
386 histSim ->GetYaxis()->SetLabelFont(43);
387 histSim ->GetYaxis()->SetLabelSize(textSize);
388 histSim ->GetXaxis()->SetLabelFont(43);
389 histSim ->GetXaxis()->SetLabelSize(textSize);
390 bool isDrawData =
false;
391 if ((histNames1D.at(iH).find(
"CVN") == std::string::npos &&
392 histNames1D.at(iH).find(
"CaloE") == std::string::npos) ||
393 (histNames1D.at(iH).find(
"CVN") != std::string::npos &&
394 cutLevels.at(icl).find(
"QualityVtxFiducial") != std::string::npos) ||
395 (histNames1D.at(iH).find(
"CVN") != std::string::npos &&
396 cutLevels.at(icl).find(
"FullSelection") != std::string::npos) ||
397 (histNames1D.at(iH).find(
"CaloE") != std::string::npos &&
398 cutLevels.at(icl).find(
"FullSelection") != std::string::npos))
404 histSim ->GetYaxis() ->SetTitleOffset(1.3);
405 histSim ->GetYaxis()->SetMaxDigits(3);
406 histSim ->GetYaxis()->SetNdivisions(515);
410 histSim ->Draw(
"hist");
411 histSimTrueNC ->Draw(
"same hist");
412 histSim ->Draw(
"same hist");
414 histDatNoCut ->SetMarkerStyle(20);
415 histDatNoCut ->SetMarkerSize(0.6);
417 histDatNoCut ->GetXaxis()->SetTitleFont(43);
418 histDatNoCut ->GetXaxis()->SetTitleSize(textSize);
419 histDatNoCut ->GetXaxis()->CenterTitle();
420 histDatNoCut ->GetYaxis()->SetTitleFont(43);
421 histDatNoCut ->GetYaxis()->SetTitleSize(textSize);
422 histDatNoCut ->GetYaxis()->CenterTitle();
423 histDatNoCut ->GetYaxis()->SetLabelFont(43);
424 histDatNoCut ->GetYaxis()->SetLabelSize(textSize);
425 histDatNoCut ->GetXaxis()->SetLabelFont(43);
426 histDatNoCut ->GetXaxis()->SetLabelSize(textSize);
427 histDatNoCut ->SetTitle(histTitles1D.at(iH).c_str());
430 histDatNoCut ->Draw(
"same p");
432 TH1D* ratioHist = (TH1D*)histDatNoCut->Clone(
"ratioHist");
433 ratioHist->Divide(histSim);
434 ratioHist->GetYaxis()->SetRangeUser(0.7, 1.29);
435 ratioHist->GetYaxis()->SetNdivisions(505);
436 ratioHist->GetYaxis()->SetTitle(
"Data/Sim");
437 ratioHist->GetYaxis()->SetTitleOffset(1.3);
438 ratioHist->GetXaxis()->SetTitleOffset(3.0);
439 ratioHist->Draw(
"p");
466 TLegend* legFOM =
new TLegend(0.5, 0.70, 0.8, 0.89);
467 if (plotFOM.at(iH) ==
true){
470 <<
"Printing cut values: " 471 <<
"\n-- Efficiency x Purity: " 485 scaleval = histDatNoCut->GetMaximum();
487 scaleval = histSim->GetMaximum()/maxVal;
489 EffTimesPurHist->GetYaxis()->SetRangeUser(0,EffTimesPurHist->GetMaximum()*maxVal);
490 EffTimesPurHist->Scale(scaleval/EffTimesPurHist->GetMaximum());
491 EffTimesPurHist->SetLineColor(
kGreen-3);
492 EffTimesPurHist->SetLineWidth(2);
493 EffTimesPurHist->Draw(
"same hist");
495 SOverSSBHist->Scale(1./SOverSSBHist->GetMaximum() * scaleval);
496 SOverSSBHist->SetLineColor(
kViolet+1);
497 SOverSSBHist->SetLineWidth(2);
498 SOverSSBHist->Draw(
"same hist");
500 SOverSBHist->Scale(0.8/SOverSBHist->GetMaximum() * scaleval);
501 SOverSBHist->SetLineColor(
kOrange+1);
502 SOverSBHist->SetLineWidth(2);
503 SOverSBHist->Draw(
"same hist");
505 legFOM->SetFillStyle(0);
506 legFOM->SetLineWidth(0);
507 legFOM->SetTextFont(43);
508 legFOM->SetTextSize(textSize*0.75);
509 legFOM->AddEntry(EffTimesPurHist,
"Eff #times Purity",
"l");
510 legFOM->AddEntry(SOverSBHist ,
"S/#sqrt{B}",
"l");
511 legFOM->AddEntry(SOverSSBHist ,
"S/#sqrt{S+B+#sigma^{2}_{syst}}",
"l");
516 TGaxis *
axis =
new TGaxis(EffTimesPurHist->GetBinLowEdge(EffTimesPurHist->GetNbinsX()+1), 0.,
517 EffTimesPurHist->GetBinLowEdge(EffTimesPurHist->GetNbinsX()+1), histSim->GetMaximum(),
518 0.0001,maxVal,510,
"+L");
520 axis->SetTitleFont(43);
521 axis->SetTitleSize(textSize);
522 axis->SetLabelFont(43);
523 axis->SetLabelSize(textSize);
524 axis->SetTitle(
"Figure Of Merit");
525 axis->SetTitleOffset(1.4);
530 TBox* box =
new TBox();
531 TBox* box2 =
new TBox(-5000, -5000, -5000, -5000);
533 box->SetY2(histSim->GetMaximum());
534 if (histCutSide.at(iH) ==
kLow){
535 box->SetX1(histSim->GetBinLowEdge(1));
536 box->SetX2(currentCuts.at(iH).at(0));
538 if (histCutSide.at(iH) ==
kHigh){
539 box->SetX1(currentCuts.at(iH).at(0));
540 box->SetX2(histSim->GetBinLowEdge(histSim->GetNbinsX()+1));
542 if (histCutSide.at(iH) ==
kBoth){
543 box->SetX1(histSim->GetBinLowEdge(1));
544 box->SetX2(currentCuts.at(iH).at(0));
545 box2->SetX1(currentCuts.at(iH).at(1));
546 box2->SetX2(histSim->GetBinLowEdge(histSim->GetNbinsX()+1));
547 box2->SetLineWidth(0);
548 box2->SetFillColorAlpha(kGray, 0.4);
550 box2->SetY2(histSim->GetMaximum());
553 box->SetLineWidth(0);
554 box->SetFillColorAlpha(kGray, 0.4);
555 if (currentCuts.at(iH).at(0) != 0 || currentCuts.at(iH).size() > 1)
562 if (plotFOM.at(iH) ==
true)
563 legFOM->Draw(
"same");
565 TLegend*
leg =
new TLegend(0.2, 0.70, 0.5, 0.89);
566 leg->AddEntry(histSim ,
"All Events" ,
"l" );
567 leg->AddEntry(histSimTrueNC,
"True NC Events",
"f" );
568 if (currentCuts.at(iH).at(0) != 0 || currentCuts.at(iH).size() > 1)
569 leg->AddEntry(box ,
"Proposed Cuts" ,
"lf");
571 leg->AddEntry(histDatNoCut,
"Data",
"p");
572 leg->SetLineWidth(0);
573 leg->SetFillStyle(0);
574 leg->SetTextFont(43);
575 leg->SetTextSize(textSize*0.75);
579 c1->SaveAs((histNames1D.at(iH)+cutLevels.at(icl)+
".png").c_str());
580 c1->SaveAs((histNames1D.at(iH)+cutLevels.at(icl)+
".pdf").c_str());
583 c1Ratio->SaveAs((histNames1D.at(iH)+cutLevels.at(icl)+
".png").c_str());
584 c1Ratio->SaveAs((histNames1D.at(iH)+cutLevels.at(icl)+
".pdf").c_str());
589 TH1D* histSimTrueVtxOutOfDet = (TH1D*)_file0->Get((
"sim"+histNames1D.at(iH)+
"Hist"+cutLevels.at(icl)+
"TrueVtxOutOfDet" ).c_str());
590 if (histSimTrueVtxOutOfDet ==
nullptr)
continue;
591 histSimTrueVtxOutOfDet -> Sumw2();
592 histSimTrueVtxOutOfDet ->
Scale(scalef);
596 histSim ->
Draw(
"hist");
597 histSimTrueVtxOutOfDet ->
Draw(
"same hist");
598 histSim ->
Draw(
"same hist");
600 if (currentCuts.at(iH).at(0) != 0 || currentCuts.at(iH).size() > 1)
602 if (histCutSide.at(iH) ==
kBoth)
609 TLegend *leg2 =
new TLegend(0.2, 0.7, 0.5, 0.89);
610 leg2->AddEntry(histSim,
"All Events",
"l");
611 leg2->AddEntry(histSimTrueVtxOutOfDet,
"Rock Events",
"f");
612 leg2->AddEntry(box ,
"Proposed Cuts" ,
"lf");
613 leg2->SetLineWidth(0);
614 leg2->SetFillStyle(0);
615 leg2->SetTextFont(43);
616 leg2->SetTextSize(textSize*0.75);
620 c1->SaveAs((histNames1D.at(iH)+cutLevels.at(icl)+
"containment.png").c_str());
621 c1->SaveAs((histNames1D.at(iH)+cutLevels.at(icl)+
"containment.pdf").c_str());
625 for (
int iH = 0; iH < histNames2D.size(); iH++){
627 TCanvas* c1 =
new TCanvas(
"c1",
"c1", 600, 400);
628 TPad *thisPad =
new TPad(
"topPad",
"", 0.005, 0.005, 0.995, 0.995);
629 thisPad ->SetTopMargin(0.1);
630 thisPad ->SetBottomMargin(0.15);
634 c1->SetRightMargin(0.18);
638 for (
int icl = 0; icl < cutLevels.size(); ++icl){
639 TH2D* histSim = (TH2D*)_file0->Get((
"sim"+histNames2D.at(iH)+cutLevels.at(icl)).c_str());
640 TH2D* histSimTrueNC = (TH2D*)_file0->Get((
"sim"+histNames2D.at(iH)+cutLevels.at(icl)+
"TrueNC").c_str());
642 histSim ->
SetTitle((
"Background"+histTitles2D.at(iH)).c_str());
643 histSimTrueNC ->
SetTitle((
"True NC in Detector"+histTitles2D.at(iH)).c_str());
645 gStyle -> SetTitleFont(43);
646 gStyle -> SetTitleFontSize(0.06);
648 histSim ->GetXaxis()->SetTitleFont(43);
649 histSim ->GetXaxis()->SetTitleSize(textSize);
650 histSim ->GetXaxis()->CenterTitle();
651 histSim ->GetYaxis()->SetTitleFont(43);
652 histSim ->GetYaxis()->SetTitleSize(textSize);
653 histSim ->GetYaxis()->CenterTitle();
654 histSimTrueNC ->GetXaxis()->SetTitleFont(43);
655 histSimTrueNC ->GetXaxis()->SetTitleSize(textSize);
656 histSimTrueNC ->GetXaxis()->CenterTitle();
657 histSimTrueNC ->GetYaxis()->SetTitleFont(43);
658 histSimTrueNC ->GetYaxis()->SetTitleSize(textSize);
659 histSimTrueNC ->GetYaxis()->CenterTitle();
664 histSim->Add(histSimTrueNC, -1);
665 histSim->Draw(
"colz");
666 c1->SaveAs((histNames2D.at(iH)+cutLevels.at(icl)+
".png").c_str());
667 c1->SaveAs((histNames2D.at(iH)+cutLevels.at(icl)+
".pdf").c_str());
669 histSimTrueNC->Draw(
"colz");
670 c1->SaveAs((histNames2D.at(iH)+cutLevels.at(icl)+
"TrueNC.png").c_str());
671 c1->SaveAs((histNames2D.at(iH)+cutLevels.at(icl)+
"TrueNC.pdf").c_str());
673 histSim->Draw(
"box");
674 histSimTrueNC->SetLineColor(kAzure+1);
675 histSimTrueNC->Draw(
"box same");
677 TLegend* leg =
new TLegend(0.6, 0.75, 0.75, 0.85);
678 leg->AddEntry(histSim,
"All Events");
679 leg->AddEntry(histSimTrueNC,
"True NC Events");
680 leg->SetLineWidth(0);
681 leg->SetFillStyle(0);
682 leg->SetTextFont(43);
683 leg->SetTextSize(textSize*0.75);
686 c1->SaveAs((histNames2D.at(iH)+cutLevels.at(icl)+
"together.png").c_str());
687 c1->SaveAs((histNames2D.at(iH)+cutLevels.at(icl)+
"together.pdf").c_str());
bin1_2sigma SetFillColor(3)
gargamelle SetTitle("Gargamelle #nu_{e} CC data")
void getMaximumFOM(TH1D *h)
TH1D * EffTimesPurHist
total data
TH1D * getFOMHist(std::string fomName, CutSide thisCutSide, FomType thisFomType, TH1D *all, TH1D *sig, TH1D *trueSig, TH2D *energyCorr=nullptr, std::vector< float > fracUncertainties={})
simulatedPeak Scale(1/simulationNormalisationFactor)