Added methods for finding a given module in the DDL map (F. Prino)
[u/mrichter/AliRoot.git] / STEER / AliESDMuonCluster.cxx
CommitLineData
d5efea33 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//-----------------------------------------------------------------------------
19/// \class AliESDMuonCluster
20///
21/// Class to describe the MUON clusters in the Event Summary Data
22///
23/// \author Philippe Pillot, Subatech
24//-----------------------------------------------------------------------------
25
26#include "AliESDMuonCluster.h"
c34d2b8c 27#include "AliESDMuonPad.h"
d5efea33 28
29#include "AliLog.h"
30
c34d2b8c 31#include <TClonesArray.h>
d5efea33 32#include <Riostream.h>
33
34/// \cond CLASSIMP
35ClassImp(AliESDMuonCluster)
36/// \endcond
37
38//_____________________________________________________________________________
39AliESDMuonCluster::AliESDMuonCluster()
c34d2b8c 40: TObject(),
41 fCharge(0.),
42 fChi2(0.),
43 fPads(0x0)
d5efea33 44{
45 /// default constructor
46 fXYZ[0] = fXYZ[1] = fXYZ[2] = 0.;
47 fErrXY[0] = fErrXY[1] = 0.;
48}
49
50//_____________________________________________________________________________
51AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
c34d2b8c 52: TObject(cluster),
53 fCharge(cluster.fCharge),
54 fChi2(cluster.fChi2),
55 fPads(0x0)
d5efea33 56{
57 /// Copy constructor
58 fXYZ[0] = cluster.fXYZ[0];
59 fXYZ[1] = cluster.fXYZ[1];
60 fXYZ[2] = cluster.fXYZ[2];
61 fErrXY[0] = cluster.fErrXY[0];
62 fErrXY[1] = cluster.fErrXY[1];
c34d2b8c 63
64 if (cluster.fPads) {
65 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
66 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
67 while (pad) {
68 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
69 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
70 }
71 }
d5efea33 72}
73
74//_____________________________________________________________________________
75AliESDMuonCluster& AliESDMuonCluster::operator=(const AliESDMuonCluster& cluster)
76{
77 /// Equal operator
78 if (this == &cluster) return *this;
79
80 TObject::operator=(cluster); // don't forget to invoke the base class' assignment operator
81
82 fXYZ[0] = cluster.fXYZ[0];
83 fXYZ[1] = cluster.fXYZ[1];
84 fXYZ[2] = cluster.fXYZ[2];
85 fErrXY[0] = cluster.fErrXY[0];
86 fErrXY[1] = cluster.fErrXY[1];
87
c34d2b8c 88 fCharge = cluster.fCharge;
89 fChi2 = cluster.fChi2;
90
91 delete fPads;
92 if (cluster.fPads) {
93 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
94 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
95 while (pad) {
96 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
97 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
98 }
99 } else fPads = 0x0;
100
d5efea33 101 return *this;
102}
103
c34d2b8c 104//__________________________________________________________________________
105AliESDMuonCluster::~AliESDMuonCluster()
106{
107 /// Destructor
108 delete fPads;
109}
110
111//__________________________________________________________________________
112void AliESDMuonCluster::Clear(Option_t* opt)
113{
114 /// Clear arrays
115 if (fPads) fPads->Clear(opt);
116}
117
118//_____________________________________________________________________________
119Int_t AliESDMuonCluster::GetNPads() const
120{
121 // return the number of pads associated to the cluster
122 if (!fPads) return 0;
123
124 return fPads->GetEntriesFast();
125}
126
127//_____________________________________________________________________________
128TClonesArray& AliESDMuonCluster::GetPads() const
129{
130 // return the array of pads associated to the cluster
131 if (!fPads) fPads = new TClonesArray("AliESDMuonPad",10);
132
133 return *fPads;
134}
135
136//_____________________________________________________________________________
137void AliESDMuonCluster::AddPad(const AliESDMuonPad &pad)
138{
139 // add a pad to the TClonesArray of pads associated to the cluster
140 if (!fPads) fPads = new TClonesArray("AliESDMuonPad",10);
141
142 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(pad);
143}
144
145//_____________________________________________________________________________
146Bool_t AliESDMuonCluster::PadsStored() const
147{
148 // return kTRUE if the pads associated to the cluster are registered
149 if (GetNPads() == 0) return kFALSE;
150
151 return kTRUE;
152}
153
d5efea33 154//_____________________________________________________________________________
155void AliESDMuonCluster::Print(Option_t */*option*/) const
156{
157 /// print cluster content
158 UInt_t cId = GetUniqueID();
159
160 cout<<Form("clusterID=%u (ch=%d, det=%d, index=%d)",
161 cId,GetChamberId(),GetDetElemId(),GetClusterIndex())<<endl;
162
c34d2b8c 163 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%5.2f, %5.2f, 0.0)",
d5efea33 164 GetX(),GetY(),GetZ(),GetErrX(),GetErrY())<<endl;
c34d2b8c 165
166 cout<<Form(" charge=%5.2f, chi2=%5.2f", GetCharge(), GetChi2())<<endl;
167
168 if (PadsStored()) {
169 cout<<" pad infos:"<<endl;
170 for (Int_t iPad=0; iPad<GetNPads(); iPad++) {
171 cout<<" ";
172 ( (AliESDMuonPad*) fPads->UncheckedAt(iPad) )->Print();
173 }
174 }
d5efea33 175}
176