AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONVStore.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15 
16 // $Id$
17 
18 //-----------------------------------------------------------------------------
94 //-----------------------------------------------------------------------------
95 
96 #include "AliMUONVStore.h"
97 
98 #include "AliMUONTreeManager.h"
99 #include "AliLog.h"
100 
101 #include <TRegexp.h>
102 #include <TClass.h>
103 
107 
108 //_____________________________________________________________________________
110 {
112 }
113 
114 //_____________________________________________________________________________
116 {
118 }
119 
120 //_____________________________________________________________________________
121 Bool_t
122 AliMUONVStore::Connect(TTree&, Bool_t) const
123 {
125  AliError("Not implemented");
126  return kFALSE;
127 }
128 
129 //_____________________________________________________________________________
131 AliMUONVStore::Create(TTree& tree, const char* what)
132 {
134  AliMUONTreeManager tman;
135 
136  TObject* o = tman.CreateObject(tree,what);;
137  if (o)
138  {
139  AliMUONVStore* c = dynamic_cast<AliMUONVStore*>(o);
140  if (!c)
141  {
142  AliErrorClass(Form("Object of class %s cannot be cast to an AliMUONVStore",
143  o->ClassName()));
144  }
145  return c;
146  }
147  return 0x0;
148 }
149 
150 //_____________________________________________________________________________
151 TObject*
152 AliMUONVStore::FindObject(Int_t, Int_t) const
153 {
155  AliError("(Int_t,Int_t) : Not implemented");
156  return 0;
157 }
158 
159 //______________________________________________________________________________
160 TObject*
161 AliMUONVStore::FindObject(const char *name) const
162 {
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.
166 
167  TIter next(CreateIterator());
168  TObject *obj;
169 
170  while ((obj = next()))
171  if (!strcmp(name, obj->GetName())) return obj;
172  return 0;
173 }
174 
175 //______________________________________________________________________________
176 TObject*
177 AliMUONVStore::FindObject(const TObject *obj) const
178 {
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.
184 
185  TIter next(CreateIterator());
186  TObject *ob;
187 
188  while ((ob = next()))
189  if (ob->IsEqual(obj)) return ob;
190  return 0;
191 }
192 
193 //_____________________________________________________________________________
194 TObject*
195 AliMUONVStore::FindObject(UInt_t uniqueID) const
196 {
199 
200  AliDebug(1,Form("uniqueID=%u",uniqueID));
201 
202  TIter next(CreateIterator());
203  TObject* o;
204  while ( ( o = next() ) )
205  {
206  if ( o->GetUniqueID() == uniqueID ) return o;
207  }
208  return 0x0;
209 }
210 
211 //______________________________________________________________________________
212 Int_t
213 AliMUONVStore::GetSize(Int_t /*i*/) const
214 {
216  AliError("Not implemented");
217  return 0;
218 }
219 
220 //______________________________________________________________________________
221 void
222 AliMUONVStore::Print(Option_t *wildcard) const
223 {
224  // Print all objects in this store.
225  // Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
226  // with names matching xxx*.
227 
228  if (!wildcard) wildcard = "";
229  TRegexp re(wildcard, kTRUE);
230  Int_t nch = strlen(wildcard);
231  TIter next(CreateIterator());
232  TObject *object;
233 
234  while ((object = next())) {
235  TString s = object->GetName();
236  if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
237  object->Print();
238  }
239 }
240 
241 //_____________________________________________________________________________
242 void
243 AliMUONVStore::Print(Option_t *wildcard, Option_t *option) const
244 {
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*.
249 
250  if (!wildcard) wildcard = "";
251  TRegexp re(wildcard, kTRUE);
252  Int_t nch = strlen(wildcard);
253  TIter next(CreateIterator());
254  TObject *object;
255 
256  while ((object = next())) {
257  TString s = object->GetName();
258  if (nch && s != wildcard && s.Index(re) == kNPOS) continue;
259  object->Print(option);
260  }
261 }
262 
virtual TIterator * CreateIterator() const =0
Return an iterator to loop over the whole store.
virtual void Print(Option_t *wildcard="") const
Print all objects whose name matches wildcard.
virtual ~AliMUONVStore()
virtual Int_t GetSize() const =0
The number of objects stored.
TTree * tree
Helper class to ease TTree (MUON) branches manipulations.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
virtual AliMUONVStore * Create() const =0
Create an empty copy of this.
TObject * CreateObject(const TTree &tree, const char *detail) const
Base class for MUON data stores.
Definition: AliMUONVStore.h:22
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
virtual TObject * FindObject(const char *name) const
Find an object by name.