3 //___________________________________________________________
4 /////////////////////////////////////////////////////////////
6 // class AliJetParticle
8 // loizides@ikf.uni-frankfurt.de
10 /////////////////////////////////////////////////////////////
12 #include <Riostream.h>
14 #include <TParticle.h>
15 #include "AliJetParticle.h"
17 ClassImp(AliJetParticle)
19 AliJetParticle::AliJetParticle() :
25 AliJetParticle::AliJetParticle(const AliJetParticle& in) :
28 SetMomentum(in.fPx,in.fPy,in.fPz,in.fE);
29 fIdxInEvent=in.fIdxInEvent;
33 AliJetParticle::AliJetParticle(const TParticle* p, Int_t idx, Int_t l) :
36 SetMomentum(p->Px(),p->Py(),p->Pz(),p->Energy());
41 AliJetParticle::AliJetParticle(Float_t px, Float_t py, Float_t pz,
42 Float_t etot, Int_t idx, Int_t l) :
45 SetMomentum(px,py,pz,etot);
50 AliJetParticle::AliJetParticle(Float_t px, Float_t py, Float_t pz,
51 Float_t etot, Int_t idx, Int_t l,
52 Float_t pt, Float_t phi, Float_t eta) :
54 fPx(px),fPy(py),fPz(pz),
55 fE(etot),fIdxInEvent(idx),fLabel(l),
56 fPt(pt),fEta(eta),fPhi(phi)
61 void AliJetParticle::Calculate()
63 //calculate values from px, py, pz
64 //which are frequently needed
66 fPt=TMath::Sqrt(fPx*fPx+fPy*fPy);
68 fEta=0.5*TMath::Log((kp+fPz+1e-30)/(kp-fPz+1e-30));
69 fPhi=TMath::Pi()+TMath::ATan2(-fPy,-fPx);
72 void AliJetParticle::Clear(Option_t* /*t*/)
85 void AliJetParticle::Print(Option_t* /*t*/) const
87 cout << fPt << " " << fEta << " " << fPhi << endl;
93 Int_t AliHBTParticle::fgDebug = 0;
94 //______________________________________________________________________________
95 AliHBTParticle::AliHBTParticle():
96 fPdgIdx(0), fIdxInEvent(0),fNPids(0),fPids(0x0),fPidProb(0x0),
97 fCalcMass(0),fPx(0), fPy(0),fPz(0),fE(0), fVx(0), fVy(0),fVz(0),fVt(0),
98 fTrackPoints(0x0),fClusterMap(0x0)
101 //______________________________________________________________________________
103 AliHBTParticle::AliHBTParticle(Int_t pdg, Int_t idx,
104 Double_t px, Double_t py, Double_t pz, Double_t etot,
105 Double_t vx, Double_t vy, Double_t vz, Double_t time):
106 fPdgIdx(0), fIdxInEvent(idx),fNPids(0),fPids(0x0),fPidProb(0x0),
108 fPx(px), fPy(py),fPz(pz),fE(etot),
109 fVx(vx), fVy(vy),fVz(vz),fVt(time),
110 fTrackPoints(0x0),fClusterMap(0x0)
115 fCalcMass = GetPDG()->Mass();
117 Double_t a2 = fE*fE -fPx*fPx -fPy*fPy -fPz*fPz;
118 if (a2 >= 0) fCalcMass = TMath::Sqrt(a2);
119 else fCalcMass = -TMath::Sqrt(-a2);
122 //______________________________________________________________________________
124 AliHBTParticle::AliHBTParticle(Int_t pdg, Float_t prob, Int_t idx,
125 Double_t px, Double_t py, Double_t pz, Double_t etot,
126 Double_t vx, Double_t vy, Double_t vz, Double_t time):
127 fPdgIdx(0), fIdxInEvent(idx),fNPids(0),fPids(0x0),fPidProb(0x0),
129 fPx(px), fPy(py),fPz(pz),fE(etot),
130 fVx(vx), fVy(vy),fVz(vz),fVt(time),
131 fTrackPoints(0x0),fClusterMap(0x0)
134 SetPdgCode(pdg,prob);
136 fCalcMass = GetPDG()->Mass();
138 Double_t a2 = fE*fE -fPx*fPx -fPy*fPy -fPz*fPz;
139 if (a2 >= 0) fCalcMass = TMath::Sqrt(a2);
140 else fCalcMass = -TMath::Sqrt(-a2);
143 //______________________________________________________________________________
144 AliHBTParticle::AliHBTParticle(const AliHBTParticle& in):
146 fPdgIdx(in.fPdgIdx), fIdxInEvent(in.fIdxInEvent),
147 fNPids(in.fNPids),fPids(new Int_t[fNPids]),fPidProb(new Float_t[fNPids]),
148 fCalcMass(in.GetCalcMass()),
149 fPx(in.Px()),fPy(in.Py()),fPz(in.Pz()),fE(in.Energy()),
150 fVx(in.Vx()),fVy(in.Vy()),fVz(in.Vz()),fVt(in.T()),
151 fTrackPoints(0x0), fClusterMap(0x0)
154 for(Int_t i = 0; i<fNPids; i++)
156 fPids[i] = in.fPids[i];
157 fPidProb[i] = in.fPidProb[i];
161 fTrackPoints = (AliHBTTrackPoints*)in.fTrackPoints->Clone();
163 fClusterMap = (AliHBTClusterMap*)in.fClusterMap->Clone();
166 //______________________________________________________________________________
167 AliHBTParticle::AliHBTParticle(const TParticle &p,Int_t idx):
168 fPdgIdx(0), fIdxInEvent(idx),
169 fNPids(0),fPids(0x0),fPidProb(0x0),
170 fCalcMass(p.GetCalcMass()),
171 fPx(p.Px()),fPy(p.Py()),fPz(p.Pz()),fE(p.Energy()),
172 fVx(p.Vx()),fVy(p.Vy()),fVz(p.Vz()),fVt(p.T()),
173 fTrackPoints(0x0),fClusterMap(0x0)
175 //all copied in the initialization
176 SetPdgCode(p.GetPdgCode());
178 //______________________________________________________________________________
180 AliHBTParticle::~AliHBTParticle()
188 //______________________________________________________________________________
190 AliHBTParticle& AliHBTParticle::operator=(const AliHBTParticle& in)
197 Int_t* fPids = new Int_t[fNPids];
198 Float_t* fPidProb = new Float_t[fNPids];
199 for (Int_t i = 0; i < fNPids;i++)
201 fPids[i] = in.fPids[i];
202 fPidProb[i] = in.fPidProb[i];
205 fPdgIdx = in.fPdgIdx;
206 fIdxInEvent = in.fIdxInEvent;
207 fCalcMass = in.GetCalcMass();
218 fTrackPoints = (in.fTrackPoints)?(AliHBTTrackPoints*)fTrackPoints->Clone():0x0;
221 fClusterMap = (in.fClusterMap)?(AliHBTClusterMap*)in.fClusterMap->Clone():0x0;
225 //______________________________________________________________________________
227 void AliHBTParticle::SetPdgCode(Int_t pdg,Float_t prob)
229 SetPIDprobability(pdg,prob);
230 fPdgIdx = GetPidSlot(pdg);
233 //______________________________________________________________________________
234 void AliHBTParticle::SetPIDprobability(Int_t pdg, Float_t prob)
236 //Sets another pdg code and corresponding probabilty
237 //Ids are set in decreasing order
238 //Check if total prbaility is not ivercoming unity is performed
239 //in case, warning is printed
240 if (fgDebug > 9) Info("SetPIDprobability","Setting PID %d prob %f",pdg,prob);
242 Float_t totprob = 0.0;//sums up probabilities
243 Int_t idx = GetPidSlot(pdg);
247 fPidProb[idx] = prob;
248 for (i = 0; i < fNPids;i++) totprob+=fPidProb[i];
249 if (totprob > (1.0+0.000001))
251 Warning("SetPIDprobability","Total probability greater than unity (%f)",totprob);
255 Info("SetPIDprobability","Current Total probability: %f",totprob);
260 Int_t currentpid = GetPdgCode();
262 Float_t* aPidProbNew = new Float_t[fNPids];
263 Int_t* aPidsNew = new Int_t[fNPids];
265 for (i = 0; i < fNPids-1;i++)//find a slot
267 if ( fPidProb[i] > prob)
269 if (fgDebug>9) Info("SetPID","Copying entry %d",i);
270 aPidProbNew[i] = fPidProb[i];
271 aPidsNew[i] = fPids[i];
272 totprob+=fPidProb[i];
277 if (fgDebug > 9) Info("SetPID","Setting new PID on entry %d",i);
278 aPidProbNew[i] = prob;
283 for (Int_t j = fNPids-1; j > i ;j--)//copy rest of old araays
285 if (fgDebug > 9) Info("SetPID","Copying from old entry %d to new entry %d",j-1,j);
286 aPidProbNew[j] = fPidProb[j-1];
287 aPidsNew[j] = fPids[j-1];
288 totprob+=fPidProb[j-1];
294 fPidProb = aPidProbNew;
297 fPdgIdx = GetPidSlot(currentpid);
298 if (fPdgIdx == -1) fPdgIdx = 0;
300 if (totprob > (1.0+0.000001))//place for numerical error
302 Warning("SetId","Total probability is greater than unity (%f)!!!",totprob);
306 //______________________________________________________________________________
308 Float_t AliHBTParticle::GetPIDprobability(Int_t pdg) const
310 //Returns probability that this particle is the type of pdg
311 Int_t idx = GetPidSlot(pdg);
312 if (idx < 0) return 0.0;//such pid was not specified for this particle
313 return fPidProb[idx];
315 //______________________________________________________________________________
317 const Char_t* AliHBTParticle::GetName() const
319 //returns name of this particle
320 static char def[4] = "XXX";
321 const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(GetPdgCode());
322 if (ap) return ap->GetName();
325 //______________________________________________________________________________
327 Int_t AliHBTParticle::GetPidSlot(Int_t pdg) const
329 //returns position of the given PID in fPids (and fPidProb) array.
330 if (fPids == 0x0) return -1;
331 for (Int_t i = 0; i< fNPids; i++)
333 if (fPids[i] == pdg) return i;
337 //______________________________________________________________________________
339 Int_t AliHBTParticle::GetNthPid(Int_t idx) const
341 //returns PID sitting on slot idx in fPids
342 if ( (idx < 0) || (idx >= fNPids) )
344 Error("GetNthPid","Out Of Bounds");
349 //______________________________________________________________________________
351 Float_t AliHBTParticle::GetNthPidProb(Int_t idx) const
353 //returns PID sitting on slot idx in fPidProb
354 if ( (idx < 0) || (idx >= fNPids) )
356 Error("GetNthPid","Out Of Bounds");
359 return fPidProb[idx];
361 //______________________________________________________________________________
363 void AliHBTParticle::Print() const
365 //prints information about particle
366 printf("____________________________________________________\n");
367 printf("Idx: %d PID: %d Name: ",fIdxInEvent,GetPdgCode());
368 TParticlePDG *pdgp = TDatabasePDG::Instance()->GetParticle(GetPdgCode());
371 printf("%s Mass: %f\n",pdgp->GetName(),pdgp->Mass());
375 printf("Not known\n");
378 printf("Px: %+f Py: %+f Pz: %+f E: %+f Calculated Mass: %f\nVx: %+f Vy: %+f Vz: %+f T: %+f\n",
379 Px(),Py(),Pz(),Energy(),GetCalcMass(),Vx(),Vy(),Vz(),T());
381 for (Int_t i = 0; i < fNPids; i++)
383 printf("# %d PID: %d Probability %f name ",i,fPids[i],fPidProb[i]);
384 const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(fPids[i]);
387 printf("%s Mass %f\n",ap->GetName(),ap->Mass());
391 printf("Not known\n");
396 //______________________________________________________________________________
398 //void AliHBTParticle::Streamer(TBuffer &b)
400 // // Stream all objects in the array to or from the I/O buffer.
401 // UInt_t R__s, R__c;
403 // if (b.IsReading())
406 // delete [] fPidProb;
408 // Version_t v = b.ReadVersion(&R__s, &R__c);
411 // AliHBTParticle::Class()->ReadBuffer(b, this);
415 // TObject::Streamer(b);
420 // Int_t* fPids = new Int_t[fNPids];
421 // Float_t* fPidProb = new Float_t[fNPids];
422 // for (i = 0;i<fNPids;i++)
426 // for (i = 0;i<fNPids;i++)
441 // Info("Streamer","Read data");
445 // b.CheckByteCount(R__s, R__c,AliHBTParticle::IsA());
449 // R__c = b.WriteVersion(AliHBTParticle::IsA(), kTRUE);
450 // TObject::Streamer(b);
451 // Info("Streamer","Read data");
457 // for (i = 0;i<fNPids;i++)
463 // for (i = 0;i<fNPids;i++)
479 // b.SetByteCount(R__c, kTRUE);