Functions
demo6.C File Reference
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Cuts/Cuts.h"
#include "3FlavorAna/Cuts/NumuCuts.h"
#include "CAFAna/Core/EventList.h"
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Vars/Vars.h"
#include "StandardRecord/Proxy/SRProxy.h"
#include "TCanvas.h"
#include "TH2.h"
#include "TStyle.h"
#include "TLegend.h"
#include "TLatex.h"

Go to the source code of this file.

Functions

void Preliminary ()
 Put NOvA Preliminary on plots. More...
 
void legend (TH1 *data, TH1 *genie, TH1 *cosmic)
 legend to depict Data vs. GENIE MC vs. COSMIC MC More...
 
void demo6 ()
 

Function Documentation

void demo6 ( )

Remove statistics from plots

Data, GENIE, Cosmic MC files

These are just place-holder histograms for ease of use with the TLegend

Spectrum to be filled from the loader List spectra we'd like to draw along with the cuts we'd like to apply Here we're defining cut to be on kCleanup

Definition at line 50 of file demo6.C.

References ana::bins, caf::Proxy< caf::SRSlice >::boxmax, caf::Proxy< caf::SRSlice >::boxmin, caf::Proxy< caf::SRTrackBranch >::cosmic, ana::DataMCComparisonAreaNormalized(), ana::SpectrumLoader::Go(), plot_xsec_1d::hgenie, Integral(), caf::Proxy< caf::SRTrackBranch >::kalman, kBlue, ana::kCleanup, ana::kCosmic, ana::kNContPlanes, ana::kNHit, ana::kNumuContainFD, kRed, demo0::kTrackLen, legend(), ana::MakeEventListFile(), caf::Proxy< caf::StandardRecord >::mc, caf::Proxy< caf::SRSlice >::ncontplanes, caf::Proxy< caf::SRSlice >::nhit, caf::Proxy< caf::SRTruthBranch >::nnu, caf::Proxy< caf::SRTrackBase >::ntracks, caf::Proxy< caf::SRKalman >::ntracks, ana::Spectrum::POT(), Preliminary(), ana::Binning::Simple(), caf::Proxy< caf::StandardRecord >::slc, sr, string, ana::Spectrum::ToTH1(), ana::Spectrum::ToTH2(), caf::Proxy< caf::SRTrackBase >::tracks, caf::Proxy< caf::SRKalman >::tracks, caf::Proxy< caf::StandardRecord >::trk, caf::Proxy< caf::SRVector3D >::X(), caf::Proxy< caf::SRVector3D >::Y(), and caf::Proxy< caf::SRVector3D >::Z().

