00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TGeoManager.h"
00013
00014 #include "TVirtualGeoTrack.h"
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 ClassImp(TVirtualGeoTrack)
00026
00027
00028 TVirtualGeoTrack::TVirtualGeoTrack()
00029 {
00030
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
00043
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
00061 }
00062
00063
00064 TVirtualGeoTrack& TVirtualGeoTrack::operator=(const TVirtualGeoTrack& gv)
00065 {
00066
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
00085 if (fTracks) {
00086 fTracks->Delete();
00087 delete fTracks;
00088 }
00089 }
00090
00091
00092 TVirtualGeoTrack *TVirtualGeoTrack::FindTrackWithId(Int_t id) const
00093 {
00094
00095
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
00118 return gGeoManager->GetPdgName(fPDG);
00119 }
00120
00121
00122 Bool_t TVirtualGeoTrack::IsInTimeRange() const
00123 {
00124
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
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