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 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /track/src/G4Track.cc (Version 11.3.0) and /track/src/G4Track.cc (Version 1.1)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                                  7 //
 26 // G4Track class implementation                <<   8 // $Id: G4Track.cc,v 1.3 1999/12/15 14:53:56 gunter Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-01-01 $
 27 //                                                 10 //
 28 // Author: Katsuya Amako, KEK - 1996           <<  11 //
 29 // Revisions: Hisaya Kurashige, 1998-2011      <<  12 //---------------------------------------------------------------
 30 // ------------------------------------------- <<  13 //
                                                   >>  14 //  G4Track.cc
                                                   >>  15 //
                                                   >>  16 // Contact:
                                                   >>  17 //   Questions and comments to this code should be sent to
                                                   >>  18 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
                                                   >>  19 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
                                                   >>  20 //
                                                   >>  21 //---------------------------------------------------------------
 31                                                    22 
 32 #include "G4Track.hh"                              23 #include "G4Track.hh"
 33 #include "G4PhysicalConstants.hh"              << 
 34 #include "G4VAuxiliaryTrackInformation.hh"     << 
 35                                                << 
 36 #include <iostream>                            << 
 37 #include <iomanip>                             << 
 38                                                    24 
 39 // ------------------------------------------- <<  25 G4Allocator<G4Track> aTrackAllocator;
 40 G4Allocator<G4Track>*& aTrackAllocator()       << 
 41 {                                              << 
 42   G4ThreadLocalStatic G4Allocator<G4Track>* _i << 
 43   return _instance;                            << 
 44 }                                              << 
 45                                                    26 
 46 // ------------------------------------------- <<  27 ///////////////////////////////////////////////////////////
 47 G4Track::G4Track(G4DynamicParticle* apValueDyn     28 G4Track::G4Track(G4DynamicParticle* apValueDynamicParticle,
 48                  G4double aValueTime,              29                  G4double aValueTime,
 49                  const G4ThreeVector& aValuePo     30                  const G4ThreeVector& aValuePosition)
 50   : fPosition(aValuePosition)                  <<  31 ///////////////////////////////////////////////////////////
 51   , fGlobalTime(aValueTime)                    << 
 52   , fVelocity(c_light)                         << 
 53 {                                                  32 {
 54   fpDynamicParticle = (apValueDynamicParticle) <<  33    fpDynamicParticle = apValueDynamicParticle;
 55                     ? apValueDynamicParticle : <<  34    fCurrentStepNumber = 0;
 56   // check if the particle type is Optical Pho <<  35    fGlobalTime = aValueTime;
 57   is_OpticalPhoton =                           <<  36    fLocalTime = 0.;
 58     (fpDynamicParticle->GetDefinition()->GetPD <<  37    fTrackLength = 0.;
 59 }                                              <<  38    fPosition = aValuePosition;
                                                   >>  39    fpTouchable = 0;
                                                   >>  40    fpNextTouchable = 0; 
 60                                                    41 
 61 // ------------------------------------------- <<  42    fpLVAtVertex = 0;
 62 G4Track::G4Track()                             <<  43    fpCreatorProcess = 0;
 63   : fVelocity(c_light)                         << 
 64   , fpDynamicParticle(new G4DynamicParticle()) << 
 65 {}                                             << 
 66                                                << 
 67 // ------------------------------------------- << 
 68 G4Track::G4Track(const G4Track& right,G4bool c << 
 69   : fVelocity(c_light)                         << 
 70 {                                              << 
 71   fCopyTouchables = copyTouchables;            << 
 72   *this = right;                               << 
 73   fCopyTouchables = true;                      << 
 74 }                                              << 
 75                                                    44 
 76 // ------------------------------------------- <<  45    fTrackStatus = fAlive;
 77 G4Track::~G4Track()                            << 
 78 {                                              << 
 79   delete fpDynamicParticle;                    << 
 80   delete fpUserInformation;                    << 
 81   ClearAuxiliaryTrackInformation();            << 
 82 }                                              << 
 83                                                << 
 84 // ------------------------------------------- << 
 85 G4Track& G4Track::operator=(const G4Track& rig << 
 86 {                                              << 
 87   if(this != &right)                           << 
 88   {                                            << 
 89     fPosition    = right.fPosition;            << 
 90     fGlobalTime  = right.fGlobalTime;          << 
 91     fLocalTime   = right.fLocalTime;           << 
 92     fTrackLength = right.fTrackLength;         << 
 93     fWeight      = right.fWeight;              << 
 94     fStepLength  = right.fStepLength;          << 
 95                                                << 
 96     // additional fields required for geometri << 
 97     if(fCopyTouchables) {                      << 
 98       fpTouchable = right.fpTouchable;         << 
 99       fpNextTouchable = right.fpNextTouchable; << 
100       fpOriginTouchable = right.fpOriginToucha << 
101     }                                          << 
102                                                << 
103     // Track ID (and Parent ID) is not copied  << 
104     fTrackID  = 0;                             << 
105     fParentID = 0;                             << 
106                                                << 
107     // CurrentStepNumber is set to be 0        << 
108     fCurrentStepNumber = 0;                    << 
109                                                << 
110     // Creator model ID                        << 
111     fCreatorModelID = right.fCreatorModelID;   << 
112                                                << 
113     // Parent resonance                        << 
114     fParentResonanceDef = right.fParentResonan << 
115     fParentResonanceID  = right.fParentResonan << 
116                                                << 
117     // velocity information                    << 
118     fVelocity = right.fVelocity;               << 
119                                                << 
120     // dynamic particle information            << 
121     delete fpDynamicParticle;                  << 
122     fpDynamicParticle = new G4DynamicParticle( << 
123                                                << 
124     // track status and flags for tracking     << 
125     fTrackStatus     = right.fTrackStatus;     << 
126     fBelowThreshold  = right.fBelowThreshold;  << 
127     fGoodForTracking = right.fGoodForTracking; << 
128                                                << 
129     // Step information (Step Length, Step Num << 
130     // are not copied                          << 
131     fpStep = nullptr;                          << 
132                                                << 
133     // vertex information                      << 
134     fVtxPosition          = right.fVtxPosition << 
135     fpLVAtVertex          = right.fpLVAtVertex << 
136     fVtxKineticEnergy     = right.fVtxKineticE << 
137     fVtxMomentumDirection = right.fVtxMomentum << 
138                                                << 
139     // CreatorProcess and UserInformation are  << 
140     fpCreatorProcess = nullptr;                << 
141     delete fpUserInformation;                  << 
142     fpUserInformation = nullptr;               << 
143                                                << 
144     prev_mat      = right.prev_mat;            << 
145     groupvel      = right.groupvel;            << 
146     prev_velocity = right.prev_velocity;       << 
147     prev_momentum = right.prev_momentum;       << 
148                                                    46 
149     is_OpticalPhoton = right.is_OpticalPhoton; <<  47    fBelowThreshold = false;
150     useGivenVelocity = right.useGivenVelocity; <<  48    fGoodForTracking = false;
151                                                <<  49    fWeight = 1.0;
152     ClearAuxiliaryTrackInformation();          << 
153   }                                            << 
154   return *this;                                << 
155 }                                                  50 }
156                                                    51 
157 // ------------------------------------------- <<  52 //////////////////
158 void G4Track::CopyTrackInfo(const G4Track& rig <<  53 G4Track::G4Track()
                                                   >>  54 //////////////////
159 {                                                  55 {
160   fCopyTouchables = copyTouchables;            <<  56    fCurrentStepNumber = 0;
161   *this = right;                               <<  57    fGlobalTime = 0.;
162   fCopyTouchables = true;                      <<  58    fLocalTime = 0.;
                                                   >>  59    fTrackLength = 0.;
                                                   >>  60    fParentID = 0;
                                                   >>  61    fTrackID = 0;
                                                   >>  62    fpTouchable = 0;
                                                   >>  63    fpNextTouchable = 0;
                                                   >>  64 
                                                   >>  65    fpDynamicParticle = 0;
                                                   >>  66    fpLVAtVertex = 0;
                                                   >>  67    fpCreatorProcess = 0;
                                                   >>  68 
                                                   >>  69    fTrackStatus = fAlive;
                                                   >>  70    fBelowThreshold = false;
                                                   >>  71    fGoodForTracking = false;
                                                   >>  72    fWeight = 1.0;
163 }                                                  73 }
164                                                    74 
165 // ------------------------------------------- <<  75 ///////////////////
166 G4double G4Track::CalculateVelocityForOpticalP <<  76 G4Track::~G4Track()
                                                   >>  77 ///////////////////
167 {                                                  78 {
168   G4double velocity = c_light;                 <<  79    delete fpDynamicParticle;
                                                   >>  80 }
169                                                    81 
170   G4Material* mat        = nullptr;            <<  82 ///////////////////
171   G4bool update_groupvel = false;              <<  83 G4double G4Track::GetVelocity() const
172   if(fpStep != nullptr)                        <<  84 ///////////////////
173   {                                            <<  85 { 
174     mat = this->GetMaterial();  //   Fix for r <<  86   G4double velocity ;
175   }                                            <<  87   
176   else                                         <<  88   G4double mass = fpDynamicParticle->GetMass();
177   {                                            << 
178     if(fpTouchable)                            << 
179     {                                          << 
180       mat = fpTouchable->GetVolume()->GetLogic << 
181     }                                          << 
182   }                                            << 
183   // check if previous step is in the same vol << 
184   //  and get new GROUPVELOCITY table if neces << 
185   if((mat != nullptr) && ((mat != prev_mat) || << 
186   {                                            << 
187     groupvel = nullptr;                        << 
188     if(mat->GetMaterialPropertiesTable() != nu << 
189       groupvel = mat->GetMaterialPropertiesTab << 
190     update_groupvel = true;                    << 
191   }                                            << 
192   prev_mat = mat;                              << 
193                                                    89 
194   if(groupvel != nullptr)                      <<  90   // mass less particle  
195   {                                            <<  91   if( mass == 0. ){
196     // light velocity = c/(rindex+d(rindex)/d( <<  92     velocity = c_light ; 
197     // values stored in GROUPVEL material prop <<  93     G4String name = fpDynamicParticle->GetDefinition()->GetParticleName();
198     velocity = prev_velocity;                  <<  94 
199                                                <<  95     // special case for photons
200     // check if momentum is same as in the pre <<  96     if(( name=="gamma")||(name=="opticalphoton")){
201     //  and calculate group velocity if necess <<  97       G4Material*
202     G4double current_momentum = fpDynamicParti <<  98   mat=fpTouchable->GetVolume()->GetLogicalVolume()->GetMaterial();
203     if(update_groupvel || (current_momentum != <<  99  
204     {                                          << 100       if(mat->GetMaterialPropertiesTable() != 0){
205       velocity      = groupvel->Value(current_ << 101   if(mat->GetMaterialPropertiesTable()->GetProperty("RINDEX") != 0 ){ 
206       prev_velocity = velocity;                << 102           // light velocity = c/reflection-index 
207       prev_momentum = current_momentum;        << 103     velocity /= 
                                                   >> 104       mat->GetMaterialPropertiesTable()->GetProperty("RINDEX")->
                                                   >> 105       GetMinProperty() ; 
                                                   >> 106   }
                                                   >> 107       }  
208     }                                             108     }
                                                   >> 109   } else {
                                                   >> 110     G4double T = fpDynamicParticle->GetKineticEnergy();
                                                   >> 111     velocity = c_light*sqrt(T*(T+2.*mass))/(T+mass) ;
209   }                                               112   }
210                                                << 
211   return velocity;                             << 
212 }                                              << 
213                                                << 
214 // ------------------------------------------- << 
215 void G4Track::SetAuxiliaryTrackInformation(G4i << 
216               G4VAuxiliaryTrackInformation* in << 
217 {                                              << 
218   if(fpAuxiliaryTrackInformationMap == nullptr << 
219   {                                            << 
220     fpAuxiliaryTrackInformationMap =           << 
221       new std::map<G4int, G4VAuxiliaryTrackInf << 
222   }                                            << 
223   if(G4PhysicsModelCatalog::GetModelIndex(id)  << 
224   {                                            << 
225     G4ExceptionDescription ED;                 << 
226     ED << "Process/model ID <" << id << "> is  << 
227     G4Exception("G4VAuxiliaryTrackInformation: << 
228                 "TRACK0982", FatalException, E << 
229   }                                            << 
230   (*fpAuxiliaryTrackInformationMap)[id] = info << 
231 }                                              << 
232                                                << 
233 // ------------------------------------------- << 
234 G4VAuxiliaryTrackInformation*                  << 
235 G4Track::GetAuxiliaryTrackInformation(G4int id << 
236 {                                              << 
237   if(fpAuxiliaryTrackInformationMap == nullptr << 
238     return nullptr;                            << 
239                                                   113   
240   auto itr = fpAuxiliaryTrackInformationMap->f << 114   return velocity ; 
241   if(itr == fpAuxiliaryTrackInformationMap->ce << 
242     return nullptr;                            << 
243   return (*itr).second;                        << 
244 }                                                 115 }
                                                   >> 116  
245                                                   117 
246 // ------------------------------------------- << 
247 void G4Track::RemoveAuxiliaryTrackInformation( << 
248 {                                              << 
249   if(fpAuxiliaryTrackInformationMap != nullptr << 
250      fpAuxiliaryTrackInformationMap->find(id)  << 
251   {                                            << 
252     fpAuxiliaryTrackInformationMap->erase(id); << 
253   }                                            << 
254 }                                              << 
255                                                   118 
256 // ------------------------------------------- << 
257 void G4Track::RemoveAuxiliaryTrackInformation( << 
258 {                                              << 
259   if(fpAuxiliaryTrackInformationMap != nullptr << 
260   {                                            << 
261     G4int id = G4PhysicsModelCatalog::GetModel << 
262     RemoveAuxiliaryTrackInformation(id);       << 
263   }                                            << 
264 }                                              << 
265                                                   119 
266 // ------------------------------------------- << 
267 void G4Track::ClearAuxiliaryTrackInformation() << 
268 {                                              << 
269   if(fpAuxiliaryTrackInformationMap == nullptr << 
270     return;                                    << 
271   for(const auto& itr : *fpAuxiliaryTrackInfor << 
272   {                                            << 
273     delete itr.second;                         << 
274   }                                            << 
275   delete fpAuxiliaryTrackInformationMap;       << 
276   fpAuxiliaryTrackInformationMap = nullptr;    << 
277 }                                              << 
278                                                   120