AliRoot Core  edcc906 (edcc906)
AliESDMuonCluster.cxx
Go to the documentation of this file.
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 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
25 
26 #include "AliESDEvent.h"
27 #include "AliESDMuonCluster.h"
28 #include "AliESDMuonPad.h"
29 
30 #include "AliLog.h"
31 
32 #include <TClonesArray.h>
33 #include <Riostream.h>
34 
35 using std::endl;
36 using std::cout;
38 ClassImp(AliESDMuonCluster)
40 
41 //_____________________________________________________________________________
43 : TObject(),
44  fCharge(0.),
45  fChi2(0.),
46  fPads(0x0),
47  fNPads(0),
48  fPadsId(0x0),
49  fLabel(-1)
50 {
52  fXYZ[0] = fXYZ[1] = fXYZ[2] = 0.;
53  fErrXY[0] = fErrXY[1] = 0.;
54 }
55 
56 //_____________________________________________________________________________
58 : TObject(cluster),
59  fCharge(cluster.fCharge),
60  fChi2(cluster.fChi2),
61  fPads(0x0),
62  fNPads(cluster.fNPads),
63  fPadsId(0x0),
64  fLabel(cluster.fLabel)
65 {
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];
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  }
81 
82  if (cluster.fPadsId) fPadsId = new TArrayI(*(cluster.fPadsId));
83 }
84 
85 //_____________________________________________________________________________
87 {
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 
99  fCharge = cluster.fCharge;
100  fChi2 = cluster.fChi2;
101  fLabel = cluster.fLabel;
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 
113  SetPadsId(cluster.fNPads, cluster.GetPadsId());
114 
115  return *this;
116 }
117 
118 //_____________________________________________________________________________
119 void AliESDMuonCluster::Copy(TObject &obj) const {
120 
124 
125  if(this==&obj)return;
126  AliESDMuonCluster *robj = dynamic_cast<AliESDMuonCluster*>(&obj);
127  if(!robj)return; // not an AliESDMuonCluster
128  *robj = *this;
129 
130 }
131 
132 //__________________________________________________________________________
134 {
136  delete fPads;
137  delete fPadsId;
138 }
139 
140 //__________________________________________________________________________
141 void AliESDMuonCluster::Clear(Option_t* opt)
142 {
144  if (opt && opt[0] == 'C') {
145  if (fPads) fPads->Clear("C");
146  } else {
147  delete fPads; fPads = 0x0;
148  }
149  delete fPadsId; fPadsId = 0x0;
150  fNPads = 0;
151 }
152 
153 //_____________________________________________________________________________
154 void AliESDMuonCluster::AddPadId(UInt_t padId)
155 {
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++);
160 }
161 
162 //_____________________________________________________________________________
163 void AliESDMuonCluster::SetPadsId(Int_t nPads, const UInt_t *padsId)
164 {
166 
167  if (nPads <= 0 || !padsId) {
168  delete fPadsId;
169  fPadsId = 0x0;
170  fNPads = 0;
171  return;
172  }
173 
174  if (!fPadsId) fPadsId = new TArrayI(nPads, reinterpret_cast<const Int_t*>(padsId));
175  else fPadsId->Set(nPads, reinterpret_cast<const Int_t*>(padsId));
176  fNPads = nPads;
177 
178 }
179 
180 //_____________________________________________________________________________
182 {
184  if (!fPads) return;
185  for (Int_t i = 0; i < fPads->GetEntriesFast(); i++) {
186  AliESDMuonPad *pad = static_cast<AliESDMuonPad*>(fPads->UncheckedAt(i));
187  AliESDMuonPad *newPad = esd.NewMuonPad();
188  *newPad = *pad;
189  AddPadId(newPad->GetUniqueID());
190  }
191  delete fPads;
192  fPads = 0x0;
193 }
194 
195 //_____________________________________________________________________________
196 void AliESDMuonCluster::Print(Option_t */*option*/) const
197 {
199  UInt_t cId = GetUniqueID();
200 
201  cout<<Form("clusterID=%u (ch=%d, det=%d, index=%d)",
202  cId,GetChamberId(),GetDetElemId(),GetClusterIndex())<<endl;
203 
204  cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%5.2f, %5.2f, 0.0)",
205  GetX(),GetY(),GetZ(),GetErrX(),GetErrY())<<endl;
206 
207  cout<<Form(" charge=%5.2f, chi2=%5.2f, MClabel=%d", GetCharge(), GetChi2(), GetLabel())<<endl;
208 
209  if (PadsStored()) {
210  cout<<" pad infos:"<<endl;
211  for (Int_t iPad=0; iPad<GetNPads(); iPad++) cout<<" "<<GetPadId(iPad)<<endl;
212  }
213 }
214 
Class to describe the MUON pads in the Event Summary Data.
Definition: AliESDMuonPad.h:16
Double32_t fCharge
cluster charge
TClonesArray * fPads
Array of pads attached to the cluster – deprecated.
Double32_t fErrXY[2]
transverse position errors
void SetPadsId(Int_t nPads, const UInt_t *padsId)
Int_t fNPads
number of pads attached to the cluster
Double_t GetY() const
Return Y-position (cm)
Double32_t fChi2
cluster chi2
UInt_t GetPadId(Int_t i) const
Return the Id of pad i.
Double_t GetChi2() const
Return the chi2 value.
TArrayI * fPadsId
array of Ids of pads attached to the cluster
Int_t GetChamberId() const
Return chamber id (0..), part of the uniqueID.
Bool_t PadsStored() const
Return kTrue if the pads&#39;Id are stored.
Class to describe the MUON clusters in the Event Summary Data.
Int_t GetClusterIndex() const
Return the index of this cluster (0..), part of the uniqueID.
Double32_t fXYZ[3]
cluster position
virtual void Clear(Option_t *opt="")
Double_t GetZ() const
Return Z-position (cm)
Int_t GetNPads() const
Return the number of pads associated to this cluster.
Double_t GetCharge() const
Return the total charge.
Double_t GetErrX() const
Return X-resolution (cm)
void Print(Option_t *="") const
Int_t GetLabel() const
Return the corresponding MC track number.
void MovePadsToESD(AliESDEvent &esd)
Int_t GetDetElemId() const
Return detection element id, part of the uniqueID.
void AddPadId(UInt_t padId)
AliESDMuonPad * NewMuonPad()
Double_t GetX() const
Return X-position (cm)
Double_t GetErrY() const
Return Y-resolution (cm)
Int_t fLabel
point to the corresponding MC track
AliESDMuonCluster & operator=(const AliESDMuonCluster &cluster)
virtual void Copy(TObject &obj) const
const UInt_t * GetPadsId() const
Return the array of pads&#39;Id.