63 TParticle::TParticle() :
64 fPdgCode(0), fStatusCode(0), fWeight(0),fCalcMass(0), fPx(0), fPy(0),
65 fPz(0), fE(0), fVx(0), fVy(0), fVz(0), fVt(0), fPolarTheta(0), fPolarPhi(0)
77 TParticle::TParticle(Int_t pdg, Int_t status,
78 Int_t mother1, Int_t mother2,
79 Int_t daughter1, Int_t daughter2,
80 Double_t px, Double_t py, Double_t pz, Double_t etot,
81 Double_t vx, Double_t vy, Double_t vz, Double_t time):
82 fPdgCode(pdg), fStatusCode(status), fWeight(1.),fPx(px), fPy(py),
83 fPz(pz), fE(etot), fVx(vx), fVy(vy), fVz(vz), fVt(time)
87 fDaughter[0] = daughter1;
88 fDaughter[1] = daughter2;
90 SetPolarisation(0,0,0);
98 TParticle::TParticle(Int_t pdg, Int_t status,
99 Int_t mother1, Int_t mother2,
100 Int_t daughter1, Int_t daughter2,
101 const TLorentzVector &p,
102 const TLorentzVector &v) :
103 fPdgCode(pdg), fStatusCode(status), fWeight(1.),fPx(p.Px()), fPy(p.Py()),
104 fPz(p.Pz()), fE(p.E()), fVx(v.X()), fVy(v.Y()), fVz(v.Z()), fVt(v.T())
106 fMother[0] = mother1;
107 fMother[1] = mother2;
108 fDaughter[0] = daughter1;
109 fDaughter[1] = daughter2;
111 SetPolarisation(0,0,0);
119 TParticle::TParticle(
const TParticle &p) :
120 TObject(p), TAttLine(p), TAtt3D(p), fPdgCode(p.fPdgCode), fStatusCode(p.fStatusCode),
121 fWeight(p.fWeight), fCalcMass(p.fCalcMass), fPx(p.fPx), fPy(p.fPy), fPz(p.fPz),
122 fE(p.fE), fVx(p.fVx), fVy(p.fVy), fVz(p.fVz), fVt(p.fVt), fPolarTheta(p.fPolarTheta),
123 fPolarPhi(p.fPolarPhi), fParticlePDG(p.fParticlePDG)
125 fMother[0]=p.fMother[0];
126 fMother[1]=p.fMother[1];
127 fDaughter[0]=p.fDaughter[0];
128 fDaughter[1]=p.fDaughter[1];
134 TParticle& TParticle::operator=(
const TParticle &p)
137 TObject::operator=(p);
138 TAttLine::operator=(p);
139 TAtt3D::operator=(p);
141 fStatusCode=p.fStatusCode;
142 fMother[0]=p.fMother[0];
143 fMother[1]=p.fMother[1];
144 fDaughter[0]=p.fDaughter[0];
145 fDaughter[1]=p.fDaughter[1];
148 fCalcMass=p.fCalcMass;
160 fPolarTheta=p.fPolarTheta;
161 fPolarPhi=p.fPolarPhi;
163 fParticlePDG=p.fParticlePDG;
171 TParticle::~TParticle()
178 Double_t TParticle::GetMass()
const
180 return GetPDG()->Mass();
186 Int_t TParticle::Beauty()
const
188 return GetPDG()->Beauty();
194 Int_t TParticle::Charm()
const
196 return GetPDG()->Charm();
202 Int_t TParticle::Strangeness()
const
204 return GetPDG()->Strangeness();
215 Int_t TParticle::DistancetoPrimitive(Int_t px, Int_t py)
217 const Int_t big = 9999;
218 Float_t xv[3], xe[3], xndc[3];
219 Float_t rmin[3], rmax[3];
220 TView *view = gPad->GetView();
221 if(!view)
return big;
224 Float_t pmom = this->P();
225 if (pmom == 0)
return big;
226 view->GetRange(rmin,rmax);
227 Float_t rbox = rmax[2];
231 xe[0] = xv[0]+rbox*fPx/pmom;
232 xe[1] = xv[1]+rbox*fPy/pmom;
233 xe[2] = xv[2]+rbox*fPz/pmom;
234 view->WCtoNDC(xv, xndc);
235 Float_t x1 = xndc[0];
236 Float_t y1 = xndc[1];
237 view->WCtoNDC(xe, xndc);
238 Float_t x2 = xndc[0];
239 Float_t y2 = xndc[1];
241 return DistancetoLine(px,py,x1,y1,x2,y2);
249 void TParticle::ExecuteEvent(Int_t, Int_t, Int_t)
251 gPad->SetCursor(kPointer);
257 const char* TParticle::GetName()
const {
258 static char def[4] =
"XXX";
259 const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(fPdgCode);
260 if (ap)
return ap->GetName();
273 TParticlePDG* TParticle::GetPDG(Int_t mode)
const
275 if (!mode || !fParticlePDG) {
276 fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode);
284 void TParticle::GetPolarisation(TVector3 &v)
const
286 if(fPolarTheta == -99 && fPolarPhi == -99)
290 v.SetXYZ(TMath::Cos(fPolarPhi)*TMath::Sin(fPolarTheta),
291 TMath::Sin(fPolarPhi)*TMath::Sin(fPolarTheta),
292 TMath::Cos(fPolarTheta));
298 const char *TParticle::GetTitle()
const
300 static char def[4] =
"XXX";
301 const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(fPdgCode);
302 if (ap)
return ap->GetTitle();
311 void TParticle::Paint(Option_t *option)
313 Float_t rmin[3], rmax[3];
314 static TPolyLine3D *pline = 0;
316 pline =
new TPolyLine3D(2);
318 Float_t pmom = this->P();
319 if (pmom == 0)
return;
320 TView *view = gPad->GetView();
322 view->GetRange(rmin,rmax);
323 Float_t rbox = rmax[2];
324 pline->SetPoint(0,Vx(), Vy(), Vz());
325 Float_t xend = Vx()+rbox*Px()/pmom;
326 Float_t yend = Vy()+rbox*Py()/pmom;
327 Float_t zend = Vz()+rbox*Pz()/pmom;
328 pline->SetPoint(1, xend, yend, zend);
329 pline->SetLineColor(GetLineColor());
330 pline->SetLineStyle(GetLineStyle());
331 pline->SetLineWidth(GetLineWidth());
332 pline->Paint(option);
340 void TParticle::Print(Option_t *)
const
342 Printf(
"TParticle: %-13s p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d",
343 GetName(),Px(),Py(),Pz(),Vx(),Vy(),Vz(),
344 fMother[0],fMother[1]);
353 void TParticle::SetPdgCode(Int_t pdg)
355 static Int_t nWarnings = 0;
357 fParticlePDG = TDatabasePDG::Instance()->GetParticle(pdg);
359 fCalcMass = fParticlePDG->Mass();
361 if (nWarnings < 10) {
362 Warning(
"SetPdgCode",
"PDG code %d unknown from TDatabasePDG",pdg);
365 Double_t a2 = fE*fE -fPx*fPx -fPy*fPy -fPz*fPz;
366 if (a2 >= 0) fCalcMass = TMath::Sqrt(a2);
367 else fCalcMass = -TMath::Sqrt(-a2);
374 void TParticle::SetPolarisation(Double_t polx, Double_t poly, Double_t polz)
376 if(polx || poly || polz) {
377 fPolarTheta = TMath::ACos(polz/TMath::Sqrt(polx*polx+poly*poly+polz*polz));
378 fPolarPhi = TMath::Pi()+TMath::ATan2(-poly,-polx);
389 void TParticle::Sizeof3D()
const
391 Float_t pmom = this->P();
392 if (pmom == 0)
return;
394 gSize3D.numPoints += npoints;
395 gSize3D.numSegs += (npoints-1);
396 gSize3D.numPolys += 0;
403 void TParticle::Streamer(TBuffer &R__b)
405 if (R__b.IsReading()) {
407 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
409 R__b.ReadClassBuffer(TParticle::Class(),
this, R__v, R__s, R__c);
410 fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode);
414 TObject::Streamer(R__b);
415 TAttLine::Streamer(R__b);
418 R__b.ReadStaticArray(fMother);
419 R__b.ReadStaticArray(fDaughter);
432 fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode);
433 R__b.CheckByteCount(R__s, R__c, TParticle::IsA());
437 R__b.WriteClassBuffer(TParticle::Class(),
this);