source: trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPFinalState.cc @ 1340

Last change on this file since 1340 was 968, checked in by garnier, 15 years ago

fichier ajoutes

File size: 9.2 KB
Line 
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//
27//080721 Create adjust_final_state method by T. Koi
28//080801 Residual reconstruction with theNDLDataA,Z (A, Z, and momentum are adjusted) by T. Koi
29
30#include "G4NeutronHPFinalState.hh"
31
32#include "G4ParticleTable.hh"
33#include "G4Gamma.hh"
34
35
36
37void G4NeutronHPFinalState::adjust_final_state ( G4LorentzVector init_4p_lab )
38{
39
40   if ( adjustResult != true ) return;
41
42   G4int nSecondaries = theResult.GetNumberOfSecondaries();
43
44   G4int sum_Z = 0;
45   G4int sum_A = 0;
46   G4int max_SecZ = 0;
47   G4int max_SecA = 0;
48   for ( int i = 0 ; i < nSecondaries ; i++ )
49   {
50      sum_Z += theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetAtomicNumber();
51      max_SecZ = std::max ( max_SecZ , theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetAtomicNumber() );
52      sum_A += theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetAtomicMass();
53      max_SecA = std::max ( max_SecA , theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetAtomicMass() );
54   }
55
56   G4ParticleDefinition* resi_pd = NULL;
57   if ( (int)(theBaseZ - sum_Z) == 0 && (int)(theBaseA + 1 - sum_A) == 0 )
58      resi_pd = G4ParticleTable::GetParticleTable()->GetIon ( max_SecZ , max_SecA , 0.0 );
59   else
60   {
61      resi_pd = G4ParticleTable::GetParticleTable()->GetIon ( int(theBaseZ - sum_Z) , (int)(theBaseA + 1 - sum_A) , 0.0 );
62      if ( resi_pd == NULL )
63      {
64        // theNDLDataZ,A has the Z and A of used NDL file
65        if ( (int)(theNDLDataZ - sum_Z) == 0 && (int)(theNDLDataA + 1 - sum_A) == 0 )
66        {
67           G4int dif_Z = ( int ) ( theNDLDataZ - theBaseZ );
68           G4int dif_A = ( int ) ( theNDLDataA - theBaseA );
69           resi_pd = G4ParticleTable::GetParticleTable()->GetIon ( max_SecZ - dif_Z , max_SecA - dif_A , 0.0 );
70           for ( int i = 0 ; i < nSecondaries ; i++ )
71           {
72              if ( theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetAtomicNumber() == max_SecZ 
73                && theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetAtomicMass() == max_SecA )
74              {
75                 G4ThreeVector p = theResult.GetSecondary( i )->GetParticle()->GetMomentum();
76                 p = p * resi_pd->GetPDGMass()/ G4ParticleTable::GetParticleTable()->GetIon ( max_SecZ , max_SecA , 0.0 )->GetPDGMass(); 
77                 theResult.GetSecondary( i )->GetParticle()->SetDefinition( resi_pd );
78                 theResult.GetSecondary( i )->GetParticle()->SetMomentum( p );
79              } 
80           }
81        }
82      }
83   }
84
85
86   G4LorentzVector secs_4p_lab( 0.0 );
87
88   G4int n_sec = theResult.GetNumberOfSecondaries();
89   G4double fast = 0;
90   G4double slow = 1;
91   G4int ifast = 0;
92   G4int islow = 0;
93   G4int ires = -1;
94
95   for ( G4int i = 0 ; i < n_sec ; i++ )
96   {
97
98      //G4cout << "HP_DB " << i
99      //       << " " << theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetParticleName()
100      //       << " 4p " << theResult.GetSecondary( i )->GetParticle()->Get4Momentum()
101      //       << " ke " << theResult.GetSecondary( i )->GetParticle()->Get4Momentum().e() - theResult.GetSecondary( i )->GetParticle()->GetDefinition()->GetPDGMass()
102      //       << G4endl;
103
104      secs_4p_lab += theResult.GetSecondary( i )->GetParticle()->Get4Momentum();
105
106      G4double beta = 0;
107      if ( theResult.GetSecondary( i )->GetParticle()->GetDefinition() != G4Gamma::Gamma() )
108      {
109         beta = theResult.GetSecondary( i )->GetParticle()->Get4Momentum().beta(); 
110      }
111      else
112      {
113         beta = 1;
114      }
115
116      if ( theResult.GetSecondary( i )->GetParticle()->GetDefinition() == resi_pd ) ires = i; 
117
118      if ( slow > beta && beta != 0 ) 
119      {
120         slow = beta; 
121         islow = i;
122      }
123
124      if ( fast <= beta ) 
125      {
126         if ( fast != 1 )
127         {
128            fast = beta; 
129            ifast = i;
130         } 
131         else
132         {
133//          fast is already photon then check E
134            G4double e = theResult.GetSecondary( i )->GetParticle()->Get4Momentum().e();
135            if ( e > theResult.GetSecondary( ifast )->GetParticle()->Get4Momentum().e() )   
136            {
137//             among photons, the highest E becomes the fastest
138               ifast = i; 
139            }
140         } 
141      }
142   }
143
144
145   G4LorentzVector dif_4p = init_4p_lab - secs_4p_lab;
146
147   //G4cout << "HP_DB dif_4p " << init_4p_lab - secs_4p_lab << G4endl;
148   //G4cout << "HP_DB dif_3p mag " << ( dif_4p.v() ).mag() << G4endl;
149   //G4cout << "HP_DB dif_e " << dif_4p.e() - ( dif_4p.v() ).mag()<< G4endl;
150
151   G4LorentzVector p4(0);
152   if ( ires == -1 ) 
153   {
154//    Create and Add Residual Nucleus
155      ires = nSecondaries;
156      nSecondaries += 1;
157
158      G4DynamicParticle* res = new G4DynamicParticle ( resi_pd , dif_4p.v() );   
159      theResult.AddSecondary ( res );   
160
161      p4 = res->Get4Momentum(); 
162      if ( slow > p4.beta() ) 
163      {
164         slow = p4.beta(); 
165         islow = ires;
166      }
167
168      dif_4p = init_4p_lab - ( secs_4p_lab + p4 ); 
169   }
170
171   //Which is bigger dif_p or dif_e
172
173   if ( dif_4p.v().mag() < std::abs( dif_4p.e() ) )
174   {
175
176      // Adjust p
177      if ( dif_4p.v().mag() < 1*MeV )
178      {
179
180         nSecondaries += 1;
181         theResult.AddSecondary ( new G4DynamicParticle ( G4Gamma::Gamma() , dif_4p.v() ) );   
182
183      }
184      else
185      {
186         //G4cout << "HP_DB Difference in dif_p is too large (>1MeV) to adjust, so that give up tuning" << G4endl;
187      }
188
189   }
190   else
191   {
192
193      // dif_p > dif_e
194      // at first momentum
195      // Move residual momentum
196
197      p4 = theResult.GetSecondary( ires )->GetParticle()->Get4Momentum();
198      theResult.GetSecondary( ires )->GetParticle()->SetMomentum( p4.v() + dif_4p.v() ); 
199      dif_4p = init_4p_lab - ( secs_4p_lab - p4 + theResult.GetSecondary( ires )->GetParticle()->Get4Momentum()  ); 
200
201      //G4cout << "HP_DB new residual kinetic energy " << theResult.GetSecondary( ires )->GetParticle()->GetKineticEnergy() << G4endl;
202
203   }
204
205   G4double dif_e = dif_4p.e() - ( dif_4p.v() ).mag();
206   //G4cout << "HP_DB dif_e " << dif_e << G4endl;
207
208   if ( dif_e > 0 )
209   {
210
211//    create 2 gamma
212
213      nSecondaries += 2;
214      G4double e1 = ( dif_4p.e() -dif_4p.v().mag() ) / 2;
215      G4double costh = 2.*G4UniformRand()-1.;
216      G4double phi = twopi*G4UniformRand();
217      G4ThreeVector dir( std::sin(std::acos(costh))*std::cos(phi), 
218                         std::sin(std::acos(costh))*std::sin(phi),
219                         costh);
220      theResult.AddSecondary ( new G4DynamicParticle ( G4Gamma::Gamma() , e1*dir ) );   
221      theResult.AddSecondary ( new G4DynamicParticle ( G4Gamma::Gamma() , -e1*dir ) );   
222
223   }
224   else    //dif_e < 0
225   {
226
227//    At first reduce KE of the fastest secondary;
228      G4double ke0 = theResult.GetSecondary( ifast )->GetParticle()->GetKineticEnergy();
229      G4ThreeVector p0 = theResult.GetSecondary( ifast )->GetParticle()->GetMomentum();
230      G4ThreeVector dir = ( theResult.GetSecondary( ifast )->GetParticle()->GetMomentum() ).unit();
231
232      //G4cout << "HP_DB ifast " << ifast << " ke0 " << ke0 << G4endl;
233
234      if ( ke0 + dif_e > 0 )
235      {
236         theResult.GetSecondary( ifast )->GetParticle()->SetKineticEnergy( ke0 + dif_e ); 
237         G4ThreeVector dp = p0 - theResult.GetSecondary( ifast )->GetParticle()->GetMomentum(); 
238
239         G4ThreeVector p = theResult.GetSecondary( islow )->GetParticle()->GetMomentum();
240         //theResult.GetSecondary( islow )->GetParticle()->SetMomentum( p - dif_e*dir );
241         theResult.GetSecondary( islow )->GetParticle()->SetMomentum( p + dp ); 
242      }
243      else
244      {
245         //G4cout << "HP_DB Difference in dif_e too large ( <0MeV ) to adjust, so that give up tuning" << G4endl;
246      }
247
248   }
249
250}
Note: See TracBrowser for help on using the repository browser.