]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/muon/AliMergeableCollection.h
Split the TaskMuMu into more manageable sub-analysis (Laurent)
[u/mrichter/AliRoot.git] / PWG / muon / AliMergeableCollection.h
CommitLineData
ac4edd2e 1#ifndef ALIMERGEABLECOLLECTION_H
2#define ALIMERGEABLECOLLECTION_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: AliMergeableCollection.h 50593 2011-07-14 17:42:28Z martinez $
8
9///////////////////////////////////////////////////////////////////////////////
10///
11/// AliMergeableCollection
12///
13/// Collection of mergeable objects, indexed by key-tuples
14///
15/// Important point is that AliMergeableCollection is *always* the
16/// owner of the objects it holds. This is why you should not
17/// use the (inherited from TCollection) Add() method but the Adopt() methods
18///
19/// \author Diego Stocco
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
73a1ccd5 30#ifndef ROOT_TFolder
31# include "TFolder.h"
32#endif
ac4edd2e 33#include "Riostream.h"
34#include <map>
35#include <string>
36
37class TMap;
38class AliMergeableCollectionIterator;
d440e2c5 39class TH1;
5376e016
CP
40class TH2;
41class TProfile;
ac4edd2e 42
73a1ccd5 43class AliMergeableCollection : public TFolder
ac4edd2e 44{
45 friend class AliMergeableCollectionIterator; // our iterator class
46
47public:
48
49 AliMergeableCollection(const char* name="", const char* title="");
50 virtual ~AliMergeableCollection();
51
52 virtual AliMergeableCollection* Clone(const char* name="") const;
53
1b331634 54 Bool_t Attach(AliMergeableCollection* mc, const char* identifier, Bool_t pruneFirstIfAlreadyExists=kFALSE);
55
ac4edd2e 56 Bool_t Adopt(TObject* obj);
57 Bool_t Adopt(const char* identifier, TObject* obj);
73a1ccd5 58
59 virtual void Browse(TBrowser* b);
60
ac4edd2e 61 virtual void Clear(Option_t *option="") { Delete(option); }
62
63 virtual TObject* FindObject(const char* fullIdentifier) const;
64
65 virtual TObject* FindObject(const TObject* object) const;
66
67 virtual void Delete(Option_t *option="");
68
69 virtual Int_t NumberOfObjects() const;
70
71 virtual Int_t NumberOfKeys() const;
72
73 TObject* GetObject(const char* fullIdentifier) const;
74 TObject* GetObject(const char* identifier, const char* objectName) const;
d440e2c5 75
76 TH1* Histo(const char* fullIdentifier) const;
77 TH1* Histo(const char* identifier, const char* objectName) const;
78
5376e016
CP
79 TH1* H1(const char* fullIdentifier) const { return Histo(fullIdentifier); }
80 TH1* H1(const char* identifier, const char* objectName) const { return Histo(identifier,objectName); }
81
82 TH2* H2(const char* fullIdentifier) const;
83 TH2* H2(const char* identifier, const char* objectName) const;
84
85 TProfile* Prof(const char* fullIdentifier) const;
86 TProfile* Prof(const char* identifier, const char* objectName) const;
87
ac4edd2e 88 virtual TIterator* CreateIterator(Bool_t dir = kIterForward) const;
89
90 virtual TList* CreateListOfKeys(Int_t index) const;
91
92 virtual TList* CreateListOfObjectNames(const char* identifier) const;
93
73a1ccd5 94 using TFolder::Remove;
95
ac4edd2e 96 virtual TObject* Remove(const char* fullIdentifier);
97
d440e2c5 98 Int_t RemoveByType(const char* typeName);
99
ac4edd2e 100 TString GetKey(const char* identifier, Int_t index, Bool_t idContainsObjName = kFALSE) const;
101 TString GetIdentifier(const char* fullIdentifier) const;
102 TString GetObjectName(const char* fullIdentifier) const;
103
104 void Print(Option_t *option="") const;
105
106 void ClearMessages();
107 void PrintMessages(const char* prefix="") const;
108
109 Long64_t Merge(TCollection* list);
110
111 AliMergeableCollection* Project(const char* identifier) const;
112
113 UInt_t EstimateSize(Bool_t show=kFALSE) const;
114
115 /// Turn on the display of empty objects for the Print method
116 void ShowEmptyObjects(Bool_t show=kTRUE) {
117 fMustShowEmptyObject = show;
118 }
119
120 void PruneEmptyObjects();
121
1b331634 122 Int_t Prune(const char* identifier);
123
ac4edd2e 124 static Bool_t MergeObject(TObject* baseObject, TObject* objToAdd);
125
d5a197f5 126 TObject* GetSum(const char* idPattern) const;
ac4edd2e 127
128 Bool_t IsEmptyObject(TObject* obj) const;
129
130private:
131
132 AliMergeableCollection(const AliMergeableCollection& rhs);
133 AliMergeableCollection& operator=(const AliMergeableCollection& rhs);
134
d440e2c5 135 TH1* HistoWithAction(const char* identifier, TObject* o, const TString& action) const;
136
ac4edd2e 137 Bool_t InternalAdopt(const char* identifier, TObject* obj);
138
139 TString InternalDecode(const char* fullIdentifier, Int_t index) const;
140
d440e2c5 141 TObject* InternalObject(const char* identifier, const char* objectName) const;
ac4edd2e 142
d440e2c5 143public:
144 TObjArray* SortAllIdentifiers() const;
145
ac4edd2e 146 TString NormalizeName(const char* identifier, const char* action) const;
147
148 TMap* Map() const;
149
150private:
151
152 mutable TMap* fMap; /// map of TMap of THashList* of TObject*...
153 Bool_t fMustShowEmptyObject; /// Whether or not to show empty objects with the Print method
154 mutable Int_t fMapVersion; /// internal version of map (to avoid custom streamer...)
155 mutable std::map<std::string,int> fMessages; //! log messages
156
5376e016 157 ClassDef(AliMergeableCollection,4) /// A collection of mergeable objects
ac4edd2e 158};
159
160class AliMergeableCollectionIterator : public TIterator
161{
162public:
163 virtual ~AliMergeableCollectionIterator();
164
165 AliMergeableCollectionIterator(const AliMergeableCollection* hcol, Bool_t direction=kIterForward);
166 AliMergeableCollectionIterator& operator=(const TIterator &rhs);
167
168 const TCollection *GetCollection() const { return 0x0; }
169
170 TObject* Next();
171
172 void Reset();
173
174private:
175 const AliMergeableCollection* fkMergeableCollection; // Mergeable objects collection being iterated
176 TIterator* fMapIterator; // Iterator for the internal map
177 TIterator* fHashListIterator; // Iterator for the current hash list
178 Bool_t fDirection; // forward or reverse
179
180 AliMergeableCollectionIterator() : fkMergeableCollection(0x0), fMapIterator(0x0), fHashListIterator(0x0), fDirection(kIterForward) {}
181
182 /// not implemented
183 AliMergeableCollectionIterator& operator=(const AliMergeableCollectionIterator &rhs);
184 /// not implemented
185 AliMergeableCollectionIterator(const AliMergeableCollectionIterator &iter);
186
187 ClassDef(AliMergeableCollectionIterator,0) // Mergeable object collection iterator
188};
189
190#endif