AliPhysics  vAN-20150723 (baea2bf)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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 //_________________________________________________________________________________________________
29 AliEmcalParticle::AliEmcalParticle(AliVTrack* track, Int_t id) :
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) :
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  fCluster->GetMomentum(vect, vtx);
79  fEta = vect.Eta();
80  fPhi = vect.Phi();
81  fPt = vect.Pt();
82  fM = 0.;
83 
85 }
86 
87 //_________________________________________________________________________________________________
89  AliVParticle(p),
90  fTrack(p.fTrack),
91  fCluster(p.fCluster),
92  fNMatched(p.fNMatched),
93  fId(p.fId),
94  fPhi(p.fPhi),
95  fEta(p.fEta),
96  fPt(p.fPt),
97  fM(p.fM),
98  fMatchedPtr(p.fMatchedPtr)
99 {
100  // Copy constructor.
101 
103 
104  memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
105  memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
106 }
107 
108 //_________________________________________________________________________________________________
110 {
111  // Destructor.
112 }
113 
114 //_________________________________________________________________________________________________
116 {
117  // Assignment operator.
118 
119  if (this != &p) {
120  fTrack = p.fTrack;
121  fCluster = p.fCluster;
122  fNMatched = p.fNMatched;
123  fId = p.fId;
124  fPhi = p.fPhi;
125  fEta = p.fEta;
126  fPt = p.fPt;
127  fM = p.fM;
129 
131  memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
132  memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
133  }
134 
135  return *this;
136 }
137 
138 //_________________________________________________________________________________________________
140 {
141  // Reset matched objects.
142 
143  for (Int_t i = 0; i < fSizeMatched; i++) {
144  fMatchedIds[i] = -1;
145  fMatchedDist[i] = 999;
146  }
147 }
148 
149 //_________________________________________________________________________________________________
150 void AliEmcalParticle::AddMatchedObj(Int_t id, Double_t d)
151 {
152  // Add a matched object.
153 
154  Int_t i = 0;
155  while (i < fNMatched && d > fMatchedDist[i])
156  ++i;
157 
158  if (i < fNMatched) {
159  memmove(fMatchedIds + i + 1, fMatchedIds + i, sizeof(UShort_t) * (fNMatched - i));
160  memmove(fMatchedDist + i + 1, fMatchedDist + i, sizeof(Double_t) * (fNMatched - i));
161  }
162 
163  fMatchedIds[i] = id;
164  fMatchedDist[i] = d;
165  ++fNMatched;
166 
167  if (fNMatched >= fSizeMatched)
168  fNMatched = fSizeMatched - 1;
169 }
170 
171 //_________________________________________________________________________________________________
172 TLorentzVector &AliEmcalParticle::GetLorentzVector(const Double_t *vertex) const
173 {
174  // Make a TLorentzVector and return it.
175 
176  static TLorentzVector vect;
177 
178  if (fTrack) {
179  vect.SetPtEtaPhiM(fPt, fEta, fPhi, fM);
180  }
181  else if (fCluster && vertex) {
182  fCluster->GetMomentum(vect, const_cast<Double_t*>(vertex));
183  }
184 
185  return vect;
186 }
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_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
AliEmcalParticle & operator=(const AliEmcalParticle &p)
UShort_t fNMatched
distances of matched tracks/clusters
void AddMatchedObj(Int_t id, Double_t d)
TObjArray * fMatchedPtr
M.
AliVTrack * fTrack
size of matched clusters array