get_data_and_cosmic.C
Go to the documentation of this file.
2 #include "CAFAna/Core/Progress.h"
3 #include "CAFAna/Core/MultiVar.h"
5 #include "CAFAna/Core/Spectrum.h"
8 #include "CAFAna/Cuts/NueCutsSecondAna.h"
9 #include "CAFAna/Vars/Vars.h"
13 #include "OscLib/OscCalcDumb.h"
14 #include "OscLib/IOscCalc.h"
17 
19 //#include "./myvars.h"
20 
21 using namespace ana;
22 
23 #include "TFile.h"
24 
25 void get_data_and_cosmic(std::string suffix = "full")
26 {
27 
28  const std::string fnameData = "dataset_def_name_newest_snapshot prod_sumrestricteddecaf_R17-03-01-prod3reco.k_fd_numi_fhc_full_v1_goodruns_nue2017";
29 
30  SpectrumLoader loaderData(fnameData);
31 
32  loaderData.SetSpillCut(kStandardSpillCuts);
33 
34  Spectrum* spects[kNumSels][kNumVars];
35  Spectrum* cosm[kNumSels][kNumVars];
36 
37  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
38  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
39  const HistAxis& axis = defs[varIdx].axis;
40  spects[selIdx][varIdx] = new Spectrum(axis.GetLabels()[0] , axis.GetBinnings()[0], loaderData, axis.GetVars()[0], sels[selIdx]&&kInBeamSpill);
41  cosm[selIdx][varIdx] = new Spectrum(axis.GetLabels()[0] , axis.GetBinnings()[0], loaderData, axis.GetVars()[0], sels[selIdx]&&kInTimingSideband);
42  }
43  }
44 
45  loaderData.Go();
46 
47  TFile* file = new TFile(("data_spectra_"+suffix+".root").c_str(), "RECREATE");
48  for(int selIdx = 0; selIdx<kNumSels; ++selIdx){
49  TDirectory* d = file->mkdir(selNames[selIdx].c_str());
50  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
51  const char* name = defs[varIdx].name.c_str();
52  spects[selIdx][varIdx]->SaveTo(d, TString::Format("spect_%s", name));
53  }
54  }
55 
56  TFile* file_cosm = new TFile(("cosmic_spectra_"+suffix+".root").c_str(), "RECREATE");
57  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
58  TDirectory* d = file_cosm->mkdir(selNames[selIdx].c_str());
59  for(int varIdx=0; varIdx<kNumVars;varIdx++){
60  const char* name = defs[varIdx].name.c_str();
61  cosm[selIdx][varIdx]->SaveTo(d, TString::Format("cosm_%s", name));
62  }
63  }
64 
65 }
const XML_Char * name
Definition: expat.h:151
const int kNumVars
Definition: vars.h:14
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const std::vector< T > & GetVars() const
Definition: HistAxis.h:92
void get_data_and_cosmic(std::string suffix="full")
std::string name
Definition: NuePlotLists.h:12
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Cut kInTimingSideband([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return(kInTimingSideband_before(sr)|| kInTimingSideband_after(sr));else return(kInTimingSideband_before(sr)|| kInTimingSideband_afterA(sr)|| kInTimingSideband_afterB(sr));}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_after.Livetime(spill));else return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_afterA.Livetime(spill)+ kInTimingSideband_afterB.Livetime(spill));}, [](const caf::SRSpillProxy *spill){return 0;})
Definition: TimingCuts.h:12
const Cut sels[kNumSels]
Definition: vars.h:44
Float_t d
Definition: plot.C:236
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
const HistDef defs[kNumVars]
Definition: vars.h:15
const int kNumSels
Definition: vars.h:43
std::vector< float > Spectrum
Definition: Constants.h:570
HistAxis axis
Definition: NuePlotLists.h:13
const std::vector< Binning > & GetBinnings() const
Definition: LabelsAndBins.h:69
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
TFile * file
Definition: cellShifts.C:17
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
const std::string selNames[kNumSels]
Definition: vars.h:46
const std::vector< std::string > & GetLabels() const
Definition: LabelsAndBins.h:68