HighLAND
DrawingTools.hxx
1 #ifndef DrawingTools_h
2 #define DrawingTools_h
3 
4 #include "DataSample.hxx"
5 #include "Experiment.hxx"
6 #include "DrawingToolsBase.hxx"
7 
8 /// The DrawingTools class provides functions for plotting information in the
9 /// micro-tree file. The DrawingTools can be used in interactive ROOT sessions
10 /// and simple ROOT macros.
11 ///
12 /// There is a distinction between the code for drawing plots (this class,
13 /// DrawingTools) and the code for selecting the right data to plot
14 /// (DataSample).
15 ///
16 /// A file must be specified when instantiating the DrawingTools class, as the
17 /// file contains important information in the "config" tree, that is used by
18 /// the DrawingTools (including the cuts that an analysis performed, and the
19 /// categories used when drawing stacked histograms.
20 ///
21 /// More documentation on how to use the DrawingTools, including example
22 /// macros, can be found in the highLevelAnalysis package documentation (follow
23 /// the links from the main page).
24 ///
25 /// TODO: This class must be properly documented.
27 public :
28 
29  DrawingTools(const std::string& file="", Int_t T2KstyleIndex=0);
30  DrawingTools(Experiment& exp, Int_t T2KstyleIndex=0);
31  virtual ~DrawingTools(){}
32 
33  void DrawToys(DataSample& data, const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
34  void DrawToysRatio(DataSample& sample1, DataSample& sample2, const std::string& cut="",
35  const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="", double norm=-1, bool pot_norm=true);
36  void DrawToysRatioTwoCuts(DataSample& sample1, DataSample& sample2, const std::string& cut1, const std::string& cut2,
37  const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="", double norm=-1, bool pot_norm=true);
38 
39 
40  TH1_h* GetHisto(DataSample& data,const std::string& name, const std::string& var, int nx, double* xbins,
41  const std::string& cut, const std::string& root_opt, const std::string& opt, double scale, bool scale_errors=true);
42 
43  using DrawingToolsBase::GetHisto;
44  TH1_h* GetHisto(HistoStack* hs, TTree* tree ,const std::string& name, const std::string& var, int nx, double* xbins,
45  const std::string& cut, const std::string& root_opt, const std::string& opt, double scale, bool scale_errors=true, int refana=-1);
46 
47  using DrawingToolsBase::GetRatioHisto;
48  TH1_h* GetRatioHisto(TTree* tree1, TTree* tree2, const std::string& name, const std::string& var, int nx, double* xbins,
49  const std::string& cut1, const std::string& cut2, const std::string& root_opt, const std::string& opt, double norm, double scale, bool scale_errors=true, int refana=-1);
50 
51  using DrawingToolsBase::FillHistoErrors;
52  void FillHistoErrors(HistoStack* hs1, HistoStack* hs2, TH1_h* histo, const std::string uopt);
53 
54  void FillHistoErrors(HistoStack* hs1, HistoStack* hs2, TTree* tree1, TTree* tree2, const std::string& name, const std::string& var, int nx, double* xbins,
55  const std::string& cut1, const std::string& cut2, const std::string& opt, double norm, TH1_h* hstat, TH1_h*& hsyst);
56 
58  void UpdateSystInfo(HistoStack* hs1, HistoStack* hs2, TTree* tree1,TTree* tree2, const std::string& var, int nx, double* xbins,
59  const std::string& cut1, const std::string& cut2, const std::string& opt, double norm);
60 
61 
62  using DrawingToolsBase::FillGraphErrors;
63  void FillGraphErrors(HistoStack* hs1, HistoStack* hs2, TGraphAsymmErrors* graph, const std::string uopt);
64 
65  TH1_h* GetHistoWithSystErrors(HistoStack* hs1, HistoStack* hs2, TTree* tree1, TTree* tree2, const std::string& name, const std::string& var, int nx, double* xbins,
66  const std::string& cut1, const std::string& cut2, const std::string& opt, double norm);
67 
69  void PrintEventNumbers(DataSample& data, const std::string& cut, const std::string& file="", int refana=-1);
70 
71 
72  void Project(HistoStack* hs, const std::string& sample_name, DataSample& sample, const std::string& var, int nx, double* xbins, int ny, double* ybins, const std::string& categ,
73  const std::string& cut, const std::string& root_opt, const std::string& opt, double norm, bool scale_errors);
74 
75  void Project(HistoStack* hs1, HistoStack* hs2, DataSample* sample1, DataSample* sample2,
76  const std::string& var, int nx, double* xbins, int ny, double* ybins, const std::string& categ,
77  const std::string& cut, const std::string& root_opt, const std::string& opt, bool scale_errors, double norm=-1, bool pot_norm=true);
78 
79 
80  void Project(HistoStack* hs1, HistoStack* hs2, SampleGroup& sampleGroup, const std::string& mcSampleName,
81  const std::string& var, int nx, double* xbins, int ny, double* ybins, const std::string& categ,
82  const std::string& cut, const std::string& root_opt, const std::string& opt, double norm, bool scale_errors);
83 
84 
85  void Project(HistoStack* hs1, HistoStack* hs2, Experiment& exp, const std::string& groupName, const std::string& mcSampleName,
86  const std::string& var, int nx, double* xbins, int ny, double* ybins, const std::string& categ,
87  const std::string& cut, const std::string& root_opt, const std::string& opt, double norm, bool scale_errors);
88 
89 
90  std::string GetCombinedCut(DataSample& sample, const std::string& cut);
91  //---------- Drawing functions -------------
92 
93  /// Print on the screen the purities for the different categories defined by "categ" and with cuts "cut".
94  /// The expected number of events are also printed, after scaling by events_ratio.
95  void PrintPurities(DataSample& data, const std::string& categ, const std::string& cut, double events_ratio = 1);
96 
97  /// Print on the screen the purities for the different categories defined by "categ" and with cuts "cut".
98  /// The expected number of events are also printed, after scaling by the data POT in the Experiment.
99  void PrintPurities(Experiment& exp, const std::string& categ, const std::string& cut, const std::string& opt="");
100 
101 
102  void Draw(DataSample& data, const std::string& name, int nbins, double* xbins, const std::string& categ="all",
103  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1,bool scale_errors=true);
104  void Draw(DataSample& data, const std::string& name, int nbins, double xmin, double xmax, const std::string& categ="all",
105  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1,bool scale_errors=true);
106 
107  void Draw(DataSample& data, const std::string& name, int nx, double* xbins, int ny, double* ybins,
108  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1);
109  void Draw(DataSample& data, const std::string& name, int nx, double xmin, double xmax, int ny, double ymin, double ymax,
110  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1);
111 
113  void DrawRatio(DataSample& data, const std::string& name, int nbins, double* xbins,
114  const std::string& cut1, const std::string& cut2, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
115  void DrawRatio(DataSample& data, const std::string& name, int nx, double xmin, double xmax,
116  const std::string& cut1, const std::string& cut2, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
117 
118  void DrawEff(DataSample& data, const std::string& name, int nbins, double* xbins,
119  const std::string& cut1, const std::string& cut2, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
120  void DrawEff(DataSample& data, const std::string& name, int nx, double xmin, double xmax,
121  const std::string& cut1, const std::string& cut2, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
122 
123  void DrawDoubleEff(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double* xbins,
124  const std::string& cut1, const std::string& cut2, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
125 
126  void DrawDoubleEff(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double xmin, double xmax,
127  const std::string& cut1, const std::string& cut2, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
128 
129 
130  void DrawSignificance(DataSample& data, const std::string& name, int nbins, double* xbins, const std::string& cut1, const std::string& cut2,
131  double norm=1, double rel_syst=0,const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
132  void DrawSignificance(DataSample& data, const std::string& name, int nbins, double xmin, double xmax, const std::string& cut1, const std::string& cut2,
133  double norm=1, double rel_syst=0,const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="");
134 
135  // ---------- Sample1/SAMPLE2 comparisons -----------------
136 
137  void Draw(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double xmin, double xmax,
138  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1, bool scale_errors=true, bool pot_norm=true);
139  void Draw(DataSample& sample1, DataSample& sample2, const std::string& var, int nbins, double* xbins,
140  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1, bool scale_errors=true, bool pot_norm=true);
141 
142  void Draw(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double xmin, double xmax, int ny, double ymin, double ymax,
143  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1, bool scale_errors=true, bool pot_norm=true);
144  void Draw(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double* xbins, int ny, double* ybins,
145  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1, bool scale_errors=true, bool pot_norm=true);
146 
147  void DrawRatio(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double xmin, double xmax,
148  const std::string& cut1, const std::string& cut2, double norm=-1, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="", bool pot_norm=true);
149  void DrawRatio(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double* xbins,
150  const std::string& cut1, const std::string& cut2, double norm=-1, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="", bool pot_norm=true);
151 
152  void DrawRatio(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double xmin, double xmax,
153  const std::string& cut="", double norm=-1, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="", bool pot_norm=true);
154  void DrawRatio(DataSample& sample1, DataSample& sample2, const std::string& var, int nx, double* xbins,
155  const std::string& cut="", double norm=-1, const std::string& root_opt="", const std::string& opt="", const std::string& leg_name="", bool pot_norm=true);
156 
157 
158  // ---------- Plots VS cut -----------------
159  void DrawEventsVSCut(DataSample& sample , const std::string& cut_norm="", int first_cut=-1, int last_cut=-1,
160  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
161  {ReadOther(sample.GetTree("config"));DrawingToolsBase::DrawEventsVSCut(sample.GetTree(),cut_norm,first_cut,last_cut,root_opt,opt,leg);}
162 
163  void DrawEventsVSCut(DataSample& sample , int branch, const std::string& cut_norm="", int first_cut=-1, int last_cut=-1,
164  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
165  {ReadOther(sample.GetTree("config"));DrawingToolsBase::DrawEventsVSCut(sample.GetTree(),branch,cut_norm,first_cut,last_cut,root_opt,opt,leg);}
166 
167  void DrawEventsVSCut(DataSample& sample , int isel, int branch, const std::string& cut_norm="", int first_cut=-1, int last_cut=-1,
168  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
169  {ReadOther(sample.GetTree("config"));DrawingToolsBase::DrawEventsVSCut(sample.GetTree(),isel,branch,cut_norm,first_cut,last_cut,root_opt,opt,leg);}
170 
171  void DrawEffVSCut(DataSample& sample , const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
172  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
173  {DrawingToolsBase::DrawEffVSCut(sample.GetTree("truth"),signal,precut,first_cut,last_cut,root_opt,opt,leg);}
174 
175  void DrawEffVSCut(DataSample& sample , int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
176  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
177  {DrawingToolsBase::DrawEffVSCut(sample.GetTree("truth"),branch,signal,precut,first_cut,last_cut,root_opt,opt,leg);}
178 
179  void DrawEffVSCut(DataSample& sample , int isel, int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
180  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
181  {DrawingToolsBase::DrawEffVSCut(sample.GetTree("truth"),isel,branch,signal,precut,first_cut,last_cut,root_opt,opt,leg);}
182 
183  void DrawPurVSCut(DataSample& sample , const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
184  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
185  {ReadOther(sample.GetTree("config"));DrawingToolsBase::DrawPurVSCut(sample.GetTree(),signal,precut,first_cut,last_cut,root_opt,opt,leg);}
186 
187  void DrawPurVSCut(DataSample& sample , int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
188  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
189  {ReadOther(sample.GetTree("config"));DrawingToolsBase::DrawPurVSCut(sample.GetTree(),branch,signal,precut,first_cut,last_cut,root_opt,opt,leg);}
190 
191  void DrawPurVSCut(DataSample& sample , int isel, int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
192  const std::string& root_opt="", const std::string& opt="", const std::string& leg="")
193  {ReadOther(sample.GetTree("config"));DrawingToolsBase::DrawPurVSCut(sample.GetTree(),isel,branch,signal,precut,first_cut,last_cut,root_opt,opt,leg);}
194 
195  //! [DrawingToolsVsCutsMethods]
196  /// Draw the ratio between two trees as a function of the cut
197  void DrawRatioVSCut(DataSample& sample1, DataSample& sample2, const std::string& precut="", int first_cut=-1, int last_cut=-1,
198  const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=-1., bool pot_norm=true);
199  void DrawRatioVSCut(DataSample& sample1, DataSample& sample2, int branch, const std::string& precut="", int first_cut=-1, int last_cut=-1,
200  const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=-1., bool pot_norm=true);
201  void DrawRatioVSCut(DataSample& sample1, DataSample& sample2, int isel, int branch, const std::string& precut="", int first_cut=-1, int last_cut=-1,
202  const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=-1., bool pot_norm=true);
203 
204 
205 
206  void DrawEffPurVSCut(DataSample& sample, const std::string& signal, const std::string& precut="", int first_cut=-1, int last_cut=-1,
207  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
208 
209  void DrawEffPurVSCut(DataSample& sample, int branch, const std::string& signal, const std::string& precut="", int first_cut=-1, int last_cut=-1,
210  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
211 
212  void DrawEffPurVSCut(DataSample& sample, int isel, int branch, const std::string& signal, const std::string& precut="", int first_cut=-1, int last_cut=-1,
213  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
214 
215  void DrawEffPurVSCut(DataSample& sample, int isel, int branch, const std::string& signal, const std::string& precut,
216  int first_cut_pur, int last_cut_pur, int first_cut_eff, int last_cut_eff,
217  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
218  //! [DrawingToolsVsCutsMethods]
219 
220  // ---------- POT -----------------
221 
222  //! [DrawingTools_POT]
223  /// Dump the POT information for this sample, provided the sample it self
224  void DumpPOT(DataSample& data);
225 
226  /// Dump the POT information for this sample, provided an Experiment and a sample group name (run1, run2a, run2w, ...)
227  void DumpPOT(Experiment& exp, const std::string& samplegroup_name);
228 
229  /// return the Good POT used to create this DataSample object.
230  double GetGoodPOT(DataSample& data);
231 
232  /// return the number of Good spills used to create this DataSample object.
233  int GetGoodSpills(DataSample& data);
234 
235  /// Print out the ratio of POTs used to create these DataSample objects.
236  /// Ratio is set to 1 if either the numerator or denominator are 0.
237  double GetPOTRatio(DataSample& sample1, DataSample& sample2, double POTsample1_byhand=-1);
238 
239  /// Print out the ratio of POTs between data and MC in this Experiment
240  /// Ratio is set to 1 if either the numerator or denominator are 0.
241  double GetPOTRatio(Experiment& exp);
242 
243  /// Get the normalisation factor to apply when comparing sample1/sample2. If "pot_norm"
244  /// is true, then the POT ratio is returned. If not, the value specified by
245  /// "norm" is returned.
246  double GetNormalisationFactor(DataSample* sample1, DataSample* sample2, double norm=-1., bool pot_norm=true, const std::string& opt="");
247  //! [DrawingTools_POT]
248 
249  // ---------- Plots with Experiments -----------------
250 
251  /// This method draws the distribution of the number of selected events for all toys (one entry per toy in the histogram), provided a cut
252  /// This is useful to check that the systematic error bars correspond to the RMS of this distribution
253  void DrawToys(Experiment& exp, const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
254 
255  /// Data-MC comparison plots using a vector of pairs of data and MC samples (Experiment), properly normalised to each other.
256  void Draw(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
257  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="",double norm=-1., bool scale_errors=true);
258  void Draw(Experiment& exp, const std::string& var, int nbins, double* xbins,
259  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1., bool scale_errors=true);
260 
261  void Draw(Experiment& exp, const std::string& var, int nx, double xmin, double xmax, int ny, double ymin, double ymax,
262  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="",double norm=-1., bool scale_errors=true);
263  void Draw(Experiment& exp, const std::string& var, int nx, double* xbins, int ny, double* ybins,
264  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1., bool scale_errors=true);
265 
266 
267  /// Data-MC comparison plots using a single pair of data and MC samples properly normalised to each other.
268  void Draw(Experiment& exp, const std::string& groupName, const std::string& var, int nx, double xmin, double xmax,
269  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="",double norm=-1., bool scale_errors=true);
270  void Draw(Experiment& exp, const std::string& groupName, const std::string& var, int nbins, double* xbins,
271  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1., bool scale_errors=true);
272 
273  void Draw(Experiment& exp, const std::string& groupName, const std::string& var, int nx, double xmin, double xmax, int ny, double ymin, double ymax,
274  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="",double norm=-1., bool scale_errors=true);
275  void Draw(Experiment& exp, const std::string& groupName, const std::string& var, int nx, double* xbins, int ny, double* ybins,
276  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1., bool scale_errors=true);
277 
278 
279  /// Data-MC comparison plots using a single pair of data and MC samples properly normalised to each other.
280  void Draw(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
281  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="",double norm=-1., bool scale_errors=true);
282  void Draw(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nbins, double* xbins,
283  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1., bool scale_errors=true);
284 
285  void Draw(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax, int ny, double ymin, double ymax,
286  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="",double norm=-1., bool scale_errors=true);
287  void Draw(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins, int ny, double* ybins,
288  const std::string& categ="all", const std::string& cut="", const std::string& root_opt="", const std::string& opt="", double norm=-1., bool scale_errors=true);
289 
290 
291  /// Compare Data and MC for each sample properly normalised to each other. All samples are drawn using the
292  /// "all" category (i.e. as 'data points' in different colours), with a legend created based on the
293  /// names given when generating the SampleGroup.
294  /// normtype can be POT or ONE
295  void CompareSampleGroups(Experiment& exp, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
296  const std::string& cut="", const std::string& root_opt="", const std::string& opt="",bool scale_errors=true, const std::string& normtype="POT");
297  void CompareSampleGroups(Experiment& exp, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
298  const std::string& cut="", const std::string& root_opt="", const std::string& opt="",bool scale_errors=true, const std::string& normtype="POT");
299 
300  /// data and mc will be FILLED here
301  void GetEventsVSCut(Experiment& exp, const std::string& name, const std::string& cut_norm, int isel, int ibranch, int& first_cut, int& last_cut,
302  const std::string& root_opt, const std::string& opt, TH1_h*& data, TH1_h*& mc);
303 
304 
305  void DrawEventsVSCut(Experiment& exp, const std::string& cut_norm="", int first_cut=-1, int last_cut=-1,
306  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
307 
308  void DrawEventsVSCut(Experiment& exp, int branch, const std::string& cut_norm="", int first_cut=-1, int last_cut=-1,
309  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
310 
311  void DrawEventsVSCut(Experiment& exp, int isel, int branch, const std::string& cut_norm="", int first_cut=-1, int last_cut=-1,
312  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
313 
314  void DrawPurVSCut(Experiment& exp, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
315  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
316 
317  void DrawPurVSCut(Experiment& exp, int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
318  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
319 
320  void DrawPurVSCut(Experiment& exp, int isel, int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
321  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
322 
323  void DrawEffVSCut(Experiment& exp, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
324  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
325 
326  void DrawEffVSCut(Experiment& exp, int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
327  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
328 
329  void DrawEffVSCut(Experiment& exp, int isel, int branch, const std::string& signal="", const std::string& precut="", int first_cut=-1, int last_cut=-1,
330  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
331 
332  void DrawEffPurVSCut(Experiment& exp , const std::string& signal, const std::string& precut, int first_cut, int last_cut,
333  const std::string& root_opt, const std::string& opt="", const std::string& leg="");
334 
335  void DrawEffPurVSCut(Experiment& exp , int branch, const std::string& signal, const std::string& precut, int first_cut, int last_cut,
336  const std::string& root_opt, const std::string& opt="", const std::string& leg="");
337 
338  void DrawEffPurVSCut(Experiment& exp , int isel, int branch, const std::string& signal, const std::string& precut, int first_cut, int last_cut,
339  const std::string& root_opt, const std::string& opt="", const std::string& leg="");
340 
341  void DrawEffPurVSCut(Experiment& exp , int isel, int branch, const std::string& signal="", const std::string& precut="",
342  int first_cut_pur=-1, int last_cut_pur=-1, int first_cut_eff=-1, int last_cut_eff=-1,
343  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
344 
345  void DrawRatioVSCut(Experiment& exp, const std::string& precut="", int first_cut=-1, int last_cut=-1,
346  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
347 
348  void DrawRatioVSCut(Experiment& exp, int branch, const std::string& precut="", int first_cut=-1, int last_cut=-1,
349  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
350 
351  void DrawRatioVSCut(Experiment& exp, int isel, int branch, const std::string& precut="", int first_cut=-1, int last_cut=-1,
352  const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
353 
354 
355  void DrawEff(Experiment& exp, bool usedata, const std::string& var, int nx, double xmin, double xmax,
356  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "", const std::string& leg_name = "");
357  void DrawEff(Experiment& exp, bool usedata, const std::string& var, int nx, double* xbins,
358  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "", const std::string& leg_name = "");
359 
360  void DrawEffNew(Experiment& exp, bool usedata, const std::string& var, int nx, double xmin, double xmax,
361  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt1 = "", const std::string& opt2 = "",
362  const std::string& leg_name = "");
363  void DrawEffNew(Experiment& exp, bool usedata, const std::string& var, int nx, double* xbins,
364  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt1 = "", const std::string& opt2 = "",
365  const std::string& leg_name = "");
366 
367  void DrawRatioNew(Experiment& exp, bool usedata, const std::string& var, int nx, double xmin, double xmax,
368  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt1 = "", const std::string& opt2 = "");
369  void DrawRatioNew(Experiment& exp, bool usedata, const std::string& var, int nx, double* xbins,
370  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt1 = "", const std::string& opt2 = "");
371 
372  void DrawPur(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
373  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "", const std::string& leg_name = "");
374  void DrawPur(Experiment& exp, const std::string& var, int nx, double* xbins,
375  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "", const std::string& leg_name = "");
376 
377  double GetEff(Experiment& exp, bool usedata,
378  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "");
379  double GetEff(Experiment& exp, bool usedata, double& errlow, double& errhigh, double& nev1, double& nev2,
380  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "");
381  TGraphAsymmErrors* GetEff(Experiment& exp, bool usedata, const std::string& var, int nx, double* xbins, double& nev1, double& nev2,
382  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt = "", bool scale_errors = true);
383  TGraphAsymmErrors* GetEffNew(Experiment& exp, bool usedata, const std::string& var, int nx, double* xbins, double& nev1, double& nev2,
384  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt1 = "",
385  const std::string& opt2 = "", bool scale_errors = true);
386 
387  void DrawRatioNew(Experiment& exp, bool usedata, const std::string& var, int nx, double* xbins, double& nev1, double& nev2,
388  const std::string& cut1, const std::string& cut2, const std::string& root_opt = "", const std::string& opt1 = "",
389  const std::string& opt2 = "", bool scale_errors = true);
390 
391  void DrawRatio(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins, int ny, double* ybins,
392  const std::string& cut, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
393 
394  void DrawRatio(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
395  const std::string& cut, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
396 
397  void DrawRatio(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
398  const std::string& cut, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
399 
400  void DrawRatio(Experiment& exp, const std::string& var, int nx, double* xbins,
401  const std::string& cut, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
402 
403  void DrawRatio(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
404  const std::string& cut, const std::string& root_opt="", const std::string& opt="", const std::string& leg="");
405 
406 
407  void AnalysisResults(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& cut, const std::string& opt, const std::string& categ="all");
408 
409  void AnalysisResults(Experiment& exp, const std::string& cut, const std::string& opt="", const std::string& categ="all");
410 
411  //------------- Draw errors -------------------
412 
413 
414 
415  Double_t DrawErrorsBase(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
416  const std::string& cut="", bool relative=false, const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
417 
418  Double_t DrawErrorsBase(HistoStack* hs, bool relative, const std::string& root_opt, const std::string& opt,const std::string& leg);
419 
420  //! [DrawingToolsDrawErrors]
421  // Draw absolute and relative errors for a given selection and binning provided a micro-tree.
422  // The option opt allows chosing statistical or systematics errors (or both).
423  Double_t DrawErrors(TTree* tree, const std::string& var, int nx, double xmin, double xmax,
424  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
425  Double_t DrawRelativeErrors(TTree* tree, const std::string& var, int nx, double xmin, double xmax,
426  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
427  Double_t DrawErrors(TTree* tree, const std::string& var, int nx, double* xbins,
428  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
429  Double_t DrawRelativeErrors(TTree* tree, const std::string& var, int nx, double* xbins,
430  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
431 
432  // compare two different trees
433  Double_t DrawRelativeErrors(TTree* tree1, TTree* tree2, const std::string& var, int nx, double xmin, double xmax,
434  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
435  Double_t DrawRelativeErrors(TTree* tree1, TTree* tree2, const std::string& var, int nx, double* xbins,
436  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
437 
438 
439 
440  // Draw absolute and relative errors for a given selection and binning provided an Experiment
441  Double_t DrawErrors(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
442  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
443  Double_t DrawRelativeErrors(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
444  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
445  Double_t DrawErrors(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
446  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
447 
448  Double_t DrawRelativeErrors(Experiment& exp, const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
449  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
450 
451  // Draw absolute and relative errors for a given selection and binning provided an Experiment,
452  // and for a given MC sample ("magnet", "sand") in a sample group (i.e. "run3")
453  Double_t DrawErrors(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
454  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
455  Double_t DrawRelativeErrors(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
456  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
457  Double_t DrawErrors(Experiment& exp, const std::string& var, int nx, double* xbins,
458  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
459 
460  Double_t DrawRelativeErrors(Experiment& exp, const std::string& var, int nx, double* xbins,
461  const std::string& cut="", const std::string& root_opt="", const std::string& opt="", const std::string& leg="", bool scale_errors=false);
462  //! [DrawingToolsDrawErrors]
463 
464  //! [DrawingToolsDrawCovMatrix]
465  /// Draw covariance matrix given a tree
466  void DrawCovMatrix(TTree* tree, const std::string& var, int nx, double xmin, double xmax,
467  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
468  void DrawCovMatrix(TTree* tree, const std::string& var, int nx, double* xbins,
469  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
470 
471  /// Draw covariance matrix given an experiment; and for a given MC sample ("magnet", "sand") in a sample group (i.e. "run3"). MC information will be used
472  void DrawCovMatrix(Experiment& exp,const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
473  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
474  void DrawCovMatrix(Experiment& exp,const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
475  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
476 
477  /// Draw covariance matrix given an experiment; MC information will be used
478  void DrawCovMatrix(Experiment& exp, const std::string& var, int nx, double* xbins,
479  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
480  void DrawCovMatrix(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
481  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
482 
483  /// Returns covariance matrix given a tree
484  const TMatrixD& GetCovMatrix(TTree* tree, const std::string& var, int nx, double* xbins,
485  const std::string& cut="", const std::string& uopt="");
486  const TMatrixD& GetCovMatrix(TTree* tree, const std::string& var, int nx, double xmin, double xmax,
487  const std::string& cut="", const std::string& uopt="");
488 
489  /// Returns covariance matrix given an experiment; and for a given MC sample ("magnet", "sand") in a sample group (i.e. "run3"). MC information will be used
490  const TMatrixD& GetCovMatrix(Experiment& exp,const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double xmin, double xmax,
491  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
492  const TMatrixD& GetCovMatrix(Experiment& exp,const std::string& groupName, const std::string& mcSampleName, const std::string& var, int nx, double* xbins,
493  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
494 
495  /// Returns covariance matrix given an experiment; MC information will be used
496  const TMatrixD& GetCovMatrix(Experiment& exp, const std::string& var, int nx, double xmin, double xmax,
497  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
498  const TMatrixD& GetCovMatrix(Experiment& exp, const std::string& var, int nx, double* xbins,
499  const std::string& cut="", const std::string& root_opt="", const std::string& uopt="");
500 
501  //! [DrawingToolsDrawCovMatrix]
502 
503  /// Draw a (covariance) matrix
504  void DrawMatrix(const TMatrixD& m, int lc, int lw, int fc, int fs, const std::string& root_opt="", const std::string& opt="");
505 
506  void SetTreeForSystErrors(TTree* tree){_treeForSystErrors= tree;}
507 
508 
509  protected:
510 
511  Double_t DrawErrorsBase(TTree* tree, const std::string& var, int nx, double* xbins,
512  const std::string& cut="", bool relative=false, const std::string& root_opt="", const std::string& opt="", const std::string& leg="", double norm=1, bool scale_errors=false);
513 
514  TTree* _treeForSystErrors;
515 
516 
517 };
518 
519 #endif
double GetGoodPOT(DataSample &data)
return the Good POT used to create this DataSample object.
void DrawCovMatrix(TTree *tree, const std::string &var, int nx, double xmin, double xmax, const std::string &cut="", const std::string &root_opt="", const std::string &uopt="")
[DrawingToolsDrawErrors]
int GetGoodSpills(DataSample &data)
return the number of Good spills used to create this DataSample object.
TTree * GetTree(Int_t index)
Returns the a tree with a given index.
Definition: TreeManager.hxx:28
void PrintEventNumbers(TTree *tree, const std::string &cut, const std::string &file="", int toy_ref=-1)
Print the event number of a specific selection.
void UpdateSystInfo(HistoStack *hs1, HistoStack *hs2, TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &opt, double norm)
fill/update systematics information (fill appopriate histograms) for the stacks
double GetNormalisationFactor(DataSample *sample1, DataSample *sample2, double norm=-1., bool pot_norm=true, const std::string &opt="")
void DrawPurVSCut(TTree *tree, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
Draw the selection purity as a function of the cut. Must use the default tree as input.
Double_t DrawErrors(TTree *tree, const std::string &var, int nx, double xmin, double xmax, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1, bool scale_errors=false)
[DrawingToolsDrawErrors]
const TMatrixD & GetCovMatrix(TTree *tree, const std::string &var, int nx, double *xbins, const std::string &cut="", const std::string &uopt="")
Returns covariance matrix given a tree.
virtual void UpdateSystInfo(HistoStack *hs1, HistoStack *hs2, TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &opt, double norm)
fill/update systematics information (fill appopriate histograms) for the stacks
void DrawRatioVSCut(DataSample &sample1, DataSample &sample2, const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=-1., bool pot_norm=true)
void DrawEffVSCut(TTree *tree, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
Draw the selection efficiency as a function of the cut. Must use the truth tree as input...
void DrawMatrix(const TMatrixD &m, int lc, int lw, int fc, int fs, const std::string &root_opt="", const std::string &opt="")
[DrawingToolsDrawCovMatrix]
double GetPOTRatio(DataSample &sample1, DataSample &sample2, double POTsample1_byhand=-1)
void ReadOther(const std::string &file)
Read any other variables in the config tree.
void CompareSampleGroups(Experiment &exp, const std::string &mcSampleName, const std::string &var, int nx, double xmin, double xmax, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", bool scale_errors=true, const std::string &normtype="POT")
void DrawEventsVSCut(TTree *tree, const std::string &cut_norm="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
void PrintPurities(DataSample &data, const std::string &categ, const std::string &cut, double events_ratio=1)
void GetEventsVSCut(Experiment &exp, const std::string &name, const std::string &cut_norm, int isel, int ibranch, int &first_cut, int &last_cut, const std::string &root_opt, const std::string &opt, TH1_h *&data, TH1_h *&mc)
data and mc will be FILLED here
void DrawRatio(TTree *tree, const std::string &var, int nbins, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
void DumpPOT(DataSample &data)
[DrawingToolsVsCutsMethods]