AliPhysics  8d00e07 (8d00e07)
AliEmcalParticle.cxx
Go to the documentation of this file.
1 //
2 // Emcal particle class, which can contain either an AliVTrack or an AliVCluster
3 //
4 // Author: S.Aiola
5 
6 #include "AliEmcalParticle.h"
7 #include "AliVCluster.h"
8 #include "AliLog.h"
9 
10 //_________________________________________________________________________________________________
12  AliVParticle(),
13  fTrack(0),
14  fCluster(0),
15  fNMatched(0),
16  fId(-1),
17  fPhi(0),
18  fEta(0),
19  fPt(0),
20  fM(0),
21  fMatchedPtr(0)
22 {
23  // Default constructor.
24 
26 }
27 
28 //_________________________________________________________________________________________________
30  AliVParticle(),
31  fTrack(track),
32  fCluster(0),
33  fNMatched(0),
34  fId(id),
35  fPhi(0),
36  fEta(0),
37  fPt(0),
38  fM(0),
39  fMatchedPtr(0)
40 {
41  // Constructor.
42 
43  if (!track) {
44  AliWarning("Null pointer passed as particle.");
45  return;
46  }
47 
48  fEta = fTrack->Eta();
49  fPhi = fTrack->Phi();
50  fPt = fTrack->Pt();
51  fM = fTrack->M();
52 
54 }
55 
56 //_________________________________________________________________________________________________
57 AliEmcalParticle::AliEmcalParticle(AliVCluster* cluster, Int_t id, Double_t vx, Double_t vy, Double_t vz, Int_t ude) :
58  AliVParticle(),
59  fTrack(0),
60  fCluster(cluster),
61  fNMatched(0),
62  fId(id),
63  fPhi(0),
64  fEta(0),
65  fPt(0),
66  fM(0),
67  fMatchedPtr(0)
68 {
69  // Constructor.
70 
71  if (!cluster) {
72  AliWarning("Null pointer passed as particle.");
73  return;
74  }
75 
76  Double_t vtx[3]; vtx[0]=vx;vtx[1]=vy;vtx[2]=vz;
77  TLorentzVector vect;
78  if (ude >= 0 && ude <= AliVCluster::kLastUserDefEnergy) {
79  fCluster->GetMomentum(vect, vtx, (AliVCluster::VCluUserDefEnergy_t)ude);
80  }
81  else {
82  fCluster->GetMomentum(vect, vtx);
83  }
84  fEta = vect.Eta();
85  fPhi = vect.Phi();
86  fPt = vect.Pt();
87  fM = 0.;
88 
90 }
91 
92 //_________________________________________________________________________________________________
94  AliVParticle(p),
95  fTrack(p.fTrack),
96  fCluster(p.fCluster),
98  fId(p.fId),
99  fPhi(p.fPhi),
100  fEta(p.fEta),
101  fPt(p.fPt),
102  fM(p.fM),
104 {
105  // Copy constructor.
106 
108 
109  memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
110  memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
111 }
112 
113 //_________________________________________________________________________________________________
115 {
116  // Destructor.
117 }
118 
119 //_________________________________________________________________________________________________
121 {
122  // Assignment operator.
123 
124  if (this != &p) {
125  fTrack = p.fTrack;
126  fCluster = p.fCluster;
127  fNMatched = p.fNMatched;
128  fId = p.fId;
129  fPhi = p.fPhi;
130  fEta = p.fEta;
131  fPt = p.fPt;
132  fM = p.fM;
134 
136  memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
137  memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
138  }
139 
140  return *this;
141 }
142 
143 //_________________________________________________________________________________________________
145 {
146  // Reset matched objects.
147 
148  for (Int_t i = 0; i < fSizeMatched; i++) {
149  fMatchedIds[i] = -1;
150  fMatchedDist[i] = 999;
151  }
152 }
153 
154 //_________________________________________________________________________________________________
156 {
157  // Add a matched object.
158 
159  Int_t i = 0;
160  while (i < fNMatched && d > fMatchedDist[i])
161  ++i;
162 
163  if (i < fNMatched) {
164  memmove(fMatchedIds + i + 1, fMatchedIds + i, sizeof(UShort_t) * (fNMatched - i));
165  memmove(fMatchedDist + i + 1, fMatchedDist + i, sizeof(Double_t) * (fNMatched - i));
166  }
167 
168  fMatchedIds[i] = id;
169  fMatchedDist[i] = d;
170  ++fNMatched;
171 
172  if (fNMatched >= fSizeMatched)
173  fNMatched = fSizeMatched - 1;
174 }
175 
176 //_________________________________________________________________________________________________
177 TLorentzVector &AliEmcalParticle::GetLorentzVector(const Double_t *vertex) const
178 {
179  // Make a TLorentzVector and return it.
180 
181  static TLorentzVector vect;
182 
183  if (fTrack) {
184  vect.SetPtEtaPhiM(fPt, fEta, fPhi, fM);
185  }
186  else if (fCluster && vertex) {
187  fCluster->GetMomentum(vect, const_cast<Double_t*>(vertex));
188  }
189 
190  return vect;
191 }
Int_t fId
number of matched objects
Double_t fMatchedDist[fSizeMatched]
ids of matched tracks/clusters, ordered from the closest to the farthest
static const UShort_t fSizeMatched
double Double_t
Definition: External.C:58
Double_t fPt
eta
TLorentzVector & GetLorentzVector(const Double_t *vertex=0) const
Double_t fPhi
id in original collection
AliVCluster * fCluster
track
Double_t fEta
phi
UShort_t fMatchedIds[fSizeMatched]
cluster
int Int_t
Definition: External.C:63
AliEmcalParticle & operator=(const AliEmcalParticle &p)
UShort_t fNMatched
distances of matched tracks/clusters
void AddMatchedObj(Int_t id, Double_t d)
unsigned short UShort_t
Definition: External.C:28
TObjArray * fMatchedPtr
M.
AliVTrack * fTrack
size of matched clusters array