Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/decay/src/G4Decay.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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 /processes/decay/src/G4Decay.cc (Version 11.3.0) and /processes/decay/src/G4Decay.cc (Version 8.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                                 23 //
                                                   >>  24 // $Id: G4Decay.cc,v 1.21 2005/11/21 18:06:07 asaim Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-08-00 $
 27 //                                                 26 //
 28 //                                                 27 // 
 29 // -------------------------------------------     28 // --------------------------------------------------------------
 30 //      GEANT 4 class implementation file          29 //      GEANT 4 class implementation file
 31 //                                                 30 //
 32 //      History: first implementation, based o     31 //      History: first implementation, based on object model of
 33 //      2nd December 1995, G.Cosmo                 32 //      2nd December 1995, G.Cosmo
 34 //      7 July 1996 H.Kurashige                    33 //      7 July 1996 H.Kurashige
 35 // -------------------------------------------     34 // ------------------------------------------------------------
 36 //   remove  BuildPhysicsTable()  28 Nov. 1997     35 //   remove  BuildPhysicsTable()  28 Nov. 1997  H.Kurashige
 37 //   change  DBL_EPSIRON to DBL_MIN 14 Dec. 19     36 //   change  DBL_EPSIRON to DBL_MIN 14 Dec. 1997  H.Kurashige
 38 //   modified for new ParticleChange 12 Mar. 1     37 //   modified for new ParticleChange 12 Mar. 1998  H.Kurashige
 39 //   modified for "GoodForTrackingFlag" 19 Jun     38 //   modified for "GoodForTrackingFlag" 19 June 1998  H.Kurashige
 40 //   rename thePhysicsTable to aPhyscisTable 2     39 //   rename thePhysicsTable to aPhyscisTable 2 Aug. 1998 H.Kurashige
 41 //   modified IsApplicable in order to protect     40 //   modified IsApplicable in order to protect the decay from registered 
 42 //   to resonances    12 Dec. 1998   H.Kurashi     41 //   to resonances    12 Dec. 1998   H.Kurashige 
 43 //   remove G4ParticleMomentum  6 Feb. 99 H.Ku     42 //   remove G4ParticleMomentum  6 Feb. 99 H.Kurashige
 44 //   modified  IsApplicable to activate G4Deca     43 //   modified  IsApplicable to activate G4Decay for resonances  1 Mar. 00 H.Kurashige 
 45 //   Add External Decayer         23 Feb. 2001     44 //   Add External Decayer         23 Feb. 2001  H.Kurashige
 46 //   change LowestBinValue,HighestBinValue and     45 //   change LowestBinValue,HighestBinValue and TotBin(200) 9 Feb. 2002
 47 //                                                 46 //
 48                                                    47 
 49 #include "G4Decay.hh"                              48 #include "G4Decay.hh"
 50                                                << 
 51 #include "G4PhysicalConstants.hh"              << 
 52 #include "G4SystemOfUnits.hh"                  << 
 53 #include "G4DynamicParticle.hh"                    49 #include "G4DynamicParticle.hh"
 54 #include "G4DecayProducts.hh"                      50 #include "G4DecayProducts.hh"
 55 #include "G4DecayTable.hh"                         51 #include "G4DecayTable.hh"
 56 #include "G4VDecayChannel.hh"                  << 
 57 #include "G4PhysicsLogVector.hh"                   52 #include "G4PhysicsLogVector.hh"
 58 #include "G4ParticleChangeForDecay.hh"             53 #include "G4ParticleChangeForDecay.hh"
 59 #include "G4VExtDecayer.hh"                        54 #include "G4VExtDecayer.hh"
 60                                                    55 
 61 // constructor                                     56 // constructor
 62 G4Decay::G4Decay(const G4String& processName)      57 G4Decay::G4Decay(const G4String& processName)
 63                                :G4VRestDiscret     58                                :G4VRestDiscreteProcess(processName, fDecay),
 64         verboseLevel(1),                           59         verboseLevel(1),
 65                                 HighestValue(2     60                                 HighestValue(20.0),
 66         fRemainderLifeTime(-1.0),              <<  61                                 pExtDecayer(0)
 67                                 pExtDecayer(nu << 
 68 {                                                  62 {
 69   // set Process Sub Type                      << 
 70   SetProcessSubType(static_cast<int>(DECAY));  << 
 71                                                << 
 72 #ifdef G4VERBOSE                                   63 #ifdef G4VERBOSE
 73   if (GetVerboseLevel()>1) {                       64   if (GetVerboseLevel()>1) {
 74     G4cout << "G4Decay  constructor " << "  Na <<  65     G4cerr << "G4Decay  constructor " << "  Name:" << processName << G4endl;
 75   }                                                66   }
 76 #endif                                             67 #endif
 77                                                << 
 78   pParticleChange = &fParticleChangeForDecay;      68   pParticleChange = &fParticleChangeForDecay;
 79 }                                                  69 }
 80                                                    70 
 81 G4Decay::~G4Decay()                                71 G4Decay::~G4Decay()
 82 {                                                  72 {
 83   if (pExtDecayer != nullptr) {                <<  73   if (pExtDecayer) {
 84     delete pExtDecayer;                            74     delete pExtDecayer;
 85   }                                                75   }
 86 }                                                  76 }
 87                                                    77 
 88 G4bool G4Decay::IsApplicable(const G4ParticleD     78 G4bool G4Decay::IsApplicable(const G4ParticleDefinition& aParticleType)
 89 {                                                  79 {
 90    // check if the particle is stable?             80    // check if the particle is stable?
 91    if (aParticleType.GetPDGLifeTime() <0.0) {      81    if (aParticleType.GetPDGLifeTime() <0.0) {
 92      return false;                                 82      return false;
 93    } else if (aParticleType.GetPDGMass() <= 0.     83    } else if (aParticleType.GetPDGMass() <= 0.0*MeV) {
 94      return false;                                 84      return false;
 95    } else {                                        85    } else {
 96      return true;                                  86      return true; 
 97    }                                               87    }
 98 }                                                  88 }
 99                                                    89 
100 G4double G4Decay::GetMeanLifeTime(const G4Trac     90 G4double G4Decay::GetMeanLifeTime(const G4Track& aTrack  ,
101                                   G4ForceCondi     91                                   G4ForceCondition*)
102 {                                                  92 {
103    // returns the mean free path in GEANT4 int     93    // returns the mean free path in GEANT4 internal units
104    G4double meanlife;                              94    G4double meanlife;
105                                                    95 
106    // get particle                                 96    // get particle 
107    const G4DynamicParticle* aParticle = aTrack     97    const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
108    const G4ParticleDefinition* aParticleDef =  <<  98    G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
109    G4double aLife = aParticleDef->GetPDGLifeTi     99    G4double aLife = aParticleDef->GetPDGLifeTime();
110                                                   100 
111    // check if the particle is stable?            101    // check if the particle is stable?
112    if (aParticleDef->GetPDGStable()) {            102    if (aParticleDef->GetPDGStable()) {
113     //1000000 times the life time of the unive << 103      meanlife = DBL_MAX;
114      meanlife = 1e24 * s;                      << 
115                                                   104     
116    } else {                                       105    } else {
117      meanlife = aLife;                            106      meanlife = aLife;
118    }                                              107    }
119                                                   108 
120 #ifdef G4VERBOSE                                  109 #ifdef G4VERBOSE
121    if (GetVerboseLevel()>1) {                     110    if (GetVerboseLevel()>1) {
122      G4cout << "mean life time: "<< meanlife/n    111      G4cout << "mean life time: "<< meanlife/ns << "[ns]" << G4endl;
123    }                                              112    }
124 #endif                                            113 #endif
125                                                   114 
126    return  meanlife;                              115    return  meanlife;
127 }                                                 116 }
128                                                   117 
129 G4double G4Decay::GetMeanFreePath(const G4Trac    118 G4double G4Decay::GetMeanFreePath(const G4Track& aTrack,G4double, G4ForceCondition*)
130 {                                                 119 {
131    // get particle                                120    // get particle 
132    const G4DynamicParticle* aParticle = aTrack    121    const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
133    const G4ParticleDefinition* aParticleDef =  << 122    G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
134    G4double aMass = aParticle->GetMass();         123    G4double aMass = aParticle->GetMass();
135    G4double aLife = aParticleDef->GetPDGLifeTi    124    G4double aLife = aParticleDef->GetPDGLifeTime();
136                                                   125 
137                                                   126 
138     // returns the mean free path in GEANT4 in    127     // returns the mean free path in GEANT4 internal units
139    G4double pathlength;                           128    G4double pathlength;
140    G4double aCtau = c_light * aLife;              129    G4double aCtau = c_light * aLife;
141                                                   130 
142    // check if the particle is stable?            131    // check if the particle is stable?
143    if (aParticleDef->GetPDGStable()) {            132    if (aParticleDef->GetPDGStable()) {
144      pathlength = DBL_MAX;                        133      pathlength = DBL_MAX;
145                                                   134 
146    //check if the particle has very short life    135    //check if the particle has very short life time ?
147    } else if (aCtau < DBL_MIN) {                  136    } else if (aCtau < DBL_MIN) { 
148      pathlength =  DBL_MIN;                       137      pathlength =  DBL_MIN;
149                                                   138  
150    } else {                                       139    } else {
151     //calculate the mean free path                140     //calculate the mean free path 
152     // by using normalized kinetic energy (= E    141     // by using normalized kinetic energy (= Ekin/mass)
153      G4double   rKineticEnergy = aParticle->Ge    142      G4double   rKineticEnergy = aParticle->GetKineticEnergy()/aMass; 
154      if ( rKineticEnergy > HighestValue) {        143      if ( rKineticEnergy > HighestValue) {
155        // gamma >>  1                             144        // gamma >>  1
156        pathlength = ( rKineticEnergy + 1.0)* a    145        pathlength = ( rKineticEnergy + 1.0)* aCtau;
157      } else if ( rKineticEnergy < DBL_MIN ) {     146      } else if ( rKineticEnergy < DBL_MIN ) {
158        // too slow particle                       147        // too slow particle
159 #ifdef G4VERBOSE                                  148 #ifdef G4VERBOSE
160        if (GetVerboseLevel()>1) {                 149        if (GetVerboseLevel()>1) {
161    G4cout << "G4Decay::GetMeanFreePath()   !!p << 150    G4cerr << "G4Decay::GetMeanFreePath()   !!particle stops!!";
162          G4cout << aParticleDef->GetParticleNa << 151          G4cerr << aParticleDef->GetParticleName() << G4endl;
163    G4cout << "KineticEnergy:" << aParticle->Ge << 152    G4cerr << "KineticEnergy:" << aParticle->GetKineticEnergy()/GeV <<"[GeV]";
164        }                                          153        }
165 #endif                                            154 #endif
166        pathlength = DBL_MIN;                      155        pathlength = DBL_MIN;
167      } else {                                     156      } else {
168        // beta <1                                 157        // beta <1 
169        pathlength = (aParticle->GetTotalMoment    158        pathlength = (aParticle->GetTotalMomentum())/aMass*aCtau ;
170      }                                            159      }
171    }                                              160    }
172   return  pathlength;                             161   return  pathlength;
173 }                                                 162 }
174                                                   163 
175 void G4Decay::BuildPhysicsTable(const G4Partic    164 void G4Decay::BuildPhysicsTable(const G4ParticleDefinition&)
176 {                                                 165 {
177   return;                                         166   return;
178 }                                                 167 }
179                                                   168 
180 G4VParticleChange* G4Decay::DecayIt(const G4Tr    169 G4VParticleChange* G4Decay::DecayIt(const G4Track& aTrack, const G4Step& )
181 {                                                 170 {
182   // The DecayIt() method returns by pointer a    171   // The DecayIt() method returns by pointer a particle-change object.
183   // Units are expressed in GEANT4 internal un    172   // Units are expressed in GEANT4 internal units.
184                                                   173 
185   //   Initialize ParticleChange                  174   //   Initialize ParticleChange
186   //     all members of G4VParticleChange are     175   //     all members of G4VParticleChange are set to equal to 
187   //     corresponding member in G4Track          176   //     corresponding member in G4Track
188   fParticleChangeForDecay.Initialize(aTrack);     177   fParticleChangeForDecay.Initialize(aTrack);
189                                                   178 
190   // get particle                                 179   // get particle 
191   const G4DynamicParticle* aParticle = aTrack.    180   const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
192   const G4ParticleDefinition* aParticleDef = a << 181   G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
193                                                   182 
194   // check if  the particle is stable             183   // check if  the particle is stable
195   if (aParticleDef->GetPDGStable()) return &fP    184   if (aParticleDef->GetPDGStable()) return &fParticleChangeForDecay ;
196                                                   185  
197                                                   186 
198   //check if thePreAssignedDecayProducts exist    187   //check if thePreAssignedDecayProducts exists
199   const G4DecayProducts* o_products = (aPartic    188   const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts());
200   G4bool isPreAssigned = (o_products != nullpt << 189   G4bool isPreAssigned = (o_products != 0);   
201   G4DecayProducts* products = nullptr;         << 190   G4DecayProducts* products = 0;
202                                                   191 
203   // decay table                                  192   // decay table
204   G4DecayTable   *decaytable = aParticleDef->G    193   G4DecayTable   *decaytable = aParticleDef->GetDecayTable();
205                                                   194  
206   // check if external decayer exists             195   // check if external decayer exists
207   G4bool isExtDecayer = (decaytable == nullptr << 196   G4bool isExtDecayer = (decaytable == 0) && (pExtDecayer !=0);
208                                                   197 
209   // Error due to NO Decay Table                  198   // Error due to NO Decay Table 
210   if ( (decaytable == nullptr) && !isExtDecaye << 199   if ( (decaytable == 0) && !isExtDecayer &&!isPreAssigned ){
                                                   >> 200 #ifdef G4VERBOSE
211     if (GetVerboseLevel()>0) {                    201     if (GetVerboseLevel()>0) {
212       G4cout <<  "G4Decay::DoIt  : decay table << 202       G4cerr <<  "G4Decay::DoIt  : decay table not defined  for ";
213       G4cout << aParticle->GetDefinition()->Ge << 203       G4cerr << aParticle->GetDefinition()->GetParticleName()<< G4endl;
214     }                                             204     }
215     G4ExceptionDescription ed;                 << 205 #endif
216     ed << "For " << aParticle->GetDefinition() << 
217        << " decay probability exist but decay  << 
218        << "- the particle will be killed;\n"   << 
219        << "    isExtDecayer: " << isExtDecayer << 
220        << "; isPreAssigned: " << isPreAssigned << 
221     G4Exception( "G4Decay::DecayIt ",          << 
222                  "DECAY101",JustWarning, ed);  << 
223                                                << 
224     fParticleChangeForDecay.SetNumberOfSeconda    206     fParticleChangeForDecay.SetNumberOfSecondaries(0);
225     // Kill the parent particle                   207     // Kill the parent particle
226     fParticleChangeForDecay.ProposeTrackStatus    208     fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
227     fParticleChangeForDecay.ProposeLocalEnergy    209     fParticleChangeForDecay.ProposeLocalEnergyDeposit(0.0); 
228                                                   210     
229     ClearNumberOfInteractionLengthLeft();         211     ClearNumberOfInteractionLengthLeft();
230     return &fParticleChangeForDecay ;             212     return &fParticleChangeForDecay ;
231   }                                               213   }
232                                                   214 
233   if (isPreAssigned) {                            215   if (isPreAssigned) {
234     // copy decay products                        216     // copy decay products 
235     products = new G4DecayProducts(*o_products    217     products = new G4DecayProducts(*o_products); 
236   } else if ( isExtDecayer ) {                    218   } else if ( isExtDecayer ) {
237     // decay according to external decayer        219     // decay according to external decayer
238     products = pExtDecayer->ImportDecayProduct    220     products = pExtDecayer->ImportDecayProducts(aTrack);
239   } else {                                        221   } else {
240     // Decay according to decay table.         << 222     // decay acoording to decay table
241     // Keep trying to choose a candidate decay << 223     // choose a decay channel
242     // of the decaying particle is below the s << 224     G4VDecayChannel *decaychannel = decaytable->SelectADecayChannel();
243     // candidate daughter particles.           << 225     if (decaychannel == 0 ){
244     // This is needed because the decay table  << 
245     // the assumption of nominal PDG masses, b << 
246     // a dynamic masses well below its nominal << 
247     // some of its decay channels can be below << 
248     // Note that, for simplicity, we ignore he << 
249     // one or more of the candidate daughter p << 
250     // wide resonance. However, if this is the << 
251     // accepted, then the masses of the resona << 
252     // be sampled by taking into account their << 
253     G4VDecayChannel* decaychannel = nullptr;   << 
254     G4double massParent = aParticle->GetMass() << 
255     decaychannel = decaytable->SelectADecayCha << 
256     if ( decaychannel == nullptr) {            << 
257       // decay channel not found                  226       // decay channel not found
258      G4ExceptionDescription ed;                << 227       G4Exception("G4Decay::DoIt  : can not determine decay channel ");
259       ed << "Can not determine decay channel f << 
260    << aParticleDef->GetParticleName() << G4end << 
261    << "  mass of dynamic particle: "           << 
262    << massParent/GeV << " (GEV)" << G4endl     << 
263    << "  dacay table has " << decaytable->entr << 
264    << " entries" << G4endl;                    << 
265       G4double checkedmass=massParent;         << 
266       if (massParent < 0.) {                   << 
267   checkedmass=aParticleDef->GetPDGMass();      << 
268   ed << "Using PDG mass ("<<checkedmass/GeV    << 
269      << "(GeV)) in IsOKWithParentMass" << G4en << 
270       }                                        << 
271       for (G4int ic =0;ic <decaytable->entries << 
272   G4VDecayChannel * dc= decaytable->GetDecayCh << 
273   ed << ic << ": BR " << dc->GetBR() << ", IsO << 
274      << dc->IsOKWithParentMass(checkedmass)    << 
275      << ", --> ";                              << 
276   G4int ndaughters=dc->GetNumberOfDaughters(); << 
277   for (G4int id=0;id<ndaughters;++id) {        << 
278     if (id>0) ed << " + ";   // seperator, exc << 
279     ed << dc->GetDaughterName(id);             << 
280   }                                            << 
281   ed << G4endl;                                << 
282       }                                        << 
283       G4Exception("G4Decay::DoIt", "DECAY003", << 
284     } else {                                      228     } else {
285       // execute DecayIt()                        229       // execute DecayIt() 
286 #ifdef G4VERBOSE                                  230 #ifdef G4VERBOSE
287       G4int temp = decaychannel->GetVerboseLev    231       G4int temp = decaychannel->GetVerboseLevel();
288       if (GetVerboseLevel()>1) {                  232       if (GetVerboseLevel()>1) {
289   G4cout << "G4Decay::DoIt  : selected decay c << 233   G4cerr << "G4Decay::DoIt  : selected decay channel  addr:" << decaychannel <<G4endl;
290          << decaychannel <<G4endl;             << 
291   decaychannel->SetVerboseLevel(GetVerboseLeve    234   decaychannel->SetVerboseLevel(GetVerboseLevel());
292       }                                           235       }
293 #endif                                            236 #endif
294       products = decaychannel->DecayIt(aPartic    237       products = decaychannel->DecayIt(aParticle->GetMass());
295 #ifdef G4VERBOSE                                  238 #ifdef G4VERBOSE
296       if (GetVerboseLevel()>1) {                  239       if (GetVerboseLevel()>1) {
297   decaychannel->SetVerboseLevel(temp);            240   decaychannel->SetVerboseLevel(temp);
298       }                                           241       }
299 #endif                                            242 #endif
300 #ifdef G4VERBOSE                                  243 #ifdef G4VERBOSE
301       if (GetVerboseLevel()>2) {               << 244       // for debug
302   if (! products->IsChecked() ) products->Dump << 245       //if (! products->IsChecked() ) products->DumpInfo();
303       }                                        << 
304 #endif                                            246 #endif
305     }                                             247     }
306   }                                               248   }
307                                                   249   
308   // get parent particle information .........    250   // get parent particle information ...................................
309   G4double   ParentEnergy  = aParticle->GetTot    251   G4double   ParentEnergy  = aParticle->GetTotalEnergy();
310   G4double   ParentMass    = aParticle->GetMas << 
311   if (ParentEnergy < ParentMass) {             << 
312     G4ExceptionDescription ed;                 << 
313     ed << "Total Energy is less than its mass  << 
314        << "\n Particle: " << aParticle->GetDef << 
315        << "\n Energy:"    << ParentEnergy/MeV  << 
316        << "\n Mass:"      << ParentMass/MeV << << 
317     G4Exception( "G4Decay::DecayIt ",          << 
318                  "DECAY102",JustWarning, ed);  << 
319     ParentEnergy = ParentMass;                 << 
320   }                                            << 
321                                                << 
322   G4ThreeVector ParentDirection(aParticle->Get    252   G4ThreeVector ParentDirection(aParticle->GetMomentumDirection());
323                                                   253 
324   //boost all decay products to laboratory fra    254   //boost all decay products to laboratory frame
325   G4double energyDeposit = 0.0;                   255   G4double energyDeposit = 0.0;
326   G4double finalGlobalTime = aTrack.GetGlobalT    256   G4double finalGlobalTime = aTrack.GetGlobalTime();
327   G4double finalLocalTime = aTrack.GetLocalTim << 
328   if (aTrack.GetTrackStatus() == fStopButAlive    257   if (aTrack.GetTrackStatus() == fStopButAlive ){
329     // AtRest case                                258     // AtRest case
330     finalGlobalTime += fRemainderLifeTime;        259     finalGlobalTime += fRemainderLifeTime;
331     finalLocalTime += fRemainderLifeTime;      << 
332     energyDeposit += aParticle->GetKineticEner    260     energyDeposit += aParticle->GetKineticEnergy();
333     if (isPreAssigned) products->Boost( Parent    261     if (isPreAssigned) products->Boost( ParentEnergy, ParentDirection);
334   } else {                                        262   } else {
335     // PostStep case                              263     // PostStep case
336     if (!isExtDecayer) products->Boost( Parent    264     if (!isExtDecayer) products->Boost( ParentEnergy, ParentDirection);
337   }                                               265   }
338    // set polarization for daughter particles  << 
339    DaughterPolarization(aTrack, products);     << 
340                                                << 
341                                                   266 
342   //add products in fParticleChangeForDecay       267   //add products in fParticleChangeForDecay
343   G4int numberOfSecondaries = products->entrie    268   G4int numberOfSecondaries = products->entries();
344   fParticleChangeForDecay.SetNumberOfSecondari    269   fParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries);
345 #ifdef G4VERBOSE                                  270 #ifdef G4VERBOSE
346   if (GetVerboseLevel()>1) {                      271   if (GetVerboseLevel()>1) {
347     G4cout << "G4Decay::DoIt  : Decay vertex : << 272     G4cerr << "G4Decay::DoIt  : Decay vertex :";
348     G4cout << " Time: " << finalGlobalTime/ns  << 273     G4cerr << " Time: " << finalGlobalTime/ns << "[ns]";
349     G4cout << " X:" << (aTrack.GetPosition()). << 274     G4cerr << " X:" << (aTrack.GetPosition()).x() /cm << "[cm]";
350     G4cout << " Y:" << (aTrack.GetPosition()). << 275     G4cerr << " Y:" << (aTrack.GetPosition()).y() /cm << "[cm]";
351     G4cout << " Z:" << (aTrack.GetPosition()). << 276     G4cerr << " Z:" << (aTrack.GetPosition()).z() /cm << "[cm]";
352     G4cout << G4endl;                          << 277     G4cerr << G4endl;
353     G4cout << "G4Decay::DoIt  : decay products << 278     G4cerr << "G4Decay::DoIt  : decay products in Lab. Frame" << G4endl;
354     products->DumpInfo();                         279     products->DumpInfo();
355   }                                               280   }
356 #endif                                            281 #endif
357   G4int index;                                    282   G4int index;
358   G4ThreeVector currentPosition;                  283   G4ThreeVector currentPosition;
359   const G4TouchableHandle thand = aTrack.GetTo    284   const G4TouchableHandle thand = aTrack.GetTouchableHandle();
360   for (index=0; index < numberOfSecondaries; i << 285   for (index=0; index < numberOfSecondaries; index++)
361     // get current position of the track       << 286   {
362     currentPosition = aTrack.GetPosition();    << 287      // get current position of the track
363     // create a new track object               << 288      currentPosition = aTrack.GetPosition();
364     G4Track* secondary = new G4Track( products << 289      // create a new track object
                                                   >> 290      G4Track* secondary = new G4Track( products->PopProducts(),
365               finalGlobalTime ,                   291               finalGlobalTime ,
366               currentPosition );                  292               currentPosition );
367     // switch on good for tracking flag        << 293      // switch on good for tracking flag
368     secondary->SetGoodForTrackingFlag();       << 294      secondary->SetGoodForTrackingFlag();
369     secondary->SetTouchableHandle(thand);      << 295      secondary->SetTouchableHandle(thand);
370     // add the secondary track in the List     << 296      // add the secondary track in the List
371     fParticleChangeForDecay.AddSecondary(secon << 297      fParticleChangeForDecay.AddSecondary(secondary);
372   }                                               298   }
373   delete products;                                299   delete products;
374                                                << 300 
375   // Kill the parent particle                     301   // Kill the parent particle
376   fParticleChangeForDecay.ProposeTrackStatus(     302   fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
377   fParticleChangeForDecay.ProposeLocalEnergyDe    303   fParticleChangeForDecay.ProposeLocalEnergyDeposit(energyDeposit); 
378   fParticleChangeForDecay.ProposeLocalTime( fi << 304   fParticleChangeForDecay.ProposeGlobalTime( finalGlobalTime );
379                                                << 
380   // Clear NumberOfInteractionLengthLeft          305   // Clear NumberOfInteractionLengthLeft
381   ClearNumberOfInteractionLengthLeft();           306   ClearNumberOfInteractionLengthLeft();
382                                                << 307 
383   return &fParticleChangeForDecay ;               308   return &fParticleChangeForDecay ;
384 }                                                 309 } 
385                                                   310 
386 void G4Decay::DaughterPolarization(const G4Tra << 
387 {                                              << 
388   // empty implementation                      << 
389 }                                              << 
390                                                << 
391                                                << 
392                                                   311 
393 void G4Decay::StartTracking(G4Track*)             312 void G4Decay::StartTracking(G4Track*)
394 {                                                 313 {
395   currentInteractionLength = -1.0;                314   currentInteractionLength = -1.0;
396   ResetNumberOfInteractionLengthLeft();           315   ResetNumberOfInteractionLengthLeft();
397                                                   316  
398   fRemainderLifeTime = -1.0;                      317   fRemainderLifeTime = -1.0;
399 }                                                 318 }
400                                                   319 
401 void G4Decay::EndTracking()                       320 void G4Decay::EndTracking()
402 {                                                 321 {
403   // Clear NumberOfInteractionLengthLeft          322   // Clear NumberOfInteractionLengthLeft
404   ClearNumberOfInteractionLengthLeft();           323   ClearNumberOfInteractionLengthLeft();
405                                                   324 
406   currentInteractionLength = -1.0;                325   currentInteractionLength = -1.0;
407 }                                                 326 }
408                                                   327 
409                                                   328 
410 G4double G4Decay::PostStepGetPhysicalInteracti    329 G4double G4Decay::PostStepGetPhysicalInteractionLength(
411                              const G4Track& tr    330                              const G4Track& track,
412                              G4double   previo    331                              G4double   previousStepSize,
413                              G4ForceCondition*    332                              G4ForceCondition* condition
414                             )                     333                             )
415 {                                                 334 {
                                                   >> 335  
416    // condition is set to "Not Forced"            336    // condition is set to "Not Forced"
417   *condition = NotForced;                         337   *condition = NotForced;
418                                                   338 
419    // pre-assigned Decay time                     339    // pre-assigned Decay time
420   G4double pTime = track.GetDynamicParticle()-    340   G4double pTime = track.GetDynamicParticle()->GetPreAssignedDecayProperTime();
421   G4double aLife = track.GetDynamicParticle()-    341   G4double aLife = track.GetDynamicParticle()->GetDefinition()->GetPDGLifeTime();
422                                                   342 
423   if (pTime < 0.) {                               343   if (pTime < 0.) {
424     // normal case                                344     // normal case 
425     if ( previousStepSize > 0.0){                 345     if ( previousStepSize > 0.0){
426       // subtract NumberOfInteractionLengthLef    346       // subtract NumberOfInteractionLengthLeft 
427       SubtractNumberOfInteractionLengthLeft(pr    347       SubtractNumberOfInteractionLengthLeft(previousStepSize);
428       if(theNumberOfInteractionLengthLeft<0.){    348       if(theNumberOfInteractionLengthLeft<0.){
429   theNumberOfInteractionLengthLeft=perMillion;    349   theNumberOfInteractionLengthLeft=perMillion;
430       }                                           350       }
431       fRemainderLifeTime = theNumberOfInteract    351       fRemainderLifeTime = theNumberOfInteractionLengthLeft*aLife;
432     }                                             352     }
433     // get mean free path                         353     // get mean free path
434     currentInteractionLength = GetMeanFreePath    354     currentInteractionLength = GetMeanFreePath(track, previousStepSize, condition);
435                                                   355     
436 #ifdef G4VERBOSE                                  356 #ifdef G4VERBOSE
437     if ((currentInteractionLength <=0.0) || (v    357     if ((currentInteractionLength <=0.0) || (verboseLevel>2)){
438       G4cout << "G4Decay::PostStepGetPhysicalI    358       G4cout << "G4Decay::PostStepGetPhysicalInteractionLength " << G4endl;
439       track.GetDynamicParticle()->DumpInfo();     359       track.GetDynamicParticle()->DumpInfo();
440       G4cout << " in Material  " << track.GetM    360       G4cout << " in Material  " << track.GetMaterial()->GetName() <<G4endl;
441       G4cout << "MeanFreePath = " << currentIn    361       G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]" <<G4endl;
442     }                                             362     }
443 #endif                                            363 #endif
444                                                   364 
445     G4double value;                               365     G4double value;
446     if (currentInteractionLength <DBL_MAX) {      366     if (currentInteractionLength <DBL_MAX) {
447       value = theNumberOfInteractionLengthLeft    367       value = theNumberOfInteractionLengthLeft * currentInteractionLength;
448       //fRemainderLifeTime = theNumberOfIntera << 
449     } else {                                      368     } else {
450       value = DBL_MAX;                            369       value = DBL_MAX;
451     }                                             370     }
452                                                   371 
453     return value;                                 372     return value;
454                                                   373 
455   } else {                                        374   } else {
456     //pre-assigned Decay time case                375     //pre-assigned Decay time case
457     // reminder proper time                       376     // reminder proper time
458     fRemainderLifeTime = pTime - track.GetProp    377     fRemainderLifeTime = pTime - track.GetProperTime();
459     if (fRemainderLifeTime <= 0.0) fRemainderL << 378     if (fRemainderLifeTime <= 0.0) fRemainderLifeTime = DBL_MIN;
460                                                << 379   
461     G4double  rvalue=0.0;                      << 
462     // use pre-assigned Decay time to determin    380     // use pre-assigned Decay time to determine PIL
463     if (aLife>0.0) {                           << 381     return (fRemainderLifeTime/aLife)*GetMeanFreePath(track, previousStepSize, condition);
464       // ordinary particle                     << 
465       rvalue = (fRemainderLifeTime/aLife)*GetM << 
466     } else {                                   << 
467      // shortlived particle                    << 
468       rvalue = c_light * fRemainderLifeTime;   << 
469      // by using normalized kinetic energy (=  << 
470      G4double   aMass =  track.GetDynamicParti << 
471      rvalue *= track.GetDynamicParticle()->Get << 
472     }                                          << 
473     return rvalue;                             << 
474   }                                               382   }
475 }                                                 383 }
476                                                   384 
477 G4double G4Decay::AtRestGetPhysicalInteraction    385 G4double G4Decay::AtRestGetPhysicalInteractionLength(
478                              const G4Track& tr    386                              const G4Track& track,
479                              G4ForceCondition*    387                              G4ForceCondition* condition
480                             )                     388                             )
481 {                                                 389 {
482      // condition is set to "Not Forced"          390      // condition is set to "Not Forced"
483   *condition = NotForced;                         391   *condition = NotForced;
484                                                   392 
485   G4double pTime = track.GetDynamicParticle()-    393   G4double pTime = track.GetDynamicParticle()->GetPreAssignedDecayProperTime();
486   if (pTime >= 0.) {                              394   if (pTime >= 0.) {
487     fRemainderLifeTime = pTime - track.GetProp    395     fRemainderLifeTime = pTime - track.GetProperTime();
488     if (fRemainderLifeTime <= 0.0) fRemainderL    396     if (fRemainderLifeTime <= 0.0) fRemainderLifeTime = DBL_MIN;
489   } else {                                        397   } else {
490     fRemainderLifeTime =                          398     fRemainderLifeTime = 
491       theNumberOfInteractionLengthLeft * GetMe    399       theNumberOfInteractionLengthLeft * GetMeanLifeTime(track, condition);
492   }                                               400   }
493   return fRemainderLifeTime;                      401   return fRemainderLifeTime;
494 }                                              << 
495                                                << 
496                                                << 
497 void G4Decay::SetExtDecayer(G4VExtDecayer* val << 
498 {                                              << 
499   pExtDecayer = val;                           << 
500                                                << 
501   // set Process Sub Type                      << 
502   if ( pExtDecayer !=0 ) {                     << 
503     SetProcessSubType(static_cast<int>(DECAY_E << 
504   }                                            << 
505 }                                              << 
506                                                << 
507 G4VParticleChange* G4Decay::PostStepDoIt(      << 
508            const G4Track& aTrack,              << 
509            const G4Step&  aStep                << 
510           )                                    << 
511 {                                              << 
512   if ( (aTrack.GetTrackStatus() == fStopButAli << 
513        (aTrack.GetTrackStatus() == fStopAndKil << 
514     fParticleChangeForDecay.Initialize(aTrack) << 
515     return &fParticleChangeForDecay;           << 
516   } else {                                     << 
517     return DecayIt(aTrack, aStep);             << 
518   }                                            << 
519 }                                              << 
520                                                << 
521 void G4Decay::ProcessDescription(std::ostream& << 
522 {                                              << 
523   outFile << GetProcessName() << ": Decay of p << 
524     << "kinematics of daughters are dertermine << 
525           << " or by PreAssignedDecayProducts\ << 
526 }                                                 402 }
527                                                   403