make_numu_thirdana_pot.C
Go to the documentation of this file.
1 //Calculate analysis exposure, selected events as a function of run
2 
3 #include <bitset>
4 #include <iostream>
6 #include "CAFAna/Cuts/Cuts.h"
8 #include "CAFAna/Cuts/NueCutsFirstAna.h"
10 #include "CAFAna/Core/Loaders.h"
11 #include "CAFAna/Core/Spectrum.h"
15 #include "CAFAna/Vars/HistAxes.h"
16 #include "CAFAna/Core/EventList.h"
18 using namespace ana;
19 
20 #include "TFile.h"
21 #include "TH1D.h"
22 
23 //fiducial mass accounting from docdb-13556
24 
26  {
27  return spill->spilltimesec;
28  });
29 const SpillVar kRun( [](const caf::SRSpillProxy* spill)
30  {
31  return spill->run;
32  });
33 const SpillVar fPOT( [](const caf::SRSpillProxy* spill)
34  {
35  return spill->spillpot;
36  });
37 
38 
39 const SpillVar kLiveMass(
40  [](const caf::SRSpillProxy* spill)
41  {
42  std::string binary = std::bitset<14>(spill->dibmask).to_string();
43  double live = 12e-6;
44  if (spill->run < 17946) live = 24e-6;
45  double sum = 0;
46  int dbcount = 1;
47  int mydb = 0;
48  for (int i=13; i>-1; --i){
49  int test = binary[i] - '0';
50  if (dbcount >= spill->dibfirst &&
51  dbcount <= spill->diblast &&
52  test == 1) mydb++;
53  if (dbcount >= spill->dibfirst &&
54  dbcount <= spill->diblast &&
55  test == 0){
56  if (mydb >= 4) sum+= live*kSecondAnaFiducialMass[mydb];
57  mydb = 0;
58  }
59  dbcount++;
60  }
61  if (mydb >= 4) sum += live*kSecondAnaFiducialMass[mydb];
62  return sum;
63  });
64 const SpillVar kLive( [](const caf::SRSpillProxy* spill)
65  {
66  if (spill->run < 17946)
67  return 24e-6;
68  else
69  return 12e-6;
70  });
71 const SpillVar fPOTMass(
72  [](const caf::SRSpillProxy* spill)
73  {
74  std::string binary = std::bitset<14>(spill->dibmask).to_string();
75  double pot = 0;
76  int dbcount = 1;
77  int mydb = 0;
78  for (int i=13; i>-1; --i){
79  int test = binary[i] - '0';
80  if (dbcount >= spill->dibfirst &&
81  dbcount <= spill->diblast &&
82  test == 1) mydb++;
83  if (dbcount >= spill->dibfirst &&
84  dbcount <= spill->diblast &&
85  test == 0){
86  if (mydb >= 4) pot+= spill->spillpot*kSecondAnaFiducialMass[mydb];
87  mydb = 0;
88  }
89  dbcount++;
90  }
91  if (mydb >= 4) pot += spill->spillpot*kSecondAnaFiducialMass[mydb];
92  return pot;
93  });
94 
95 const Var kSliceTime(
96  [](const caf::SRProxy* sr)
97  {
98  return sr->hdr.unixtime;
99  });
100 
101 
102 void make_numu_thirdana_pot(const std::string& filename_input, const std::string& filename_output)
103 {
104  TH1::SetDefaultSumw2();
105 
106  //binned in unix time encompassing first analysis period
107  TH1D* hLiveMass = new TH1D("hLiveMass","livetime exposure;run;exposure (s #times kT)",12473, 12939.5, 25412.5);
108  TH1D* hLive = new TH1D("hLive","livetime;run;livetime (s)",12473, 12939.5, 25412.5);
109  TH1D* hPOTMass = new TH1D("hPOTMass","exposure;run;exposure (POT #times kT)",12473, 12939.5, 25412.5);
110  TH1D* hPOT = new TH1D("hPOT","POT;run;POT",12473, 12939.5, 25412.5);
111  TH1D* hLiveMassT = new TH1D("hLiveMassT","livetime exposure;run;exposure (s #times kT)",9900,1391000000,1490000000);
112  TH1D* hLiveT = new TH1D("hLiveT","livetime;run;livetime (s)",9900,1391000000,1490000000);
113  TH1D* hPOTMassT = new TH1D("hPOTMassT","exposure;run;exposure (POT #times kT)",9900,1391000000,1490000000);
114  TH1D* hPOTT = new TH1D("hPOTT","POT;run;POT",9900,1391000000,1490000000);
115 
116 
117  //load data files
118  //SpectrumLoader loaderFDData("/pnfs/nova/persistent/production/concat/R16-03-03-prod2reco.f/*/prod_restricteddecaf_R16-03-03-prod2reco.f_fd_numi_fhc_*_nue_contain_v1_goodruns_prod2-snapshot/prod_restricteddecaf_R16-03-03-prod2reco.f_fd_numi_fhc_*_nue_contain_v1_goodruns*.root", kCosmic);
119  //SpectrumLoader loaderFDData("fardet_r00018000_s01_t00_R16-03-03-prod2reco.d_v1_data.caf.root", kCosmic);
120  std::string input = "defname: " + filename_input;
121  SpectrumLoader loaderFDData(input, kCosmic);
122 
123  loaderFDData.SetSpillCut(kStandardSpillCuts);
124  loaderFDData.AddSpillHistogram(hLiveMass,kRun,kStandardSpillCuts, kLiveMass);
125  loaderFDData.AddSpillHistogram(hLive,kRun,kStandardSpillCuts, kLive);
126  loaderFDData.AddSpillHistogram(hPOTMass,kRun,kStandardSpillCuts, fPOTMass);
127  loaderFDData.AddSpillHistogram(hPOT,kRun,kStandardSpillCuts, fPOT);
128  loaderFDData.AddSpillHistogram(hLiveMassT,kSpillTime,kStandardSpillCuts, kLiveMass);
130  loaderFDData.AddSpillHistogram(hPOTMassT,kSpillTime,kStandardSpillCuts, fPOTMass);
132  loaderFDData.Go();
133 
134  TFile* outFile = new TFile(filename_output.c_str(), "RECREATE");
135  hLiveMass->Write();
136  hLive->Write();
137  hPOTMass->Write();
138  hPOT->Write();
139  hLiveMassT->Write();
140  hLiveT->Write();
141  hPOTMassT->Write();
142  hPOTT->Write();
143  outFile->Close();
144 
145 }
const SpillVar kLive([](const caf::SRSpillProxy *spill){if(spill->run< 17946) return 24e-6;else return 12e-6;})
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2137
caf::Proxy< float > spillpot
Definition: SRProxy.h:1407
const SpillVar kSpillTime([](const caf::SRSpillProxy *spill){return spill->spilltimesec;})
const SpillVar kLiveMass([](const caf::SRSpillProxy *spill){std::string binary=std::bitset< 14 >(spill->dibmask).to_string();double live=12e-6;if(spill->run< 17946) live=24e-6;double sum=0;int dbcount=1;int mydb=0;for(int i=13;i >-1;--i){int test=binary[i]- '0';if(dbcount >=spill->dibfirst && dbcount<=spill->diblast && test==1) mydb++;if(dbcount >=spill->dibfirst && dbcount<=spill->diblast && test==0){if(mydb >=4) sum+=live *kSecondAnaFiducialMass[mydb];mydb=0;}dbcount++;}if(mydb >=4) sum+=live *kSecondAnaFiducialMass[mydb];return sum;})
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
caf::Proxy< short unsigned int > dibfirst
Definition: SRProxy.h:1362
void make_numu_thirdana_pot(const std::string &filename_input, const std::string &filename_output)
const Var kSliceTime([](const caf::SRProxy *sr){return sr->slc.meantime/1000;})
Definition: NumuVars.h:34
void SetSpillCut(const SpillCut &cut)
TFile * outFile
Definition: PlotXSec.C:135
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.
caf::Proxy< long unsigned int > spilltimesec
Definition: SRProxy.h:1409
const SpillVar fPOTMass([](const caf::SRSpillProxy *spill){std::string binary=std::bitset< 14 >(spill->dibmask).to_string();double pot=0;int dbcount=1;int mydb=0;for(int i=13;i >-1;--i){int test=binary[i]- '0';if(dbcount >=spill->dibfirst && dbcount<=spill->diblast && test==1) mydb++;if(dbcount >=spill->dibfirst && dbcount<=spill->diblast && test==0){if(mydb >=4) pot+=spill->spillpot *kSecondAnaFiducialMass[mydb];mydb=0;}dbcount++;}if(mydb >=4) pot+=spill->spillpot *kSecondAnaFiducialMass[mydb];return pot;})
#define pot
caf::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
Proxy for caf::SRSpill.
Definition: SRProxy.h:1346
caf::Proxy< unsigned int > run
Definition: SRProxy.h:1406
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
caf::Proxy< short unsigned int > dibmask
Definition: SRProxy.h:1364
const SpillVar fPOT([](const caf::SRSpillProxy *spill){return spill->spillpot;})
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
caf::Proxy< float > unixtime
Definition: SRProxy.h:255
const double kSecondAnaFiducialMass[15]
Definition: Exposures.h:119
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
const Var kRun
Definition: Vars.cxx:20
Template for Var and SpillVar.
Double_t sum
Definition: plot.C:31
Float_t e
Definition: plot.C:35
enum BeamMode string