Compatibility with ROOT trunk
[u/mrichter/AliRoot.git] / STEER / ESD / 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
fe0324de 26#include "AliESDEvent.h"
d5efea33 27#include "AliESDMuonCluster.h"
c34d2b8c 28#include "AliESDMuonPad.h"
d5efea33 29
30#include "AliLog.h"
31
c34d2b8c 32#include <TClonesArray.h>
d5efea33 33#include <Riostream.h>
34
66b0310c 35using std::endl;
36using std::cout;
d5efea33 37/// \cond CLASSIMP
38ClassImp(AliESDMuonCluster)
39/// \endcond
40
41//_____________________________________________________________________________
42AliESDMuonCluster::AliESDMuonCluster()
c34d2b8c 43: TObject(),
44 fCharge(0.),
45 fChi2(0.),
2e2d0c44 46 fPads(0x0),
fe0324de 47 fNPads(0),
48 fPadsId(0x0),
2e2d0c44 49 fLabel(-1)
d5efea33 50{
51 /// default constructor
52 fXYZ[0] = fXYZ[1] = fXYZ[2] = 0.;
53 fErrXY[0] = fErrXY[1] = 0.;
54}
55
56//_____________________________________________________________________________
57AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
c34d2b8c 58: TObject(cluster),
59 fCharge(cluster.fCharge),
60 fChi2(cluster.fChi2),
2e2d0c44 61 fPads(0x0),
fe0324de 62 fNPads(cluster.fNPads),
63 fPadsId(0x0),
2e2d0c44 64 fLabel(cluster.fLabel)
d5efea33 65{
66 /// Copy constructor
67 fXYZ[0] = cluster.fXYZ[0];
68 fXYZ[1] = cluster.fXYZ[1];
69 fXYZ[2] = cluster.fXYZ[2];
70 fErrXY[0] = cluster.fErrXY[0];
71 fErrXY[1] = cluster.fErrXY[1];
c34d2b8c 72
73 if (cluster.fPads) {
74 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
75 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
76 while (pad) {
77 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
78 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
79 }
80 }
fe0324de 81
82 if (cluster.fPadsId) fPadsId = new TArrayI(*(cluster.fPadsId));
d5efea33 83}
84
85//_____________________________________________________________________________
86AliESDMuonCluster& AliESDMuonCluster::operator=(const AliESDMuonCluster& cluster)
87{
88 /// Equal operator
89 if (this == &cluster) return *this;
90
91 TObject::operator=(cluster); // don't forget to invoke the base class' assignment operator
92
93 fXYZ[0] = cluster.fXYZ[0];
94 fXYZ[1] = cluster.fXYZ[1];
95 fXYZ[2] = cluster.fXYZ[2];
96 fErrXY[0] = cluster.fErrXY[0];
97 fErrXY[1] = cluster.fErrXY[1];
98
c34d2b8c 99 fCharge = cluster.fCharge;
100 fChi2 = cluster.fChi2;
2e2d0c44 101 fLabel = cluster.fLabel;
c34d2b8c 102
103 delete fPads;
104 if (cluster.fPads) {
105 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
106 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
107 while (pad) {
108 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
109 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
110 }
111 } else fPads = 0x0;
112
fe0324de 113 SetPadsId(cluster.fNPads, cluster.GetPadsId());
114
d5efea33 115 return *this;
116}
117
c34d2b8c 118//__________________________________________________________________________
119AliESDMuonCluster::~AliESDMuonCluster()
120{
121 /// Destructor
122 delete fPads;
fe0324de 123 delete fPadsId;
c34d2b8c 124}
125
126//__________________________________________________________________________
fe0324de 127void AliESDMuonCluster::Clear(Option_t* opt)
c34d2b8c 128{
129 /// Clear arrays
fe0324de 130 if (opt && opt[0] == 'C') {
131 if (fPads) fPads->Clear("C");
132 } else {
133 delete fPads; fPads = 0x0;
134 }
135 delete fPadsId; fPadsId = 0x0;
136 fNPads = 0;
c34d2b8c 137}
138
139//_____________________________________________________________________________
fe0324de 140void AliESDMuonCluster::AddPadId(UInt_t padId)
c34d2b8c 141{
fe0324de 142 /// Add the given pad Id to the list associated to the cluster
143 if (!fPadsId) fPadsId = new TArrayI(10);
144 if (fPadsId->GetSize() <= fNPads) fPadsId->Set(fNPads+10);
145 fPadsId->AddAt(static_cast<Int_t>(padId), fNPads++);
c34d2b8c 146}
147
148//_____________________________________________________________________________
fe0324de 149void AliESDMuonCluster::SetPadsId(Int_t nPads, const UInt_t *padsId)
c34d2b8c 150{
fe0324de 151 /// Fill the list pads'Id associated to the cluster with the given list
c34d2b8c 152
fe0324de 153 if (nPads <= 0 || !padsId) {
154 delete fPadsId;
155 fPadsId = 0x0;
156 fNPads = 0;
157 return;
158 }
159
160 if (!fPadsId) fPadsId = new TArrayI(nPads, reinterpret_cast<const Int_t*>(padsId));
161 else fPadsId->Set(nPads, reinterpret_cast<const Int_t*>(padsId));
162 fNPads = nPads;
c34d2b8c 163
c34d2b8c 164}
165
166//_____________________________________________________________________________
fe0324de 167void AliESDMuonCluster::MovePadsToESD(AliESDEvent &esd)
c34d2b8c 168{
fe0324de 169 /// move the pads to the new ESD structure
170 if (!fPads) return;
171 for (Int_t i = 0; i < fPads->GetEntriesFast(); i++) {
172 AliESDMuonPad *pad = static_cast<AliESDMuonPad*>(fPads->UncheckedAt(i));
173 AliESDMuonPad *newPad = esd.NewMuonPad();
174 *newPad = *pad;
175 AddPadId(newPad->GetUniqueID());
176 }
177 delete fPads;
178 fPads = 0x0;
c34d2b8c 179}
180
d5efea33 181//_____________________________________________________________________________
182void AliESDMuonCluster::Print(Option_t */*option*/) const
183{
184 /// print cluster content
185 UInt_t cId = GetUniqueID();
186
187 cout<<Form("clusterID=%u (ch=%d, det=%d, index=%d)",
188 cId,GetChamberId(),GetDetElemId(),GetClusterIndex())<<endl;
189
c34d2b8c 190 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%5.2f, %5.2f, 0.0)",
d5efea33 191 GetX(),GetY(),GetZ(),GetErrX(),GetErrY())<<endl;
c34d2b8c 192
2e2d0c44 193 cout<<Form(" charge=%5.2f, chi2=%5.2f, MClabel=%d", GetCharge(), GetChi2(), GetLabel())<<endl;
c34d2b8c 194
195 if (PadsStored()) {
196 cout<<" pad infos:"<<endl;
fe0324de 197 for (Int_t iPad=0; iPad<GetNPads(); iPad++) cout<<" "<<GetPadId(iPad)<<endl;
c34d2b8c 198 }
d5efea33 199}
200