]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/muon/AliHistogramCollection.h
Coverity fix (an obsolete constructor removed)
[u/mrichter/AliRoot.git] / PWG3 / muon / AliHistogramCollection.h
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
30
31 class TH1;
32 class TMap;
33 class AliHistogramCollectionIterator;
34
35 class AliHistogramCollection : public TNamed
36 {
37   friend class AliHistogramCollectionIterator; // our iterator class
38
39 public:
40
41   AliHistogramCollection(const char* name="", const char* title="");
42   virtual ~AliHistogramCollection();
43   
44   Bool_t Adopt(const char* keyA, TH1* histo);
45   Bool_t Adopt(const char* keyA, const char* keyB, TH1* histo);
46   Bool_t Adopt(const char* keyA, const char* keyB, const char* keyC, TH1* histo);
47   Bool_t Adopt(const char* keyA, const char* keyB, const char* keyC, const char* keyD, TH1* histo);
48     
49   virtual void Clear(Option_t *option="") { Delete(option); }
50   
51   virtual TObject* FindObject(const char* identifier) const;
52
53   virtual TObject* FindObject(const TObject* key) const;
54
55   virtual void Delete(Option_t *option="");
56   
57   virtual Int_t NumberOfHistograms() const;
58
59   virtual Int_t NumberOfKeys() const;
60
61   TH1* Histo(const char* identifier) const;
62   TH1* Histo(const char* keyA, const char* histoname) const;
63   TH1* Histo(const char* keyA, const char* keyB, const char* histoname) const;
64   TH1* Histo(const char* keyA, const char* keyB, const char* keyC, const char* histoname) const;
65   TH1* Histo(const char* keyA, const char* keyB, const char* keyC, const char* keyD, const char* histoname) const;
66   
67   virtual TIterator* CreateIterator(Bool_t dir = kIterForward) const;
68   
69   virtual TObject* Remove(TObject *obj);
70
71   TString KeyA(const char* identifier) const;
72   TString KeyB(const char* identifier) const;
73   TString KeyC(const char* identifier) const;
74   TString KeyD(const char* identifier) const;
75   TString HistoName(const char* identifier) const;
76   
77   void Print(Option_t *option="") const;
78
79   Long64_t Merge(TCollection* list);
80   
81   AliHistogramCollection* Project(const char* keyA, const char* keyB) const;
82   
83   UInt_t EstimateSize(Bool_t show=kFALSE) const;
84   
85   /// Turn on the display of empty histograms for the Print method
86   void ShowEmptyHistograms(Bool_t show=kTRUE) {
87     fMustShowEmptyHistogram = show;
88   }
89   
90   void PruneEmptyHistograms();
91   
92 private:
93   
94   AliHistogramCollection(const AliHistogramCollection& rhs);
95   AliHistogramCollection& operator=(const AliHistogramCollection& rhs);
96
97   Bool_t InternalAdopt(const char* identifier, TH1* histo);
98   
99 public://should be private
100   TString InternalDecode(const char* identifier, Int_t index) const;
101   
102 //private:
103   TH1* InternalHisto(const char* identifier, const char* histoname) const;  
104   TObjArray* SortAllIdentifiers() const;
105   
106 private:
107   TMap* fMap; /// map of TMap of THashList* of TH1*...
108   Bool_t fMustShowEmptyHistogram; /// Whether or not to show empty histograms with the Print method
109   
110
111   ClassDef(AliHistogramCollection,1) /// A collection of histograms
112 };
113
114 class AliHistogramCollectionIterator : public TIterator
115 {  
116 private:
117   const AliHistogramCollection* fkHistogramCollection; // histogram collection being iterated
118   TIterator* fMapIterator; // Iterator for the internal map
119   TIterator* fHashListIterator; // Iterator for the current hash list
120   Bool_t fDirection; // forward or reverse
121
122   AliHistogramCollectionIterator() : fkHistogramCollection(0x0), fMapIterator(0x0), fHashListIterator(0x0), fDirection(kIterForward) {}
123
124   /// not implemented
125   AliHistogramCollectionIterator& operator=(const AliHistogramCollectionIterator &rhs);
126   /// not implemented
127   AliHistogramCollectionIterator(const AliHistogramCollectionIterator &iter);
128   
129 public:
130   virtual ~AliHistogramCollectionIterator();
131   
132   AliHistogramCollectionIterator(const AliHistogramCollection* hcol, Bool_t direction=kIterForward);
133   AliHistogramCollectionIterator& operator=(const TIterator &rhs);
134   
135   const TCollection *GetCollection() const { return 0x0; }
136
137   TObject* Next();
138   
139   void Reset();
140   
141   ClassDef(AliHistogramCollectionIterator,0)  // Histogram collection iterator
142 };
143
144 #endif