G4NeutronCaptureAtRest.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //    G4NeutronCaptureAtRest physics process
00027 //    Larry Felawka (TRIUMF), April 1998
00028 //---------------------------------------------------------------------
00029 
00030 #include <string.h>
00031 #include <cmath>
00032 #include <stdio.h>
00033 
00034 #include "G4NeutronCaptureAtRest.hh"
00035 #include "G4SystemOfUnits.hh"
00036 #include "G4DynamicParticle.hh"
00037 #include "G4ParticleTypes.hh"
00038 #include "Randomize.hh" 
00039 #include "G4HadronicProcessStore.hh"
00040 #include "G4HadronicDeprecate.hh"
00041 
00042 #define MAX_SECONDARIES 100
00043 
00044 // constructor
00045  
00046 G4NeutronCaptureAtRest::G4NeutronCaptureAtRest(const G4String& processName,
00047                                       G4ProcessType   aType ) :
00048   G4VRestProcess (processName, aType),       // initialization
00049   massProton(G4Proton::Proton()->GetPDGMass()/GeV),
00050   massNeutron(G4Neutron::Neutron()->GetPDGMass()/GeV),
00051   massElectron(G4Electron::Electron()->GetPDGMass()/GeV),
00052   massDeuteron(G4Deuteron::Deuteron()->GetPDGMass()/GeV),
00053   massAlpha(G4Alpha::Alpha()->GetPDGMass()/GeV),
00054   pdefGamma(G4Gamma::Gamma()),
00055   pdefNeutron(G4Neutron::Neutron())
00056 {
00057   G4HadronicDeprecate("G4NeutronCaptureAtRest");
00058   if (verboseLevel>0) {
00059     G4cout << GetProcessName() << " is created "<< G4endl;
00060   }
00061   SetProcessSubType(fHadronAtRest);
00062   pv   = new G4GHEKinematicsVector [MAX_SECONDARIES+1];
00063   eve  = new G4GHEKinematicsVector [MAX_SECONDARIES];
00064   gkin = new G4GHEKinematicsVector [MAX_SECONDARIES];
00065 
00066   G4HadronicProcessStore::Instance()->RegisterExtraProcess(this);
00067 }
00068  
00069 // destructor
00070  
00071 G4NeutronCaptureAtRest::~G4NeutronCaptureAtRest()
00072 {
00073   G4HadronicProcessStore::Instance()->DeRegisterExtraProcess(this);
00074   delete [] pv;
00075   delete [] eve;
00076   delete [] gkin;
00077 }
00078  
00079 void G4NeutronCaptureAtRest::PreparePhysicsTable(const G4ParticleDefinition& p) 
00080 {
00081   G4HadronicProcessStore::Instance()->RegisterParticleForExtraProcess(this, &p);
00082 }
00083 
00084 void G4NeutronCaptureAtRest::BuildPhysicsTable(const G4ParticleDefinition& p) 
00085 {
00086   G4HadronicProcessStore::Instance()->PrintInfo(&p);
00087 }
00088  
00089 // methods.............................................................................
00090  
00091 G4bool G4NeutronCaptureAtRest::IsApplicable(
00092                                  const G4ParticleDefinition& particle
00093                                  )
00094 {
00095    return ( &particle == pdefNeutron );
00096 
00097 }
00098  
00099 // Warning - this method may be optimized away if made "inline"
00100 G4int G4NeutronCaptureAtRest::GetNumberOfSecondaries()
00101 {
00102   return ( ngkine );
00103 
00104 }
00105 
00106 // Warning - this method may be optimized away if made "inline"
00107 G4GHEKinematicsVector* G4NeutronCaptureAtRest::GetSecondaryKinematics()
00108 {
00109   return ( &gkin[0] );
00110 
00111 }
00112 
00113 G4double G4NeutronCaptureAtRest::AtRestGetPhysicalInteractionLength(
00114                                    const G4Track& track,
00115                                    G4ForceCondition* condition
00116                                    )
00117 {
00118   // beggining of tracking 
00119   ResetNumberOfInteractionLengthLeft();
00120 
00121   // condition is set to "Not Forced"
00122   *condition = NotForced;
00123 
00124   // get mean life time
00125   currentInteractionLength = GetMeanLifeTime(track, condition);
00126 
00127   if ((currentInteractionLength <0.0) || (verboseLevel>2)){
00128     G4cout << "G4NeutronCaptureAtRestProcess::AtRestGetPhysicalInteractionLength ";
00129     G4cout << "[ " << GetProcessName() << "]" <<G4endl;
00130     track.GetDynamicParticle()->DumpInfo();
00131     G4cout << " in Material  " << track.GetMaterial()->GetName() <<G4endl;
00132     G4cout << "MeanLifeTime = " << currentInteractionLength/ns << "[ns]" <<G4endl;
00133   }
00134 
00135   return theNumberOfInteractionLengthLeft * currentInteractionLength;
00136 
00137 }
00138 
00139 G4VParticleChange* G4NeutronCaptureAtRest::AtRestDoIt(
00140                                             const G4Track& track,
00141                                             const G4Step& 
00142                                             )
00143 //
00144 // Handles Neutrons at rest; a Neutron can either create secondaries or
00145 // do nothing (in which case it should be sent back to decay-handling
00146 // section
00147 //
00148 {
00149 
00150 //   Initialize ParticleChange
00151 //     all members of G4VParticleChange are set to equal to 
00152 //     corresponding member in G4Track
00153 
00154   aParticleChange.Initialize(track);
00155 
00156 //   Store some global quantities that depend on current material and particle
00157 
00158   globalTime = track.GetGlobalTime()/s;
00159   G4Material * aMaterial = track.GetMaterial();
00160   const G4int numberOfElements = aMaterial->GetNumberOfElements();
00161   const G4ElementVector* theElementVector = aMaterial->GetElementVector();
00162 
00163   const G4double* theAtomicNumberDensity = aMaterial->GetAtomicNumDensityVector();
00164   G4double normalization = 0;
00165   for ( G4int i1=0; i1 < numberOfElements; i1++ )
00166   {
00167     normalization += theAtomicNumberDensity[i1] ; // change when nucleon specific
00168                                                   // probabilities are included.
00169   }
00170   G4double runningSum= 0.;
00171   G4double random = G4UniformRand()*normalization;
00172   for ( G4int i2=0; i2 < numberOfElements; i2++ )
00173   {
00174     runningSum += theAtomicNumberDensity[i2]; // change when nucleon specific
00175                                               // probabilities are included.
00176     if (random<=runningSum)
00177     {
00178       targetCharge = G4double((*theElementVector)[i2]->GetZ());
00179       targetAtomicMass = (*theElementVector)[i2]->GetN();
00180     }
00181   }
00182   if (random>runningSum)
00183   {
00184     targetCharge = G4double((*theElementVector)[numberOfElements-1]->GetZ());
00185     targetAtomicMass = (*theElementVector)[numberOfElements-1]->GetN();
00186 
00187   }
00188 
00189   if (verboseLevel>1) {
00190     G4cout << "G4NeutronCaptureAtRest::AtRestDoIt is invoked " <<G4endl;
00191     }
00192 
00193   G4ParticleMomentum momentum;
00194   G4float localtime;
00195 
00196   G4ThreeVector   position = track.GetPosition();
00197 
00198   GenerateSecondaries(); // Generate secondaries
00199 
00200   aParticleChange.SetNumberOfSecondaries( ngkine ); 
00201 
00202   for ( G4int isec = 0; isec < ngkine; isec++ ) {
00203     G4DynamicParticle* aNewParticle = new G4DynamicParticle;
00204     aNewParticle->SetDefinition( gkin[isec].GetParticleDef() );
00205     aNewParticle->SetMomentum( gkin[isec].GetMomentum() * GeV );
00206 
00207     localtime = globalTime + gkin[isec].GetTOF();
00208 
00209     G4Track* aNewTrack = new G4Track( aNewParticle, localtime*s, position );
00210                 aNewTrack->SetTouchableHandle(track.GetTouchableHandle());
00211     aParticleChange.AddSecondary( aNewTrack );
00212 
00213   }
00214 
00215   aParticleChange.ProposeLocalEnergyDeposit( 0.0*GeV );
00216 
00217   aParticleChange.ProposeTrackStatus(fStopAndKill); // Kill the incident Neutron
00218 
00219 //   clear InteractionLengthLeft
00220 
00221   ResetNumberOfInteractionLengthLeft();
00222 
00223   return &aParticleChange;
00224 
00225 }
00226 
00227 
00228 void G4NeutronCaptureAtRest::GenerateSecondaries()
00229 {
00230   static G4int index;
00231   static G4int l;
00232   static G4int nopt;
00233   static G4int i;
00234   // DHW 15 May 2011: unused: static G4ParticleDefinition* jnd;
00235 
00236   for (i = 1; i <= MAX_SECONDARIES; ++i) {
00237     pv[i].SetZero();
00238   }
00239 
00240   ngkine = 0;            // number of generated secondary particles
00241   ntot = 0;
00242   result.SetZero();
00243   result.SetMass( massNeutron );
00244   result.SetKineticEnergyAndUpdate( 0. );
00245   result.SetTOF( 0. );
00246   result.SetParticleDef( pdefNeutron );
00247 
00248   NeutronCapture(&nopt);
00249 
00250   // *** CHECK WHETHER THERE ARE NEW PARTICLES GENERATED ***
00251   if (ntot != 0 || result.GetParticleDef() != pdefNeutron) {
00252     // *** CURRENT PARTICLE IS NOT THE SAME AS IN THE BEGINNING OR/AND ***
00253     // *** ONE OR MORE SECONDARIES HAVE BEEN GENERATED ***
00254 
00255     // --- INITIAL PARTICLE TYPE HAS BEEN CHANGED ==> PUT NEW TYPE ON ---
00256     // --- THE GEANT TEMPORARY STACK ---
00257 
00258     // --- PUT PARTICLE ON THE STACK ---
00259     gkin[0] = result;
00260     gkin[0].SetTOF( result.GetTOF() * 5e-11 );
00261     ngkine = 1;
00262 
00263     // --- ALL QUANTITIES ARE TAKEN FROM THE GHEISHA STACK WHERE THE ---
00264     // --- CONVENTION IS THE FOLLOWING ---
00265 
00266     // --- ONE OR MORE SECONDARIES HAVE BEEN GENERATED ---
00267     for (l = 1; l <= ntot; ++l) {
00268       index = l - 1;
00269       // DHW 15 May 2011: unused: jnd = eve[index].GetParticleDef();
00270 
00271       // --- ADD PARTICLE TO THE STACK IF STACK NOT YET FULL ---
00272       if (ngkine < MAX_SECONDARIES) {
00273         gkin[ngkine] = eve[index];
00274         gkin[ngkine].SetTOF( eve[index].GetTOF() * 5e-11 );
00275         ++ngkine;
00276       }
00277     }
00278   }
00279   else {
00280     // --- NO SECONDARIES GENERATED AND PARTICLE IS STILL THE SAME ---
00281     // --- ==> COPY EVERYTHING BACK IN THE CURRENT GEANT STACK ---
00282     ngkine = 0;
00283     ntot = 0;
00284     globalTime += result.GetTOF() * G4float(5e-11);
00285   }
00286 
00287   // --- LIMIT THE VALUE OF NGKINE IN CASE OF OVERFLOW ---
00288   ngkine = G4int(std::min(ngkine,G4int(MAX_SECONDARIES)));
00289 
00290 } // GenerateSecondaries
00291 
00292 
00293 void G4NeutronCaptureAtRest::Normal(G4float *ran)
00294 {
00295   static G4int i;
00296 
00297   // *** NVE 14-APR-1988 CERN GENEVA ***
00298   // ORIGIN : H.FESEFELDT (27-OCT-1983)
00299 
00300   *ran = G4float(-6.);
00301   for (i = 1; i <= 12; ++i) {
00302     *ran += G4UniformRand();
00303   }
00304 
00305 } // Normal
00306 
00307 
00308 void G4NeutronCaptureAtRest::NeutronCapture(G4int *nopt)
00309 {
00310   static G4int nt;
00311   static G4float xp, pcm;
00312   static G4float ran;
00313 
00314   // *** ROUTINE FOR CAPTURE OF NEUTRAL BARYONS ***
00315   // *** NVE 04-MAR-1988 CERN GENEVA ***
00316   // ORIGIN : H.FESEFELDT (02-DEC-1986)
00317 
00318   *nopt = 1;
00319   pv[1] = result;
00320   pv[2].SetZero();
00321   pv[2].SetMass( AtomAs(targetAtomicMass, targetCharge) );
00322   pv[2].SetMomentumAndUpdate( 0., 0., 0. );
00323   pv[2].SetTOF( result.GetTOF() );
00324   pv[2].SetParticleDef( NULL );
00325   pv[MAX_SECONDARIES].Add( pv[1], pv[2] );
00326   pv[MAX_SECONDARIES].SetMomentum( -pv[MAX_SECONDARIES].GetMomentum().x(), -pv[MAX_SECONDARIES].GetMomentum().y(), -pv[MAX_SECONDARIES].GetMomentum().z() );
00327   pv[MAX_SECONDARIES].SetParticleDef( NULL );
00328   Normal(&ran);
00329   pcm = ran * G4float(.001) + G4float(.0065);
00330   ran = G4UniformRand();
00331   result.SetTOF( result.GetTOF() - std::log(ran) * G4float(480.) );
00332   pv[3].SetZero();
00333   pv[3].SetMass( 0. );
00334   pv[3].SetKineticEnergyAndUpdate( pcm );
00335   pv[3].SetTOF( result.GetTOF() );
00336   pv[3].SetParticleDef( pdefGamma );
00337   pv[3].Lor( pv[3], pv[MAX_SECONDARIES] );
00338   nt = 3;
00339   xp = G4float(.008) - pcm;
00340   if (xp >= G4float(0.)) {
00341     nt = 4;
00342     pv[4].SetZero();
00343     pv[4].SetMass( 0. );
00344     pv[4].SetKineticEnergyAndUpdate( xp );
00345     pv[4].SetTOF( result.GetTOF() );
00346     pv[4].SetParticleDef( pdefGamma );
00347     pv[4].Lor( pv[4], pv[MAX_SECONDARIES] );
00348   }
00349   result = pv[3];
00350   if (nt == 4) {
00351     if (ntot < MAX_SECONDARIES-1) {
00352       eve[ntot++] = pv[4];
00353     }
00354   }
00355 
00356 } // NeutronCapture
00357 
00358 
00359 G4double G4NeutronCaptureAtRest::AtomAs(G4float a, G4float z)
00360 {
00361   G4float ret_val;
00362   G4double d__1, d__2;
00363 
00364   static G4double aa;
00365   static G4int ia, iz;
00366   static G4double zz;
00367   static G4float rma, rmd;
00368   static G4int ipp;
00369   static G4float rmn, rmp;
00370   static G4int izz;
00371   static G4float rmel;
00372   static G4double mass;
00373 
00374   // *** DETERMINATION OF THE ATOMIC MASS ***
00375   // *** NVE 19-MAY-1988 CERN GENEVA ***
00376   // ORIGIN : H.FESEFELDT (02-DEC-1986)
00377 
00378   // --- GET ATOMIC (= ELECTRONS INCL.) MASSES (IN MEV) FROM RMASS ARRAY ---
00379   // --- ELECTRON ---
00380   rmel = massElectron * G4float(1e3);
00381   // --- PROTON ---
00382   rmp = massProton * G4float(1e3);
00383   // --- NEUTRON ---
00384   rmn = massNeutron * G4float(1e3);
00385   // --- DEUTERON ---
00386   rmd = massDeuteron * G4float(1e3) + rmel;
00387   // --- ALPHA ---
00388   rma = massAlpha * G4float(1e3) + rmel * G4float(2.);
00389 
00390   ret_val = G4float(0.);
00391   aa = a * 1.;
00392   zz = z * 1.;
00393   ia = G4int(a + G4float(.5));
00394   if (ia < 1) {
00395     return ret_val;
00396   }
00397   iz = G4int(z + G4float(.5));
00398   if (iz < 0 || iz > ia) {
00399     return ret_val;
00400   }
00401   mass = 0.;
00402   if (ia == 1) {
00403     if (iz == 0) {
00404       mass = rmn;
00405     }
00406     else if (iz == 1) {
00407       mass = rmp + rmel;
00408     }
00409   }
00410   else if (ia == 2 && iz == 1) {
00411     mass = rmd;
00412   }
00413   else if (ia == 4 && iz == 2) {
00414     mass = rma;
00415   }
00416   else if ( (ia == 2 && iz != 1) || ia == 3 || (ia == 4 && iz != 2) || ia > 4) {
00417     d__1 = aa / G4float(2.) - zz;
00418     d__2 = zz;
00419     mass = (aa - zz) * rmn + zz * rmp + zz * rmel - aa * G4float(15.67) +
00420       std::pow(aa, .6666667) * G4float(17.23) + d__1 * d__1 * G4float(93.15) / aa +
00421       d__2 * d__2 * G4float(.6984523) / std::pow(aa, .3333333);
00422     ipp = (ia - iz) % 2;
00423     izz = iz % 2;
00424     if (ipp == izz) {
00425       mass += (ipp + izz - 1) * G4float(12.) * std::pow(aa, -.5);
00426     }
00427   }
00428   ret_val = mass * G4float(.001);
00429   return ret_val;
00430 
00431 } // AtomAs

Generated on Mon May 27 17:48:58 2013 for Geant4 by  doxygen 1.4.7