Functions
runTwoSampleDecomp.C File Reference
#include "3FlavorAna/Cuts/NumuCuts.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/HistAxis.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Core/Utilities.h"
#include "CAFAna/Decomp/TwoSampleDecomp.h"
#include "CAFAna/Cuts/Cuts.h"
#include "CAFAna/Vars/Vars.h"
#include "CAFAna/Vars/HistAxes.h"
#include "CAFAna/Analysis/Style.h"
#include <iostream>
#include <string>
#include "TCanvas.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH1.h"

Go to the source code of this file.

Functions

TCanvas * drawTwoPad (TCanvas *top, TCanvas *bottom, TCanvas *can=NULL, float titleOffY=0.035, float leftMargin=0.13, float topMargin=0.1, float bottomFraction=0.4)
 
void runTwoSampleDecomp ()
 

Function Documentation

TCanvas* drawTwoPad ( TCanvas *  top,
TCanvas *  bottom,
TCanvas *  can = NULL,
float  titleOffY = 0.035,
float  leftMargin = 0.13,
float  topMargin = 0.1,
float  bottomFraction = 0.4 
)

Definition at line 26 of file runTwoSampleDecomp.C.

References demo5::c1, demo5::c2, allTimeWatchdog::can, and stan::math::fabs().

Referenced by runTwoSampleDecomp().

29 {
30  DontAddDirectory guard;
31 
32  float pixels = 18.;
33  float labPix = 15.;
34  float labOff = 5.;
35 
36  if (not can) can = new TCanvas();
37 
38  can->SetBottomMargin(0);
39  can->Divide(1,2, 0,0);
40  TVirtualPad* c1 = can->cd(1);
41  c1->SetPad(0,bottomFraction,1,1);
42  c1->SetFillStyle(0);
43  top->DrawClonePad();
44  c1->SetRightMargin(.05);
45  c1->SetTopMargin(topMargin);
46  c1->SetBottomMargin(0.005);
47  c1->SetLeftMargin(leftMargin);
48 
49  c1->Update();
50  float textSizeFac = 1.0/
51  (fabs(c1->YtoAbsPixel(c1->GetY2()) - c1->YtoAbsPixel(c1->GetY1())));
52  float marginSize = 80;
53  float textsizeA = pixels/(c1->GetAbsHNDC()*c1->GetWh());
54  float textsizeAl = labPix/(c1->GetAbsHNDC()*c1->GetWh());
55  float textsizeAo = labOff/(c1->GetWw() * c1->GetAbsWNDC());
56 
57  for(const auto& obj:*(c1->GetListOfPrimitives()))
58 
59  {
60  if (obj->InheritsFrom("TH1"))
61  {
62  ((TH1*)obj)->GetYaxis()->SetTitleSize(textsizeA);
63  ((TH1*)obj)->GetYaxis()->SetLabelSize(textsizeAl);
64  ((TH1*)obj)->GetYaxis()->SetLabelOffset(textsizeAo);
65  ((TH1*)obj)->GetYaxis()->SetTitleOffset(titleOffY / textsizeA);
66  }
67  }
68  c1->Update();
69 
70  TVirtualPad* c2 = can->cd(2);
71  c2->SetPad(0,0.0,1,bottomFraction);
72  bottom->DrawClonePad();
73  c2->SetTopMargin(0.025);
74  c2->SetBottomMargin(.22);
75  c2->SetRightMargin(0.05);
76  c2->SetLeftMargin(leftMargin);
77  c2->Update();
78 
79  float textsize = pixels/(c2->GetAbsHNDC()*c2->GetWh());
80  float textsizel = labPix/(c2->GetAbsHNDC()*c2->GetWh());
81  float textsizeo = labOff/(c2->GetWw() * c2->GetAbsWNDC());
82  float textsizex = pixels/(c2->GetAbsHNDC()*c2->GetWh());
83  float textsizelx = labPix/(c2->GetAbsHNDC()*c2->GetWh());
84  textsizeAl = labPix/(c2->GetAbsHNDC()*c2->GetWh());
85  float textsizeox = labOff/(c2->GetWw() * c2->GetAbsWNDC());
86 
87  for(const auto& obj:*(c2->GetListOfPrimitives()))
88  {
89  if(obj->InheritsFrom("TH1"))
90  {
91  ((TH1*)obj)->GetYaxis()->SetTitleSize(textsize);
92  ((TH1*)obj)->GetYaxis()->SetLabelSize(textsizel);
93  ((TH1*)obj)->GetYaxis()->SetLabelOffset(textsizeAo);
94  ((TH1*)obj)->GetXaxis()->SetTitleSize(textsizex);
95  ((TH1*)obj)->GetXaxis()->SetLabelSize(textsizelx);
96  ((TH1*)obj)->GetXaxis()->SetLabelOffset(textsizeox);
97  ((TH1*)obj)->GetYaxis()->SetTitleOffset(titleOffY / textsize) ;
98  ((TH1*)obj)->GetXaxis()->SetTitleOffset(0.9);
99  }
100  }
101 
102 
103  c2->Update();
104  can->Update();
105 
106  return can;
107 }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
c2
Definition: demo5.py:33
c1
Definition: demo5.py:24
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
TGeoVolume * top
Definition: make_fe_box.C:9
void runTwoSampleDecomp ( )

