Analyse_Data2DataComp.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
2 #include "NuXAna/Cuts/NusCuts.h"
5 #include "CAFAna/Core/Var.h"
6 #include "CAFAna/Core/Spectrum.h"
8 #include "CAFAna/Vars/HistAxes.h"
9 #include "NuXAna/Vars/NusVars.h"
11 
12 #include "TFile.h"
13 #include "TSystem.h"
14 
15 using namespace ana;
16 
17 void Analyse_Data2DataComp(std::string data1 = "", std::string data2 = "", std::string s_OutFile = "") {
18 
19  //CUTS TO DIVIDE DETECTOR INTO QUADRANTS.
20  const Cut kUpperWest([](const caf::SRProxy* sr){
21  return ( sr->slc.meanpos.x > 0.0 ) && ( sr->slc.meanpos.y > 0.0 );
22  });
23 
24  const Cut kLowerEast([](const caf::SRProxy* sr){
25  return ( sr->slc.meanpos.x < 0.0 ) && ( sr->slc.meanpos.y < 0.0 );
26  });
27 
28  //CUTS TO DIVIDE ENERGY
29  const Cut kLowEnergy([](const caf::SRProxy* sr) {
30  double energy = kNus18Energy(sr);
31  if (energy < 3.0) return true;
32  return false;
33  });
34  const Cut kHighEnergy([](const caf::SRProxy* sr) {
35  double energy = kNus18Energy(sr);
36  if (energy > 3.0) return true;
37  return false;
38  });
39 
40  //VARS
41  const Var kCVNnc = SIMPLEVAR(sel.cvnProd3Train.ncid);
42 
43  std::vector<SpectrumLoader*> loaders;
44  loaders.push_back(new SpectrumLoader(data1));
45  loaders.push_back(new SpectrumLoader(data2));
46 
47  //DEFINE ARRAY OF LOADERS AND SPECTRA.
48  unsigned int nLoader = 2;
49  std::vector<Spectrum*> spectra[nLoader];
50 
51  for (unsigned int L = 0; L < nLoader; ++L) {
52 
53  // DEFINE ALL SPECTRA HERE:
54  spectra[L].push_back(new Spectrum("NHit in Slice (all slices)", Binning::Simple(15, 0, 300), *loaders[L], kNHit, kNus18ND ));
55  spectra[L].push_back(new Spectrum("NHit in Slice (upper-West)", Binning::Simple(15, 0, 300), *loaders[L], kNHit, kNus18ND && kUpperWest));
56  spectra[L].push_back(new Spectrum("NHit in Slice (lower-East)", Binning::Simple(15, 0, 300), *loaders[L], kNHit, kNus18ND && kLowerEast));
57  spectra[L].push_back(new Spectrum("NHit in Slice (low-energy)", Binning::Simple(15, 0, 300), *loaders[L], kNHit, kNus18ND && kLowEnergy));
58  spectra[L].push_back(new Spectrum("NHit in Slice (high-energy)", Binning::Simple(15, 0, 300), *loaders[L], kNHit, kNus18ND && kHighEnergy));
59 
60  spectra[L].push_back(new Spectrum("Deposited Energy (all slices)", Binning::Simple(40, 0, 20), *loaders[L], kNus18Energy, kNus18ND));
61  spectra[L].push_back(new Spectrum("Deposited Energy (upper-West)", Binning::Simple(40, 0, 20), *loaders[L], kNus18Energy, kNus18ND && kUpperWest));
62  spectra[L].push_back(new Spectrum("Deposited Energy (lower-East)", Binning::Simple(40, 0, 20), *loaders[L], kNus18Energy, kNus18ND && kLowerEast));
63  spectra[L].push_back(new Spectrum("Deposited Energy (low-energy)", Binning::Simple(40, 0, 20), *loaders[L], kNus18Energy, kNus18ND && kLowEnergy));
64  spectra[L].push_back(new Spectrum("Deposited Energy (high energy)", Binning::Simple(40, 0, 20), *loaders[L], kNus18Energy, kNus18ND && kHighEnergy));
65 
66  spectra[L].push_back(new Spectrum("CVNnc Response (all slices)", Binning::Simple(50, 0, 1), *loaders[L], kCVNnc, kNus18ND ));
67  spectra[L].push_back(new Spectrum("CVNnc Response (upper-West)", Binning::Simple(50, 0, 1), *loaders[L], kCVNnc, kNus18ND && kUpperWest));
68  spectra[L].push_back(new Spectrum("CVNnc Response (lower-East)", Binning::Simple(50, 0, 1), *loaders[L], kCVNnc, kNus18ND && kLowerEast));
69  spectra[L].push_back(new Spectrum("CVNnc Response (low-energy)", Binning::Simple(50, 0, 1), *loaders[L], kCVNnc, kNus18ND && kLowEnergy));
70  spectra[L].push_back(new Spectrum("CVNnc Response (high-energy)", Binning::Simple(50, 0, 1), *loaders[L], kCVNnc, kNus18ND && kHighEnergy));
71 
72  spectra[L].push_back(new Spectrum("BDT Response (all slices)", Binning::Simple(50, 0, 1), *loaders[L], kNCCosRejAltp4_6, kNus18ND ));
73  spectra[L].push_back(new Spectrum("BDT Response (upper-West)", Binning::Simple(50, 0, 1), *loaders[L], kNCCosRejAltp4_6, kNus18ND && kUpperWest));
74  spectra[L].push_back(new Spectrum("BDT Response (lower-East)", Binning::Simple(50, 0, 1), *loaders[L], kNCCosRejAltp4_6, kNus18ND && kLowerEast));
75  spectra[L].push_back(new Spectrum("BDT Response (low-energy)", Binning::Simple(50, 0, 1), *loaders[L], kNCCosRejAltp4_6, kNus18ND && kLowEnergy));
76  spectra[L].push_back(new Spectrum("BDT Response (high-energy)", Binning::Simple(50, 0, 1), *loaders[L], kNCCosRejAltp4_6, kNus18ND && kHighEnergy));
77 
78  spectra[L].push_back(new Spectrum("True Energy", Binning::Simple(40, 0, 20), *loaders[L], kTrueE, kNus18ND));
79 
80  }
81 
82  loaders[0]->SetSpillCut(kStandardSpillCuts);
83  loaders[0]->Go();
84  loaders[1]->SetSpillCut(kStandardSpillCuts);
85  loaders[1]->Go();
86 
87  //LOOP OVER ARRAY AND WRITE OUT SPECTRA TO FILE.
88  char dirName[256];
89  TFile *outFile = new TFile(s_OutFile.c_str(), "RECREATE");
90 
91  for (unsigned int L = 0; L < nLoader; ++L)
92  for (unsigned int S = 0; S < spectra[L].size(); ++S)
93  spectra[L][S]->SaveTo(outFile, Form("dir_Var%d_DataSet%d", S, L));
94 
95  std::cout << "\n\n\nALL DONE!\n\n\n";
96 
97 }
const Var kNCCosRejAltp4_6
Definition: NusVarsTemp.h:110
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kNus18Energy([](const caf::SRProxy *sr){bool h_FHC=sr->spill.isFHC;bool h_RHC=sr->spill.isRHC;double cale=sr->slc.calE;double recoE=0.;if(h_FHC &&sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE18 *cale;else if(h_FHC &&sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE18 *cale;else if(h_RHC &&sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE18RHC *cale;else if(h_RHC &&sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE18RHC *cale;return recoE;})
Definition: NusVars.h:63
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
#define S(x, n)
const Var kCVNnc
PID
Definition: Vars.cxx:44
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
#define SIMPLEVAR(CAFNAME)
Definition: Var.h:11
std::vector< double > Spectrum
Definition: Constants.h:746
void Analyse_Data2DataComp(bool isFHC=true, std::string data1="", std::string data2="", std::string s_OutFile="")
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
TFile * outFile
Definition: PlotXSec.C:135
static constexpr double L
caf::Proxy< float > x
Definition: SRProxy.h:106
const Var kNHit
Definition: Vars.cxx:71
double energy
Definition: plottest35.C:25
caf::StandardRecord * sr
const Cut kNus18ND
Full Nus18 ND analysis selection.
Definition: NusCuts18.h:137
OStream cout
Definition: OStream.cxx:6
std::string dirName
Definition: PlotSpectra.h:47
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2142
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
caf::Proxy< float > y
Definition: SRProxy.h:107
caf::Proxy< caf::SRVector3D > meanpos
Definition: SRProxy.h:1310
std::vector< Loaders * > loaders
Definition: syst_header.h:386
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
enum BeamMode string