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(const char *name) const
161 // Find an object in this collection using its name. Requires a sequential
162 // scan till the object has been found. Returns 0 if object with specified
163 // name is not found.
165 TIter next(CreateIterator());
168 while ((obj = next()))
169 if (!strcmp(name, obj->GetName())) return obj;
173 //______________________________________________________________________________
175 AliMUONVStore::FindObject(const TObject *obj) const
177 // Find an object in this store using the object's IsEqual()
178 // member function. Requires a sequential scan till the object has
179 // been found. Returns 0 if object is not found.
180 // Typically this function is overridden by a more efficient version
181 // in concrete collection classes.
183 TIter next(CreateIterator());
186 while ((ob = next()))
187 if (ob->IsEqual(obj)) return ob;
191 //_____________________________________________________________________________
193 AliMUONVStore::FindObject(UInt_t uniqueID) const
195 /// Generic find method. Should be overriden by derived class if it can
196 /// be made more efficient there.
198 AliDebug(1,Form("uniqueID=%u",uniqueID));
200 TIter next(CreateIterator());
202 while ( ( o = next() ) )
204 if ( o->GetUniqueID() == uniqueID ) return o;
209 //______________________________________________________________________________
211 AliMUONVStore::GetSize(Int_t /*i*/) const
213 /// Number of objects store for "i", whatever that can means
214 AliError("Not implemented");
218 //______________________________________________________________________________
220 AliMUONVStore::Print(Option_t *wildcard) const
222 // Print all objects in this store.
223 // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
224 // with names matching xxx*.
226 if (!wildcard) wildcard = "";
227 TRegexp re(wildcard, kTRUE);
228 Int_t nch = strlen(wildcard);
229 TIter next(CreateIterator());
232 while ((object = next())) {
233 TString s = object->GetName();
234 if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
239 //_____________________________________________________________________________
241 AliMUONVStore::Print(Option_t *wildcard, Option_t *option) const
243 // Print all objects in this store, passing option to the
244 // objects Print() method.
245 // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
246 // with names matching xxx*.
248 if (!wildcard) wildcard = "";
249 TRegexp re(wildcard, kTRUE);
250 Int_t nch = strlen(wildcard);
251 TIter next(CreateIterator());
254 while ((object = next())) {
255 TString s = object->GetName();
256 if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
257 object->Print(option);