]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONClusterStoreV1.cxx
No more misaligned_geometry
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterStoreV1.cxx
CommitLineData
e8adc3ac 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/// \class AliMUONClusterStoreV1
19///
20/// Implementation of VClusterStore.
21///
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.
25///
26/// \author Laurent Aphecetche, Subatech
27///
28
29#include "AliMUONClusterStoreV1.h"
30
31#include "AliLog.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>
39#include <TTree.h>
40
41/// \cond CLASSIMP
42ClassImp(AliMUONClusterStoreV1)
43/// \endcond
44
45//_____________________________________________________________________________
46AliMUONClusterStoreV1::AliMUONClusterStoreV1()
47: AliMUONVClusterStore(),
48fClusters(new TObjArray(AliMpConstants::NofChambers()))
49{
50 /// ctor. Set correct ownerships
51 fClusters->SetOwner(kTRUE);
52 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
53 {
54 TClonesArray* tca = new TClonesArray("AliMUONRawCluster",100);
55 tca->SetOwner(kTRUE);
56 fClusters->AddAt(tca,i);
57 }
58 AliDebug(1,"");
59}
60
61//_____________________________________________________________________________
62AliMUONClusterStoreV1::AliMUONClusterStoreV1(const AliMUONClusterStoreV1&)
63: AliMUONVClusterStore(),
64fClusters(0x0)
65{
66 /// copy ctor
67 AliError("Please implement me");
68}
69
70//_____________________________________________________________________________
71AliMUONClusterStoreV1&
72AliMUONClusterStoreV1::operator=(const AliMUONClusterStoreV1&)
73{
74 /// assignment operator
75 AliError("Please implement me");
76 return *this;
77}
78
79//_____________________________________________________________________________
80AliMUONClusterStoreV1::~AliMUONClusterStoreV1()
81{
82 /// dtor
83 AliDebug(1,"");
84 delete fClusters;
85}
86
87//_____________________________________________________________________________
88Bool_t
89AliMUONClusterStoreV1::Add(const AliMUONRawCluster& cluster)
90{
91 /// Add a cluster to this store
92 Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
93 TClonesArray* array = ChamberClusters(iChamber);
94 if (!array)
95 {
96 return kFALSE;
97 }
98 new((*array)[array->GetLast()+1]) AliMUONRawCluster(cluster);
99 return kTRUE;
100}
101
102//_____________________________________________________________________________
103TClonesArray*
104AliMUONClusterStoreV1::ChamberClusters(Int_t chamberId) const
105{
106 /// Get the internal array of clusters for a given chamber
107 TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
108 if (!array)
109 {
110 AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
111 return 0x0;
112 }
113 return array;
114}
115
116//_____________________________________________________________________________
117TObject**
118AliMUONClusterStoreV1::ChamberClustersPtr(Int_t chamberId) const
119{
120 /// Get the internal array of clusters for a given chamber
121 TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
122 if (!array)
123 {
124 AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
125 return 0x0;
126 }
127 return fClusters->GetObjectRef(array);
128}
129
130//_____________________________________________________________________________
131Bool_t
132AliMUONClusterStoreV1::Connect(TTree& tree, Bool_t alone) const
133{
134 /// Connect this to the tree, i.e. make the branches or set their addresses.
135
136 AliMUONTreeManager tman;
137 Bool_t ok(kTRUE);
138
139 TBranch* b = tree.GetBranch("MUONRawClusters1");
140
141 Bool_t isMaking = (b == 0);
142
143 if ( isMaking )
144 {
145 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
146 {
147 TString branchName(Form("MUONRawClusters%d",i+1));
148 ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray",
149 branchName.Data(),ChamberClustersPtr(i));
150 }
151
152 }
153 else
154 {
155 if (alone) tman.UpdateBranchStatuses(tree,"MUONRawClusters");
156 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
157 {
158 TString branchName(Form("MUONRawClusters%d",i+1));
159 ok = ok && tman.SetAddress(tree,branchName.Data(),
160 ChamberClustersPtr(i));
161 }
162 }
163 return ok;
164}
165
166//_____________________________________________________________________________
167AliMUONRawCluster*
168AliMUONClusterStoreV1::Remove(AliMUONRawCluster& cluster)
169{
170 /// Remove a cluster
171 Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
172 TClonesArray* array = ChamberClusters(iChamber);
173 TObject* o = array->Remove(&cluster);
174 if (o)
175 {
176 array->Compress();
177 }
178 return static_cast<AliMUONRawCluster*>(o);
179}
180
181//_____________________________________________________________________________
182void
183AliMUONClusterStoreV1::Clear(Option_t*)
184{
185 /// Reset internal arrays
186 AliDebug(1,"");
187 /// Reset the tclonesarray, but keep the tobjarray's size constant.
188 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
189 {
190 ChamberClusters(i)->Clear("C");
191 }
192}
193
194//_____________________________________________________________________________
195TIterator*
196AliMUONClusterStoreV1::CreateIterator() const
197{
198 /// Return an iterator to loop over our clusters
199 return new AliMUONTOTCAStoreIterator(fClusters,0,AliMpConstants::NofTrackingChambers()-1);
200}
201
202//_____________________________________________________________________________
203TIterator*
204AliMUONClusterStoreV1::CreateChamberIterator(Int_t firstChamber, Int_t lastChamber) const
205{
206 /// Return an iterator to loop over our clusters
207 return new AliMUONTOTCAStoreIterator(fClusters,firstChamber,lastChamber);
208}
209
210//_____________________________________________________________________________
211Int_t
212AliMUONClusterStoreV1::GetSize() const
213{
22dce0e3 214 /// Return the number of clusters we hold
d8af3c98 215 Int_t n(0);
216 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
217 {
218 n += ChamberClusters(i)->GetLast()+1;
219 }
220 return n;
e8adc3ac 221}