51 {
52  /// Remove statistics from plots
53  gStyle->SetOptStat(0);
54 
55  /// Data, GENIE, Cosmic MC files
56  const std::string fData = "$NOVA_PROD/data/FarDet/S13-10-11/numi/hadd/fardet_r11761*v3a*caf.root";
57  const std::string fGENIE = "$NOVA_PROD/mc/B13-10-23/genie/fd/ImprovedTrans_newMultiplexReadoutSim/fd_r01_s??_*fhc*caf.root";
58  const std::string fCOSMICS = "$NOVA_PROD/mc/B13-10-23/cosmics/fd/ImprovedTrans_newMultiplexReadoutSim/fd_r01_s??_*cosmics*caf.root";
59 
60  //-------------------------------------------------------------------------
61  /// These are just place-holder histograms for ease of use with the TLegend
62  TH1 *hdata = new TH1("hdata", "hdata", 10, 0, 1);
63  TH1 *hgenie = new TH1("hgenie", "hgenie", 10, 0, 1);
64  TH1 *hcosmic = new TH1("hcosmic", "hcosmic", 10, 0, 1);
65 
66  hdata->SetLineWidth(2);
67  hgenie->SetLineWidth(2);
68  hcosmic->SetLineWidth(2);
69 
70  hdata->SetLineColor(kBlack);
71  hgenie->SetLineColor(kRed);
72  hcosmic->SetLineColor(kBlue);
73 
74  hdata->SetMarkerStyle(kFullCircle);
75  //------------------------------------------------------------------------
76 
77 
78  //------------------------------------------------------------------------
79  // Specify variables needed and arbitrary code to extract value from
80  // SRProxy
81  const Var kBoxMinX( [](const caf::SRProxy* sr)
82  {
83  return sr->slc.boxmin.X();
84  });
85  // Don't use this one, but is another example of a Var definition
86  // with the lambda function
87  const Var kNContPlanes([](const caf::SRProxy* sr)
88  {
89  if(sr->slc.ncontplanes == 0) return (unsigned int)0.0;
90  return sr->slc.ncontplanes;
91  });
92 
93  const Var kHitRatio( [](const caf::SRProxy* sr)
94  {
95  if(sr->trk.cosmic.ntracks == 0) return 0.0;
96  return ((sr->trk.cosmic.tracks[0].nhit*1.0)/(1.0*sr->slc.nhit));
97  });
98 
99  // Cut variable on hit ratio
100  const Cut kHitRatioCut([](const caf::SRProxy* sr)
101  {
102  return ((sr->trk.cosmic.tracks[0].nhit*1.0)/(1.0*sr->slc.nhit)) > 0.88;
103  });
104 
105  const Cut kCleanup([](const caf::SRProxy* sr)
106  {
107  return (sr->slc.nhit > 20 &&
108  sr->trk.cosmic.tracks[0].view == 2);
109  });
110 
111  const Cut kNNu([](const caf::SRProxy* sr)
112  {
113  return (sr->mc.nnu > 0);
114  });
115 
116  const Cut k2DBContain( // If we pretend there's no Cosmics, this works well
117  [](const caf::SRProxy* sr)
118  {
119  return (sr->slc.boxmin.X() > -700 &&
120  sr->slc.boxmin.Y() > -700 &&
121  sr->slc.boxmax.X() < 700 &&
122  sr->slc.boxmax.Y() < 660 &&
123  sr->slc.boxmin.Z() > 100 &&
124  sr->slc.boxmax.Z() < 800);
125  });
126 
127  const Var kTrackLen([](const caf::SRProxy* sr)
128  {
129  if(sr->trk.kalman.ntracks == 0) return 0.0f;
130  return sr->trk.kalman.tracks[0].len;
131  });
132 
133  const Var kNHit([](const caf::SRProxy* sr){return sr->slc.nhit;});
134 
135 
136  //SpectrumLoader definitions
137  SpectrumLoader loadData(fData);
138  SpectrumLoader loadGENIE(fGENIE);
139  SpectrumLoader loadCOSMICS(fCOSMICS,kCosmic);
140 
141  //Any particular binning types for spectra
142  const Binning bins = Binning::Simple(100, 0, 1000);
143 
144  const Binning binsX = Binning::Simple(425, -850, 850);
145 
146  //--------------------------------------------------------------------------
147  /// Spectrum to be filled from the loader
148  /// List spectra we'd like to draw along with the cuts we'd like to apply
149  /// Here we're defining cut to be on kCleanup
150  Spectrum boxminxD("Slice Box Min X (cm)", binsX, loadData, kBoxMinX,kCleanup); // DATA
151  Spectrum boxminxG("Slice Box Min X (cm)", binsX, loadGENIE, kBoxMinX, kNNu && kCleanup); // GENIE MC
152  Spectrum boxminxC("Slice Box Min X", binsX, loadCOSMICS, kBoxMinX, kCleanup); // COSMIC MC
153 
154  // Nhits vs Track Length 2D Spectrum
155  Spectrum nhittracklen("Nhits vs Track Length", loadCOSMICS,
156  bins, kTrackLen, bins, kNHit,kCleanup && kNumuContainFD); // COSMIC MC
157 
158  // Do it!
159  loadGENIE.Go();
160  loadData.Go();
161  loadCOSMICS.Go();
162 
163  //Pick data set we'd like to print run/subrun/event information to text file
164  //Cut on genie events with a neutrino that pass kCleanup and k2DBEnter
165  MakeEventListFile(fGENIE,kNNu && kCleanup,"event-list-genie.txt");
166  //Same cuts to a file for Data - obviously can't rely on truth for a neutrino
167  MakeEventListFile(fData,kCleanup,"event-list-data.txt");
168 //Same cuts to a file for Data - obviously can't rely on truth for a neutrino
169  MakeEventListFile(fCOSMICS,kCleanup,"event-list-cosmics.txt");
170 
171  //--------------------------------------------------------------------------
172  //We have histograms
173 
174  // Nhits vs TrackLength
175 
176 
177  TH2* hnht = nhittracklen.ToTH2(nhittracklen.POT());
178  hnht->Draw("colz");
179  Preliminary();
180 
181  // Slice Box Min X
182  TCanvas *minx = new TCanvas();
183  //Make Data vs. MC area normalized
184  DataMCComparisonAreaNormalized(boxminxD,boxminxG);
185  //Add Cosmic MC for comparison
186  TH1* boxminxc = boxminxC.ToTH1(boxminxC.POT());
187  boxminxc->SetLineColor(kBlue);
188  //Scale Cosmic MC appropriately
189  boxminxc->Scale(boxminxD.ToTH1(boxminxD.POT())->Integral()/boxminxc->Integral());
190  boxminxc->Draw("hist same");
191  minx->SetLogy();
192  //Add Preliminary tag and legend
193  Preliminary();
194  legend(hdata,hgenie,hcosmic);
195 
196 }
void legend(TH1 *data, TH1 *genie, TH1 *cosmic)
legend to depict Data vs. GENIE MC vs. COSMIC MC
Definition: demo6.C:37
enum BeamMode kRed
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
caf::Proxy< std::vector< caf::SRTrack > > tracks
Definition: SRProxy.h:1731
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1778
double Integral(const Spectrum &s, const double pot, int cvnregion)
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
void MakeEventListFile(const std::string &wildcard, const std::vector< Cut > &cuts, const std::vector< std::string > &outputs, bool includeSliceIndex, bool includeSliceTime, bool includeCycleNumber, const SpillCut *spillCut, bool includeBatchNumber)
Make a set of files listing all the events passing cuts One output file is created for each cut in th...
Definition: EventList.cxx:255
caf::Proxy< unsigned int > ncontplanes
Definition: SRProxy.h:1314
const Var kNContPlanes
Definition: NusVars.cxx:13
const Cut kNumuContainFD([](const caf::SRProxy *sr){ std::pair< int, int > planes=calcFirstLastLivePlane(sr->slc.firstplane, std::bitset< 14 >(sr->hdr.dibmask));int planestofront=sr->slc.firstplane-planes.first;int planestoback=planes.second-sr->slc.lastplane;return( sr->slc.ncellsfromedge > 1 &&planestofront > 1 &&planestoback > 1 &&sr->sel.contain.kalfwdcell > 10 &&sr->sel.contain.kalbakcell > 10 &&sr->sel.contain.cosfwdcell > 0 &&sr->sel.contain.cosbakcell > 0);})
Definition: NumuCuts.h:20
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void Preliminary()
Put NOvA Preliminary on plots.
Definition: demo6.C:26
caf::Proxy< caf::SRVector3D > boxmin
Definition: SRProxy.h:1291
caf::Proxy< unsigned int > nhit
Definition: SRProxy.h:1315
TH1 * DataMCComparisonAreaNormalized(const Spectrum &data, const Spectrum &mc)
Definition: Plots.cxx:74
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2145
caf::StandardRecord * sr
const Binning bins
kTrackLen
Definition: demo0.py:15
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
const Cut kCleanup([](const caf::SRProxy *sr){return(sr->slc.nhit > 20 && sr->trk.cosmic.tracks[0].view==2);})
2 di-block era cleanup before applying other cuts
Definition: Cuts.h:54
caf::Proxy< caf::SRKalman > kalman
Definition: SRProxy.h:1797
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2142
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
caf::Proxy< caf::SRTrackBase > cosmic
Definition: SRProxy.h:1795
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1780
enum BeamMode kBlue
kNHit
Definition: demo1.py:19
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1730
caf::Proxy< caf::SRVector3D > boxmax
Definition: SRProxy.h:1290
enum BeamMode string
void legend ( TH1 *  data,
TH1 *  genie,
TH1 *  cosmic 
)

