]>
Commit | Line | Data |
---|---|---|
d899f664 | 1 | #ifndef ALIHISTOGRAMCOLLECTION_H |
2 | #define ALIHISTOGRAMCOLLECTION_H | |
3 | ||
4 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
7 | // $Id$ | |
8 | ||
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | /// | |
11 | /// AliHistogramCollection | |
12 | /// | |
13 | /// Collection of histograms, indexed by key-tuples | |
14 | /// | |
15 | /// Important point is that AliHistogramCollection is *always* the | |
16 | /// owner of the histograms it holds. This is why you should not | |
17 | /// use the (inherited from TCollection) Add() method but the Adopt() methods | |
18 | /// | |
19 | /// \author Laurent Aphecetche | |
20 | ||
21 | #ifndef ROOT_TNamed | |
22 | # include "TNamed.h" | |
23 | #endif | |
24 | #ifndef ROOT_TString | |
25 | # include "TString.h" | |
26 | #endif | |
27 | #ifndef ROOT_TCollection | |
28 | # include "TCollection.h" | |
29 | #endif | |
2f331ac9 | 30 | #include "Riostream.h" |
5eabea87 | 31 | #include <map> |
32 | #include <string> | |
d899f664 | 33 | |
34 | class TH1; | |
35 | class TMap; | |
36 | class AliHistogramCollectionIterator; | |
d440e2c5 | 37 | class AliMergeableCollection; |
d899f664 | 38 | |
39 | class AliHistogramCollection : public TNamed | |
40 | { | |
41 | friend class AliHistogramCollectionIterator; // our iterator class | |
42 | ||
43 | public: | |
44 | ||
45 | AliHistogramCollection(const char* name="", const char* title=""); | |
46 | virtual ~AliHistogramCollection(); | |
5eabea87 | 47 | |
48 | virtual AliHistogramCollection* Clone(const char* name="") const; | |
d899f664 | 49 | |
d440e2c5 | 50 | AliMergeableCollection* Convert() const; |
51 | ||
5eabea87 | 52 | Bool_t Adopt(TH1* histo); |
d899f664 | 53 | Bool_t Adopt(const char* keyA, TH1* histo); |
54 | Bool_t Adopt(const char* keyA, const char* keyB, TH1* histo); | |
55 | Bool_t Adopt(const char* keyA, const char* keyB, const char* keyC, TH1* histo); | |
56 | Bool_t Adopt(const char* keyA, const char* keyB, const char* keyC, const char* keyD, TH1* histo); | |
57 | ||
58 | virtual void Clear(Option_t *option="") { Delete(option); } | |
59 | ||
60 | virtual TObject* FindObject(const char* identifier) const; | |
61 | ||
62 | virtual TObject* FindObject(const TObject* key) const; | |
63 | ||
64 | virtual void Delete(Option_t *option=""); | |
65 | ||
66 | virtual Int_t NumberOfHistograms() const; | |
67 | ||
68 | virtual Int_t NumberOfKeys() const; | |
69 | ||
70 | TH1* Histo(const char* identifier) const; | |
71 | TH1* Histo(const char* keyA, const char* histoname) const; | |
72 | TH1* Histo(const char* keyA, const char* keyB, const char* histoname) const; | |
73 | TH1* Histo(const char* keyA, const char* keyB, const char* keyC, const char* histoname) const; | |
74 | TH1* Histo(const char* keyA, const char* keyB, const char* keyC, const char* keyD, const char* histoname) const; | |
75 | ||
76 | virtual TIterator* CreateIterator(Bool_t dir = kIterForward) const; | |
77 | ||
2f331ac9 | 78 | virtual TList* CreateListOfKeysA() const; |
79 | virtual TList* CreateListOfKeysB() const; | |
80 | virtual TList* CreateListOfKeysC() const; | |
81 | virtual TList* CreateListOfKeysD() const; | |
82 | ||
83 | virtual TList* CreateListOfHistogramNames(const char* keyA, const char* keyB="", const char* keyC="", const char* keyD="") const; | |
84 | ||
d899f664 | 85 | virtual TObject* Remove(TObject *obj); |
86 | ||
87 | TString KeyA(const char* identifier) const; | |
88 | TString KeyB(const char* identifier) const; | |
89 | TString KeyC(const char* identifier) const; | |
90 | TString KeyD(const char* identifier) const; | |
91 | TString HistoName(const char* identifier) const; | |
92 | ||
93 | void Print(Option_t *option="") const; | |
5eabea87 | 94 | |
95 | void ClearMessages(); | |
96 | void PrintMessages(const char* prefix="") const; | |
97 | ||
d899f664 | 98 | Long64_t Merge(TCollection* list); |
99 | ||
5eabea87 | 100 | AliHistogramCollection* Project(const char* keyA, const char* keyB="", const char* keyC="", const char* keyD="") const; |
d899f664 | 101 | |
102 | UInt_t EstimateSize(Bool_t show=kFALSE) const; | |
103 | ||
104 | /// Turn on the display of empty histograms for the Print method | |
105 | void ShowEmptyHistograms(Bool_t show=kTRUE) { | |
106 | fMustShowEmptyHistogram = show; | |
107 | } | |
108 | ||
109 | void PruneEmptyHistograms(); | |
110 | ||
111 | private: | |
112 | ||
113 | AliHistogramCollection(const AliHistogramCollection& rhs); | |
114 | AliHistogramCollection& operator=(const AliHistogramCollection& rhs); | |
115 | ||
2f331ac9 | 116 | TList* CreateListOfKeys(Int_t index) const; |
117 | ||
d899f664 | 118 | Bool_t InternalAdopt(const char* identifier, TH1* histo); |
119 | ||
5eabea87 | 120 | Bool_t HistoSameAxis(TH1 *h0, TH1 *h1) const; |
121 | ||
d899f664 | 122 | TString InternalDecode(const char* identifier, Int_t index) const; |
123 | ||
d899f664 | 124 | TH1* InternalHisto(const char* identifier, const char* histoname) const; |
125 | TObjArray* SortAllIdentifiers() const; | |
126 | ||
5eabea87 | 127 | TString NormalizeName(const char* identifier, const char* action) const; |
128 | ||
129 | TMap* Map() const; | |
130 | ||
d899f664 | 131 | private: |
5eabea87 | 132 | |
2f331ac9 | 133 | mutable TMap* fMap; // map of TMap of THashList* of TH1*... |
134 | Bool_t fMustShowEmptyHistogram; // Whether or not to show empty histograms with the Print method | |
135 | mutable Int_t fMapVersion; // internal version of map (to avoid custom streamer...) | |
5eabea87 | 136 | mutable std::map<std::string,int> fMessages; //! log messages |
d899f664 | 137 | |
2f331ac9 | 138 | ClassDef(AliHistogramCollection,7) // A collection of histograms |
d899f664 | 139 | }; |
140 | ||
141 | class AliHistogramCollectionIterator : public TIterator | |
142 | { | |
d899f664 | 143 | public: |
144 | virtual ~AliHistogramCollectionIterator(); | |
145 | ||
146 | AliHistogramCollectionIterator(const AliHistogramCollection* hcol, Bool_t direction=kIterForward); | |
147 | AliHistogramCollectionIterator& operator=(const TIterator &rhs); | |
148 | ||
149 | const TCollection *GetCollection() const { return 0x0; } | |
150 | ||
151 | TObject* Next(); | |
152 | ||
153 | void Reset(); | |
154 | ||
5eabea87 | 155 | private: |
156 | const AliHistogramCollection* fkHistogramCollection; // histogram collection being iterated | |
157 | TIterator* fMapIterator; // Iterator for the internal map | |
158 | TIterator* fHashListIterator; // Iterator for the current hash list | |
159 | Bool_t fDirection; // forward or reverse | |
160 | ||
161 | AliHistogramCollectionIterator() : fkHistogramCollection(0x0), fMapIterator(0x0), fHashListIterator(0x0), fDirection(kIterForward) {} | |
162 | ||
163 | /// not implemented | |
164 | AliHistogramCollectionIterator& operator=(const AliHistogramCollectionIterator &rhs); | |
165 | /// not implemented | |
166 | AliHistogramCollectionIterator(const AliHistogramCollectionIterator &iter); | |
167 | ||
d899f664 | 168 | ClassDef(AliHistogramCollectionIterator,0) // Histogram collection iterator |
169 | }; | |
170 | ||
171 | #endif |