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
00042 #include "G4Track.hh"
00043 #include "G4PhysicalConstants.hh"
00044 #include "G4ParticleTable.hh"
00045 #include "G4VelocityTable.hh"
00046
00047 #include <iostream>
00048 #include <iomanip>
00049
00050 G4Allocator<G4Track> aTrackAllocator;
00051
00052 G4VelocityTable* G4Track::velTable=0;
00053
00055 G4Track::G4Track(G4DynamicParticle* apValueDynamicParticle,
00056 G4double aValueTime,
00057 const G4ThreeVector& aValuePosition)
00059 : fCurrentStepNumber(0), fPosition(aValuePosition),
00060 fGlobalTime(aValueTime), fLocalTime(0.),
00061 fTrackLength(0.),
00062 fParentID(0), fTrackID(0),
00063 fVelocity(c_light),
00064 fpDynamicParticle(apValueDynamicParticle),
00065 fTrackStatus(fAlive),
00066 fBelowThreshold(false), fGoodForTracking(false),
00067 fStepLength(0.0), fWeight(1.0),
00068 fpStep(0),
00069 fVtxKineticEnergy(0.0),
00070 fpLVAtVertex(0), fpCreatorProcess(0),
00071 fpUserInformation(0),
00072 prev_mat(0), groupvel(0),
00073 prev_velocity(0.0), prev_momentum(0.0),
00074 is_OpticalPhoton(false),
00075 useGivenVelocity(false)
00076 {
00077 static G4bool isFirstTime = true;
00078 static G4ParticleDefinition* fOpticalPhoton =0;
00079 if ( isFirstTime ) {
00080 isFirstTime = false;
00081
00082 fOpticalPhoton = G4ParticleTable::GetParticleTable()->FindParticle("opticalphoton");
00083 }
00084
00085 is_OpticalPhoton = (fpDynamicParticle->GetDefinition() == fOpticalPhoton);
00086
00087 if (velTable ==0 ) velTable = G4VelocityTable::GetVelocityTable();
00088
00089 fVelocity = CalculateVelocity();
00090
00091 }
00092
00094 G4Track::G4Track()
00096 : fCurrentStepNumber(0),
00097 fGlobalTime(0), fLocalTime(0.),
00098 fTrackLength(0.),
00099 fParentID(0), fTrackID(0),
00100 fVelocity(c_light),
00101 fpDynamicParticle(0),
00102 fTrackStatus(fAlive),
00103 fBelowThreshold(false), fGoodForTracking(false),
00104 fStepLength(0.0), fWeight(1.0),
00105 fpStep(0),
00106 fVtxKineticEnergy(0.0),
00107 fpLVAtVertex(0), fpCreatorProcess(0),
00108 fpUserInformation(0),
00109 prev_mat(0), groupvel(0),
00110 prev_velocity(0.0), prev_momentum(0.0),
00111 is_OpticalPhoton(false),
00112 useGivenVelocity(false)
00113 {
00114 }
00116 G4Track::G4Track(const G4Track& right)
00118 : fCurrentStepNumber(0),
00119 fGlobalTime(0), fLocalTime(0.),
00120 fTrackLength(0.),
00121 fParentID(0), fTrackID(0),
00122 fVelocity(c_light),
00123 fpDynamicParticle(0),
00124 fTrackStatus(fAlive),
00125 fBelowThreshold(false), fGoodForTracking(false),
00126 fStepLength(0.0), fWeight(1.0),
00127 fpStep(0),
00128 fVtxKineticEnergy(0.0),
00129 fpLVAtVertex(0), fpCreatorProcess(0),
00130 fpUserInformation(0),
00131 prev_mat(0), groupvel(0),
00132 prev_velocity(0.0), prev_momentum(0.0),
00133 is_OpticalPhoton(false),
00134 useGivenVelocity(false)
00135 {
00136 *this = right;
00137 }
00138
00140 G4Track::~G4Track()
00142 {
00143 delete fpDynamicParticle;
00144 delete fpUserInformation;
00145 }
00146
00148 G4Track & G4Track::operator=(const G4Track &right)
00150 {
00151 if (this != &right) {
00152 fPosition = right.fPosition;
00153 fGlobalTime = right.fGlobalTime;
00154 fLocalTime = right.fLocalTime;
00155 fTrackLength = right.fTrackLength;
00156 fWeight = right.fWeight;
00157 fStepLength = right.fStepLength;
00158
00159
00160 fTrackID = 0;
00161 fParentID =0;
00162
00163
00164 fCurrentStepNumber = 0;
00165
00166
00167 fVelocity = right.fVelocity;
00168
00169
00170 fpDynamicParticle = new G4DynamicParticle(*(right.fpDynamicParticle));
00171
00172
00173 fTrackStatus = right.fTrackStatus;
00174 fBelowThreshold = right.fBelowThreshold;
00175 fGoodForTracking = right.fGoodForTracking;
00176
00177
00178
00179 fpStep=0;
00180
00181
00182 fVtxPosition = right.fVtxPosition;
00183 fpLVAtVertex = right.fpLVAtVertex;
00184 fVtxKineticEnergy = right.fVtxKineticEnergy;
00185 fVtxMomentumDirection = right.fVtxMomentumDirection;
00186
00187
00188 fpCreatorProcess = 0;
00189 fpUserInformation = 0;
00190
00191 prev_mat = right.prev_mat;
00192 groupvel = right.groupvel;
00193 prev_velocity = right.prev_velocity;
00194 prev_momentum = right.prev_momentum;
00195
00196 is_OpticalPhoton = right.is_OpticalPhoton;
00197 useGivenVelocity = right.useGivenVelocity;
00198 }
00199 return *this;
00200 }
00201
00203 void G4Track::CopyTrackInfo(const G4Track& right)
00205 {
00206 *this = right;
00207 }
00208
00210 G4double G4Track::CalculateVelocity() const
00212 {
00213 if (useGivenVelocity) return fVelocity;
00214
00215 G4double velocity = c_light ;
00216
00217 G4double mass = fpDynamicParticle->GetMass();
00218
00219
00220 if ( is_OpticalPhoton ) return CalculateVelocityForOpticalPhoton();
00221
00222
00223 if (mass<DBL_MIN) {
00224
00225 velocity = c_light;
00226 } else {
00227 G4double T = (fpDynamicParticle->GetKineticEnergy())/mass;
00228 if (T > GetMaxTOfVelocityTable()) {
00229 velocity = c_light;
00230 } else if (T<DBL_MIN) {
00231 velocity =0.;
00232 } else if (T<GetMinTOfVelocityTable()) {
00233 velocity = c_light*std::sqrt(T*(T+2.))/(T+1.0);
00234 } else {
00235 velocity = velTable->Value(T);
00236 }
00237
00238 }
00239 return velocity ;
00240 }
00241
00243 G4double G4Track::CalculateVelocityForOpticalPhoton() const
00245 {
00246
00247 G4double velocity = c_light ;
00248
00249
00250 G4Material* mat=0;
00251 G4bool update_groupvel = false;
00252 if ( fpStep !=0 ){
00253 mat= this->GetMaterial();
00254 }else{
00255 if (fpTouchable!=0){
00256 mat=fpTouchable->GetVolume()->GetLogicalVolume()->GetMaterial();
00257 }
00258 }
00259
00260
00261 if ((mat != 0) && ((mat != prev_mat)||(groupvel==0))) {
00262 groupvel = 0;
00263 if(mat->GetMaterialPropertiesTable() != 0)
00264 groupvel = mat->GetMaterialPropertiesTable()->GetProperty("GROUPVEL");
00265 update_groupvel = true;
00266 }
00267 prev_mat = mat;
00268
00269 if (groupvel != 0 ) {
00270
00271
00272 velocity = prev_velocity;
00273
00274
00275
00276 G4double current_momentum = fpDynamicParticle->GetTotalMomentum();
00277 if( update_groupvel || (current_momentum != prev_momentum) ) {
00278 velocity =
00279 groupvel->Value(current_momentum);
00280 prev_velocity = velocity;
00281 prev_momentum = current_momentum;
00282 }
00283 }
00284
00285 return velocity ;
00286 }
00287
00289 void G4Track::SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
00291 {
00292 G4VelocityTable::SetVelocityTableProperties(t_max, t_min, nbin);
00293 velTable = G4VelocityTable::GetVelocityTable();
00294 }
00295
00297 G4double G4Track::GetMaxTOfVelocityTable()
00299 { return G4VelocityTable::GetMaxTOfVelocityTable();}
00300
00302 G4double G4Track::GetMinTOfVelocityTable()
00303
00304 { return G4VelocityTable::GetMinTOfVelocityTable();}
00305
00307 G4int G4Track::GetNbinOfVelocityTable()
00308
00309 { return G4VelocityTable::GetNbinOfVelocityTable();}
00310