demo5.C
Go to the documentation of this file.
1 // Use that prediction to make a contour for a really dumb numu analysis
2 
4 
5 #include "CAFAna/Core/Binning.h"
6 #include "CAFAna/Cuts/Cuts.h"
7 #include "CAFAna/Fit/Fit.h"
8 #include "CAFAna/Vars/FitVars.h"
9 #include "CAFAna/Vars/Vars.h"
10 #include "CAFAna/Analysis/Plots.h"
13 #include "CAFAna/Core/Spectrum.h"
16 
18 
19 #include "TCanvas.h"
20 
21 
22 using namespace ana;
23 
24 
25 void demo5()
26 {
27  const std::string fname = "prod_sumdecaf_R17-03-01-prod3reco.k_fd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1";
28  const std::string fnameSwap = "prod_sumdecaf_R17-03-01-prod3reco.k_fd_genie_fluxswap_fhc_nova_v08_period1_nue_or_numu_or_nus_contain_v1";
29 
30  SpectrumLoader loader(fname);
31  SpectrumLoader loaderSwap(fnameSwap);
32 
33  const Binning bins = Binning::Simple(100, 0, 1000);
34 
35  // All interaction types
36  PredictionNoExtrap pred(loader, loaderSwap, "Number of hits in slice", bins, kNHit, kNoCut);
37  // Another way of defining a PredNoExtrap. Note there are different `ProdXLoaders` depending on Ana year.
38  /*
39  Header: #include "CAFAna/Analysis/Prod4Loaders.h"
40 
41  Loaders *loader = new Prod4NomLoaders( <ECAFType::>, <Loaders::kFHC/Loaders::kRHC>, <std::string Period> );
42 
43  pred = new PredictionNoExtrap( *loader, "Number of hits per slice", bins, kNHit, kNoCut);
44  */
45  // Finding Vars:
46  // All CAFAna Vars should be in `CAFAna/Vars`. The most general should be in `CAFAna/Vars/Vars.h`.
47  // A quick search using grep/find/<etc> in that directory should hopefully yield the Var you want.
48 
49 
50  // Do it!
51  loader.Go();
52  loaderSwap.Go();
53 
54  // How to scale histograms
55  const double pot = 18e20;
56 
57  // Make a calculator. This is the fastest variant
59 
60  calc.SetL(810);
61  calc.SetRho(2.75);
62  calc.SetDmsq21(7.6e-5);
63  calc.SetDmsq32(2.35e-3);
64  calc.SetTh12(asin(sqrt(.87))/2);
65  calc.SetTh13(asin(sqrt(.10))/2);
66  calc.SetTh23(TMath::Pi()/4);
67  calc.SetdCP(0);
68 
69  new TCanvas;
70  // What does it predict at these oscillation parameters?
71  Spectrum spred = pred.Predict(&calc);
72  // Add some poisson fluctuations, for fun
73  Spectrum mock = spred.MockData(pot);
74 
75  // See all the components
76  DataMCComparisonComponents(mock, &pred, &calc);
77  // http://nusoft.fnal.gov/nova/novasoft/doxygen/html/namespaceana.html#a19a474dbc249aab1b2c3fb5ae723c22e
78  // Personally, I (Karl W), tend to expand the contents of that function into my macro, but it's a useful function.
79  // Also note that you can specify different;
80  // Flavours - http://nusoft.fnal.gov/nova/novasoft/doxygen/html/namespaceana_1_1Flavors.html#aa60f64652048d17d131d9da6e38df26eaf6d7acd93b8a01cbaf2d7a86a7858124
81  // Currents - http://nusoft.fnal.gov/nova/novasoft/doxygen/html/namespaceana_1_1Current.html#a0284685bc4ae90572e7c9ac760ec6873af9f37ae1299b9b253572ac1de34dc4ad
82  // Signs - http://nusoft.fnal.gov/nova/novasoft/doxygen/html/namespaceana.html#a46dc35ff760761f9c65207f8663d3487a022f571a6e5da9f570c50e5df4ef9849
83 
84  // What did it look like unoscillated?
85  pred.PredictUnoscillated().ToTH1(pot)->Draw("hist same");
86 
87 
88  // Not too complicated to make a contour too
89  new TCanvas;
90  SingleSampleExperiment expt(&pred, mock);
91  FrequentistSurface surf(&expt, &calc,
92  // This version throws illegal axis coordinate values
93  // &kFitSinSq2Theta23, 30, .85, .1,
94  // Less traditional, more correct, option
95  &kFitSinSqTheta23, 30, .35, .65,
96  &kFitDmSq32Scaled, 30, 2.2, 2.8);
97  surf.Draw();
98  surf.DrawContour(Gaussian68Percent2D(surf), 7, kRed); // dashed
99  surf.DrawBestFit(kRed);
100 }
osc::OscCalculatorDumb calc
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Spectrum Predict(osc::IOscCalculator *calc) const override
Oscillation analysis framework, runs over CAF files outside of ART.
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:553
void SetDmsq21(const T &dmsq21) override
Optimized version of OscCalculatorPMNS.
Definition: StanTypedefs.h:28
TH1 * DataMCComparisonComponents(const Spectrum &data, const IPrediction *mc, osc::IOscCalculator *calc)
Plot MC broken down into flavour components, overlayed with data.
Definition: Plots.cxx:113
string fnameSwap
Definition: demo4.py:6
T sqrt(T number)
Definition: d0nt_math.hpp:156
TH2 * Gaussian68Percent2D(const FrequentistSurface &s)
Up-value surface for 68% confidence in 2D in gaussian approximation.
virtual Spectrum PredictUnoscillated() const
Definition: IPrediction.cxx:82
spred
Definition: demo4.py:26
void SetTh23(const T &th23) override
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
void SetDmsq32(const T &dmsq32) override
Log-likelihood scan across two parameters.
void SetdCP(const T &dCP) override
void DrawBestFit(Color_t color, Int_t marker=kFullCircle) const
Draw the best fit point.
Definition: ISurface.cxx:33
expt
Definition: demo5.py:34
void demo5()
Definition: demo5.C:25
void Draw() const
Draw the surface itself.
Definition: ISurface.cxx:20
const Var kNHit
Definition: Vars.cxx:69
void DrawContour(TH2 *fc, Style_t style, Color_t color, double minchi=-1)
Definition: ISurface.cxx:45
#define pot
void SetL(double L) override
virtual void Go() override
Load all the registered spectra.
void SetTh13(const T &th13) override
const FitDmSq32Scaled kFitDmSq32Scaled
Definition: FitVars.cxx:17
loader
Definition: demo0.py:10
const Binning bins
Definition: NumuCC_CPiBin.h:8
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Spectrum MockData(double pot, int idx=0) const
Mock data is FakeData with Poisson fluctuations applied.
Definition: Spectrum.cxx:787
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
void SetTh12(const T &th12) override
const FitSinSqTheta23 kFitSinSqTheta23
Definition: FitVars.cxx:15
void SetRho(double rho) override
Prediction that just uses FD MC, with no extrapolation.
mock
Definition: demo4.py:28
Float_t e
Definition: plot.C:35
loaderSwap
Definition: demo4.py:9
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
Definition: Cut.h:117
T asin(T number)
Definition: d0nt_math.hpp:60
Compare a single data spectrum to the MC + cosmics expectation.
surf
Definition: demo5.py:35