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