Functions | Variables
specprod_numuccinc.C File Reference
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Vars/XsecTunes.h"
#include "CAFAna/Systs/XSecSystLists.h"
#include "CAFAna/XSec/GenieMultiverseSyst.h"
#include "CAFAna/Vars/GenieWeights.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "NDAna/numucc_inc/NumuCCIncBins.h"
#include "NDAna/numucc_inc/NumuCCIncVars.h"
#include "NDAna/numucc_inc/NumuCCIncCuts.h"
#include "NDAna/numucc_inc/NDXSecMuonPID.h"
#include "NDAna/numucc_inc/UnfoldingVariable.h"
#include "TFile.h"
#include <iostream>
#include <string>
#include <map>

Go to the source code of this file.

Functions

void specprod_numuccinc (std::string outfileName, int firstGenie, int lastGenie, int firstPPFX=-1, int lastPPFX=-1)
 

Variables

const std::string NOMINAL_DATASET = "nd_fhc_remid-hotfix_caf_minus_muonid_training_minus_fakedata"
 Macro for numucc_inc for running on NERSC. More...
 
const unsigned int N_GENIE_UNIVERSES = 1000
 
const unsigned int N_PPFX_UNIVERSES = 100
 
const ana::NuTruthVar wgt_xsST = ana::kXSecCVWgt2018_smallerDISScale_NT
 
const ana::Var wgt_xs = ana::VarFromNuTruthVar(wgt_xsST, 1)
 
const ana::NuTruthVar wgtST = ana::kPPFXFluxCVWgtST*wgt_xsST
 
const ana::Var wgt = ana::VarFromNuTruthVar(wgtST, 1)
 

Function Documentation

void specprod_numuccinc ( std::string  outfileName,
int  firstGenie,
int  lastGenie,
int  firstPPFX = -1,
int  lastPPFX = -1 
)

Definition at line 39 of file specprod_numuccinc.C.

References om::cout, dir, allTimeWatchdog::endl, exit(), makeBrightnessMap::fOut, ana::getAllXsecSysts_2018_RPAFix(), ana::GetkPPFXFluxUnivWgtST(), ana::GenieMultiverseParameters::GetSystShifts(), ana::SpectrumLoader::Go(), ana::kAllNumuCC1DCuts, ana::kAllNumuCCCuts, ana::kIsTrueSig1DST, ana::kIsTrueSigST, ana::kNoShift, ana::kRecoEStandardAxis(), ana::kRecoMuKEVsCosVsEavailStandardAxis(), ana::kRecoQ2StandardAxis(), ana::kStandardSpillCuts, ana::kTrueEStandardAxisST(), ana::kTrueMuKEVsCosVsEavailStandardAxisST(), ana::kTrueQ2StandardAxisST(), N_GENIE_UNIVERSES, NOMINAL_DATASET, ana::xsec::UnfoldingVariable::SaveSpectrums(), ana::SpectrumLoaderBase::SetSpillCut(), art::to_string(), and PandAna.Demos.tute_pid_validation::var.

