TPrimary.cxx

Go to the documentation of this file.
00001 // @(#)root/eg:$Id: TPrimary.cxx 35915 2010-09-30 14:25:54Z brun $
00002 // Author: Ola Nordmann   21/09/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //______________________________________________________________________________
00013 //
00014 // old version of a  dynamic particle class created by event generators.
00015 // This class is now obsolete. Use TParticle instead.
00016 
00017 #include "TObject.h"
00018 #include "Rtypes.h"
00019 #include "TString.h"
00020 #include "TAttParticle.h"
00021 #include "TPrimary.h"
00022 #include "TView.h"
00023 #include "TMath.h"
00024 #include "TVirtualPad.h"
00025 #include "TPolyLine3D.h"
00026 
00027 ClassImp(TPrimary)
00028 
00029 //______________________________________________________________________________
00030 TPrimary::TPrimary()
00031 {
00032 //
00033 //  Primary vertex particle default constructor
00034 //
00035 
00036    //do nothing
00037    fPart         = 0;
00038    fFirstMother  = 0;
00039    fSecondMother = 0;
00040    fGeneration   = 0;
00041    fPx           = 0;
00042    fPy           = 0;
00043    fPz           = 0;
00044    fEtot         = 0;
00045    fVx           = 0;
00046    fVy           = 0;
00047    fVz           = 0;
00048    fTime         = 0;
00049    fTimeEnd      = 0;
00050    fType         = "";
00051 
00052 }
00053 
00054 //______________________________________________________________________________
00055 TPrimary::TPrimary(Int_t part, Int_t first, Int_t second, Int_t gener,
00056                    Double_t px, Double_t py, Double_t pz,
00057                    Double_t etot, Double_t vx, Double_t vy, Double_t vz,
00058                    Double_t time, Double_t timend, const char *type)
00059 {
00060 //
00061 //  TPrimary vertex particle normal constructor
00062 //
00063    fPart         = part;
00064    fFirstMother  = first;
00065    fSecondMother = second;
00066    fGeneration   = gener;
00067    fPx           = px;
00068    fPy           = py;
00069    fPz           = pz;
00070    fEtot         = etot;
00071    fVx           = vx;
00072    fVy           = vy;
00073    fVz           = vz;
00074    fTime         = time;
00075    fTimeEnd      = timend;
00076    fType         = type;
00077 }
00078 
00079 //______________________________________________________________________________
00080 TPrimary::~TPrimary()
00081 {
00082 //
00083 //   Primaray vertex particle default destructor
00084 //
00085 
00086    //do nothing
00087 }
00088 
00089 
00090 //______________________________________________________________________________
00091 Int_t TPrimary::DistancetoPrimitive(Int_t px, Int_t py)
00092 {
00093 //*-*-*-*-*-*-*-*Compute distance from point px,py to a primary track*-*-*-*
00094 //*-*            ====================================================
00095 //*-*
00096 //*-*  Compute the closest distance of approach from point px,py to each segment
00097 //*-*  of a track.
00098 //*-*  The distance is computed in pixels units.
00099 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
00100 
00101    const Int_t big = 9999;
00102    Float_t xv[3], xe[3], xndc[3];
00103    Float_t rmin[3], rmax[3];
00104    TView *view = gPad->GetView();
00105    if(!view) return big;
00106 
00107    // compute first and last point in pad coordinates
00108    Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
00109    if (pmom == 0) return big;
00110    view->GetRange(rmin,rmax);
00111    Float_t rbox = rmax[2];
00112    xv[0] = fVx;
00113    xv[1] = fVy;
00114    xv[2] = fVz;
00115    xe[0] = fVx+rbox*fPx/pmom;
00116    xe[1] = fVy+rbox*fPy/pmom;
00117    xe[2] = fVz+rbox*fPz/pmom;
00118    view->WCtoNDC(xv, xndc);
00119    Float_t x1 = xndc[0];
00120    Float_t y1 = xndc[1];
00121    view->WCtoNDC(xe, xndc);
00122    Float_t x2 = xndc[0];
00123    Float_t y2 = xndc[1];
00124 
00125    return DistancetoLine(px,py,x1,y1,x2,y2);
00126 }
00127 
00128 
00129 //______________________________________________________________________________
00130 void TPrimary::ExecuteEvent(Int_t, Int_t, Int_t)
00131 {
00132 //*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
00133 //*-*                  =========================================
00134 
00135    gPad->SetCursor(kPointer);
00136 }
00137 
00138 //______________________________________________________________________________
00139 const char *TPrimary::GetName() const
00140 {
00141    //return name of primary particle
00142    static char def[4] = "XXX";
00143    const TAttParticle *ap = GetParticle();
00144    if (ap) return ap->GetName();
00145    else    return def;
00146 }
00147 
00148 //______________________________________________________________________________
00149 const TAttParticle *TPrimary::GetParticle() const
00150 {
00151 //
00152 //  returning a pointer to the particle attributes
00153 //
00154    if (!TAttParticle::fgList) TAttParticle::DefinePDG();
00155    return TAttParticle::GetParticle(fPart);
00156 }
00157 
00158 //______________________________________________________________________________
00159 const char *TPrimary::GetTitle() const
00160 {
00161    //return title of primary particle
00162    static char title[128];
00163    Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
00164    snprintf(title,128,"pmom=%f GeV",pmom);
00165    return title;
00166 }
00167 
00168 //______________________________________________________________________________
00169 void TPrimary::Paint(Option_t *option)
00170 {
00171 //
00172 //  Paint a primary track
00173 //
00174    Float_t rmin[3], rmax[3];
00175    static TPolyLine3D *pline = 0;
00176    if (!pline) {
00177       pline = new TPolyLine3D(2);
00178    }
00179    Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
00180    if (pmom == 0) return;
00181    TView *view = gPad->GetView();
00182    if (!view) return;
00183    view->GetRange(rmin,rmax);
00184    Float_t rbox = rmax[2];
00185    pline->SetPoint(0,fVx, fVy, fVz);
00186    Float_t xend = fVx+rbox*fPx/pmom;
00187    Float_t yend = fVy+rbox*fPy/pmom;
00188    Float_t zend = fVz+rbox*fPz/pmom;
00189    pline->SetPoint(1, xend, yend, zend);
00190    pline->SetLineColor(GetLineColor());
00191    pline->SetLineStyle(GetLineStyle());
00192    pline->SetLineWidth(GetLineWidth());
00193    pline->Paint(option);
00194 }
00195 
00196 //______________________________________________________________________________
00197 void TPrimary::Print(Option_t *) const
00198 {
00199 //
00200 //  Print the internals of the primary vertex particle
00201 //
00202    char def[8] = "XXXXXXX";
00203    const char *name;
00204    TAttParticle *ap = (TAttParticle*)GetParticle();
00205    if (ap) name = ap->GetName();
00206    else    name = def;
00207    Printf("TPrimary: %-13s  p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d %s",
00208    name,fPx,fPy,fPz,fVx,fVy,fVz,
00209    fFirstMother,fSecondMother,fType.Data());
00210 }
00211 
00212 //______________________________________________________________________________
00213 void TPrimary::Sizeof3D() const
00214 {
00215 //*-*-*-*-*-*Return total X3D size of this primary*-*-*-*-*-*-*
00216 //*-*        =====================================
00217 
00218    Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
00219    if (pmom == 0) return;
00220    Int_t npoints = 2;
00221    gSize3D.numPoints += npoints;
00222    gSize3D.numSegs   += (npoints-1);
00223    gSize3D.numPolys  += 0;
00224 
00225 }
00226 

Generated on Tue Jul 5 14:45:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1