]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONClusterStoreV1.cxx
fit fraction cut bug fixed
[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
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
44ClassImp(AliMUONClusterStoreV1)
45/// \endcond
46
47//_____________________________________________________________________________
48AliMUONClusterStoreV1::AliMUONClusterStoreV1()
49: AliMUONVClusterStore(),
50fClusters(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//_____________________________________________________________________________
64AliMUONClusterStoreV1::AliMUONClusterStoreV1(const AliMUONClusterStoreV1&)
65: AliMUONVClusterStore(),
66fClusters(0x0)
67{
68 /// copy ctor
69 AliError("Please implement me");
70}
71
72//_____________________________________________________________________________
73AliMUONClusterStoreV1&
74AliMUONClusterStoreV1::operator=(const AliMUONClusterStoreV1&)
75{
76 /// assignment operator
77 AliError("Please implement me");
78 return *this;
79}
80
81//_____________________________________________________________________________
82AliMUONClusterStoreV1::~AliMUONClusterStoreV1()
83{
84 /// dtor
85 AliDebug(1,"");
86 delete fClusters;
87}
88
2060b217 89//_____________________________________________________________________________
90AliMUONVCluster* AliMUONClusterStoreV1::CreateCluster(Int_t /*chamberId*/, Int_t detElemId, Int_t /*clusterIndex*/) const
91{
92 /// Create a cluster
93 AliMUONVCluster* vCluster = new AliMUONRawCluster();
94 (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
95 return vCluster;
96}
97
e8adc3ac 98//_____________________________________________________________________________
99Bool_t
2060b217 100AliMUONClusterStoreV1::Add(const AliMUONVCluster& vCluster)
e8adc3ac 101{
102 /// Add a cluster to this store
2060b217 103 const AliMUONRawCluster* cluster = dynamic_cast<const AliMUONRawCluster*>(&vCluster);
104
105 if (!cluster)
106 {
107 AliError(Form("Cluster is not of the expected type (%s vs AliMUONRawCluster)",
108 vCluster.ClassName()));
109 return 0x0;
110 }
111
112 Int_t iChamber = AliMpDEManager::GetChamberId(cluster->GetDetElemId());
e8adc3ac 113 TClonesArray* array = ChamberClusters(iChamber);
114 if (!array)
115 {
116 return kFALSE;
117 }
2060b217 118 new((*array)[array->GetLast()+1]) AliMUONRawCluster(*cluster);
e8adc3ac 119 return kTRUE;
120}
121
2060b217 122//_____________________________________________________________________________
123AliMUONVCluster* AliMUONClusterStoreV1::Add(Int_t chamberId, Int_t detElemId, Int_t /*clusterIndex*/)
124{
125 /// Add a cluster to this store
126 TClonesArray* array = ChamberClusters(chamberId);
127 if (!array) return 0x0;
128
129 AliMUONVCluster* vCluster = static_cast<AliMUONVCluster*> (new((*array)[array->GetLast()+1]) AliMUONRawCluster());
130 (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
131 return vCluster;
132}
133
e8adc3ac 134//_____________________________________________________________________________
135TClonesArray*
136AliMUONClusterStoreV1::ChamberClusters(Int_t chamberId) const
137{
138 /// Get the internal array of clusters for a given chamber
139 TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
140 if (!array)
141 {
142 AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
143 return 0x0;
144 }
145 return array;
146}
147
148//_____________________________________________________________________________
149TObject**
150AliMUONClusterStoreV1::ChamberClustersPtr(Int_t chamberId) const
151{
152 /// Get the internal array of clusters for a given chamber
153 TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
154 if (!array)
155 {
156 AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
157 return 0x0;
158 }
159 return fClusters->GetObjectRef(array);
160}
161
162//_____________________________________________________________________________
163Bool_t
164AliMUONClusterStoreV1::Connect(TTree& tree, Bool_t alone) const
165{
166 /// Connect this to the tree, i.e. make the branches or set their addresses.
167
168 AliMUONTreeManager tman;
169 Bool_t ok(kTRUE);
170
171 TBranch* b = tree.GetBranch("MUONRawClusters1");
172
173 Bool_t isMaking = (b == 0);
174
175 if ( isMaking )
176 {
177 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
178 {
179 TString branchName(Form("MUONRawClusters%d",i+1));
180 ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray",
181 branchName.Data(),ChamberClustersPtr(i));
182 }
183
184 }
185 else
186 {
187 if (alone) tman.UpdateBranchStatuses(tree,"MUONRawClusters");
188 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
189 {
190 TString branchName(Form("MUONRawClusters%d",i+1));
191 ok = ok && tman.SetAddress(tree,branchName.Data(),
192 ChamberClustersPtr(i));
193 }
194 }
195 return ok;
196}
197
198//_____________________________________________________________________________
2060b217 199AliMUONVCluster*
200AliMUONClusterStoreV1::Remove(AliMUONVCluster& cluster)
e8adc3ac 201{
202 /// Remove a cluster
203 Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
204 TClonesArray* array = ChamberClusters(iChamber);
205 TObject* o = array->Remove(&cluster);
206 if (o)
207 {
208 array->Compress();
209 }
2060b217 210 return static_cast<AliMUONVCluster*>(o);
e8adc3ac 211}
212
213//_____________________________________________________________________________
214void
215AliMUONClusterStoreV1::Clear(Option_t*)
216{
217 /// Reset internal arrays
218 AliDebug(1,"");
219 /// Reset the tclonesarray, but keep the tobjarray's size constant.
220 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
221 {
222 ChamberClusters(i)->Clear("C");
223 }
224}
225
226//_____________________________________________________________________________
227TIterator*
228AliMUONClusterStoreV1::CreateIterator() const
229{
230 /// Return an iterator to loop over our clusters
231 return new AliMUONTOTCAStoreIterator(fClusters,0,AliMpConstants::NofTrackingChambers()-1);
232}
233
234//_____________________________________________________________________________
235TIterator*
236AliMUONClusterStoreV1::CreateChamberIterator(Int_t firstChamber, Int_t lastChamber) const
237{
238 /// Return an iterator to loop over our clusters
239 return new AliMUONTOTCAStoreIterator(fClusters,firstChamber,lastChamber);
240}
241
242//_____________________________________________________________________________
243Int_t
244AliMUONClusterStoreV1::GetSize() const
245{
22dce0e3 246 /// Return the number of clusters we hold
d8af3c98 247 Int_t n(0);
248 for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
249 {
250 n += ChamberClusters(i)->GetLast()+1;
251 }
252 return n;
e8adc3ac 253}
2060b217 254