00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "TView.h"
00042 #include "TVirtualPad.h"
00043 #include "TPolyLine3D.h"
00044 #include "TParticlePDG.h"
00045 #include "TDatabasePDG.h"
00046 #include "TParticle.h"
00047 #include "TClass.h"
00048 #include "X3DBuffer.h"
00049
00050 ClassImp(TParticle)
00051
00052
00053 TParticle::TParticle() :
00054 fPdgCode(0), fStatusCode(0), fWeight(0),fCalcMass(0), fPx(0), fPy(0),
00055 fPz(0), fE(0), fVx(0), fVy(0), fVz(0), fVt(0), fPolarTheta(0), fPolarPhi(0)
00056 {
00057
00058 fMother[0] = 0;
00059 fMother[1] = 0;
00060 fDaughter[0] = 0;
00061 fDaughter[1] = 0;
00062 fParticlePDG = 0;
00063 }
00064
00065
00066 TParticle::TParticle(Int_t pdg, Int_t status,
00067 Int_t mother1, Int_t mother2,
00068 Int_t daughter1, Int_t daughter2,
00069 Double_t px, Double_t py, Double_t pz, Double_t etot,
00070 Double_t vx, Double_t vy, Double_t vz, Double_t time):
00071 fPdgCode(pdg), fStatusCode(status), fWeight(1.),fPx(px), fPy(py),
00072 fPz(pz), fE(etot), fVx(vx), fVy(vy), fVz(vz), fVt(time)
00073 {
00074
00075 fMother[0] = mother1;
00076 fMother[1] = mother2;
00077 fDaughter[0] = daughter1;
00078 fDaughter[1] = daughter2;
00079
00080 SetPolarisation(0,0,0);
00081
00082 SetPdgCode(pdg);
00083 }
00084
00085
00086 TParticle::TParticle(Int_t pdg, Int_t status,
00087 Int_t mother1, Int_t mother2,
00088 Int_t daughter1, Int_t daughter2,
00089 const TLorentzVector &p,
00090 const TLorentzVector &v) :
00091 fPdgCode(pdg), fStatusCode(status), fWeight(1.),fPx(p.Px()), fPy(p.Py()),
00092 fPz(p.Pz()), fE(p.E()), fVx(v.X()), fVy(v.Y()), fVz(v.Z()), fVt(v.T())
00093 {
00094
00095 fMother[0] = mother1;
00096 fMother[1] = mother2;
00097 fDaughter[0] = daughter1;
00098 fDaughter[1] = daughter2;
00099
00100 SetPolarisation(0,0,0);
00101
00102 SetPdgCode(pdg);
00103 }
00104
00105
00106 TParticle::TParticle(const TParticle &p) :
00107 TObject(p), TAttLine(p), TAtt3D(p), fPdgCode(p.fPdgCode), fStatusCode(p.fStatusCode),
00108 fWeight(p.fWeight), fCalcMass(p.fCalcMass), fPx(p.fPx), fPy(p.fPy), fPz(p.fPz),
00109 fE(p.fE), fVx(p.fVx), fVy(p.fVy), fVz(p.fVz), fVt(p.fVt), fPolarTheta(p.fPolarTheta),
00110 fPolarPhi(p.fPolarPhi), fParticlePDG(p.fParticlePDG)
00111 {
00112
00113
00114 fMother[0]=p.fMother[0];
00115 fMother[1]=p.fMother[1];
00116 fDaughter[0]=p.fDaughter[0];
00117 fDaughter[1]=p.fDaughter[1];
00118 }
00119
00120
00121 TParticle& TParticle::operator=(const TParticle &p)
00122 {
00123
00124
00125 if(this!=&p) {
00126 TObject::operator=(p);
00127 TAttLine::operator=(p);
00128 TAtt3D::operator=(p);
00129 fPdgCode=p.fPdgCode;
00130 fStatusCode=p.fStatusCode;
00131 fMother[0]=p.fMother[0];
00132 fMother[1]=p.fMother[1];
00133 fDaughter[0]=p.fDaughter[0];
00134 fDaughter[1]=p.fDaughter[1];
00135 fWeight=p.fWeight;
00136
00137 fCalcMass=p.fCalcMass;
00138
00139 fPx=p.fPx;
00140 fPy=p.fPy;
00141 fPz=p.fPz;
00142 fE=p.fE;
00143
00144 fVx=p.fVx;
00145 fVy=p.fVy;
00146 fVz=p.fVz;
00147 fVt=p.fVt;
00148
00149 fPolarTheta=p.fPolarTheta;
00150 fPolarPhi=p.fPolarPhi;
00151
00152 fParticlePDG=p.fParticlePDG;
00153 }
00154 return *this;
00155 }
00156
00157
00158 TParticle::~TParticle()
00159 {
00160
00161 }
00162
00163
00164 Double_t TParticle::GetMass()
00165 {
00166
00167 return GetPDG()->Mass();
00168 }
00169
00170
00171 Int_t TParticle::Beauty()
00172 {
00173
00174 return GetPDG()->Beauty();
00175 }
00176
00177
00178 Int_t TParticle::Charm()
00179 {
00180
00181 return GetPDG()->Charm();
00182 }
00183
00184
00185 Int_t TParticle::Strangeness()
00186 {
00187
00188 return GetPDG()->Strangeness();
00189 }
00190
00191
00192 Int_t TParticle::DistancetoPrimitive(Int_t px, Int_t py)
00193 {
00194
00195
00196
00197
00198
00199
00200
00201
00202 const Int_t big = 9999;
00203 Float_t xv[3], xe[3], xndc[3];
00204 Float_t rmin[3], rmax[3];
00205 TView *view = gPad->GetView();
00206 if(!view) return big;
00207
00208
00209 Float_t pmom = this->P();
00210 if (pmom == 0) return big;
00211 view->GetRange(rmin,rmax);
00212 Float_t rbox = rmax[2];
00213 xv[0] = fVx;
00214 xv[1] = fVy;
00215 xv[2] = fVz;
00216 xe[0] = xv[0]+rbox*fPx/pmom;
00217 xe[1] = xv[1]+rbox*fPy/pmom;
00218 xe[2] = xv[2]+rbox*fPz/pmom;
00219 view->WCtoNDC(xv, xndc);
00220 Float_t x1 = xndc[0];
00221 Float_t y1 = xndc[1];
00222 view->WCtoNDC(xe, xndc);
00223 Float_t x2 = xndc[0];
00224 Float_t y2 = xndc[1];
00225
00226 return DistancetoLine(px,py,x1,y1,x2,y2);
00227 }
00228
00229
00230
00231 void TParticle::ExecuteEvent(Int_t, Int_t, Int_t)
00232 {
00233
00234
00235
00236 gPad->SetCursor(kPointer);
00237 }
00238
00239
00240 const char* TParticle::GetName() const {
00241
00242 static char def[4] = "XXX";
00243 const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(fPdgCode);
00244 if (ap) return ap->GetName();
00245 else return def;
00246 }
00247
00248
00249
00250 TParticlePDG* TParticle::GetPDG(Int_t mode)
00251 {
00252
00253
00254
00255
00256
00257
00258
00259 if (!mode || !fParticlePDG) {
00260 (((TParticle*)this)->fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode));
00261
00262
00263 }
00264 return fParticlePDG;
00265 }
00266
00267
00268 void TParticle::GetPolarisation(TVector3 &v)
00269 {
00270
00271 if(fPolarTheta == -99 && fPolarPhi == -99)
00272
00273 v.SetXYZ(0.,0.,0.);
00274 else
00275 v.SetXYZ(TMath::Cos(fPolarPhi)*TMath::Sin(fPolarTheta),
00276 TMath::Sin(fPolarPhi)*TMath::Sin(fPolarTheta),
00277 TMath::Cos(fPolarTheta));
00278 }
00279
00280
00281 const char *TParticle::GetTitle() const
00282 {
00283
00284 static char def[4] = "XXX";
00285 const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(fPdgCode);
00286 if (ap) return ap->GetTitle();
00287 else return def;
00288 }
00289
00290
00291 void TParticle::Paint(Option_t *option)
00292 {
00293
00294
00295
00296 Float_t rmin[3], rmax[3];
00297 static TPolyLine3D *pline = 0;
00298 if (!pline) {
00299 pline = new TPolyLine3D(2);
00300 }
00301 Float_t pmom = this->P();
00302 if (pmom == 0) return;
00303 TView *view = gPad->GetView();
00304 if (!view) return;
00305 view->GetRange(rmin,rmax);
00306 Float_t rbox = rmax[2];
00307 pline->SetPoint(0,Vx(), Vy(), Vz());
00308 Float_t xend = Vx()+rbox*Px()/pmom;
00309 Float_t yend = Vy()+rbox*Py()/pmom;
00310 Float_t zend = Vz()+rbox*Pz()/pmom;
00311 pline->SetPoint(1, xend, yend, zend);
00312 pline->SetLineColor(GetLineColor());
00313 pline->SetLineStyle(GetLineStyle());
00314 pline->SetLineWidth(GetLineWidth());
00315 pline->Paint(option);
00316 }
00317
00318
00319 void TParticle::Print(Option_t *) const
00320 {
00321
00322
00323
00324
00325 Printf("TParticle: %-13s p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d",
00326 GetName(),Px(),Py(),Pz(),Vx(),Vy(),Vz(),
00327 fMother[0],fMother[1]);
00328 }
00329
00330
00331 void TParticle::SetPdgCode(Int_t pdg)
00332 {
00333
00334
00335
00336
00337 static Int_t nWarnings = 0;
00338 fPdgCode = pdg;
00339 fParticlePDG = TDatabasePDG::Instance()->GetParticle(pdg);
00340 if (fParticlePDG) {
00341 fCalcMass = fParticlePDG->Mass();
00342 } else {
00343 if (nWarnings < 10) {
00344 Warning("SetPdgCode","PDG code %d unknown from TDatabasePDG",pdg);
00345 nWarnings++;
00346 }
00347 Double_t a2 = fE*fE -fPx*fPx -fPy*fPy -fPz*fPz;
00348 if (a2 >= 0) fCalcMass = TMath::Sqrt(a2);
00349 else fCalcMass = -TMath::Sqrt(-a2);
00350 }
00351 }
00352
00353
00354 void TParticle::SetPolarisation(Double_t polx, Double_t poly, Double_t polz)
00355 {
00356
00357 if(polx || poly || polz) {
00358 fPolarTheta = TMath::ACos(polz/TMath::Sqrt(polx*polx+poly*poly+polz*polz));
00359 fPolarPhi = TMath::Pi()+TMath::ATan2(-poly,-polx);
00360 } else {
00361 fPolarTheta = -99;
00362 fPolarPhi = -99;
00363 }
00364 }
00365
00366
00367 void TParticle::Sizeof3D() const
00368 {
00369
00370
00371
00372 Float_t pmom = this->P();
00373 if (pmom == 0) return;
00374 Int_t npoints = 2;
00375 gSize3D.numPoints += npoints;
00376 gSize3D.numSegs += (npoints-1);
00377 gSize3D.numPolys += 0;
00378
00379 }
00380
00381
00382 void TParticle::Streamer(TBuffer &R__b)
00383 {
00384
00385
00386 if (R__b.IsReading()) {
00387 UInt_t R__s, R__c;
00388 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00389 if (R__v > 1) {
00390 R__b.ReadClassBuffer(TParticle::Class(), this, R__v, R__s, R__c);
00391 fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode);
00392 return;
00393 }
00394
00395 TObject::Streamer(R__b);
00396 TAttLine::Streamer(R__b);
00397 R__b >> fPdgCode;
00398 R__b >> fStatusCode;
00399 R__b.ReadStaticArray(fMother);
00400 R__b.ReadStaticArray(fDaughter);
00401 R__b >> fWeight;
00402 R__b >> fCalcMass;
00403 R__b >> fPx;
00404 R__b >> fPy;
00405 R__b >> fPz;
00406 R__b >> fE;
00407 R__b >> fVx;
00408 R__b >> fVy;
00409 R__b >> fVz;
00410 R__b >> fVt;
00411 R__b >> fPolarTheta;
00412 R__b >> fPolarPhi;
00413 fParticlePDG = TDatabasePDG::Instance()->GetParticle(fPdgCode);
00414 R__b.CheckByteCount(R__s, R__c, TParticle::IsA());
00415
00416
00417 } else {
00418 R__b.WriteClassBuffer(TParticle::Class(),this);
00419 }
00420 }