legend to depict Data vs. GENIE MC vs. COSMIC MC

Definition at line 37 of file demo6.C.

References MECModelEnuComparisons::leg.

Referenced by demo6().

37  {
38 
39  TLegend *leg = new TLegend(.50,.57,.84,.84);
40  leg->AddEntry(data,"Far Detector Data","lpe");
41  leg->AddEntry(genie,"GENIE Simulation","l");
42  leg->AddEntry(cosmic,"Cosmic Simulation","l");
43  leg->SetBorderSize(0); //no border for legend
44  leg->SetFillColor(0); //fill colour is white
45  leg->Draw();
46 
47 }
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
const XML_Char const XML_Char * data
Definition: expat.h:268
Sum up livetimes from individual cosmic triggers.
void Preliminary ( )

Put NOvA Preliminary on plots.

Definition at line 26 of file demo6.C.

References kBlue, and prelim.

Referenced by demo6().

27 {
28  TLatex* prelim = new TLatex(.9, .95, "NO#nuA Preliminary");
29  prelim->SetTextColor(kBlue);
30  prelim->SetNDC();
31  prelim->SetTextSize(2/30.);
32  prelim->SetTextAlign(32);
33  prelim->Draw();
34 }
TLatex * prelim
Definition: Xsec_final.C:133
enum BeamMode kBlue