Definition at line 110 of file runTwoSampleDecomp.C.

References dir, ana::TwoSampleDecomp::DrawRatios(), ana::TwoSampleDecomp::DrawSigBkgOverlay(), drawTwoPad(), ana::TwoSampleDecomp::DrawTwoSamplesWithRatios(), ana::SpectrumLoader::Go(), caf::SRTrackBranch::kalman, ana::kIsNumuCC(), dqsf::kLeft, ana::kNumuND, caf::SRKalman::ntracks, outFile, ana::TwoSampleDecomp::SaveTo(), ana::Binning::Simple(), sr, string, caf::SRKalman::tracks, and caf::StandardRecord::trk.

111 {
112 
113 
114  const std::string pathMC = "/data/novazfs1/users/rocco/2015-08-17_numu_fa_decaf_hadd/hadd_prod_decaf_S15-05-22a_nd_genie_fhc_nonswap_numu_contain_all_v2.1.root";
115  const std::string pathData = "/data/novazfs1/users/rocco/2015-08-17_numu_fa_decaf_hadd/hadd_prod_decaf_S15-05-22a_nd_numi_numu_contain_goodruns.root";
116 
117  SpectrumLoader loaderMC (pathMC);
118  SpectrumLoader loaderData(pathData);
119 
120 
121  const Cut kLeft(
122  {"trk.kalman.ntracks","trk.kalman.tracks.start.x"},
123  [](const caf::SRProxy* sr)
124  {
125  if(sr->trk.kalman.ntracks > 0){
126  double startX = sr->trk.kalman.tracks.start.X();
127  return startX > 0;
128  }
129  return false;
130  });
131 
132  const Cut kDiag(
133  {"trk.kalman.ntracks","trk.kalman.tracks.start.x", "trk.kalman.tracks.start.y"},
134  [](const caf::SRProxy* sr)
135  {
136  if(sr->trk.kalman.ntracks > 0){
137  double startX = sr->trk.kalman.tracks.start.X();
138  double startY = sr->trk.kalman.tracks.start.Y();
139  return startX-startY > 0;
140  }
141  return false;
142  });
143 
144 
145 
146  const Cut kFront(
147  {"trk.kalman.tracks.stop.z"},
148  [](const caf::SRProxy* sr)
149  {
150  if(sr->trk.kalman.ntracks > 0){
151  double stopZ = sr->trk.kalman.tracks.stop.Z();
152  return stopZ < 900;
153  }
154  return false;
155  });
156 
157 
158  const HistAxis numuCCShiftAxis( "Reconstructed Neutrino Energy (GeV)",
159  Binning::Simple(20, 0, 5), kCCEshift );
160 
161 
162 
163  TwoSampleDecomp tsd(loaderMC, loaderData,
164  numuCCShiftAxis, kDiag, kIsNumuCC, kNumuND);
165 
166 
167  loaderMC.Go();
168  loaderData.Go();
169 
170  TFile outFile("twoSampleDecomp.root", "RECREATE");
171  TDirectory* dir = outFile.mkdir("mc");
172 
173 
174  tsd.SaveTo(dir);
175 
176 
177  TCanvas* cOverlay = new TCanvas();
178  tsd.DrawSigBkgOverlay();
179  TCanvas* cBothSamples = new TCanvas();
180  tsd.DrawTwoSamplesWithRatios();
181 
182  TCanvas* cRatios = new TCanvas();
183  tsd.DrawRatios();
184 
185  TCanvas* cSplit = new TCanvas();
186  drawTwoPad(cBothSamples, cRatios, cSplit);
187 
188 }
size_t ntracks
Definition: SRKalman.h:23
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Class for data driven decomposition of signal and background using two different samples with slightl...
SRKalman kalman
Tracks produced by KalmanTrack.
Definition: SRTrackBranch.h:24
TFile * outFile
Definition: PlotXSec.C:135
const Cut kNumuND
Definition: NumuCuts.h:55
caf::StandardRecord * sr
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
TDirectory * dir
Definition: macro.C:5
TCanvas * drawTwoPad(TCanvas *top, TCanvas *bottom, TCanvas *can=NULL, float titleOffY=0.035, float leftMargin=0.13, float topMargin=0.1, float bottomFraction=0.4)
SRTrackBranch trk
Track branch: nhit, len, etc.
std::vector< SRKalmanTrack > tracks
3D Tracks produced by KalmanTrack
Definition: SRKalman.h:16
enum BeamMode string