simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
TSHistogramFld.h
1 /*
2  * TSHistogramFld.h
3  *
4  * Created on: Jun 2, 2014
5  * Author: Silvestro di Luise
6  * Silvestro.Di.Luise@cern.ch
7  *
8  *
9  * Class to create a folder of Histograms (TH1,TH2, TH2Poly...)
10  *
11  * Each histogram-axis has associated the name of the corresponding TSVariable.
12  * Those names are to be provided when the histogram is added to the folder
13  * via the Add method.
14  *
15  * Several Fill methods are provided to fill all the histograms
16  * at the same time from a given set of TSVariable values.
17  *
18  *
19  * Folder is the Owner of the Added Objects
20  *
21  *
22  *
23  */
24 
25 #ifndef TSHISTOGRAMFLD_H_
26 #define TSHISTOGRAMFLD_H_
27 
28 #include <string>
29 #include <map>
30 
31 #include <TString.h>
32 
33 #include <TFile.h>
34 #include <TH2Poly.h>
35 #include <TList.h>
36 
37 
38 
39 class TSHistogramFld: public TList {
40 
41 public:
43  TSHistogramFld(TString name);
44  virtual ~TSHistogramFld();
45 
46  void Add(TObject*, TString, TString="");
47  int AddPolyBinContent(TH2Poly &,int bin, double w=1);
48  TSHistogramFld* Clone(TString name="") const;
49  void AppendToAllNames(TString, TString sep="_");
50  void AppendToAllTitles(TString, TString sep=" ");
51  void Clear(Option_t* opt="");
52  void Copy(TSHistogramFld&);
53  int Fill(int N, TString* list, double* values);
54  int Fill(std::vector<TString>&, std::vector<double>&);
55  int Fill(TString vx, TString vy, double x, double y, double w=1, int opt=0);
56  int Fill(TString vx, double x, double w=1, int opt=0);
57  int FillPoly(TH2Poly *h, double x, double y, double w=1, int opt=1);
58 
59  int FillHistosFromFile(TFile *,TString opt="");
60 
61  int GetHistoDim(int) const;
62  TString GetHistoName(int) const;
63  TString GetHistoNameX(int) const;
64  TString GetHistoNameY(int) const;
65  TList *GetListOf(TString) const;
66  TObject* GetObject(int) const;
67  float GetOutliersFrac(TString, TString ="") const;
68  TObject* GetTagHisto(TString, TString ="") const;
69  int Import(TSHistogramFld&);
70  bool IsSumw2() const {return fSumw2;}
71 
72  void Init();
73 
74  bool IsTH1(const TObject& ) const;
75  bool IsTH2(const TObject& ) const;
76  bool IsTH2Poly(const TObject& ) const;
77 
78  void PrependToAllNames(TString,TString sep="_");
79  void PrependToAllTitles(TString,TString sep=" ");
80  void ReplaceToAllTitles(TString);
81  void RenameAllWithBase(TString,TString sep="_");
82  void ResetHistos();
83 
84  void SetSumw2(bool =false);
85 
86 private:
87 
88 
89  bool fSumw2;
90 
91  void ApplyTH2Style(TH2 *);
92 
93  struct fHistoSettings{
94  int Position;
95  TString Name;
96  int Dim;
97  TString NameX;
98  TString NameY;
99  };
100 
101  std::map<int,fHistoSettings*> fHistoSetsList;
102 
103  std::map<TString,int> fObjPos;
104  std::map<int,TString> fObjName;
105 
106  std::map<int,TString> fObjNameX;
107  std::map<int,TString> fObjNameY;
108 
109 
110 
111 };
112 
113 #endif /* TSHISTOGRAMFLD_H_ */
int Fill(int N, TString *list, double *values)
Definition: TSHistogramFld.cc:308
Definition: TSHistogramFld.h:39
int FillPoly(TH2Poly *h, double x, double y, double w=1, int opt=1)
Definition: TSHistogramFld.cc:366