1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 /// \class AliMUONVStore
20 /// A store is a container, which can be searched for (using FindObject methods),
21 /// iterated upon (using CreateIterator() method), and into which you can
22 /// add objects (using Add)
24 /// In addition, a store can be connected to a TTree.
26 /// The general way of dealing with I/O for MUON is a two stage process :
28 /// 1) first get a TTree pointer using the AliLoader mechanism (this is AliRoot
31 /// 2) connect that TTree to a MUON (virtual) data container using
32 /// the container's Connect(TTree&) method (this is MUON specific)
34 /// Example for reading digits for nevents
38 /// AliMUONVDigitStore* digitStore(0x0);
40 /// AliLoader* loader = ... ( get loader from somewhere, e.g. AliRunLoader::GetDetectorLoader());
41 /// loader->LoadDigits("READ"); // load digits
43 /// for ( Int_t i = 0; i < nevents; ++i )
45 /// TTree* treeD = loader->TreeD(); // get the tree
46 /// if (!digitStore) digitStore = static_cast<AliMUONVDigitStore*>
47 /// (AliMUONVDigitStore::CreateStore(*treeD,"Digit")); // creates a container for digits
48 /// (concrete class is given by the tree itself)
49 /// digitStore->Connect(*treeD);
50 /// treeD->GetEvent(0); // actual reading of the data
52 /// the digitStore is now filled and ready to be used
55 /// digitStore->Clear(); // reset once used
60 /// Please note that for reading data, you do *not* need to know the concrete
61 /// container class, as it is given to you by the TTree
63 /// Example for writing digits
67 /// get the loader and do a loader->LoadDigits("RECREATE" or "UPDATE")
68 /// (generally done by the framework itself)
70 /// AliMUONVDigitStore* digitStore = new AliMUONDigitStoreV1
71 /// // for writing, must decide on the concrete store class to use
73 /// for ( Int_t i = 0; i < nevents; ++i )
75 /// TTree* treeD = loader->TreeD();
76 /// digitStore->Connect(*treeD);
78 /// ... put some digits in the digitStore
82 /// loader->WriteDigits("OVERWRITE");
85 /// delete digitStore;
87 /// loader->UnloadDigits();
91 /// In the write case, one *must* specify a concrete class for the container
94 #include "AliMUONVStore.h"
96 #include "AliMUONTreeManager.h"
103 ClassImp(AliMUONVStore)
106 //_____________________________________________________________________________
107 AliMUONVStore::AliMUONVStore() : TObject()
112 //_____________________________________________________________________________
113 AliMUONVStore::~AliMUONVStore()
118 //_____________________________________________________________________________
120 AliMUONVStore::Connect(TTree&, Bool_t) const
122 /// Connect to a Ttree
123 AliError("Not implemented");
127 //_____________________________________________________________________________
129 AliMUONVStore::Create(TTree& tree, const char* what)
131 /// Create a store from a tree. Forwarded to AliMUONTreeManager::CreateStore
132 AliMUONTreeManager tman;
134 TObject* o = tman.CreateObject(tree,what);;
137 AliMUONVStore* c = dynamic_cast<AliMUONVStore*>(o);
140 AliErrorClass(Form("Object of class %s cannot be cast to an AliMUONVStore",
148 //_____________________________________________________________________________
150 AliMUONVStore::FindObject(Int_t, Int_t) const
152 /// Find an object using 2 identifiers
153 AliError("Not implemented");
157 //_____________________________________________________________________________
159 AliMUONVStore::FindObject(Int_t,Int_t, Int_t) const
161 /// Find an object using 3 identifiers
162 AliError("Not implemented");
166 //_____________________________________________________________________________
168 AliMUONVStore::FindObject(Int_t, Int_t, Int_t, Int_t) const
170 /// Find an object using 4 identifiers
171 AliError("Not implemented");
175 //______________________________________________________________________________
177 AliMUONVStore::FindObject(const char *name) const
179 // Find an object in this collection using its name. Requires a sequential
180 // scan till the object has been found. Returns 0 if object with specified
181 // name is not found.
183 TIter next(CreateIterator());
186 while ((obj = next()))
187 if (!strcmp(name, obj->GetName())) return obj;
191 //______________________________________________________________________________
193 AliMUONVStore::FindObject(const TObject *obj) const
195 // Find an object in this store using the object's IsEqual()
196 // member function. Requires a sequential scan till the object has
197 // been found. Returns 0 if object is not found.
198 // Typically this function is overridden by a more efficient version
199 // in concrete collection classes (e.g. THashTable).
201 TIter next(CreateIterator());
204 while ((ob = next()))
205 if (ob->IsEqual(obj)) return ob;
209 //_____________________________________________________________________________
211 AliMUONVStore::FindObject(UInt_t uniqueID) const
213 /// Generic find method. Should be overriden by derived class if it can
214 /// be made more efficient there.
216 AliDebug(1,Form("uniqueID=%u",uniqueID));
218 TIter next(CreateIterator());
220 while ( ( o = next() ) )
222 if ( o->GetUniqueID() == uniqueID ) return o;
227 //______________________________________________________________________________
229 AliMUONVStore::GetSize(Int_t /*i*/) const
231 /// Number of objects store for "i", whatever that can means
232 AliError("Not implemented");
236 //______________________________________________________________________________
238 AliMUONVStore::Print(Option_t *wildcard) const
240 // Print all objects in this store.
241 // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
242 // with names matching xxx*.
244 if (!wildcard) wildcard = "";
245 TRegexp re(wildcard, kTRUE);
246 Int_t nch = strlen(wildcard);
247 TIter next(CreateIterator());
250 while ((object = next())) {
251 TString s = object->GetName();
252 if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
257 //_____________________________________________________________________________
259 AliMUONVStore::Print(Option_t *wildcard, Option_t *option) const
261 // Print all objects in this store, passing option to the
262 // objects Print() method.
263 // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
264 // with names matching xxx*.
266 if (!wildcard) wildcard = "";
267 TRegexp re(wildcard, kTRUE);
268 Int_t nch = strlen(wildcard);
269 TIter next(CreateIterator());
272 while ((object = next())) {
273 TString s = object->GetName();
274 if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
275 object->Print(option);