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>
38 ClassImp(AliESDMuonCluster)
41 //_____________________________________________________________________________
42 AliESDMuonCluster::AliESDMuonCluster()
51 /// default constructor
52 fXYZ[0] = fXYZ[1] = fXYZ[2] = 0.;
53 fErrXY[0] = fErrXY[1] = 0.;
56 //_____________________________________________________________________________
57 AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
59 fCharge(cluster.fCharge),
62 fNPads(cluster.fNPads),
64 fLabel(cluster.fLabel)
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];
74 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
75 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
77 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
78 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
82 if (cluster.fPadsId) fPadsId = new TArrayI(*(cluster.fPadsId));
85 //_____________________________________________________________________________
86 AliESDMuonCluster& AliESDMuonCluster::operator=(const AliESDMuonCluster& cluster)
89 if (this == &cluster) return *this;
91 TObject::operator=(cluster); // don't forget to invoke the base class' assignment operator
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];
99 fCharge = cluster.fCharge;
100 fChi2 = cluster.fChi2;
101 fLabel = cluster.fLabel;
105 fPads = new TClonesArray("AliESDMuonPad",cluster.fPads->GetEntriesFast());
106 AliESDMuonPad *pad = (AliESDMuonPad*) cluster.fPads->First();
108 new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(*pad);
109 pad = (AliESDMuonPad*) cluster.fPads->After(pad);
113 SetPadsId(cluster.fNPads, cluster.GetPadsId());
118 //_____________________________________________________________________________
119 void AliESDMuonCluster::Copy(TObject &obj) const {
121 /// This overwrites the virtual TOBject::Copy()
122 /// to allow run time copying without casting
125 if(this==&obj)return;
126 AliESDMuonCluster *robj = dynamic_cast<AliESDMuonCluster*>(&obj);
127 if(!robj)return; // not an AliESDMuonCluster
132 //__________________________________________________________________________
133 AliESDMuonCluster::~AliESDMuonCluster()
140 //__________________________________________________________________________
141 void AliESDMuonCluster::Clear(Option_t* opt)
144 if (opt && opt[0] == 'C') {
145 if (fPads) fPads->Clear("C");
147 delete fPads; fPads = 0x0;
149 delete fPadsId; fPadsId = 0x0;
153 //_____________________________________________________________________________
154 void AliESDMuonCluster::AddPadId(UInt_t padId)
156 /// Add the given pad Id to the list associated to the cluster
157 if (!fPadsId) fPadsId = new TArrayI(10);
158 if (fPadsId->GetSize() <= fNPads) fPadsId->Set(fNPads+10);
159 fPadsId->AddAt(static_cast<Int_t>(padId), fNPads++);
162 //_____________________________________________________________________________
163 void AliESDMuonCluster::SetPadsId(Int_t nPads, const UInt_t *padsId)
165 /// Fill the list pads'Id associated to the cluster with the given list
167 if (nPads <= 0 || !padsId) {
174 if (!fPadsId) fPadsId = new TArrayI(nPads, reinterpret_cast<const Int_t*>(padsId));
175 else fPadsId->Set(nPads, reinterpret_cast<const Int_t*>(padsId));
180 //_____________________________________________________________________________
181 void AliESDMuonCluster::MovePadsToESD(AliESDEvent &esd)
183 /// move the pads to the new ESD structure
185 for (Int_t i = 0; i < fPads->GetEntriesFast(); i++) {
186 AliESDMuonPad *pad = static_cast<AliESDMuonPad*>(fPads->UncheckedAt(i));
187 AliESDMuonPad *newPad = esd.NewMuonPad();
189 AddPadId(newPad->GetUniqueID());
195 //_____________________________________________________________________________
196 void AliESDMuonCluster::Print(Option_t */*option*/) const
198 /// print cluster content
199 UInt_t cId = GetUniqueID();
201 cout<<Form("clusterID=%u (ch=%d, det=%d, index=%d)",
202 cId,GetChamberId(),GetDetElemId(),GetClusterIndex())<<endl;
204 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%5.2f, %5.2f, 0.0)",
205 GetX(),GetY(),GetZ(),GetErrX(),GetErrY())<<endl;
207 cout<<Form(" charge=%5.2f, chi2=%5.2f, MClabel=%d", GetCharge(), GetChi2(), GetLabel())<<endl;
210 cout<<" pad infos:"<<endl;
211 for (Int_t iPad=0; iPad<GetNPads(); iPad++) cout<<" "<<GetPadId(iPad)<<endl;