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[ 10.5.p1 ] [ 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/G4ParticleChangeForDecay.cc (Version 11.3.0) and /track/src/G4ParticleChangeForDecay.cc (Version 10.6.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ParticleChangeForDecay class implementati << 
 27 //                                                 26 //
 28 // Author: Hisaya Kurashige, 23 March 1998     <<  27 //
 29 // ------------------------------------------- <<  28 // 
                                                   >>  29 // --------------------------------------------------------------
                                                   >>  30 //  GEANT 4 class implementation file 
                                                   >>  31 //
                                                   >>  32 //  
                                                   >>  33 //  
                                                   >>  34 // ------------------------------------------------------------
                                                   >>  35 //   Implemented for the new scheme                 23 Mar. 1998  H.Kurahige
                                                   >>  36 //   Remove modification of energy/momentum         20 Jul, 1998  H.Kurashige
                                                   >>  37 // --------------------------------------------------------------
 30                                                    38 
 31 #include "G4ParticleChangeForDecay.hh"             39 #include "G4ParticleChangeForDecay.hh"
 32 #include "G4SystemOfUnits.hh"                      40 #include "G4SystemOfUnits.hh"
 33 #include "G4Track.hh"                              41 #include "G4Track.hh"
 34 #include "G4Step.hh"                               42 #include "G4Step.hh"
                                                   >>  43 #include "G4TrackFastVector.hh"
 35 #include "G4DynamicParticle.hh"                    44 #include "G4DynamicParticle.hh"
 36 #include "G4ExceptionSeverity.hh"                  45 #include "G4ExceptionSeverity.hh"
 37                                                    46 
 38 // ------------------------------------------- << 
 39 G4ParticleChangeForDecay::G4ParticleChangeForD     47 G4ParticleChangeForDecay::G4ParticleChangeForDecay()
 40 {}                                             <<  48   : G4VParticleChange(), 
                                                   >>  49     theGlobalTime0(0.),theLocalTime0(0.),theTimeChange(0.)
                                                   >>  50 {
                                                   >>  51 #ifdef G4VERBOSE
                                                   >>  52   if (verboseLevel>2) {
                                                   >>  53     G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl;
                                                   >>  54   }
                                                   >>  55 #endif
                                                   >>  56 }
                                                   >>  57 
                                                   >>  58 G4ParticleChangeForDecay::~G4ParticleChangeForDecay() 
                                                   >>  59 {
                                                   >>  60 #ifdef G4VERBOSE
                                                   >>  61   if (verboseLevel>2) {
                                                   >>  62     G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl;
                                                   >>  63   }
                                                   >>  64 #endif
                                                   >>  65 }
 41                                                    66 
 42 // ------------------------------------------- <<  67 G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right)
                                                   >>  68 {
                                                   >>  69   theGlobalTime0 = right.theGlobalTime0;
                                                   >>  70   theLocalTime0 = right.theLocalTime0;
                                                   >>  71   theTimeChange = right.theTimeChange;
                                                   >>  72   thePolarizationChange = right.thePolarizationChange;
                                                   >>  73 }
                                                   >>  74 
                                                   >>  75 
                                                   >>  76 G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right)
                                                   >>  77 {
                                                   >>  78   if (this != &right){
                                                   >>  79     if (theNumberOfSecondaries>0) {
                                                   >>  80 #ifdef G4VERBOSE
                                                   >>  81       if (verboseLevel>0) {
                                                   >>  82   G4cout << "G4ParticleChangeForDecay: assignment operator Warning  ";
                                                   >>  83   G4cout << "theListOfSecondaries is not empty ";
                                                   >>  84        }
                                                   >>  85 #endif
                                                   >>  86       for (G4int index= 0; index<theNumberOfSecondaries; index++){
                                                   >>  87   if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
                                                   >>  88       }
                                                   >>  89     }
                                                   >>  90     delete theListOfSecondaries; 
                                                   >>  91     theListOfSecondaries =  new G4TrackFastVector();
                                                   >>  92     theNumberOfSecondaries = right.theNumberOfSecondaries;
                                                   >>  93     for (G4int index = 0; index<theNumberOfSecondaries; index++){
                                                   >>  94       G4Track* newTrack =  new G4Track(*((*right.theListOfSecondaries)[index] ));
                                                   >>  95       theListOfSecondaries->SetElement(index, newTrack);          }
                                                   >>  96 
                                                   >>  97     theStatusChange = right.theStatusChange;
                                                   >>  98     theTrueStepLength = right.theTrueStepLength;
                                                   >>  99     theLocalEnergyDeposit = right.theLocalEnergyDeposit;
                                                   >> 100     theSteppingControlFlag = right.theSteppingControlFlag;
                                                   >> 101     
                                                   >> 102     theGlobalTime0 = right.theGlobalTime0;
                                                   >> 103     theLocalTime0 = right.theLocalTime0;
                                                   >> 104     theTimeChange = right.theTimeChange;
                                                   >> 105     thePolarizationChange = right.thePolarizationChange;
                                                   >> 106   }
                                                   >> 107   return *this;
                                                   >> 108 }
                                                   >> 109 
                                                   >> 110 G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const
                                                   >> 111 {
                                                   >> 112    return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
                                                   >> 113 }
                                                   >> 114 
                                                   >> 115 G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const
                                                   >> 116 {
                                                   >> 117    return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
                                                   >> 118 }
                                                   >> 119 
                                                   >> 120 //----------------------------------------------------------------
                                                   >> 121 // methods for Initialization
                                                   >> 122 //
 43 void G4ParticleChangeForDecay::Initialize(cons    123 void G4ParticleChangeForDecay::Initialize(const G4Track& track)
 44 {                                                 124 {
 45   // use base class's method at first             125   // use base class's method at first
 46   G4VParticleChange::Initialize(track);           126   G4VParticleChange::Initialize(track);
 47                                                   127 
                                                   >> 128   const G4DynamicParticle*  pParticle = track.GetDynamicParticle();
                                                   >> 129 
 48   // set TimeChange equal to local time of the    130   // set TimeChange equal to local time of the parent track
 49   theLocalTime0 = theTimeChange = track.GetLoc << 131   theTimeChange                = track.GetLocalTime();
 50                                                   132 
 51   // set initial Local/Global time of the pare    133   // set initial Local/Global time of the parent track
 52   theGlobalTime0 = track.GetGlobalTime();      << 134   theLocalTime0           = track.GetLocalTime();
                                                   >> 135   theGlobalTime0          = track.GetGlobalTime();
 53                                                   136 
 54   // set the Polarization equal to those of th    137   // set the Polarization equal to those of the parent track
 55   thePolarizationChange = track.GetDynamicPart << 138   thePolarizationChange  = pParticle->GetPolarization();
 56 }                                                 139 }
 57                                                   140 
 58 // ------------------------------------------- << 141 //----------------------------------------------------------------
                                                   >> 142 // methods for updating G4Step 
                                                   >> 143 //
                                                   >> 144 
 59 G4Step* G4ParticleChangeForDecay::UpdateStepFo    145 G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep)
 60 {                                              << 146 { 
 61   G4StepPoint* pPostStepPoint = pStep->GetPost << 147   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 
 62                                                   148 
 63   if(isParentWeightProposed)                   << 149   if (isParentWeightProposed ){
 64   {                                            << 150     pPostStepPoint->SetWeight( theParentWeight );
 65     pPostStepPoint->SetWeight(theParentWeight) << 
 66   }                                               151   }
 67   // update polarization                          152   // update polarization
 68   pPostStepPoint->SetPolarization(thePolarizat << 153   pPostStepPoint->SetPolarization( thePolarizationChange );
 69                                                   154 
 70   // update the G4Step specific attributes     << 155   //  Update the G4Step specific attributes 
 71   return UpdateStepInfo(pStep);                   156   return UpdateStepInfo(pStep);
 72 }                                                 157 }
 73                                                   158 
 74 // ------------------------------------------- << 159 
 75 G4Step* G4ParticleChangeForDecay::UpdateStepFo    160 G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep)
 76 {                                              << 161 { 
 77   // A physics process always calculates the f    162   // A physics process always calculates the final state of the particle
 78                                                   163 
 79   G4StepPoint* pPostStepPoint = pStep->GetPost << 164   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 
 80                                                   165 
 81   // update polarization                          166   // update polarization
 82   pPostStepPoint->SetPolarization(thePolarizat << 167   pPostStepPoint->SetPolarization( thePolarizationChange );
 83                                                << 168  
 84   // update time                                  169   // update time
 85   pPostStepPoint->SetGlobalTime(GetGlobalTime( << 170   pPostStepPoint->SetGlobalTime( GetGlobalTime() );
 86   pPostStepPoint->SetLocalTime(theTimeChange); << 171   pPostStepPoint->SetLocalTime(  theTimeChange ); 
 87   pPostStepPoint->AddProperTime(theTimeChange  << 172   pPostStepPoint->AddProperTime (theTimeChange-theLocalTime0);
 88                                                   173 
 89 #ifdef G4VERBOSE                                  174 #ifdef G4VERBOSE
 90   if(debugFlag) { CheckIt(*theCurrentTrack); } << 175   G4Track*     aTrack  = pStep->GetTrack();
                                                   >> 176   if (debugFlag) CheckIt(*aTrack);
 91 #endif                                            177 #endif
 92                                                   178 
 93   if(isParentWeightProposed)                   << 179   if (isParentWeightProposed )pPostStepPoint->SetWeight( theParentWeight );
 94     pPostStepPoint->SetWeight(theParentWeight) << 
 95                                                   180 
 96   //  Update the G4Step specific attributes    << 181   //  Update the G4Step specific attributes 
 97   return UpdateStepInfo(pStep);                   182   return UpdateStepInfo(pStep);
 98 }                                                 183 }
 99                                                   184 
100 // ------------------------------------------- << 
101 void G4ParticleChangeForDecay::DumpInfo() cons    185 void G4ParticleChangeForDecay::DumpInfo() const
102 {                                                 186 {
103   // Show header                               << 187 // Show header
104   G4VParticleChange::DumpInfo();                  188   G4VParticleChange::DumpInfo();
105                                                   189 
106   G4long oldprc = G4cout.precision(8);         << 190   G4int oldprc = G4cout.precision(3);
107   G4cout << "      --------------------------- << 191   G4cout << " proposed local Time (ns)     : " 
108   G4cout << "    G4ParticleChangeForDecay prop << 192          << std::setw(20) << theTimeChange/ns << G4endl;
109   G4cout << "    Proposed local Time (ns): " < << 193   G4cout << " initial local Time (ns)      : "
110          << theTimeChange / ns << G4endl;      << 194    << std::setw(20) << theLocalTime0/ns << G4endl;
111   G4cout << "    Initial local Time (ns) : " < << 195   G4cout << " initial global Time (ns)      : "
112          << theLocalTime0 / ns << G4endl;      << 196    << std::setw(20) << theGlobalTime0/ns << G4endl;
113   G4cout << "    Initial global Time (ns): " < << 
114          << theGlobalTime0 / ns << G4endl;     << 
115   G4cout << "    Current global Time (ns): " < << 
116          << theCurrentTrack->GetGlobalTime() / << 
117   G4cout.precision(oldprc);                       197   G4cout.precision(oldprc);
118 }                                                 198 }
119                                                   199 
120 // ------------------------------------------- << 
121 G4bool G4ParticleChangeForDecay::CheckIt(const    200 G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack)
122 {                                                 201 {
                                                   >> 202   G4bool    exitWithError = false;
                                                   >> 203 
                                                   >> 204   G4double  accuracy;
                                                   >> 205 
123   // local time should not go back                206   // local time should not go back
124   G4bool itsOK = true;                         << 207   G4bool itsOK =true;
125   if(theTimeChange < theLocalTime0)            << 208   accuracy = -1.0*(theTimeChange - theLocalTime0)/ns;
126   {                                            << 209   if (accuracy > accuracyForWarning) {
127     itsOK         = false;                     << 210     itsOK = false;
128     ++nError;                                  << 211     exitWithError = (accuracy > accuracyForException);
129 #ifdef G4VERBOSE                               << 212 #ifdef G4VERBOSE
130     if(nError < maxError)                      << 213     G4cout << "  G4ParticleChangeForDecay::CheckIt    : ";
131     {                                          << 214     G4cout << "the local time goes back  !!" 
132       G4cout << "  G4ParticleChangeForDecay::C << 215      << "  Difference:  " << accuracy  << "[ns] " <<G4endl;
133       G4cout << "the local time goes back  !!" << 216     G4cout << "initial local time "<< theLocalTime0/ns <<   "[ns] " 
134        << "  Difference:  " << (theTimeChange  << 217      << "initial global time "<< theGlobalTime0/ns  << "[ns] " <<G4endl;
135              << "[ns] " << G4endl;             << 218     G4cout << aTrack.GetDefinition()->GetParticleName()
136       G4cout << "initial local time " << theLo << 219      << " E=" << aTrack.GetKineticEnergy()/MeV
137        << "initial global time " << theGlobalT << 220      << " pos=" << aTrack.GetPosition().x()/m
138        << G4endl;                              << 221      << ", " << aTrack.GetPosition().y()/m
139     }                                          << 222      << ", " << aTrack.GetPosition().z()/m
                                                   >> 223      <<G4endl;
140 #endif                                            224 #endif
141     theTimeChange = theLocalTime0;             << 
142   }                                               225   }
143                                                   226 
144   if(!itsOK)                                   << 227   // dump out information of this particle change
145   {                                            << 
146     if(nError < maxError)                      << 
147     {                                          << 
148 #ifdef G4VERBOSE                                  228 #ifdef G4VERBOSE
149       // dump out information of this particle << 229   if (!itsOK) DumpInfo();
150       DumpInfo();                              << 
151 #endif                                            230 #endif
152       G4Exception("G4ParticleChangeForDecay::C << 231 
153                   JustWarning, "time is illega << 232   // Exit with error
154     }                                          << 233   if (exitWithError) {
                                                   >> 234     G4Exception("G4ParticleChangeForDecay::CheckIt",
                                                   >> 235     "TRACK005",EventMustBeAborted,
                                                   >> 236     "time was  illegal");
                                                   >> 237   } 
                                                   >> 238 
                                                   >> 239   // correction
                                                   >> 240   if (!itsOK) {
                                                   >> 241     theTimeChange = aTrack.GetLocalTime();
155   }                                               242   }
156                                                   243 
157   return (itsOK) && G4VParticleChange::CheckIt << 244   itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
                                                   >> 245   return itsOK;
158 }                                                 246 }
                                                   >> 247 
                                                   >> 248 
                                                   >> 249 
                                                   >> 250 
                                                   >> 251 
159                                                   252