1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliESDMuonCluster
21 /// Class to describe the MUON clusters in the Event Summary Data
23 /// \author Philippe Pillot, Subatech
24 //-----------------------------------------------------------------------------
26 #include "AliESDEvent.h"
27 #include "AliESDMuonCluster.h"
28 #include "AliESDMuonPad.h"
32 #include <TClonesArray.h>
33 #include <Riostream.h>
36 ClassImp(AliESDMuonCluster)
39 //_____________________________________________________________________________
40 AliESDMuonCluster::AliESDMuonCluster()
49 /// default constructor
50 fXYZ[0] = fXYZ[1] = fXYZ[2] = 0.;
51 fErrXY[0] = fErrXY[1] = 0.;
54 //_____________________________________________________________________________
55 AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
57 fCharge(cluster.fCharge),
60 fNPads(cluster.fNPads),
62 fLabel(cluster.fLabel)
65 fXYZ[0] = cluster.fXYZ[0];
66 fXYZ[1] = cluster.fXYZ[1];
67 fXYZ[2] = cluster.fXYZ[2];
68 fErrXY[0] = cluster.fErrXY[0];
69 fErrXY[1] = cluster.fErrXY[1];
72 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
73 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
75 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
76 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
80 if (cluster.fPadsId) fPadsId = new TArrayI(*(cluster.fPadsId));
83 //_____________________________________________________________________________
84 AliESDMuonCluster& AliESDMuonCluster::operator=(const AliESDMuonCluster& cluster)
87 if (this == &cluster) return *this;
89 TObject::operator=(cluster); // don't forget to invoke the base class' assignment operator
91 fXYZ[0] = cluster.fXYZ[0];
92 fXYZ[1] = cluster.fXYZ[1];
93 fXYZ[2] = cluster.fXYZ[2];
94 fErrXY[0] = cluster.fErrXY[0];
95 fErrXY[1] = cluster.fErrXY[1];
97 fCharge = cluster.fCharge;
98 fChi2 = cluster.fChi2;
99 fLabel = cluster.fLabel;
103 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
104 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
106 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
107 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
111 SetPadsId(cluster.fNPads, cluster.GetPadsId());
116 //__________________________________________________________________________
117 AliESDMuonCluster::~AliESDMuonCluster()
124 //__________________________________________________________________________
125 void AliESDMuonCluster::Clear(Option_t* opt)
128 if (opt && opt[0] == 'C') {
129 if (fPads) fPads->Clear("C");
131 delete fPads; fPads = 0x0;
133 delete fPadsId; fPadsId = 0x0;
137 //_____________________________________________________________________________
138 void AliESDMuonCluster::AddPadId(UInt_t padId)
140 /// Add the given pad Id to the list associated to the cluster
141 if (!fPadsId) fPadsId = new TArrayI(10);
142 if (fPadsId->GetSize() <= fNPads) fPadsId->Set(fNPads+10);
143 fPadsId->AddAt(static_cast<Int_t>(padId), fNPads++);
146 //_____________________________________________________________________________
147 void AliESDMuonCluster::SetPadsId(Int_t nPads, const UInt_t *padsId)
149 /// Fill the list pads'Id associated to the cluster with the given list
151 if (nPads <= 0 || !padsId) {
158 if (!fPadsId) fPadsId = new TArrayI(nPads, reinterpret_cast<const Int_t*>(padsId));
159 else fPadsId->Set(nPads, reinterpret_cast<const Int_t*>(padsId));
164 //_____________________________________________________________________________
165 void AliESDMuonCluster::MovePadsToESD(AliESDEvent &esd)
167 /// move the pads to the new ESD structure
169 for (Int_t i = 0; i < fPads->GetEntriesFast(); i++) {
170 AliESDMuonPad *pad = static_cast<AliESDMuonPad*>(fPads->UncheckedAt(i));
171 AliESDMuonPad *newPad = esd.NewMuonPad();
173 AddPadId(newPad->GetUniqueID());
179 //_____________________________________________________________________________
180 void AliESDMuonCluster::Print(Option_t */*option*/) const
182 /// print cluster content
183 UInt_t cId = GetUniqueID();
185 cout<<Form("clusterID=%u (ch=%d, det=%d, index=%d)",
186 cId,GetChamberId(),GetDetElemId(),GetClusterIndex())<<endl;
188 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%5.2f, %5.2f, 0.0)",
189 GetX(),GetY(),GetZ(),GetErrX(),GetErrY())<<endl;
191 cout<<Form(" charge=%5.2f, chi2=%5.2f, MClabel=%d", GetCharge(), GetChi2(), GetLabel())<<endl;
194 cout<<" pad infos:"<<endl;
195 for (Int_t iPad=0; iPad<GetNPads(); iPad++) cout<<" "<<GetPadId(iPad)<<endl;