TVirtualGeoTrack.cxx

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TVirtualGeoTrack.cxx 33212 2010-04-26 12:19:20Z agheata $
00002 // Author: Andrei Gheata  2003/04/10
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 #include "TGeoManager.h"
00013 
00014 #include "TVirtualGeoTrack.h"
00015 
00016 //______________________________________________________________________________
00017 // TVirtualGeoTrack - Base class for user-defined tracks attached to a geometry.
00018 //             Tracks are 3D objects made of points and they store a 
00019 //             pointer to a TParticle. The geometry manager holds a list
00020 //             of all tracks that will be deleted on destruction of 
00021 //             gGeoManager.
00022 //
00023 //______________________________________________________________________________
00024 
00025 ClassImp(TVirtualGeoTrack)
00026 
00027 //______________________________________________________________________________
00028 TVirtualGeoTrack::TVirtualGeoTrack()
00029 {
00030 //*-*-*-*-*-*-*-*-*-*-*Virtual tracks default constructor*-*-*-*-*-*-*-*-*
00031 //*-*                  ==================================
00032    fPDG        = 0;
00033    fId         = -1;
00034    fParent     = 0;
00035    fParticle   = 0;
00036    fTracks     = 0;
00037 }
00038 
00039 //______________________________________________________________________________
00040 TVirtualGeoTrack::TVirtualGeoTrack(Int_t id, Int_t pdgcode, TVirtualGeoTrack *parent, TObject *particle)
00041 {
00042 // Constructor providing ID for parent track (-1 for primaries), ID of this
00043 // track and related particle pointer.
00044    fPDG        = pdgcode;
00045    fId         = id;
00046    fParent     = parent;
00047    fParticle   = particle;
00048    fTracks     = 0;
00049 }
00050 
00051 //_____________________________________________________________________________
00052 TVirtualGeoTrack::TVirtualGeoTrack(const TVirtualGeoTrack& other)
00053                  :TObject(other), TGeoAtt(other), TAttLine(other), TAttMarker(other),
00054                   fPDG(other.fPDG),
00055                   fId(other.fId),
00056                   fParent(other.fParent),
00057                   fParticle(other.fParticle),
00058                   fTracks(other.fTracks)
00059 {
00060 // Copy ctor. NOT TO BE CALLED.
00061 }
00062 
00063 //_____________________________________________________________________________
00064 TVirtualGeoTrack& TVirtualGeoTrack::operator=(const TVirtualGeoTrack& gv) 
00065 {
00066    // Assignment operator. NOT TO BE CALLED.
00067    if(this!=&gv) {
00068       TObject::operator=(gv);
00069       TGeoAtt::operator=(gv);
00070       TAttLine::operator=(gv);
00071       TAttMarker::operator=(gv);
00072       fPDG=gv.fPDG;
00073       fId=gv.fId;
00074       fParent=gv.fParent;
00075       fParticle=gv.fParticle;
00076       fTracks=gv.fTracks;
00077    } 
00078    return *this;
00079 }
00080 
00081 //______________________________________________________________________________
00082 TVirtualGeoTrack::~TVirtualGeoTrack()
00083 {
00084 // Destructor.
00085    if (fTracks) {
00086       fTracks->Delete();
00087       delete fTracks;
00088    }   
00089 }
00090 
00091 //______________________________________________________________________________
00092 TVirtualGeoTrack *TVirtualGeoTrack::FindTrackWithId(Int_t id) const
00093 {
00094 // Recursively search through this track for a daughter
00095 // particle (at any depth) with the specified id
00096    TVirtualGeoTrack* trk=0;
00097    if (GetId()==id) {
00098       trk = (TVirtualGeoTrack*)this;
00099       return trk;
00100    }
00101    TVirtualGeoTrack* kid=0;
00102    Int_t nd = GetNdaughters();
00103    for (Int_t i=0; i<nd; i++) if (GetDaughterId(i) == id) return GetDaughter(i);
00104    for (Int_t i=0; i<nd; i++) {
00105       kid = GetDaughter(i);
00106       if (kid!=0) {
00107          trk = kid->FindTrackWithId(id);
00108          if (trk!=0) break;
00109       }
00110    }
00111    return trk;
00112 }
00113 
00114 //______________________________________________________________________________
00115 const char *TVirtualGeoTrack::GetName() const
00116 {
00117 // Get the PDG name.
00118    return gGeoManager->GetPdgName(fPDG);
00119 }
00120 
00121 //______________________________________________________________________________
00122 Bool_t TVirtualGeoTrack::IsInTimeRange() const
00123 {
00124 // True if track TOF range overlaps with time interval of TGeoManager
00125    Double_t tmin, tmax;
00126    Bool_t timecut = gGeoManager->GetTminTmax(tmin,tmax);
00127    if (!timecut) return kTRUE;
00128    const Double_t *point = GetFirstPoint();
00129    if (!point) return kFALSE;
00130    if (point[3]>tmax) return kFALSE;
00131    point = GetLastPoint();
00132    if (point[3]<tmin) return kFALSE;
00133    return kTRUE;
00134 }     
00135 
00136 //______________________________________________________________________________
00137 void TVirtualGeoTrack::SetName(const char *name)
00138 {
00139 // Set a default name for this track.
00140    gGeoManager->SetPdgName(fPDG, name);
00141    if (!strcmp(name, "gamma")) {
00142       SetLineColor(kGreen);
00143       SetMarkerColor(kGreen);
00144       SetLineWidth(1);
00145       SetLineStyle(kDotted);
00146       return;
00147    }     
00148    if (!strcmp(name, "pi+") || !strcmp(name, "proton") || !strcmp(name, "K+")) {
00149       SetLineColor(kRed);
00150       SetMarkerColor(kRed);
00151       SetLineWidth(2);
00152       return;
00153    }     
00154    if (!strcmp(name, "pi-") || !strcmp(name, "K-")) {
00155       SetLineColor(30);
00156       SetMarkerColor(30);
00157       SetLineWidth(2);
00158       return;
00159    }     
00160    if (!strcmp(name, "pi0") || !strcmp(name, "K0")) {
00161       SetLineColor(kCyan);
00162       SetMarkerColor(kCyan);
00163       SetLineWidth(2);
00164       return;
00165    }     
00166    if (!strcmp(name, "neutron")) {
00167       SetLineColor(16);
00168       SetMarkerColor(16);
00169       SetLineWidth(1);
00170       SetLineStyle(kDotted);
00171       return;
00172    }     
00173    if (!strcmp(name, "Alpha") || !strcmp(name, "Deuteron") || !strcmp(name, "Triton")) {
00174       SetLineColor(kMagenta);
00175       SetMarkerColor(kMagenta);
00176       SetLineWidth(3);
00177       return;
00178    }     
00179    if (!strcmp(name, "e-") || !strcmp(name, "mu-")) {
00180       SetLineColor(kBlue);
00181       SetMarkerColor(kBlue);
00182       SetLineWidth(1);
00183       SetLineStyle(kDotted);
00184       return;
00185    }     
00186    if (!strcmp(name, "e+") || !strcmp(name, "mu+")) {
00187       SetLineColor(kMagenta);
00188       SetMarkerColor(kMagenta);
00189       SetLineWidth(1);
00190       SetLineStyle(kDotted);
00191       return;
00192    }     
00193 }
00194 
00195    

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