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 //-----------------------------------------------------------------------------
19 /// \class AliMUONVStore
21 /// A store is a container, which can be searched for (using FindObject methods),
22 /// iterated upon (using CreateIterator() method), and into which you can
23 /// add objects (using Add)
25 /// In addition, a store can be connected to a TTree.
27 /// The general way of dealing with I/O for MUON is a two stage process :
29 /// 1) first get a TTree pointer using the AliLoader mechanism (this is AliRoot
32 /// 2) connect that TTree to a MUON (virtual) data container using
33 /// the container's Connect(TTree&) method (this is MUON specific)
35 /// Example for reading digits for nevents
39 /// AliMUONVDigitStore* digitStore(0x0);
41 /// AliLoader* loader = ... ( get loader from somewhere, e.g. AliRunLoader::GetDetectorLoader());
42 /// loader->LoadDigits("READ"); // load digits
44 /// for ( Int_t i = 0; i < nevents; ++i )
46 /// TTree* treeD = loader->TreeD(); // get the tree
47 /// if (!digitStore) digitStore = static_cast<AliMUONVDigitStore*>
48 /// (AliMUONVDigitStore::CreateStore(*treeD,"Digit")); // creates a container for digits
49 /// (concrete class is given by the tree itself)
50 /// digitStore->Connect(*treeD);
51 /// treeD->GetEvent(0); // actual reading of the data
53 /// the digitStore is now filled and ready to be used
56 /// digitStore->Clear(); // reset once used
61 /// Please note that for reading data, you do *not* need to know the concrete
62 /// container class, as it is given to you by the TTree
64 /// Example for writing digits
68 /// get the loader and do a loader->LoadDigits("RECREATE" or "UPDATE")
69 /// (generally done by the framework itself)
71 /// AliMUONVDigitStore* digitStore = new AliMUONDigitStoreV1
72 /// // for writing, must decide on the concrete store class to use
74 /// for ( Int_t i = 0; i < nevents; ++i )
76 /// TTree* treeD = loader->TreeD();
77 /// digitStore->Connect(*treeD);
79 /// ... put some digits in the digitStore
83 /// loader->WriteDigits("OVERWRITE");
86 /// delete digitStore;
88 /// loader->UnloadDigits();
92 /// In the write case, one *must* specify a concrete class for the container
94 //-----------------------------------------------------------------------------
96 #include "AliMUONVStore.h"
98 #include "AliMUONTreeManager.h"
105 ClassImp(AliMUONVStore)
108 //_____________________________________________________________________________
109 AliMUONVStore::AliMUONVStore() : TObject()
114 //_____________________________________________________________________________
115 AliMUONVStore::~AliMUONVStore()
120 //_____________________________________________________________________________
122 AliMUONVStore::Connect(TTree&, Bool_t) const
124 /// Connect to a Ttree
125 AliError("Not implemented");
129 //_____________________________________________________________________________
131 AliMUONVStore::Create(TTree& tree, const char* what)
133 /// Create a store from a tree. Forwarded to AliMUONTreeManager::CreateStore
134 AliMUONTreeManager tman;
136 TObject* o = tman.CreateObject(tree,what);;
139 AliMUONVStore* c = dynamic_cast<AliMUONVStore*>(o);
142 AliErrorClass(Form("Object of class %s cannot be cast to an AliMUONVStore",
150 //_____________________________________________________________________________
152 AliMUONVStore::FindObject(Int_t, Int_t) const
154 /// Find an object using 2 identifiers
155 AliError("(Int_t,Int_t) : Not implemented");
159 //______________________________________________________________________________
161 AliMUONVStore::FindObject(const char *name) const
163 // Find an object in this collection using its name. Requires a sequential
164 // scan till the object has been found. Returns 0 if object with specified
165 // name is not found.
167 TIter next(CreateIterator());
170 while ((obj = next()))
171 if (!strcmp(name, obj->GetName())) return obj;
175 //______________________________________________________________________________
177 AliMUONVStore::FindObject(const TObject *obj) const
179 // Find an object in this store using the object's IsEqual()
180 // member function. Requires a sequential scan till the object has
181 // been found. Returns 0 if object is not found.
182 // Typically this function is overridden by a more efficient version
183 // in concrete collection classes.
185 TIter next(CreateIterator());
188 while ((ob = next()))
189 if (ob->IsEqual(obj)) return ob;
193 //_____________________________________________________________________________
195 AliMUONVStore::FindObject(UInt_t uniqueID) const
197 /// Generic find method. Should be overriden by derived class if it can
198 /// be made more efficient there.
200 AliDebug(1,Form("uniqueID=%u",uniqueID));
202 TIter next(CreateIterator());
204 while ( ( o = next() ) )
206 if ( o->GetUniqueID() == uniqueID ) return o;
211 //______________________________________________________________________________
213 AliMUONVStore::GetSize(Int_t /*i*/) const
215 /// Number of objects store for "i", whatever that can means
216 AliError("Not implemented");
220 //______________________________________________________________________________
222 AliMUONVStore::Print(Option_t *wildcard) const
224 // Print all objects in this store.
225 // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
226 // with names matching xxx*.
228 if (!wildcard) wildcard = "";
229 TRegexp re(wildcard, kTRUE);
230 Int_t nch = strlen(wildcard);
231 TIter next(CreateIterator());
234 while ((object = next())) {
235 TString s = object->GetName();
236 if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
241 //_____________________________________________________________________________
243 AliMUONVStore::Print(Option_t *wildcard, Option_t *option) const
245 // Print all objects in this store, passing option to the
246 // objects Print() method.
247 // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
248 // with names matching xxx*.
250 if (!wildcard) wildcard = "";
251 TRegexp re(wildcard, kTRUE);
252 Int_t nch = strlen(wildcard);
253 TIter next(CreateIterator());
256 while ((object = next())) {
257 TString s = object->GetName();
258 if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
259 object->Print(option);