3 // Emcal particle class, which can contain either an AliVTrack or an AliVCluster
7 #include "AliEmcalParticle.h"
8 #include "AliVCluster.h"
11 //_________________________________________________________________________________________________
12 AliEmcalParticle::AliEmcalParticle() :
22 // Default constructor.
24 ResetMatchedObjects();
27 //_________________________________________________________________________________________________
28 AliEmcalParticle::AliEmcalParticle(TObject *particle, Int_t id, Double_t vx, Double_t vy, Double_t vz) :
41 AliWarning("Null pointer passed as particle.");
45 fTrack = dynamic_cast<AliVTrack*>(particle);
51 fCluster = dynamic_cast<AliVCluster*>(particle);
53 Double_t vtx[3]; vtx[0]=vx;vtx[1]=vy;vtx[2]=vz;
55 fCluster->GetMomentum(vect, vtx);
62 if (!fTrack && !fCluster) {
63 AliWarning("Particle type not recognized (not AliVTrack nor AliVCluster).");
67 ResetMatchedObjects();
70 //_________________________________________________________________________________________________
71 AliEmcalParticle::AliEmcalParticle(const AliEmcalParticle &p) :
75 fNMatched(p.fNMatched),
83 ResetMatchedObjects();
85 memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
86 memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
89 //_________________________________________________________________________________________________
90 AliEmcalParticle::~AliEmcalParticle()
95 //_________________________________________________________________________________________________
96 AliEmcalParticle &AliEmcalParticle::operator=(const AliEmcalParticle &p)
98 // Assignment operator.
102 fCluster = p.fCluster;
103 fNMatched = p.fNMatched;
109 ResetMatchedObjects();
110 memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
111 memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
117 //_________________________________________________________________________________________________
118 void AliEmcalParticle::ResetMatchedObjects()
120 // Reset matched objects.
122 for (Int_t i = 0; i < fSizeMatched; i++) {
124 fMatchedDist[i] = 999;
128 //_________________________________________________________________________________________________
129 void AliEmcalParticle::AddMatchedObj(Int_t id, Double_t d)
131 // Add a matched object.
134 while (i < fNMatched && d > fMatchedDist[i])
138 memmove(fMatchedIds + i + 1, fMatchedIds + i, sizeof(UShort_t) * (fNMatched - i));
139 memmove(fMatchedDist + i + 1, fMatchedDist + i, sizeof(Double_t) * (fNMatched - i));
146 if (fNMatched >= fSizeMatched)
147 fNMatched = fSizeMatched - 1;
150 //_________________________________________________________________________________________________
151 TLorentzVector &AliEmcalParticle::GetLorentzVector(const Double_t *vertex) const
153 // Make a TLorentzVector and return it.
155 static TLorentzVector vect;
158 vect.SetPtEtaPhiM(fTrack->Pt(), fTrack->Eta(), fTrack->Phi(), M());
160 else if (fCluster && vertex) {
161 fCluster->GetMomentum(vect, const_cast<Double_t*>(vertex));