test_fluxhadr_prod_weights_Flux.C
Go to the documentation of this file.
1 #include "CAFAna/Core/Binning.h"
2 #include "CAFAna/Cuts/Cuts.h"
3 #include "CAFAna/Core/Spectrum.h"
7 #include "CAFAna/Systs/Systs.h"
10 #include "CAFAna/Vars/Vars.h"
11 
12 #include "TCanvas.h"
13 #include "TH1.h"
14 #include "TFile.h"
15 #include "TLegend.h"
16 #include "TLine.h"
17 #include "TLatex.h"
18 #include "THStack.h"
19 
20 using namespace ana;
21 
23 
24 
25  const Var kMinervaWeight = kNDMinervaRwtVar;
26  const Var kNOvAWeight = kNDMippNA49NOvARwtVar;
27  SystShifts beamPlus(&kBeamMinerva, 1);
28  SystShifts beamMinus(&kBeamMinerva,-1);
29  SystShifts beamPlusN(&kBeamMippNA49, 1);
30  SystShifts beamMinusN(&kBeamMippNA49,-1);
31 
32  SpectrumLoader loaderNDMC("defname:prod_caf_S15-05-22a_nd_genie_fhc_nonswap_ndnewpos with limit 100");
33  SpectrumLoader loaderNDData("defname:prod_caf_S15-05-22a_nd_numi_goodruns with limit 100");
34  const Cut numuCC([](const caf::SRProxy* sr)
35  {
36  if(sr->mc.nnu == 0) return false;
37  assert(sr->mc.nnu == 1);
38  return (sr->mc.nu[0].iscc && abs(sr->mc.nu[0].pdg)==14);
39  });
40 
41  const Cut kIsGoodBeamS([](const caf::SRProxy* sr)
42  {
43  return(sr->spill.isgoodspill && sr->spill.hornI !=0 );
44  }
45  );
46  const Cut kIsGoodMC([](const caf::SRProxy* sr)
47  {
48  if(sr->mc.nnu == 0) return false;
49  assert(sr->mc.nnu == 1);
50  return(sr->mc.nnu == 1);
51  }
52  );
53  //*******************
54  const Cut kdata = kIsGoodBeamS && kNumuND;
55  const Cut kmc = kIsGoodMC && kNumuND;
56  const Var kNuE = SIMPLEVAR(energy.numu.trkccE);
57 
58  const HistAxis axisEnu(
59  "E_{#nu} (GeV)", Binning::Simple(40, 0, 10), kNuE);
60  //*******************
61 
62  Spectrum Enu (loaderNDMC, axisEnu, kmc, kNoShift);
63  Spectrum Enudata (loaderNDData, axisEnu, kdata, kNoShift); // Nominal MC and Data
64 
65  Spectrum EnuNOvA (loaderNDMC, axisEnu, kmc, kNoShift,kNOvAWeight);// Rewt Nominal MC w.r.t MIPP+NA49 wts from NOvA(Thick MIPP target)
66 
67  Spectrum EnuMinerva (loaderNDMC, axisEnu, kmc, kNoShift,kMinervaWeight);// Rewt Nominal MC w.r.t Minerva's wts from Leo(thin target)
68 
69  Spectrum EnuMinervaplus(loaderNDMC, axisEnu, kmc, beamPlus); //kMinervaWeight); plus systematic uncertainty with zero weight
70  Spectrum EnuMinervaMinus(loaderNDMC, axisEnu, kmc, beamMinus);//, kMinervaWeight); minus systematic uncertainty with zero weight
71 
72  Spectrum EnuNOvAplus(loaderNDMC, axisEnu, kmc, beamPlusN);//, kNOvAWeight); plus systematic uncertainty with zero weight
73  Spectrum EnuNOvAMinus(loaderNDMC, axisEnu, kmc, beamMinusN); //, kNOvAWeight); minus systematic uncertainty with zero weight
74 
75 
76  loaderNDMC.Go();
77  loaderNDData.Go();
78 
79  TFile * file = new TFile ("test_Rwt_HD.root","recreate");//HD- hadro-production weight for Flux
80 
81  Enu.SaveTo(file, "Enu");
82  Enudata.SaveTo(file, "Enudata");
83  EnuMinerva.SaveTo(file, "EnuMinerva");
84  EnuNOvA.SaveTo(file, "EnuNOvA");
85  EnuMinervaplus.SaveTo(file, "EnuMinervaplus");
86  EnuNOvAplus.SaveTo(file, "EnuNOvAplus");
87  EnuMinervaMinus.SaveTo(file, "EnuMinervaMinus");
88  EnuNOvAMinus.SaveTo(file, "EnuNOvAMinus");
89  //return;
90 
91  //****************************************************
92  double thePOT = 1E20;
93 
94  auto hEnu= Enu.ToTH1(thePOT);
95  auto hEnuMinerva= EnuMinerva.ToTH1(thePOT);
96  auto hEnudata= Enudata.ToTH1(thePOT);
97  auto hEnuNOvA= EnuNOvA.ToTH1(thePOT);
98 
99  hEnu->Draw("Hist");
100  hEnuMinerva->SetLineColor(4);
101  hEnuNOvA->SetLineColor(2);
102  hEnudata->Draw("p same");
103  hEnuMinerva->Draw("Hist same");
104  hEnuNOvA->Draw("Hist same");
105 
106  return;
107 }
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2143
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
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:148
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
void abs(TH1 *hist)
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
caf::Proxy< bool > isgoodspill
Definition: SRProxy.h:1377
caf::Proxy< float > hornI
Definition: SRProxy.h:1371
void test_fluxhadr_prod_weights_Flux()
const Cut kNumuND
Definition: NumuCuts.h:55
double energy
Definition: plottest35.C:25
const Var kNDMippNA49NOvARwtVar
Definition: Vars.h:141
caf::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const Var kNDMinervaRwtVar
Definition: Vars.h:139
const SystShifts kNoShift
Definition: SystShifts.cxx:21
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:88
TFile * file
Definition: cellShifts.C:17
assert(nhit_max >=nhit_nbins)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107