make_nue_ana2019_rhc_ub_pot.C
Go to the documentation of this file.
1 #include <bitset>
2 #include <iostream>
4 #include "CAFAna/Cuts/Cuts.h"
6 #include "CAFAna/Cuts/NueCutsFirstAna.h"
8 #include "CAFAna/Core/Loaders.h"
9 #include "CAFAna/Core/Spectrum.h"
13 #include "CAFAna/Vars/HistAxes.h"
14 #include "CAFAna/Core/EventList.h"
16 using namespace ana;
17 
18 #include "TFile.h"
19 #include "TH1D.h"
20 
21 //fiducial mass accounting from docdb-13556
22 
24  {
25  return spill->spilltimesec;
26  });
27 const SpillVar kRun( [](const caf::SRSpillProxy* spill)
28  {
29  return spill->run;
30  });
31 const SpillVar kSpillPOT([](const caf::SRSpillProxy* spill)
32  {
33  return spill->spillpot;
34  });
35 
36 
37 const SpillVar kLiveMass(
38  [](const caf::SRSpillProxy* spill)
39  {
40  std::string binary = std::bitset<14>(spill->dibmask).to_string();
41  double live = 12e-6;
42  if (spill->run < 17946) live = 24e-6;
43  double sum = 0;
44  int dbcount = 1;
45  int mydb = 0;
46  for (int i=13; i>-1; --i){
47  int test = binary[i] - '0';
48  if (dbcount >= spill->dibfirst &&
49  dbcount <= spill->diblast &&
50  test == 1) mydb++;
51  if (dbcount >= spill->dibfirst &&
52  dbcount <= spill->diblast &&
53  test == 0){
54  if (mydb >= 4) sum+= live*kAna2017FiducialMass[mydb];
55  mydb = 0;
56  }
57  dbcount++;
58  }
59  if (mydb >= 4) sum += live*kAna2017FiducialMass[mydb];
60  return sum;
61  });
62 const SpillVar kLive( [](const caf::SRSpillProxy* spill)
63  {
64  if (spill->run < 17946)
65  return 24e-6;
66  else
67  return 12e-6;
68  });
69 const SpillVar kPOTMass(
70  [](const caf::SRSpillProxy* spill)
71  {
72  std::string binary = std::bitset<14>(spill->dibmask).to_string();
73  double pot = 0;
74  int dbcount = 1;
75  int mydb = 0;
76  for (int i=13; i>-1; --i){
77  int test = binary[i] - '0';
78  if (dbcount >= spill->dibfirst &&
79  dbcount <= spill->diblast &&
80  test == 1) mydb++;
81  if (dbcount >= spill->dibfirst &&
82  dbcount <= spill->diblast &&
83  test == 0){
84  if (mydb >= 4) pot+= spill->spillpot*kAna2017FiducialMass[mydb];
85  mydb = 0;
86  }
87  dbcount++;
88  }
89  if (mydb >= 4) pot += spill->spillpot*kAna2017FiducialMass[mydb];
90  return pot;
91  });
92 
93 const Var kSliceTime(
94  [](const caf::SRProxy* sr)
95  {
96  return sr->hdr.unixtime;
97  });
98 
99 
101 {
102  TH1::SetDefaultSumw2();
103 
104  //binned in unix time encompassing first analysis period
105  TH1D* hLiveMass = new TH1D("hLiveMass","livetime exposure;run;exposure (s #times kT)",19458, 12939.5, 32397.5);
106  TH1D* hLive = new TH1D("hLive","livetime;run;livetime (s)",19458, 12939.5, 32397.5);
107  TH1D* hPOTMass = new TH1D("hPOTMass","exposure;run;exposure (POT #times kT)",19458, 12939.5, 32397.5);
108  TH1D* hPOT = new TH1D("hPOT","POT;run;POT",19458, 12939.5, 32397.5);
109  TH1D* hLiveMassT = new TH1D("hLiveMassT","livetime exposure;run;exposure (s #times kT)",16900,1391000000,1560000000);
110  TH1D* hLiveT = new TH1D("hLiveT","livetime;run;livetime (s)",16900,1391000000,1560000000);
111  TH1D* hPOTMassT = new TH1D("hPOTMassT","exposure;run;exposure (POT #times kT)",16900,1391000000,1560000000);
112  TH1D* hPOTT = new TH1D("hPOTT","POT;run;POT",16900,1391000000,1560000000);
113 
114 
115  //load data files
116  SpectrumLoader loaderFDData("prod4_sumrestricteddecaf_fd_numi_rhc_full_goodruns_nue2019", kCosmic);
117 
118  loaderFDData.SetSpillCut(kStandardSpillCuts);
119  loaderFDData.AddSpillHistogram(hLiveMass,kRun,kStandardSpillCuts, kLiveMass);
120  loaderFDData.AddSpillHistogram(hLive,kRun,kStandardSpillCuts, kLive);
121  loaderFDData.AddSpillHistogram(hPOTMass,kRun,kStandardSpillCuts, kPOTMass);
123  loaderFDData.AddSpillHistogram(hLiveMassT,kSpillTime,kStandardSpillCuts, kLiveMass);
125  loaderFDData.AddSpillHistogram(hPOTMassT,kSpillTime,kStandardSpillCuts, kPOTMass);
127  loaderFDData.Go();
128 
129  TFile* outFile = new TFile("nue_ana2019_rhc_pot.root", "RECREATE");
130  hLiveMass->Write();
131  hLive->Write();
132  hPOTMass->Write();
133  hPOT->Write();
134  hLiveMassT->Write();
135  hLiveT->Write();
136  hPOTMassT->Write();
137  hPOTT->Write();
138  outFile->Close();
139 
140 }
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 *kAna2017FiducialMass[mydb];mydb=0;}dbcount++;}if(mydb >=4) sum+=live *kAna2017FiducialMass[mydb];return sum;})
void make_nue_ana2019_rhc_ub_pot()
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
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
caf::Proxy< short unsigned int > dibfirst
Definition: SRProxy.h:1362
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.
const Var kSpillPOT
Return the POT for the spill.
Definition: SpillVars.cxx:33
const SpillVar kLive([](const caf::SRSpillProxy *spill){if(spill->run< 17946) return 24e-6;else return 12e-6;})
caf::Proxy< long unsigned int > spilltimesec
Definition: SRProxy.h:1409
#define pot
caf::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
Proxy for caf::SRSpill.
Definition: SRProxy.h:1346
const SpillVar kPOTMass([](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 *kAna2017FiducialMass[mydb];mydb=0;}dbcount++;}if(mydb >=4) pot+=spill->spillpot *kAna2017FiducialMass[mydb];return pot;})
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 SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
caf::Proxy< float > unixtime
Definition: SRProxy.h:255
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
const double kAna2017FiducialMass[15]
Definition: Exposures.h:179
const SpillVar kSpillTime([](const caf::SRSpillProxy *spill){return spill->spilltimesec;})
enum BeamMode string