- Three classes by MinJung Kweon AliHFEpriVtx, AliHFEsecVtx and AliHFEmcQA for primar...
[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.),
2e2d0c44 43 fPads(0x0),
44 fLabel(-1)
d5efea33 45{
46 /// default constructor
47 fXYZ[0] = fXYZ[1] = fXYZ[2] = 0.;
48 fErrXY[0] = fErrXY[1] = 0.;
49}
50
51//_____________________________________________________________________________
52AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
c34d2b8c 53: TObject(cluster),
54 fCharge(cluster.fCharge),
55 fChi2(cluster.fChi2),
2e2d0c44 56 fPads(0x0),
57 fLabel(cluster.fLabel)
d5efea33 58{
59 /// Copy constructor
60 fXYZ[0] = cluster.fXYZ[0];
61 fXYZ[1] = cluster.fXYZ[1];
62 fXYZ[2] = cluster.fXYZ[2];
63 fErrXY[0] = cluster.fErrXY[0];
64 fErrXY[1] = cluster.fErrXY[1];
c34d2b8c 65
66 if (cluster.fPads) {
67 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
68 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
69 while (pad) {
70 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
71 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
72 }
73 }
d5efea33 74}
75
76//_____________________________________________________________________________
77AliESDMuonCluster& AliESDMuonCluster::operator=(const AliESDMuonCluster& cluster)
78{
79 /// Equal operator
80 if (this == &cluster) return *this;
81
82 TObject::operator=(cluster); // don't forget to invoke the base class' assignment operator
83
84 fXYZ[0] = cluster.fXYZ[0];
85 fXYZ[1] = cluster.fXYZ[1];
86 fXYZ[2] = cluster.fXYZ[2];
87 fErrXY[0] = cluster.fErrXY[0];
88 fErrXY[1] = cluster.fErrXY[1];
89
c34d2b8c 90 fCharge = cluster.fCharge;
91 fChi2 = cluster.fChi2;
2e2d0c44 92 fLabel = cluster.fLabel;
c34d2b8c 93
94 delete fPads;
95 if (cluster.fPads) {
96 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
97 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
98 while (pad) {
99 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
100 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
101 }
102 } else fPads = 0x0;
103
d5efea33 104 return *this;
105}
106
c34d2b8c 107//__________________________________________________________________________
108AliESDMuonCluster::~AliESDMuonCluster()
109{
110 /// Destructor
111 delete fPads;
112}
113
114//__________________________________________________________________________
115void AliESDMuonCluster::Clear(Option_t* opt)
116{
117 /// Clear arrays
118 if (fPads) fPads->Clear(opt);
119}
120
121//_____________________________________________________________________________
122Int_t AliESDMuonCluster::GetNPads() const
123{
124 // return the number of pads associated to the cluster
125 if (!fPads) return 0;
126
127 return fPads->GetEntriesFast();
128}
129
130//_____________________________________________________________________________
131TClonesArray& AliESDMuonCluster::GetPads() const
132{
133 // return the array of pads associated to the cluster
134 if (!fPads) fPads = new TClonesArray("AliESDMuonPad",10);
135
136 return *fPads;
137}
138
139//_____________________________________________________________________________
140void AliESDMuonCluster::AddPad(const AliESDMuonPad &pad)
141{
142 // add a pad to the TClonesArray of pads associated to the cluster
143 if (!fPads) fPads = new TClonesArray("AliESDMuonPad",10);
144
145 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(pad);
146}
147
148//_____________________________________________________________________________
149Bool_t AliESDMuonCluster::PadsStored() const
150{
151 // return kTRUE if the pads associated to the cluster are registered
152 if (GetNPads() == 0) return kFALSE;
153
154 return kTRUE;
155}
156
d5efea33 157//_____________________________________________________________________________
158void AliESDMuonCluster::Print(Option_t */*option*/) const
159{
160 /// print cluster content
161 UInt_t cId = GetUniqueID();
162
163 cout<<Form("clusterID=%u (ch=%d, det=%d, index=%d)",
164 cId,GetChamberId(),GetDetElemId(),GetClusterIndex())<<endl;
165
c34d2b8c 166 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%5.2f, %5.2f, 0.0)",
d5efea33 167 GetX(),GetY(),GetZ(),GetErrX(),GetErrY())<<endl;
c34d2b8c 168
2e2d0c44 169 cout<<Form(" charge=%5.2f, chi2=%5.2f, MClabel=%d", GetCharge(), GetChi2(), GetLabel())<<endl;
c34d2b8c 170
171 if (PadsStored()) {
172 cout<<" pad infos:"<<endl;
173 for (Int_t iPad=0; iPad<GetNPads(); iPad++) {
174 cout<<" ";
175 ( (AliESDMuonPad*) fPads->UncheckedAt(iPad) )->Print();
176 }
177 }
d5efea33 178}
179