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 AliMUONClusterStoreV1
20 /// Implementation of VClusterStore.
22 /// This one is a basic implementation, let's say "legacy" one, i.e.
23 /// compatible with what we stored in MUON.RecPoints.root files before
24 /// the switch to data stores.
26 /// \author Laurent Aphecetche, Subatech
29 #include "AliMUONClusterStoreV1.h"
32 #include "AliMUONRawCluster.h"
33 #include "AliMUONTOTCAStoreIterator.h"
34 #include "AliMUONTreeManager.h"
35 #include "AliMpConstants.h"
36 #include "AliMpDEManager.h"
37 #include <TClonesArray.h>
38 #include <TObjArray.h>
42 ClassImp(AliMUONClusterStoreV1)
45 //_____________________________________________________________________________
46 AliMUONClusterStoreV1::AliMUONClusterStoreV1()
47 : AliMUONVClusterStore(),
48 fClusters(new TObjArray(AliMpConstants::NofChambers()))
50 /// ctor. Set correct ownerships
51 fClusters->SetOwner(kTRUE);
52 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
54 TClonesArray* tca = new TClonesArray("AliMUONRawCluster",100);
56 fClusters->AddAt(tca,i);
61 //_____________________________________________________________________________
62 AliMUONClusterStoreV1::AliMUONClusterStoreV1(const AliMUONClusterStoreV1&)
63 : AliMUONVClusterStore(),
67 AliError("Please implement me");
70 //_____________________________________________________________________________
71 AliMUONClusterStoreV1&
72 AliMUONClusterStoreV1::operator=(const AliMUONClusterStoreV1&)
74 /// assignment operator
75 AliError("Please implement me");
79 //_____________________________________________________________________________
80 AliMUONClusterStoreV1::~AliMUONClusterStoreV1()
87 //_____________________________________________________________________________
89 AliMUONClusterStoreV1::Add(const AliMUONRawCluster& cluster)
91 /// Add a cluster to this store
92 Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
93 TClonesArray* array = ChamberClusters(iChamber);
98 new((*array)[array->GetLast()+1]) AliMUONRawCluster(cluster);
102 //_____________________________________________________________________________
104 AliMUONClusterStoreV1::ChamberClusters(Int_t chamberId) const
106 /// Get the internal array of clusters for a given chamber
107 TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
110 AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
116 //_____________________________________________________________________________
118 AliMUONClusterStoreV1::ChamberClustersPtr(Int_t chamberId) const
120 /// Get the internal array of clusters for a given chamber
121 TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
124 AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
127 return fClusters->GetObjectRef(array);
130 //_____________________________________________________________________________
132 AliMUONClusterStoreV1::Connect(TTree& tree, Bool_t alone) const
134 /// Connect this to the tree, i.e. make the branches or set their addresses.
136 AliMUONTreeManager tman;
139 TBranch* b = tree.GetBranch("MUONRawClusters1");
141 Bool_t isMaking = (b == 0);
145 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
147 TString branchName(Form("MUONRawClusters%d",i+1));
148 ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray",
149 branchName.Data(),ChamberClustersPtr(i));
155 if (alone) tman.UpdateBranchStatuses(tree,"MUONRawClusters");
156 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
158 TString branchName(Form("MUONRawClusters%d",i+1));
159 ok = ok && tman.SetAddress(tree,branchName.Data(),
160 ChamberClustersPtr(i));
166 //_____________________________________________________________________________
168 AliMUONClusterStoreV1::Remove(AliMUONRawCluster& cluster)
171 Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
172 TClonesArray* array = ChamberClusters(iChamber);
173 TObject* o = array->Remove(&cluster);
178 return static_cast<AliMUONRawCluster*>(o);
181 //_____________________________________________________________________________
183 AliMUONClusterStoreV1::Clear(Option_t*)
185 /// Reset internal arrays
187 /// Reset the tclonesarray, but keep the tobjarray's size constant.
188 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
190 ChamberClusters(i)->Clear("C");
194 //_____________________________________________________________________________
196 AliMUONClusterStoreV1::CreateIterator() const
198 /// Return an iterator to loop over our clusters
199 return new AliMUONTOTCAStoreIterator(fClusters,0,AliMpConstants::NofTrackingChambers()-1);
202 //_____________________________________________________________________________
204 AliMUONClusterStoreV1::CreateChamberIterator(Int_t firstChamber, Int_t lastChamber) const
206 /// Return an iterator to loop over our clusters
207 return new AliMUONTOTCAStoreIterator(fClusters,firstChamber,lastChamber);
210 //_____________________________________________________________________________
212 AliMUONClusterStoreV1::GetSize() const
214 /// Return the number of clusters we hold
216 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
218 n += ChamberClusters(i)->GetLast()+1;