40 {
41  // Maps for the UnfoldingVariable class. Store in order of [(uint) iuniv][(string) "varname"]
42  std::map<unsigned int, std::map<std::string, ana::xsec::UnfoldingVariable* > > genieUnfoldingVars;
43  std::map<unsigned int, std::map<std::string, ana::xsec::UnfoldingVariable* > > ppfxUnfoldingVars;
44 
45  // Create the nominal spectrum loader
46  ana::SpectrumLoader * nominalLoader = new ana::SpectrumLoader(NOMINAL_DATASET.c_str());
47  nominalLoader->SetSpillCut(ana::kStandardSpillCuts);
48 
49  if ((firstGenie < 0 || lastGenie < firstGenie) && (firstPPFX < 0 || lastPPFX < firstPPFX))
50  {
51  cout << "Invalid choices for both genie and ppfx universes. Will not create spectrums.\nExiting..." << endl;
52  exit(1);
53  }
54 
55  // Load the genie, use firstGenie < 0 to skip them all
56  if (firstGenie >= 0 && lastGenie >= firstGenie)
57  {
58  cout << "Running " << to_string(lastGenie - firstGenie + 1) << " genie universes. (" << to_string(firstGenie) << "-" << to_string(lastGenie) << ")" << endl;
60  std::vector<ana::SystShifts> genie_shifts = verse.GetSystShifts();
61 
62  for(int igenie = firstGenie; igenie <= lastGenie; ++igenie)
63  {
64  genieUnfoldingVars[igenie]["EAvail"] = new ana::xsec::UnfoldingVariable(nominalLoader,
66  &ana::kAllNumuCCCuts, &ana::kIsTrueSigST, &genie_shifts[igenie], &wgtST);
67 
68  genieUnfoldingVars[igenie]["ENu"] = new ana::xsec::UnfoldingVariable(nominalLoader,
70  &ana::kAllNumuCC1DCuts, &ana::kIsTrueSig1DST, &genie_shifts[igenie], &wgtST);
71 
72  genieUnfoldingVars[igenie]["Q2"] = new ana::xsec::UnfoldingVariable(nominalLoader,
74  &ana::kAllNumuCC1DCuts, &ana::kIsTrueSig1DST, &genie_shifts[igenie], &wgtST);
75  }
76  }
77 
78  // Load the ppfx, use firstPPFX < 0 to skip them all
79  if (firstPPFX >= 0 && lastPPFX >= firstPPFX)
80  {
81  cout << "Running " << to_string(lastPPFX - firstPPFX + 1) << " ppfx universes. (" << to_string(firstPPFX) << "-" << to_string(lastPPFX) << ")" << endl;
82  const std::vector<ana::NuTruthVar> vppfxST = ana::GetkPPFXFluxUnivWgtST();
83 
84  for(int ippfx = firstPPFX; ippfx <= lastPPFX; ++ippfx)
85  {
86  const ana::NuTruthVar * xsTimesPPFXi = new ana::NuTruthVar(wgt_xsST * vppfxST[ippfx]);
87 
88  ppfxUnfoldingVars[ippfx]["EAvail"] = new ana::xsec::UnfoldingVariable(nominalLoader,
91 
92  ppfxUnfoldingVars[ippfx]["ENu"] = new ana::xsec::UnfoldingVariable(nominalLoader,
95 
96  ppfxUnfoldingVars[ippfx]["Q2"] = new ana::xsec::UnfoldingVariable(nominalLoader,
99  }
100  }
101 
102  // Fill the spectrums
103  nominalLoader->Go();
104 
105  // Store it all.
106  TFile* fOut = new TFile(outfileName.c_str(), "RECREATE");
107  fOut->cd();
108  TDirectory* dir;
109 
110  // Save the genie universes (carefully grabbing by references for slight optimization)
111  for (const std::pair<unsigned int, std::map<std::string, ana::xsec::UnfoldingVariable* > >& genieUnivVars : genieUnfoldingVars)
112  {
113  unsigned int genieUniv = genieUnivVars.first;
114  std::string genieUnivStr = to_string(genieUniv);
115  std::string folderName = "genie" + genieUnivStr;
116  const std::map<std::string, ana::xsec::UnfoldingVariable*>& unfoldVars = genieUnivVars.second;
117 
118  dir = fOut->mkdir(folderName.c_str());
119  dir->cd();
120  for (const std::pair<std::string, ana::xsec::UnfoldingVariable*>& genieUnivVar : unfoldVars)
121  {
122  std::string varName = genieUnivVar.first;
123  ana::xsec::UnfoldingVariable * var = genieUnivVar.second;
124 
125  TDirectory * varDir = dir->mkdir(varName.c_str());
126  var->SaveSpectrums(varDir);
127  }
128  }
129 
130  // Save the ppfx universes
131  for (const std::pair<unsigned int, std::map<std::string, ana::xsec::UnfoldingVariable* > >& ppfxUnivVars : ppfxUnfoldingVars)
132  {
133  unsigned int ppfxUniv = ppfxUnivVars.first;
134  std::string ppfxUnivStr = to_string(ppfxUniv);
135  std::string folderName = "ppfx" + ppfxUnivStr;
136  const std::map<std::string, ana::xsec::UnfoldingVariable*>& unfoldVars = ppfxUnivVars.second;
137 
138  dir = fOut->mkdir(folderName.c_str());
139  dir->cd();
140  for (const std::pair<std::string, ana::xsec::UnfoldingVariable*>& ppfxUnivVar : unfoldVars)
141  {
142  std::string varName = ppfxUnivVar.first;
143  ana::xsec::UnfoldingVariable * var = ppfxUnivVar.second;
144 
145  TDirectory * varDir = dir->mkdir(varName.c_str());
146  var->SaveSpectrums(varDir);
147  }
148  }
149  fOut->Close();
150  return;
151 }
const NuTruthCut kIsTrueSigST
const HistAxis kRecoQ2StandardAxis("Reco Q2 (GeV)", q2bins, kRecoq2)
void SaveSpectrums(TDirectory *d)
Save each necessary Spectrum to its own subfolder of dir.
const NuTruthCut kIsTrueSig1DST
void SetSpillCut(const SpillCut &cut)
const NuTruthHistAxis kTrueQ2StandardAxisST("True Q2 (GeV)", q2bins, kTrueQ2_NT)
_Var< caf::SRNeutrinoProxy > NuTruthVar
Var designed to be used over the nuTree, ie all neutrinos, not just those that got slices...
Definition: Var.h:82
virtual void Go() override
Load all the registered spectra.
std::vector< NuTruthVar > GetkPPFXFluxUnivWgtST()
Definition: PPFXWeights.cxx:33
const std::string NOMINAL_DATASET
Macro for numucc_inc for running on NERSC.
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
const Cut kAllNumuCC1DCuts
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::vector< const ISyst * > getAllXsecSysts_2018_RPAFix()
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
TDirectory * dir
Definition: macro.C:5
const ana::NuTruthVar wgtST
exit(0)
const NuTruthHistAxis kTrueMuKEVsCosVsEavailStandardAxisST("True T_{#mu} vs cos #{theta} vs Neutrino Energy (GeV)", angvsmukevseavailbins, kTrueMuKEVsCosVsEavailST)
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const HistAxis kRecoMuKEVsCosVsEavailStandardAxis("Reco. T_{#mu} vs cos #{theta} vs Available Energy (GeV)", angvsmukevseavailbins, kRecoMuKEVsCosVsEavail)
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
Template for Var and SpillVar.
const HistAxis kRecoEStandardAxis("Reconstructed Neutrino Energy (GeV)", enubins, kRecoE)
const NuTruthHistAxis kTrueEStandardAxisST("True Neutrino Energy (GeV)", enubins, kTrueEST)
const unsigned int N_GENIE_UNIVERSES
const Cut kAllNumuCCCuts
const ana::NuTruthVar wgt_xsST

Variable Documentation

const unsigned int N_GENIE_UNIVERSES = 1000

Definition at line 31 of file specprod_numuccinc.C.

Referenced by specprod_numuccinc().

const unsigned int N_PPFX_UNIVERSES = 100

Definition at line 32 of file specprod_numuccinc.C.

const std::string NOMINAL_DATASET = "nd_fhc_remid-hotfix_caf_minus_muonid_training_minus_fakedata"

Macro for numucc_inc for running on NERSC.

Author
Connor Johnson
Date
Sept 2019

Definition at line 30 of file specprod_numuccinc.C.

Referenced by specprod_numuccinc().

Definition at line 37 of file specprod_numuccinc.C.

Referenced by fnex::EventListManipulator::AddFakeDataToEventList(), upmuana::UpMuAnalysis::analyze(), CAFReweightExample(), fnex::ShifterAndWeighter::CalcInterpolatedWgt(), cmf::ShifterAndWeighter::CalcLinearInterpWgt(), fnex::ShifterAndWeighter::CalcLinearInterpWgt(), fnex::ShifterAndWeighter::CalcNearTrueEnergyRatioWeights(), cafrwgt::CAFReweight::CalcWeight(), cafrwgt::CAFReweight::CalcWeightVector(), fnex::ShifterAndWeighter::CalibSystWeight(), jw::CompNormSyst::CompNormSyst(), fnex::ShifterAndWeighter::ExtrapolationWeight(), cmf::CAFToEventList::FillMCVals(), calib::EnergyStandardCandles::FillMichelRecoInfo(), fnex::AnalysisSetupBase::FindXSecWeightSA(), genie::geometry::ROOTGeomAnalyzer::GenerateVertex(), GetCommandLineArgs(), ana::MINERvA_MEC_Wgt_Var::GetWeight(), fnex::Spectrum::Histogram(), fnex::ShifterAndWeighter::HornCurrentWeight(), cmf::ShifterAndWeighter::MaCCQEReducedWeight(), fnex::ShifterAndWeighter::MaCCQEReducedWeight(), main(), fnex::MCVarVals::MCVarVals(), cmf::ShifterAndWeighter::MECEnuShapeWeight(), fnex::ShifterAndWeighter::MECEnuShapeWeight(), cmf::ShifterAndWeighter::MECInitStateNPFracWeight(), fnex::ShifterAndWeighter::MECInitStateNPFracWeight(), cmf::ShifterAndWeighter::MECShapeWeight(), fnex::ShifterAndWeighter::MECShapeWeight(), genie::flux::operator<<(), genie::flux::GSimpleNtpEntry::Reset(), cmf::ShifterAndWeighter::RPACCQEshapeSuppWeight(), fnex::ShifterAndWeighter::RPACCQEshapeSuppWeight(), genie::flux::GDk2NuFlux::ScanForMaxWeight(), genie::flux::GNuMIFlux::ScanForMaxWeight(), SelectInitState(), fnex::MCVarVals::SetGENIEVarVal(), ana::CompNormSyst::Shift(), jw::CompNormSyst::Shift(), specprod_numuccinc(), cmf::ShifterAndWeighter::TotalWeightFromWeighters(), fnex::ShifterAndWeighter::TotalWeightFromWeighters(), cmf::ShifterAndWeighter::Weight(), fnex::ShifterAndWeighter::Weight(), and genie::flux::GDk2NuFluxXMLHelper::~GDk2NuFluxXMLHelper().

Definition at line 35 of file specprod_numuccinc.C.

Referenced by specprod_numuccinc().

Definition at line 34 of file specprod_numuccinc.C.

Referenced by specprod_numuccinc().

Definition at line 36 of file specprod_numuccinc.C.

Referenced by specprod_numuccinc().