sa_fd_cut_tables.C
Go to the documentation of this file.
1 // This macro is used to make the nue energy blessed plots. (see doc 11789)
2 // Oscillation parameters are same as those in nue_ana_basic macro
3 
4 #include "CAFAna/Cuts/Cuts.h"
7 
10 #include "CAFAna/Core/Spectrum.h"
11 #include "CAFAna/Vars/Vars.h"
13 #include "CAFAna/Cuts/TimingCuts.h"
16 
18 #include "TH1D.h"
19 
20 using namespace ana;
21 
22 
24 {
25 
26  const std::string fnamemc = "dataset_def_name_newest_snapshot prod_caf_R16-03-03-prod2reco.a_fd_genie_nonswap_fhc_nova_v08_full_v1";
27  SpectrumLoader loadermc(fnamemc);
28 
29  const std::string fnamemcswap = "dataset_def_name_newest_snapshot prod_caf_R16-03-03-prod2reco.a_fd_genie_fluxswap_fhc_nova_v08_full_v1";
30  SpectrumLoader loadermcswap(fnamemcswap);
31 
32  const std::string fnamecos = "dataset_def_name_newest_snapshot prod_limitedcaf_R16-03-03-prod2reco.a_fd_cosmic_full_nueveto_v1_goodruns";
33  SpectrumLoader loadercos(fnamecos, kCosmic);
34 
36  loadermcswap.SetSpillCut(kStandardSpillCuts);
38 
39  //------------------------------------------------------------
40 
41  const SpillVar kSpillDummy([](const caf::SRSpill* s)
42  {return 1.0;});
43 
44  //------------------------------------------------------------
45 
46  const SpillVar kCosmicLiveTime(
47  [](const caf::SRSpill* s)
48  {
49  double time =
52  // this is really just 475 - 25
53  return time;
54 
55  });
56 
57  //------------------------------------------------------------
58 
59  const SpillVar kCosmicExposureLiveTime(
60  [&](const caf::SRSpill* s)
61  {
62  int dib;
63  if(s->maskstatus != 1)
64  dib = 0;
65  else
66  dib = s->diblast - s->dibfirst + 1;
67 
68  // this is really just 475 - 25
69  double time =
72 
73  return kFirstAnaFiducialMass[dib]*time;
74  });
75 
76  //------------------------------------------------------------
77 
78  TH1D* exp_time_cos = new TH1D("exp_time_cos",
79  "Livetime ;;us*kT",
80  1,0.5,1.5);
81  loadercos.AddSpillHistogram(exp_time_cos, kSpillDummy,
83  kCosmicExposureLiveTime);
84 
85  TH1D* time_cos = new TH1D("time_cos",
86  "Livetime ;;us",
87  1,0.5,1.5);
88  loadercos.AddSpillHistogram(time_cos, kSpillDummy,
90  kCosmicLiveTime);
91 
92 
93  Spectrum* spec[ncuts][nvars];
94  Spectrum* spec_nminus1_lid[ncuts_nminus1][nvars];
95  Spectrum* spec_nminus1_lem[ncuts_nminus1][nvars];
96  Spectrum* spec_nminus1_cvn[ncuts_nminus1][nvars];
97 
98  IPrediction* preds[ncuts][nvars];
99  IPrediction* preds_nminus1_lid[ncuts_nminus1][nvars];
100  IPrediction* preds_nminus1_lem[ncuts_nminus1][nvars];
101  IPrediction* preds_nminus1_cvn[ncuts_nminus1][nvars];
102 
103  //------------------------------------------------------------
104 
105  for(int iv = 0; iv < nvars; iv++){
106  for(int ic = 0; ic < ncuts_nminus1; ic++){
107  spec_nminus1_lid[ic][iv] = new Spectrum(loadercos, axisarray[iv],
109 
110  spec_nminus1_lem[ic][iv] = new Spectrum(loadercos, axisarray[iv],
112 
113  spec_nminus1_cvn[ic][iv] = new Spectrum(loadercos, axisarray[iv],
115 
116 
117  preds_nminus1_lid[ic][iv] = new PredictionNoExtrap(loadermc, loadermcswap,
118  axisarray[iv].label,
119  axisarray[iv].bins,
120  axisarray[iv].var,
123  preds_nminus1_lem[ic][iv] = new PredictionNoExtrap(loadermc, loadermcswap,
124  axisarray[iv].label,
125  axisarray[iv].bins,
126  axisarray[iv].var,
129  preds_nminus1_cvn[ic][iv] = new PredictionNoExtrap(loadermc, loadermcswap,
130  axisarray[iv].label,
131  axisarray[iv].bins,
132  axisarray[iv].var,
135 
136  }// end loop over nminus1 cuts
137 
138  for(int ic = 0; ic < ncuts; ic++){
139  preds[ic][iv] = new PredictionNoExtrap(loadermc, loadermcswap,
140  axisarray[iv].label,
141  axisarray[iv].bins,
142  axisarray[iv].var,
143  cutsarray[ic],
145 
146  spec[ic][iv] = new Spectrum(loadercos, axisarray[iv],
148 
149  }// end loop over cuts
150 
151  }// end loop over vars
152 
153  loadermc.Go();
154  loadercos.Go();
155  loadermcswap.Go();
156 
157  std::cout<<"making output file \n";
158  TFile fout("fout_sa_fd_cut_tables.root", "RECREATE");
159 
160  exp_time_cos->Write();
161  time_cos->Write();
162 
163  for(int iv = 0; iv < nvars; iv++){
164 
165  for(int ic = 0; ic < ncuts_nminus1; ic++){
166 
167  char name[50];
168 
169  sprintf(name, "spec_nminus1_lid_%s_%s", cutnames_nminus1[ic].c_str(),
170  axisarray[iv].label.c_str());
171  spec_nminus1_lid[ic][iv]->SaveTo(fout.mkdir(name));
172 
173  sprintf(name, "pred_nminus1_lid_%s_%s", cutnames_nminus1[ic].c_str(),
174  axisarray[iv].label.c_str());
175  preds_nminus1_lid[ic][iv]->SaveTo(fout.mkdir(name));
176 
177  sprintf(name, "spec_nminus1_lem_%s_%s", cutnames_nminus1[ic].c_str(),
178  axisarray[iv].label.c_str());
179  spec_nminus1_lem[ic][iv]->SaveTo(fout.mkdir(name));
180 
181  sprintf(name, "pred_nminus1_lem_%s_%s", cutnames_nminus1[ic].c_str(),
182  axisarray[iv].label.c_str());
183  preds_nminus1_lem[ic][iv]->SaveTo(fout.mkdir(name));
184 
185  sprintf(name, "spec_nminus1_cvn_%s_%s", cutnames_nminus1[ic].c_str(),
186  axisarray[iv].label.c_str());
187  spec_nminus1_cvn[ic][iv]->SaveTo(fout.mkdir(name));
188 
189  sprintf(name, "pred_nminus1_cvn_%s_%s", cutnames_nminus1[ic].c_str(),
190  axisarray[iv].label.c_str());
191  preds_nminus1_cvn[ic][iv]->SaveTo(fout.mkdir(name));
192 
193  }// end loop over nminus1 cuts
194 
195  for(int ic = 0; ic < ncuts; ic++){
196 
197  char name[50];
198  sprintf(name, "spec_%s_%s", cutnames[ic].c_str(),
199  axisarray[iv].label.c_str());
200  spec[ic][iv]->SaveTo(fout.mkdir(name));
201 
202  sprintf(name, "pred_%s_%s", cutnames[ic].c_str(),
203  axisarray[iv].label.c_str());
204  preds[ic][iv]->SaveTo(fout.mkdir(name));
205 
206  }// end loop over cuts
207  }// end loop over vars
208 }
const XML_Char * name
Definition: expat.h:151
Oscillation analysis framework, runs over CAF files outside of ART.
const SpillCut kRunsFilter([](const caf::SRSpillProxy *s){static std::set< int > warned;if(s->det!=caf::kFARDET) return true;if(kFilteredRunList.find(s->run)==kFilteredRunList.end()) return true;else{ if(!warned.count(s->run)&&!s->ismc) std::cout<<"\n!!WARNING!!Event in Run "<< s->run<<" was removed by manual bad runs list \n"<<"(CAFAna/Cuts/FilteredRunList.h).\n"<<"THIS SHOULD NOT HAPPEN!! REPORT INCIDENT TO DQ \n"<<"AND PRODUCTION GROUPS SO THIS RUN CAN BE LOGGED IN \n"<<"THE DATABASE WHERE IT IS SUPPOSED TO BE AND NOT IN \n"<<"A TEXT FILE!!!"<< std::endl;warned.insert(s->run);return false;}})
Definition: SpillCuts.h:15
virtual void SaveTo(TDirectory *dir) const
const std::string cutnames_nminus1[ncuts_nminus1]
Definition: sa_fd_arrays.h:43
const int ncuts
Definition: sa_fd_arrays.h:7
const double kFirstAnaFiducialMass[15]
Definition: Exposures.h:48
const int nvars
Definition: sa_fd_arrays.h:144
var
void SetSpillCut(const SpillCut &cut)
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
const char * label
unsigned short dibfirst
first diblock in detector configuration (1-14)
Definition: SRSpill.h:56
const XML_Char * s
Definition: expat.h:262
const double kMinTimingSidebandBeforeMicroSec
const Cut kInCosmicTimingWindow([](const caf::SRProxy *sr){const double t=sr->slc.meantime;if(t< 1000 *util::kMinTimingSidebandBeforeMicroSec|| t > 1000 *util::kMaxTimingSidebandAfterMicroSec) return false;return true;}, [](const caf::SRSpillProxy *spill){return 1e-6 *(util::kMaxTimingSidebandAfterMicroSec-util::kMinTimingSidebandBeforeMicroSec);})
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.h:16
const Cut cutsarray_nminus1_lid[ncuts_nminus1]
Definition: sa_fd_arrays.h:55
virtual void AddSpillHistogram(TH1 *h, const SpillVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
Uses include counting the total POT or spills in a run.
unsigned short diblast
last diblock in detector configuration (1-14)
Definition: SRSpill.h:57
void sa_fd_cut_tables()
virtual void Go() override
Load all the registered spectra.
unsigned short maskstatus
Definition: SRSpill.h:62
const std::string cutnames[ncuts]
Definition: sa_fd_arrays.h:27
const SystShifts kNoShift
Definition: SystShifts.h:112
OStream cout
Definition: OStream.cxx:6
const int ncuts_nminus1
Definition: sa_fd_arrays.h:41
const Cut cutsarray_nminus1_lem[ncuts_nminus1]
Definition: sa_fd_arrays.h:75
const Binning bins
Definition: NumuCC_CPiBin.h:8
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const HistAxis axisarray[nvars]
Definition: sa_fd_arrays.h:145
const Var kTuftsWeightCC
Definition: XsecTunes.h:32
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Cut cutsarray[ncuts]
Definition: sa_fd_arrays.h:9
const Cut cutsarray_nminus1_cvn[ncuts_nminus1]
Definition: sa_fd_arrays.h:95
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:28
Prediction that just uses FD MC, with no extrapolation.
const double kMaxTimingSidebandAfterMicroSec
void SaveTo(TDirectory *dir) const
Definition: Spectrum.cxx:1029
Template for Var and SpillVar.
Definition: Var.h:16