HighLAND
FluxWeighting.hxx
1 #ifndef FluxWeighting_h
2 #define FluxWeighting_h
3 
4 #include <TFile.h>
5 #include <TH1D.h>
6 #include <string>
7 #include "BaseDataClasses.hxx"
8 
9 /// This class provides functions to weight events according to a flux tuning.
10 /// A flux tuning file must be downloaded from t2k.org, and be accessible to
11 /// this code. The path to this file must be specified in the constructor of
12 /// this class. Analysers may wish to use the Parameters class, so that the
13 /// path to the weighting file may be specified in a parameters file, rather
14 /// than hard-coded.
15 ///
16 /// Flux tuning files can be downloaded from:
17 /// http://www.t2k.org/beam/NuFlux/FluxRelease
18 ///
19 /// baseAnalysis provides tools to simplify the application of the
20 /// FluxWeighting.
21 /// In your analysis class, you should specify the following three lines in your
22 /// class constructor:
23 /// _applyFluxWeight = <whether to enable the flux weighting>;
24 /// _fluxFile = <path to the file containing flux histograms>;
25 /// _fluxTuning = <name of the tuning to apply (say, tuned11b)>;
26 ///
27 /// baseAnalysis will then save the appropriate weight based on the true
28 /// neutrino
29 /// flavour and energy in the ND::box().Vertex->TrueVertex member.
30 /// So, you should set the the ND::box().Vertex and ND::box().Vertex->TrueVertex
31 /// members in your analysis, based on the track you have selected. See
32 /// std_numucc_actions::FindVertex() for an example of how to set them. Note
33 /// that
34 /// std_numucc_actions::FindVertex() is called in
35 /// StandardCutsNumuCC::ApplyAllCuts().
37  public:
38  /// Instantiate the flux tuning, reading in the relevant histograms for
39  /// applying the flux tuning.
40  ///
41  /// fluxfile is the ROOT file containing the flux weighting histograms.
42  ///
43  /// tuning if the name of the tuning to use, as specified in the histogram
44  /// titles. For example, the 'tuned11b' tuning will use the histograms with
45  /// titles like enu_nd5_tuned11b_numu_ratio.
46  FluxWeighting(std::string const& fluxfolder, std::string const& version,
47  std::string const& tuning,
48  std::string const& planeident = "nd5");
49 
50  virtual ~FluxWeighting();
51 
52  /// Update the weight associated with this bunch, based on the true vertex.
53  /// The bunch weight is saved automatically to the output micro-tree, and
54  /// is used when plotting histograms with the DrawingTools.
55  void UpdateBunchWeight(AnaBunchB& bunch, AnaTrueVertexB* vertex,
56  int RunPeriod);
57 
58  /// Update the weight associated with this event, based on the true vertex.
59  /// The bunch weight is saved automatically to the output micro-tree, and
60  /// is used when plotting histograms with the DrawingTools.
61  void UpdateEventWeight(AnaEventB& event, AnaTrueVertexB* vertex);
62 
63  /// Get the flux weighting to apply to this vertex, based on the true
64  /// neutrino type and energy.
65  ///
66  /// Analysers should generally use the UpdateBunchWeight() function, rather
67  /// than the GetWeight() function, as the former will automatically save
68  /// the weight to the output micro-tree, for use with the DrawingTools.
69  Float_t GetWeight(AnaTrueVertexB* vertex, int RunPeriod);
70 
71  /// const-safe version of the GetWeight function. See other interface for
72  /// details.
73  Float_t GetWeight(const AnaTrueVertexB& vertex, int RunPeriod);
74 
75  private:
76  /// Histogram of weights for muon neutrinos.
77  TH1D* run1_weight_numu;
78  TH1D* run2_weight_numu;
79  TH1D* run3b_weight_numu;
80  TH1D* run3c_weight_numu;
81  TH1D* run4_weight_numu;
82  TH1D* run5a_weight_numu;
83  TH1D* run5b_weight_numu;
84  TH1D* run5c_weight_numu;
85  TH1D* run6b_weight_numu;
86  TH1D* run6c_weight_numu;
87  TH1D* run6d_weight_numu;
88  TH1D* run6e_weight_numu;
89 
90  /// Histogram of weights for muon anti-neutrinos.
91  TH1D* run1_weight_numubar;
92  TH1D* run2_weight_numubar;
93  TH1D* run3b_weight_numubar;
94  TH1D* run3c_weight_numubar;
95  TH1D* run4_weight_numubar;
96  TH1D* run5a_weight_numubar;
97  TH1D* run5b_weight_numubar;
98  TH1D* run5c_weight_numubar;
99  TH1D* run6b_weight_numubar;
100  TH1D* run6c_weight_numubar;
101  TH1D* run6d_weight_numubar;
102  TH1D* run6e_weight_numubar;
103 
104  /// Histogram of weights for electron neutrinos.
105  TH1D* run1_weight_nue;
106  TH1D* run2_weight_nue;
107  TH1D* run3b_weight_nue;
108  TH1D* run3c_weight_nue;
109  TH1D* run4_weight_nue;
110  TH1D* run5a_weight_nue;
111  TH1D* run5b_weight_nue;
112  TH1D* run5c_weight_nue;
113  TH1D* run6b_weight_nue;
114  TH1D* run6c_weight_nue;
115  TH1D* run6d_weight_nue;
116  TH1D* run6e_weight_nue;
117 
118  /// Histogram of weights for electron anti-neutrinos.
119  TH1D* run1_weight_nuebar;
120  TH1D* run2_weight_nuebar;
121  TH1D* run3b_weight_nuebar;
122  TH1D* run3c_weight_nuebar;
123  TH1D* run4_weight_nuebar;
124  TH1D* run5a_weight_nuebar;
125  TH1D* run5b_weight_nuebar;
126  TH1D* run5c_weight_nuebar;
127  TH1D* run6b_weight_nuebar;
128  TH1D* run6c_weight_nuebar;
129  TH1D* run6d_weight_nuebar;
130  TH1D* run6e_weight_nuebar;
131 
132  /// The input file containing the weights histograms.
133  TFile* run1_file;
134  TFile* run2_file;
135  TFile* run3b_file;
136  TFile* run3c_file;
137  TFile* run4_file;
138  TFile* run5a_file;
139  TFile* run5b_file;
140  TFile* run5c_file;
141  TFile* run6b_file;
142  TFile* run6c_file;
143  TFile* run6d_file;
144  TFile* run6e_file;
145 };
146 
147 #endif
Representation of a true Monte Carlo vertex.
FluxWeighting(std::string const &fluxfolder, std::string const &version, std::string const &tuning, std::string const &planeident="nd5")
void UpdateBunchWeight(AnaBunchB &bunch, AnaTrueVertexB *vertex, int RunPeriod)
Float_t GetWeight(AnaTrueVertexB *vertex, int RunPeriod)
void UpdateEventWeight(AnaEventB &event, AnaTrueVertexB *vertex)