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() :
23 // Default constructor.
25 ResetMatchedObjects();
28 //_________________________________________________________________________________________________
29 AliEmcalParticle::AliEmcalParticle(TObject *particle, Int_t id, Double_t vx, Double_t vy, Double_t vz) :
43 AliWarning("Null pointer passed as particle.");
47 fTrack = dynamic_cast<AliVTrack*>(particle);
53 fCluster = dynamic_cast<AliVCluster*>(particle);
55 Double_t vtx[3]; vtx[0]=vx;vtx[1]=vy;vtx[2]=vz;
57 fCluster->GetMomentum(vect, vtx);
64 if (!fTrack && !fCluster) {
65 AliWarning("Particle type not recognized (not AliVTrack nor AliVCluster).");
69 ResetMatchedObjects();
72 //_________________________________________________________________________________________________
73 AliEmcalParticle::AliEmcalParticle(const AliEmcalParticle &p) :
77 fNMatched(p.fNMatched),
82 fMatchedPtr(p.fMatchedPtr)
86 ResetMatchedObjects();
88 memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
89 memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
92 //_________________________________________________________________________________________________
93 AliEmcalParticle::~AliEmcalParticle()
98 //_________________________________________________________________________________________________
99 AliEmcalParticle &AliEmcalParticle::operator=(const AliEmcalParticle &p)
101 // Assignment operator.
105 fCluster = p.fCluster;
106 fNMatched = p.fNMatched;
111 fMatchedPtr = p.fMatchedPtr;
113 ResetMatchedObjects();
114 memcpy(fMatchedIds, p.fMatchedIds, sizeof(UShort_t) * fSizeMatched);
115 memcpy(fMatchedDist, p.fMatchedDist, sizeof(Double_t) * fSizeMatched);
121 //_________________________________________________________________________________________________
122 void AliEmcalParticle::ResetMatchedObjects()
124 // Reset matched objects.
126 for (Int_t i = 0; i < fSizeMatched; i++) {
128 fMatchedDist[i] = 999;
132 //_________________________________________________________________________________________________
133 void AliEmcalParticle::AddMatchedObj(Int_t id, Double_t d)
135 // Add a matched object.
138 while (i < fNMatched && d > fMatchedDist[i])
142 memmove(fMatchedIds + i + 1, fMatchedIds + i, sizeof(UShort_t) * (fNMatched - i));
143 memmove(fMatchedDist + i + 1, fMatchedDist + i, sizeof(Double_t) * (fNMatched - i));
150 if (fNMatched >= fSizeMatched)
151 fNMatched = fSizeMatched - 1;
154 //_________________________________________________________________________________________________
155 TLorentzVector &AliEmcalParticle::GetLorentzVector(const Double_t *vertex) const
157 // Make a TLorentzVector and return it.
159 static TLorentzVector vect;
162 vect.SetPtEtaPhiM(fTrack->Pt(), fTrack->Eta(), fTrack->Phi(), M());
164 else if (fCluster && vertex) {
165 fCluster->GetMomentum(vect, const_cast<Double_t*>(vertex));