[826] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[1196] | 27 | // $Id: G4Track.cc,v 1.32 2009/04/08 08:07:24 kurasige Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
[826] | 29 | // |
---|
| 30 | // |
---|
| 31 | //--------------------------------------------------------------- |
---|
| 32 | // |
---|
| 33 | // G4Track.cc |
---|
| 34 | // |
---|
| 35 | //--------------------------------------------------------------- |
---|
| 36 | // Add copy constructor Hisaya Feb. 07 01 |
---|
| 37 | // Fix GetVelocity Hisaya Feb. 17 01 |
---|
| 38 | // Modification for G4TouchableHandle 22 Oct. 2001 R.Chytracek// |
---|
| 39 | // Fix GetVelocity (bug report #741) Horton-Smith Apr 14 2005 |
---|
[1196] | 40 | // Remove massless check in GetVelocity 02 Apr. 09 H.Kurashige |
---|
[826] | 41 | |
---|
| 42 | #include "G4Track.hh" |
---|
| 43 | |
---|
| 44 | G4Allocator<G4Track> aTrackAllocator; |
---|
| 45 | |
---|
| 46 | /////////////////////////////////////////////////////////// |
---|
| 47 | G4Track::G4Track(G4DynamicParticle* apValueDynamicParticle, |
---|
| 48 | G4double aValueTime, |
---|
| 49 | const G4ThreeVector& aValuePosition) |
---|
| 50 | /////////////////////////////////////////////////////////// |
---|
| 51 | : fCurrentStepNumber(0), fPosition(aValuePosition), |
---|
| 52 | fGlobalTime(aValueTime), fLocalTime(0.), |
---|
| 53 | fTrackLength(0.), |
---|
| 54 | fParentID(0), fTrackID(0), |
---|
| 55 | fpDynamicParticle(apValueDynamicParticle), |
---|
| 56 | fTrackStatus(fAlive), |
---|
| 57 | fBelowThreshold(false), fGoodForTracking(false), |
---|
| 58 | fStepLength(0.0), fWeight(1.0), |
---|
| 59 | fpStep(0), |
---|
| 60 | fVtxKineticEnergy(0.0), |
---|
| 61 | fpLVAtVertex(0), fpCreatorProcess(0), |
---|
| 62 | fpUserInformation(0) |
---|
| 63 | { |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | ////////////////// |
---|
| 67 | G4Track::G4Track() |
---|
| 68 | ////////////////// |
---|
| 69 | : fCurrentStepNumber(0), |
---|
| 70 | fGlobalTime(0), fLocalTime(0.), |
---|
| 71 | fTrackLength(0.), |
---|
| 72 | fParentID(0), fTrackID(0), |
---|
| 73 | fpDynamicParticle(0), |
---|
| 74 | fTrackStatus(fAlive), |
---|
| 75 | fBelowThreshold(false), fGoodForTracking(false), |
---|
| 76 | fStepLength(0.0), fWeight(1.0), |
---|
| 77 | fpStep(0), |
---|
| 78 | fVtxKineticEnergy(0.0), |
---|
| 79 | fpLVAtVertex(0), fpCreatorProcess(0), |
---|
| 80 | fpUserInformation(0) |
---|
| 81 | { |
---|
| 82 | } |
---|
| 83 | ////////////////// |
---|
| 84 | G4Track::G4Track(const G4Track& right) |
---|
| 85 | ////////////////// |
---|
| 86 | { |
---|
| 87 | *this = right; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /////////////////// |
---|
| 91 | G4Track::~G4Track() |
---|
| 92 | /////////////////// |
---|
| 93 | { |
---|
| 94 | delete fpDynamicParticle; |
---|
| 95 | delete fpUserInformation; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | ////////////////// |
---|
| 99 | G4Track & G4Track::operator=(const G4Track &right) |
---|
| 100 | ////////////////// |
---|
| 101 | { |
---|
| 102 | if (this != &right) { |
---|
| 103 | fPosition = right.fPosition; |
---|
| 104 | fGlobalTime = right.fGlobalTime; |
---|
| 105 | fLocalTime = right.fLocalTime; |
---|
| 106 | fTrackLength = right.fTrackLength; |
---|
| 107 | fWeight = right.fWeight; |
---|
| 108 | fStepLength = right.fStepLength; |
---|
| 109 | |
---|
| 110 | // Track ID (and Parent ID) is not copied and set to zero for new track |
---|
| 111 | fTrackID = 0; |
---|
| 112 | fParentID =0; |
---|
| 113 | |
---|
| 114 | // CurrentStepNumber is set to be 0 |
---|
| 115 | fCurrentStepNumber = 0; |
---|
| 116 | |
---|
| 117 | // dynamic particle information |
---|
| 118 | fpDynamicParticle = new G4DynamicParticle(*(right.fpDynamicParticle)); |
---|
| 119 | |
---|
| 120 | // track status and flags for tracking |
---|
| 121 | fTrackStatus = right.fTrackStatus; |
---|
| 122 | fBelowThreshold = right.fBelowThreshold; |
---|
| 123 | fGoodForTracking = right.fGoodForTracking; |
---|
| 124 | |
---|
| 125 | // Step information (Step Length, Step Number, pointer to the Step,) |
---|
| 126 | // are not copied |
---|
| 127 | fpStep=0; |
---|
| 128 | |
---|
| 129 | // vertex information |
---|
| 130 | fVtxPosition = right.fVtxPosition; |
---|
| 131 | fpLVAtVertex = right.fpLVAtVertex; |
---|
| 132 | fVtxKineticEnergy = right.fVtxKineticEnergy; |
---|
| 133 | fVtxMomentumDirection = right.fVtxMomentumDirection; |
---|
| 134 | |
---|
| 135 | // CreatorProcess and UserInformation are not copied |
---|
| 136 | fpCreatorProcess = 0; |
---|
| 137 | fpUserInformation = 0; |
---|
| 138 | } |
---|
| 139 | return *this; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | /////////////////// |
---|
| 143 | void G4Track::CopyTrackInfo(const G4Track& right) |
---|
| 144 | ////////////////// |
---|
| 145 | { |
---|
| 146 | *this = right; |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | #include "G4ParticleTable.hh" |
---|
| 150 | /////////////////// |
---|
| 151 | G4double G4Track::GetVelocity() const |
---|
| 152 | /////////////////// |
---|
| 153 | { |
---|
| 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 ; |
---|
| 170 | |
---|
| 171 | G4double mass = fpDynamicParticle->GetMass(); |
---|
| 172 | |
---|
[1196] | 173 | velocity = c_light ; |
---|
[826] | 174 | |
---|
[1196] | 175 | // special case for photons |
---|
| 176 | if ( (fOpticalPhoton !=0) && |
---|
| 177 | (fpDynamicParticle->GetDefinition()==fOpticalPhoton) ){ |
---|
[826] | 178 | |
---|
[1196] | 179 | G4Material* mat=0; |
---|
| 180 | G4bool update_groupvel = false; |
---|
| 181 | if ( this->GetStep() ){ |
---|
| 182 | mat= this->GetMaterial(); // Fix for repeated volumes |
---|
| 183 | }else{ |
---|
| 184 | if (fpTouchable!=0){ |
---|
| 185 | mat=fpTouchable->GetVolume()->GetLogicalVolume()->GetMaterial(); |
---|
| 186 | } |
---|
| 187 | } |
---|
| 188 | // check if previous step is in the same volume |
---|
| 189 | // and get new GROUPVELOVITY table if necessary |
---|
| 190 | if ((mat != prev_mat)||(groupvel==0)) { |
---|
| 191 | groupvel = 0; |
---|
| 192 | if(mat->GetMaterialPropertiesTable() != 0) |
---|
| 193 | groupvel = mat->GetMaterialPropertiesTable()->GetProperty("GROUPVEL"); |
---|
| 194 | update_groupvel = true; |
---|
| 195 | } |
---|
| 196 | prev_mat = mat; |
---|
| 197 | |
---|
| 198 | if (groupvel != 0 ) { |
---|
| 199 | // light velocity = c/(rindex+d(rindex)/d(log(E_phot))) |
---|
| 200 | // values stored in GROUPVEL material properties vector |
---|
| 201 | velocity = prev_velocity; |
---|
[826] | 202 | |
---|
[1196] | 203 | // check if momentum is same as in the previous step |
---|
| 204 | // and calculate group velocity if necessary |
---|
| 205 | if( update_groupvel || (fpDynamicParticle->GetTotalMomentum() != prev_momentum) ) { |
---|
| 206 | velocity = |
---|
| 207 | groupvel->GetProperty(fpDynamicParticle->GetTotalMomentum()); |
---|
[826] | 208 | prev_velocity = velocity; |
---|
[1196] | 209 | prev_momentum = fpDynamicParticle->GetTotalMomentum(); |
---|
| 210 | } |
---|
| 211 | } |
---|
[826] | 212 | |
---|
| 213 | } else { |
---|
[1196] | 214 | if (mass<DBL_MIN) { |
---|
| 215 | velocity = c_light; |
---|
| 216 | } else { |
---|
| 217 | G4double T = fpDynamicParticle->GetKineticEnergy(); |
---|
| 218 | velocity = c_light*std::sqrt(T*(T+2.*mass))/(T+mass); |
---|
| 219 | } |
---|
[826] | 220 | } |
---|
| 221 | |
---|
| 222 | return velocity ; |
---|
| 223 | } |
---|