AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONClusterStoreV1.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 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
30 
31 #include "AliMUONClusterStoreV1.h"
32 
33 #include "AliLog.h"
34 #include "AliMUONRawCluster.h"
36 #include "AliMUONTreeManager.h"
37 #include "AliMpConstants.h"
38 #include "AliMpDEManager.h"
39 #include <TClonesArray.h>
40 #include <TObjArray.h>
41 #include <TTree.h>
42 
46 
47 //_____________________________________________________________________________
50 fClusters(new TObjArray(AliMpConstants::NofChambers()))
51 {
53  fClusters->SetOwner(kTRUE);
54  for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
55  {
56  TClonesArray* tca = new TClonesArray("AliMUONRawCluster",100);
57  fClusters->AddAt(tca,i);
58  }
59  AliDebug(1,"");
60 }
61 
62 //_____________________________________________________________________________
65 fClusters(0x0)
66 {
68  AliError("Please implement me");
69 }
70 
71 //_____________________________________________________________________________
74 {
76  AliError("Please implement me");
77  return *this;
78 }
79 
80 //_____________________________________________________________________________
82 {
84  AliDebug(1,"");
85  delete fClusters;
86 }
87 
88 //_____________________________________________________________________________
89 AliMUONVCluster* AliMUONClusterStoreV1::CreateCluster(Int_t /*chamberId*/, Int_t detElemId, Int_t /*clusterIndex*/) const
90 {
92  AliMUONVCluster* vCluster = new AliMUONRawCluster();
93  (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
94  return vCluster;
95 }
96 
97 //_____________________________________________________________________________
100 {
102  const AliMUONRawCluster* cluster = dynamic_cast<const AliMUONRawCluster*>(&vCluster);
103 
104  if (!cluster)
105  {
106  AliError(Form("Cluster is not of the expected type (%s vs AliMUONRawCluster)",
107  vCluster.ClassName()));
108  return 0x0;
109  }
110 
111  Int_t iChamber = AliMpDEManager::GetChamberId(cluster->GetDetElemId());
112  TClonesArray* array = ChamberClusters(iChamber);
113  if (!array)
114  {
115  return 0x0;
116  }
117 
118  return new((*array)[array->GetLast()+1]) AliMUONRawCluster(*cluster);
119 }
120 
121 //_____________________________________________________________________________
122 AliMUONVCluster* AliMUONClusterStoreV1::Add(Int_t chamberId, Int_t detElemId, Int_t /*clusterIndex*/)
123 {
125  TClonesArray* array = ChamberClusters(chamberId);
126  if (!array) return 0x0;
127 
128  AliMUONVCluster* vCluster = static_cast<AliMUONVCluster*> (new((*array)[array->GetLast()+1]) AliMUONRawCluster());
129  (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
130  return vCluster;
131 }
132 
133 //_____________________________________________________________________________
134 TClonesArray*
136 {
138  TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
139  if (!array)
140  {
141  AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
142  return 0x0;
143  }
144  return array;
145 }
146 
147 //_____________________________________________________________________________
148 TObject**
150 {
152  TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
153  if (!array)
154  {
155  AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
156  return 0x0;
157  }
158  return fClusters->GetObjectRef(array);
159 }
160 
161 //_____________________________________________________________________________
162 Bool_t
163 AliMUONClusterStoreV1::Connect(TTree& tree, Bool_t alone) const
164 {
166 
167  AliMUONTreeManager tman;
168  Bool_t ok(kTRUE);
169 
170  TBranch* b = tree.GetBranch("MUONRawClusters1");
171 
172  Bool_t isMaking = (b == 0);
173 
174  if ( isMaking )
175  {
176  for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
177  {
178  TString branchName(Form("MUONRawClusters%d",i+1));
179  ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray",
180  branchName.Data(),ChamberClustersPtr(i));
181  }
182 
183  }
184  else
185  {
186  if (alone) tman.UpdateBranchStatuses(tree,"MUONRawClusters");
187  for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
188  {
189  TString branchName(Form("MUONRawClusters%d",i+1));
190  ok = ok && tman.SetAddress(tree,branchName.Data(),
191  ChamberClustersPtr(i));
192  }
193  }
194  return ok;
195 }
196 
197 //_____________________________________________________________________________
200 {
202  Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
203  TClonesArray* array = ChamberClusters(iChamber);
204  TObject* o = array->Remove(&cluster);
205  if (o)
206  {
207  array->Compress();
208  }
209  return static_cast<AliMUONVCluster*>(o);
210 }
211 
212 //_____________________________________________________________________________
213 void
215 {
217  AliDebug(1,"");
219  for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
220  {
221  ChamberClusters(i)->Clear("C");
222  }
223 }
224 
225 //_____________________________________________________________________________
226 TIterator*
228 {
231 }
232 
233 //_____________________________________________________________________________
234 TIterator*
235 AliMUONClusterStoreV1::CreateChamberIterator(Int_t firstChamber, Int_t lastChamber) const
236 {
238  return new AliMUONTOTCAStoreIterator(fClusters,firstChamber,lastChamber);
239 }
240 
241 //_____________________________________________________________________________
242 Int_t
244 {
246  Int_t n(0);
247  for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
248  {
249  n += ChamberClusters(i)->GetLast()+1;
250  }
251  return n;
252 }
253 
Iterator on a store composed of a TObjArray of TClonesArrays.
Bool_t SetAddress(TTree &tree, const char *branchName, void *address) const
#define TObjArray
TObjArray * fClusters
! Array of TClonesArray of VClusters
TObject ** ChamberClustersPtr(Int_t chamberId) const
TTree * tree
Helper class to ease TTree (MUON) branches manipulations.
virtual AliMUONVCluster * Add(const AliMUONVCluster &Cluster)
Add a cluster object to the store.
TObjArray * array
Definition: AnalyzeLaser.C:12
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
virtual TIterator * CreateIterator() const
Return an iterator to loop over the whole store.
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
abstract base class for clusters
virtual Int_t GetDetElemId() const
Return detection element Id.
MUON raw cluster.
Implementation of VClusterStore.
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
virtual void Clear(Option_t *opt="")
Clear container.
Interface of a cluster container.
virtual TIterator * CreateChamberIterator(Int_t firstChamberId, Int_t lastChamberId) const
Return an iterator to loop over the store in the given chamber range.
void UpdateBranchStatuses(TTree &tree, const char *pattern) const
virtual AliMUONVCluster * Remove(AliMUONVCluster &cluster)
Remove a cluster object to the store.
virtual AliMUONVCluster * CreateCluster(Int_t, Int_t detElemId, Int_t) const
Create a cluster.
virtual Int_t GetSize() const
The number of objects stored.
static Int_t GetDetElemId(UInt_t uniqueID)
Return detection element id, part of the uniqueID.
Bool_t MakeBranch(TTree &tree, const char *storeClassName, const char *branchClassName, const char *branchName, void *address, Int_t bufferSize=4000, Int_t splitLevel=99) const
Globally used constants definition.
AliMUONClusterStoreV1 & operator=(const AliMUONClusterStoreV1 &rhs)
static Int_t NofTrackingChambers()
Return number of tracking chambers.
TClonesArray * ChamberClusters(Int_t chamberId) const