2 // Emcal particle class, which can contain either an AliVTrack or an AliVCluster
6 #include "AliEmcalParticle.h"
7 #include "AliVCluster.h"
10 //_________________________________________________________________________________________________
11 AliEmcalParticle::AliEmcalParticle() :
23 // Default constructor.
25 ResetMatchedObjects();
28 //_________________________________________________________________________________________________
29 AliEmcalParticle::AliEmcalParticle(TObject *particle, Int_t id, Double_t vx, Double_t vy, Double_t vz) :
44 AliWarning("Null pointer passed as particle.");
48 fTrack = dynamic_cast<AliVTrack*>(particle);
55 fCluster = dynamic_cast<AliVCluster*>(particle);
57 Double_t vtx[3]; vtx[0]=vx;vtx[1]=vy;vtx[2]=vz;
59 fCluster->GetMomentum(vect, vtx);
67 if (!fTrack && !fCluster) {
68 AliWarning("Particle type not recognized (not AliVTrack nor AliVCluster).");
72 ResetMatchedObjects();
75 //_________________________________________________________________________________________________
76 AliEmcalParticle::AliEmcalParticle(const AliEmcalParticle &p) :
80 fNMatched(p.fNMatched),
86 fMatchedPtr(p.fMatchedPtr)
90 ResetMatchedObjects();
92 memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
93 memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
96 //_________________________________________________________________________________________________
97 AliEmcalParticle::~AliEmcalParticle()
102 //_________________________________________________________________________________________________
103 AliEmcalParticle &AliEmcalParticle::operator=(const AliEmcalParticle &p)
105 // Assignment operator.
109 fCluster = p.fCluster;
110 fNMatched = p.fNMatched;
116 fMatchedPtr = p.fMatchedPtr;
118 ResetMatchedObjects();
119 memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
120 memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
126 //_________________________________________________________________________________________________
127 void AliEmcalParticle::ResetMatchedObjects()
129 // Reset matched objects.
131 for (Int_t i = 0; i < fSizeMatched; i++) {
133 fMatchedDist[i] = 999;
137 //_________________________________________________________________________________________________
138 void AliEmcalParticle::AddMatchedObj(Int_t id, Double_t d)
140 // Add a matched object.
143 while (i < fNMatched && d > fMatchedDist[i])
147 memmove(fMatchedIds + i + 1, fMatchedIds + i, sizeof(UShort_t) * (fNMatched - i));
148 memmove(fMatchedDist + i + 1, fMatchedDist + i, sizeof(Double_t) * (fNMatched - i));
155 if (fNMatched >= fSizeMatched)
156 fNMatched = fSizeMatched - 1;
159 //_________________________________________________________________________________________________
160 TLorentzVector &AliEmcalParticle::GetLorentzVector(const Double_t *vertex) const
162 // Make a TLorentzVector and return it.
164 static TLorentzVector vect;
167 vect.SetPtEtaPhiM(fPt, fEta, fPhi, fM);
169 else if (fCluster && vertex) {
170 fCluster->GetMomentum(vect, const_cast<Double_t*>(vertex));