Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LENDInelastic.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 #include "G4LENDInelastic.hh"
27 #include "G4SystemOfUnits.hh"
28 #include "G4Nucleus.hh"
29 #include "G4ParticleTable.hh"
30 
32 {
33 
34  G4ThreeVector proj_p = aTrack.Get4Momentum().vect();
35 
36  G4double temp = aTrack.GetMaterial()->GetTemperature();
37 
38  //G4int iZ = int ( aTarg.GetZ() );
39  //G4int iA = int ( aTarg.GetN() );
40  //migrate to integer A and Z (GetN_asInt returns number of neutrons in the nucleus since this)
41  G4int iZ = aTarg.GetZ_asInt();
42  G4int iA = aTarg.GetA_asInt();
43  //G4cout << "target: Z = " << iZ << " N = " << iA << G4endl;
44 
45  G4double ke = aTrack.GetKineticEnergy();
46  //G4cout << "projectile: KE = " << ke/MeV << " [MeV]" << G4endl;
47 
48  G4HadFinalState* theResult = &theParticleChange;
49  theResult->Clear();
50 
51  G4GIDI_target* aTarget = usedTarget_map.find( lend_manager->GetNucleusEncoding( iZ , iA ) )->second->GetTarget();
52  std::vector<G4GIDI_Product>* products = aTarget->getOthersFinalState( ke*MeV, temp, NULL, NULL );
53  if ( products != NULL )
54  {
55 
56  G4ThreeVector psum(0);
57 
58  int totN = 0;
59  for ( G4int j = 0; j < int( products->size() ); j++ )
60  {
61 
62  G4int jZ = (*products)[j].Z;
63  G4int jA = (*products)[j].A;
64 
65  //G4cout << "ZA = " << 1000 * (*products)[j].Z + (*products)[j].A << " EK = "
66  // << (*products)[j].kineticEnergy
67  // << " px " << (*products)[j].px
68  // << " py " << (*products)[j].py
69  // << " pz " << (*products)[j].pz
70  // << G4endl;
71 
73 
74  if ( jA == 1 && jZ == 1 )
75  {
76  theSec->SetDefinition( G4Proton::Proton() );
77  totN += 1;
78  }
79  else if ( jA == 1 && jZ == 0 )
80  {
81  theSec->SetDefinition( G4Neutron::Neutron() );
82  totN += 1;
83  }
84  else if ( jZ > 0 )
85  {
86  if ( jA != 0 )
87  {
88  theSec->SetDefinition( G4ParticleTable::GetParticleTable()->FindIon( jZ , jA , 0 , 0 ) );
89  totN += jA;
90  }
91  else
92  {
93  theSec->SetDefinition( G4ParticleTable::GetParticleTable()->FindIon( jZ , iA+1-totN , 0 , 0 ) );
94  }
95  }
96  else
97  {
98  theSec->SetDefinition( G4Gamma::Gamma() );
99  }
100 
101  G4ThreeVector p( (*products)[j].px*MeV , (*products)[j].py*MeV , (*products)[j].pz*MeV );
102  psum += p;
103  if ( p.mag() == 0 ) p = proj_p - psum;
104 
105  theSec->SetMomentum( p );
106 
107  theResult->AddSecondary( theSec );
108  }
109  }
110  delete products;
111 
112  theResult->SetStatusChange( stopAndKill );
113 
114  return theResult;
115 
116 }