HighLAND
SystematicTools.hxx
1 #ifndef SystematicsTools_h
2 #define SystematicsTools_h
3 
4 #include <stdio.h>
5 #include <iostream>
6 #include <map>
7 #include <vector>
8 #include <TROOT.h>
9 #include <TChain.h>
10 #include <TFile.h>
11 #include <TH1F.h>
12 #include <TH2F.h>
13 #include <TH3F.h>
14 #include "TVectorD.h"
15 #include "TMatrixD.h"
16 #include "HistoStack.hxx"
17 
18 /// This class handles computing systematic errors.
19 ///
20 /// TODO: This class needs to be documented properly.
22  public :
23 
24  bool errdebug;
25 
27 
28  virtual ~SystematicsTools(){}
29 
30  //----------- Functions to compute systematics ------------------
31 
32  /// Update the histos necesary to compute the covariance matrix
33  void UpdateSystematicCov(HistoStack* hs, TTree* tree, const std::string& var, int nx, double* xbins, const std::string& cut, int NTOYS, const std::string& uopt);
34 
35  void FillSystematicHistos(TTree* tree, const std::string& var, int nx, double* xbins, const std::string& cut, int NTOYS, const std::string& uopt, TH2_h* h2, TH2_h* h1w);
36 
37  const TMatrixD& GetSystematicCovBase(HistoStack* hs1, HistoStack* hs2, const std::string& uopt, const std::string& group);
38  void GetSystematicHistos(const std::string& group, HistoStack* hs1, HistoStack* hs2, TH2_h*& h2, TH2_h*& h1w);
39 
40  const TMatrixD& GetSystematicCov(HistoStack* hs, const std::string& uopt, const std::string& group="");
41  const TMatrixD& GetRatioSystematicCov(HistoStack* hs1, HistoStack* hs2, const std::string& uopt, const std::string& group="");
42  const TMatrixD& GetSystematicCov(TTree* tree, const std::string& var, int nx, double* xbins, const std::string& cut, int NTOYS, const std::string& uopt);
43  const TMatrixD& GetSystematicCovBase(TH2_h& h2, TH2_h& h1w, const std::string& uopt);
44 
45 
46  bool CheckSystComputed(TTree* tree1, TTree* tree2, const std::string& var, int nx, double* xbins, const std::string& cut1, const std::string& cut2, double norm, int NTOYS, const std::string& uopt);
47 
48  bool TreeHasVar(TTree* tree, const std::string& var);
49  int GetVarFromTree(TTree* tree, const std::string& var);
50 
51  // convert integer to string
52  std::string GetString(int code);
53 
54  void SetSoftwareVersion(const std::string& ver){_softwareVersion = ver;}
55 
56  bool IsValidWeight(Double_t weight);
57 
58  protected:
59 
60  TMatrixD _covTotal;
61  TMatrixD _cov;
62  TMatrixD _w_cov;
63  TMatrixD _st_cov;
64  bool _syst_computed;
65 
66  TTree* _tree1_syst;
67  TTree* _tree2_syst;
68  std::string _var_syst;
69  int _nbins_syst;
70  double _xbins_syst[1000];
71  std::string _cut_syst1;
72  std::string _cut_syst2;
73  double _norm_syst;
74  int _NTOYS_syst;
75  std::string _uopt_syst;
76 
77  std::string _softwareVersion;
78 
79 };
80 
81 
82 
83 #endif
84 
85 
void UpdateSystematicCov(HistoStack *hs, TTree *tree, const std::string &var, int nx, double *xbins, const std::string &cut, int NTOYS, const std::string &uopt)
Update the histos necesary to compute the covariance matrix.