Changeset 1340 for trunk/source/track/src/G4Track.cc
- Timestamp:
- Nov 5, 2010, 3:45:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/track/src/G4Track.cc
r1337 r1340 25 25 // 26 26 // 27 // $Id: G4Track.cc,v 1.3 2 2009/04/08 08:07:24kurasige Exp $28 // GEANT4 tag $Name: geant4-09-04-beta-01$27 // $Id: G4Track.cc,v 1.35 2010/09/21 00:33:05 kurasige Exp $ 28 // GEANT4 tag $Name: track-V09-03-09 $ 29 29 // 30 30 // … … 41 41 42 42 #include "G4Track.hh" 43 #include "G4ParticleTable.hh" 43 44 44 45 G4Allocator<G4Track> aTrackAllocator; 46 47 G4PhysicsLogVector* G4Track::velTable = 0; 48 49 const G4double G4Track::maxT = 100.0; 50 const G4double G4Track::minT = 0.0001; 45 51 46 52 /////////////////////////////////////////////////////////// … … 60 66 fVtxKineticEnergy(0.0), 61 67 fpLVAtVertex(0), fpCreatorProcess(0), 62 fpUserInformation(0) 68 fpUserInformation(0), 69 prev_mat(0), groupvel(0), 70 prev_velocity(0.0), prev_momentum(0.0), 71 is_OpticalPhoton(false) 63 72 { 73 static G4bool isFirstTime = true; 74 static G4ParticleDefinition* fOpticalPhoton =0; 75 if ( isFirstTime ) { 76 isFirstTime = false; 77 // set fOpticalPhoton 78 fOpticalPhoton = G4ParticleTable::GetParticleTable()->FindParticle("opticalphoton"); 79 } 80 // check if the particle type is Optical Photon 81 is_OpticalPhoton = (fpDynamicParticle->GetDefinition() == fOpticalPhoton); 82 83 if (velTable==0) PrepareVelocityTable(); 64 84 } 65 85 … … 78 98 fVtxKineticEnergy(0.0), 79 99 fpLVAtVertex(0), fpCreatorProcess(0), 80 fpUserInformation(0) 100 fpUserInformation(0), 101 prev_mat(0), groupvel(0), 102 prev_velocity(0.0), prev_momentum(0.0), 103 is_OpticalPhoton(false) 81 104 { 82 105 } … … 84 107 G4Track::G4Track(const G4Track& right) 85 108 ////////////////// 109 : fCurrentStepNumber(0), 110 fGlobalTime(0), fLocalTime(0.), 111 fTrackLength(0.), 112 fParentID(0), fTrackID(0), 113 fpDynamicParticle(0), 114 fTrackStatus(fAlive), 115 fBelowThreshold(false), fGoodForTracking(false), 116 fStepLength(0.0), fWeight(1.0), 117 fpStep(0), 118 fVtxKineticEnergy(0.0), 119 fpLVAtVertex(0), fpCreatorProcess(0), 120 fpUserInformation(0), 121 prev_mat(0), groupvel(0), 122 prev_velocity(0.0), prev_momentum(0.0), 123 is_OpticalPhoton(false) 86 124 { 87 125 *this = right; … … 136 174 fpCreatorProcess = 0; 137 175 fpUserInformation = 0; 176 177 prev_mat = right.prev_mat; 178 groupvel = right.groupvel; 179 prev_velocity = right.prev_velocity; 180 prev_momentum = right.prev_momentum; 181 182 is_OpticalPhoton = right.is_OpticalPhoton; 183 138 184 } 139 185 return *this; … … 147 193 } 148 194 149 #include "G4ParticleTable.hh"150 195 /////////////////// 151 196 G4double G4Track::GetVelocity() const 152 197 /////////////////// 153 198 { 154 static G4bool isFirstTime = true; 155 static G4ParticleDefinition* fOpticalPhoton =0; 156 157 static G4Material* prev_mat =0; 158 static G4MaterialPropertyVector* groupvel =0; 159 static G4double prev_velocity =0; 160 static G4double prev_momentum =0; 161 162 163 if ( isFirstTime ) { 164 isFirstTime = false; 165 // set fOpticalPhoton 166 fOpticalPhoton = G4ParticleTable::GetParticleTable()->FindParticle("opticalphoton"); 167 } 168 169 G4double velocity ; 199 200 G4double velocity = c_light ; 170 201 171 202 G4double mass = fpDynamicParticle->GetMass(); 172 203 173 velocity = c_light ;174 175 204 // special case for photons 176 if ( (fOpticalPhoton !=0) && 177 (fpDynamicParticle->GetDefinition()==fOpticalPhoton) ){ 205 if ( is_OpticalPhoton ) { 178 206 179 207 G4Material* mat=0; … … 187 215 } 188 216 // check if previous step is in the same volume 189 // and get new GROUPVELO VITY table if necessary190 if ((mat != prev_mat)||(groupvel==0)) {217 // and get new GROUPVELOCITY table if necessary 218 if ((mat != 0) && ((mat != prev_mat)||(groupvel==0))) { 191 219 groupvel = 0; 192 220 if(mat->GetMaterialPropertiesTable() != 0) … … 203 231 // check if momentum is same as in the previous step 204 232 // and calculate group velocity if necessary 205 if( update_groupvel || (fpDynamicParticle->GetTotalMomentum() != prev_momentum) ) { 233 G4double current_momentum = fpDynamicParticle->GetTotalMomentum(); 234 if( update_groupvel || (current_momentum != prev_momentum) ) { 206 235 velocity = 207 groupvel->GetProperty( fpDynamicParticle->GetTotalMomentum());208 209 prev_momentum = fpDynamicParticle->GetTotalMomentum();236 groupvel->GetProperty(current_momentum); 237 prev_velocity = velocity; 238 prev_momentum = current_momentum; 210 239 } 211 240 } 212 241 213 242 } else { 243 // particles other than optical photon 214 244 if (mass<DBL_MIN) { 245 // Zero Mass 215 246 velocity = c_light; 216 247 } else { 217 G4double T = fpDynamicParticle->GetKineticEnergy(); 218 velocity = c_light*std::sqrt(T*(T+2.*mass))/(T+mass); 219 } 248 G4double T = (fpDynamicParticle->GetKineticEnergy())/mass; 249 if (T > maxT) { 250 velocity = c_light; 251 } else if (T<DBL_MIN) { 252 velocity =0.; 253 } else if (T<minT) { 254 velocity = c_light*std::sqrt(T*(T+2.))/(T+1.0); 255 } else { 256 velocity = velTable->Value(T); 257 } 258 } 259 220 260 } 221 261 222 262 return velocity ; 223 263 } 264 265 /////////////////// 266 void G4Track::PrepareVelocityTable() 267 /////////////////// 268 { 269 const G4int NBIN=300; 270 velTable = new G4PhysicsLogVector(minT, maxT, NBIN); 271 for (G4int i=0; i<=NBIN; i++){ 272 G4double T = velTable->Energy(i); 273 velTable->PutValue(i, c_light*std::sqrt(T*(T+2.))/(T+1.0) ); 274 } 275 return; 276 }
Note: See TracChangeset
for help on using the changeset viewer.