VarsAndCuts.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Cuts/Cuts.h"
6 #include "CAFAna/Cuts/NumuCuts.h"
7 #include "CAFAna/Core/Loaders.h"
9 #include "CAFAna/Core/Spectrum.h"
11 #include "CAFAna/Vars/Vars.h"
12 #include "CAFAna/Analysis/Calcs.h"
13 #include "CAFAna/Analysis/Plots.h"
14 
16 
17 #include "TStyle.h"
18 #include "TCanvas.h"
19 #include "TGraph.h"
20 #include "TGraphAsymmErrors.h"
21 #include "TFile.h"
22 #include "TH1.h"
23 #include "TH2.h"
24 #include "TLegend.h"
25 #include "TLatex.h"
26 #include "TProfile.h"
27 #include "TTimeStamp.h"
28 #include "TPaveLabel.h"
29 
30 using namespace ana;
31 
32 // Vars
33 const Var kTime = SIMPLEVAR(hdr.unixtime);
34 const Var kYear = SIMPLEVAR(hdr.year);
35 const Var kMonth = SIMPLEVAR(hdr.month);
36 
37 // Spill vars
39  {
40  return spill->spilltimesec;
41  });
42 
43 const SpillVar kPOTe15([](const caf::SRSpillProxy* spill)
44  {
45  return spill->spillpot/1e15;
46  });
47 
48 const SpillVar kPOTe12([](const caf::SRSpillProxy* spill)
49  {
50  return spill->spillpot/1e12;
51  });
52 
53 SpillCut kHasBatches([](const caf::SRSpillProxy* spill)
54  {
55  return spill->intx.size() > 0 && spill->inty.size() > 0;
56  });
57 
58 SpillVar getBatchPOT(unsigned int iBatch)
59 {
60  SpillVar kBatchInt([iBatch](const caf::SRSpillProxy* spill)
61  {
62  if(iBatch >= spill->intx.size()) return -1.0;
63  if(iBatch >= spill->inty.size()) return -1.0;
64 
65  return 0.5*(spill->intx[iBatch] + spill->inty[iBatch]);
66  });
67 
68  return kBatchInt;
69 }
70 
71 SpillCut getYearAndMonth(unsigned int iYear, unsigned int iMonth)
72 {
73  SpillCut kYandM([iYear, iMonth](const caf::SRSpillProxy* spill)
74  {
75  TTimeStamp spilltime(spill->spilltimesec);
76  unsigned int year, month, day;
77  spilltime.GetDate(kFALSE, 0, &year, &month, &day);
78  return (year == iYear && month == iMonth);
79  });
80 
81  return kYandM;
82 };
83 
84 const Var kSpillPOT([](const caf::SRProxy *sr)
85  {
86  return sr->spill.spillpot/1e12;
87  });
88 
89 const Var kSliceTime([](const caf::SRProxy *sr)
90  {
91  return sr->slc.meantime/1000;
92  });
93 
94 /// ====================================================================== ///
95 
96 Cut getBatch(unsigned int iBatch)
97 {
98  const Cut kInBatch([iBatch](const caf::SRProxy *sr)
99  {
100  return sr->slc.meantime > 218.0e3 + (10./6)*iBatch*1.e3
101  && sr->slc.meantime < 218.0e3 + (10./6)*(iBatch+1)*1.e3;
102  });
103 
104  return kInBatch;
105 }
106 
107  /// ====================================================================== ///
108 
109  struct Plot
110  {
113  Binning bins;
114  Var var;
116  double yRangeLow;
117  double yRangeHigh;
118  };
119 
120  struct Dataset
121  {
123  unsigned int year;
124  unsigned int month;
125  unsigned int style; // 20, 21, 22, 23 and 29 are acceptable
126  unsigned int color; // kRed, kBlue, kOrange, kGreen + 2, kViolet
127  };
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2142
const SpillVar kPOTe12([](const caf::SRSpillProxy *spill){return spill->spillpot/1e12;})
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
SpillVar getBatchPOT(unsigned int iBatch)
Definition: VarsAndCuts.h:58
unsigned int year
Definition: VarsAndCuts.h:123
caf::Proxy< float > spillpot
Definition: SRProxy.h:1406
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2125
const Var kSliceTime([](const caf::SRProxy *sr){return sr->slc.meantime/1000;})
Definition: NumuVars.h:34
const Var kTime
Definition: VarsAndCuts.h:33
const char * label
const SpillVar kSpillTime([](const caf::SRSpillProxy *spill){return spill->spilltimesec;})
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:88
====================================================================== ///
Definition: CutFlow_Data.C:28
const Var kSpillPOT
Return the POT for the spill.
Definition: SpillVars.cxx:33
SpillCut kHasBatches([](const caf::SRSpillProxy *spill){return spill->intx.size() > 0 &&spill->inty.size() > 0;})
double yRangeLow
Definition: VarsAndCuts.h:116
std::string label
Definition: VarsAndCuts.h:122
unsigned int style
Definition: VarsAndCuts.h:125
SpillCut getYearAndMonth(unsigned int iYear, unsigned int iMonth)
Definition: VarsAndCuts.h:71
caf::StandardRecord * sr
Print the time of each NuMI spill, or another specified trigger type. This is intended for use by Eli...
unsigned int color
Definition: VarsAndCuts.h:126
unsigned int month
Definition: VarsAndCuts.h:124
const Binning bins
Definition: NumuCC_CPiBin.h:8
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2141
double yRangeHigh
Definition: VarsAndCuts.h:117
caf::Proxy< float > meantime
Definition: SRProxy.h:1310
const SpillVar kPOTe15([](const caf::SRSpillProxy *spill){return spill->spillpot/1e15;})
Cut getBatch(unsigned int iBatch)
====================================================================== ///
Definition: VarsAndCuts.h:96
const Var kYear
Definition: VarsAndCuts.h:34
Template for Cut and SpillCut.
Definition: Cut.h:15
Cut cut
Definition: VarsAndCuts.h:115
const Var kMonth
Definition: VarsAndCuts.h:35
static constexpr Double_t year
Definition: Munits.h:185
enum BeamMode string