Geant4  10.01.p01
G4NeutronHPInelasticCompFS.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 // neutron_hp -- source file
27 // J.P. Wellisch, Nov-1996
28 // A prototype of the low energy neutron transport model.
29 //
30 // 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi)
31 // 070606 bug fix and migrate to enable to Partial cases by T. Koi
32 // 080603 bug fix for Hadron Hyper News #932 by T. Koi
33 // 080612 bug fix contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #4,6
34 // 080717 bug fix of calculation of residual momentum by T. Koi
35 // 080801 protect negative avalable energy by T. Koi
36 // introduce theNDLDataA,Z which has A and Z of NDL data by T. Koi
37 // 081024 G4NucleiPropertiesTable:: to G4NucleiProperties::
38 // 090514 Fix bug in IC electron emission case
39 // Contribution from Chao Zhang (Chao.Zhang@usd.edu) and Dongming Mei(Dongming.Mei@usd.edu)
40 // 100406 "nothingWasKnownOnHadron=1" then sample mu isotropic in CM
41 // add two_body_reaction
42 // 100909 add safty
43 // 101111 add safty for _nat_ data case in Binary reaction, but break conservation
44 // 110430 add Reaction Q value and break up flag (MF3::QI and LR)
45 //
47 #include "G4NeutronHPManager.hh"
48 #include "G4PhysicalConstants.hh"
49 #include "G4SystemOfUnits.hh"
50 #include "G4Nucleus.hh"
51 #include "G4NucleiProperties.hh"
52 #include "G4He3.hh"
53 #include "G4Alpha.hh"
54 #include "G4Electron.hh"
55 #include "G4NeutronHPDataUsed.hh"
56 #include "G4IonTable.hh"
57 
59 {
60  // char the[100] = {""};
61  // std::ostrstream ost(the, 100, std::ios::out);
62  // ost <<gammaPath<<"z"<<ZR<<".a"<<AR;
63  // G4String * aName = new G4String(the);
64  // std::ifstream from(*aName, std::ios::in);
65 
66  std::ostringstream ost;
67  ost <<gammaPath<<"z"<<ZR<<".a"<<AR;
68  G4String aName = ost.str();
69  std::ifstream from(aName, std::ios::in);
70 
71  if(!from) return; // no data found for this isotope
72  // std::ifstream theGammaData(*aName, std::ios::in);
73  std::ifstream theGammaData(aName, std::ios::in);
74 
75  theGammas.Init(theGammaData);
76  // delete aName;
77 }
78 
80 {
81  gammaPath = "/Inelastic/Gammas/";
82  if(!getenv("G4NEUTRONHPDATA"))
83  throw G4HadronicException(__FILE__, __LINE__, "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
84  G4String tBase = getenv("G4NEUTRONHPDATA");
85  gammaPath = tBase+gammaPath;
86  G4String tString = dirName;
87  G4bool dbool;
88  G4NeutronHPDataUsed aFile = theNames.GetName(static_cast<G4int>(A), static_cast<G4int>(Z), M, tString, aFSType, dbool);
89  G4String filename = aFile.GetName();
90  SetAZMs( A, Z, M, aFile );
91  //theBaseA = aFile.GetA();
92  //theBaseZ = aFile.GetZ();
93  //theNDLDataA = (int)aFile.GetA();
94  //theNDLDataZ = aFile.GetZ();
95  //if(!dbool || ( Z<2.5 && ( std::abs(theBaseZ - Z)>0.0001 || std::abs(theBaseA - A)>0.0001)))
96  if ( !dbool || ( Z<2.5 && ( std::abs(theNDLDataZ - Z)>0.0001 || std::abs(theNDLDataA - A)>0.0001)) )
97  {
98  if(getenv("NeutronHPNamesLogging")) G4cout << "Skipped = "<< filename <<" "<<A<<" "<<Z<<G4endl;
99  hasAnyData = false;
100  hasFSData = false;
101  hasXsec = false;
102  return;
103  }
104  //theBaseA = A;
105  //theBaseZ = G4int(Z+.5);
106  //std::ifstream theData(filename, std::ios::in);
107  std::istringstream theData(std::ios::in);
108  G4NeutronHPManager::GetInstance()->GetDataStream(filename,theData);
109  if(!theData) //"!" is a operator of ios
110  {
111  hasAnyData = false;
112  hasFSData = false;
113  hasXsec = false;
114  //theData.close();
115  return;
116  }
117  // here we go
118  G4int infoType, dataType, dummy;
119  G4int sfType, it;
120  hasFSData = false;
121  while (theData >> infoType)
122  {
123  hasFSData = true;
124  theData >> dataType;
125  theData >> sfType >> dummy;
126  it = 50;
127  if(sfType>=600||(sfType<100&&sfType>=50)) it = sfType%50;
128  if(dataType==3)
129  {
130  //theData >> dummy >> dummy;
131  //TK110430
132  // QI and LR introudced since G4NDL3.15
133  G4double dqi;
134  G4int ilr;
135  theData >> dqi >> ilr;
136 
137  QI[ it ] = dqi*eV;
138  LR[ it ] = ilr;
139  theXsection[it] = new G4NeutronHPVector;
140  G4int total;
141  theData >> total;
142  theXsection[it]->Init(theData, total, eV);
143  //std::cout << theXsection[it]->GetXsec(1*MeV) << std::endl;
144  }
145  else if(dataType==4)
146  {
148  theAngularDistribution[it]->Init(theData);
149  }
150  else if(dataType==5)
151  {
153  theEnergyDistribution[it]->Init(theData);
154  }
155  else if(dataType==6)
156  {
158  theEnergyAngData[it]->Init(theData);
159  }
160  else if(dataType==12)
161  {
163  theFinalStatePhotons[it]->InitMean(theData);
164  }
165  else if(dataType==13)
166  {
168  theFinalStatePhotons[it]->InitPartials(theData);
169  }
170  else if(dataType==14)
171  {
172  theFinalStatePhotons[it]->InitAngular(theData);
173  }
174  else if(dataType==15)
175  {
176  theFinalStatePhotons[it]->InitEnergies(theData);
177  }
178  else
179  {
180  throw G4HadronicException(__FILE__, __LINE__, "Data-type unknown to G4NeutronHPInelasticCompFS");
181  }
182  }
183  //theData.close();
184 }
185 
187 {
188 
189 // it = 0 has without Photon
190  G4double running[50];
191  running[0] = 0;
192  unsigned int i;
193  for(i=0; i<50; i++)
194  {
195  if(i!=0) running[i]=running[i-1];
196  if(theXsection[i] != 0)
197  {
198  running[i] += std::max(0., theXsection[i]->GetXsec(eKinetic));
199  }
200  }
201  G4double random = G4UniformRand();
202  G4double sum = running[49];
203  G4int it = 50;
204  if(0!=sum)
205  {
206  G4int i0;
207  for(i0=0; i0<50; i0++)
208  {
209  it = i0;
210  if(random < running[i0]/sum) break;
211  }
212  }
213 //debug: it = 1;
214  return it;
215 }
216 
217 
218  //n,p,d,t,he3,a
220 {
221 
222 // prepare neutron
223  if ( theResult.Get() == NULL ) theResult.Put( new G4HadFinalState );
224  theResult.Get()->Clear();
225  G4double eKinetic = theTrack.GetKineticEnergy();
226  const G4HadProjectile *incidentParticle = &theTrack;
227  G4ReactionProduct theNeutron( incidentParticle->GetDefinition() );
228  theNeutron.SetMomentum( incidentParticle->Get4Momentum().vect() );
229  theNeutron.SetKineticEnergy( eKinetic );
230 
231 // prepare target
232  G4int i;
233  for(i=0; i<50; i++)
234  { if(theXsection[i] != 0) { break; } }
235 
236  G4double targetMass=0;
237  G4double eps = 0.0001;
238  targetMass = ( G4NucleiProperties::GetNuclearMass(static_cast<G4int>(theBaseA+eps), static_cast<G4int>(theBaseZ+eps))) /
240 // if(theEnergyAngData[i]!=0)
241 // targetMass = theEnergyAngData[i]->GetTargetMass();
242 // else if(theAngularDistribution[i]!=0)
243 // targetMass = theAngularDistribution[i]->GetTargetMass();
244 // else if(theFinalStatePhotons[50]!=0)
245 // targetMass = theFinalStatePhotons[50]->GetTargetMass();
246  G4Nucleus aNucleus;
248  G4ThreeVector neuVelo = (1./incidentParticle->GetDefinition()->GetPDGMass())*theNeutron.GetMomentum();
249  theTarget = aNucleus.GetBiasedThermalNucleus( targetMass, neuVelo, theTrack.GetMaterial()->GetTemperature());
250 
251 // prepare the residual mass
252  G4double residualMass=0;
253  G4double residualZ = theBaseZ - aDefinition->GetPDGCharge();
254  G4double residualA = theBaseA - aDefinition->GetBaryonNumber()+1;
255  residualMass = ( G4NucleiProperties::GetNuclearMass(static_cast<G4int>(residualA+eps), static_cast<G4int>(residualZ+eps)) ) /
257 
258 // prepare energy in target rest frame
259  G4ReactionProduct boosted;
260  boosted.Lorentz(theNeutron, theTarget);
261  eKinetic = boosted.GetKineticEnergy();
262 // G4double momentumInCMS = boosted.GetTotalMomentum();
263 
264 // select exit channel for composite FS class.
265  G4int it = SelectExitChannel( eKinetic );
266 
267 // set target and neutron in the relevant exit channel
268  InitDistributionInitialState(theNeutron, theTarget, it);
269 
270  G4ReactionProductVector * thePhotons = 0;
271  G4ReactionProductVector * theParticles = 0;
272  G4ReactionProduct aHadron;
273  aHadron.SetDefinition(aDefinition); // what if only cross-sections exist ==> Na 23 11 @@@@
274  G4double availableEnergy = theNeutron.GetKineticEnergy() + theNeutron.GetMass() - aHadron.GetMass() +
275  (targetMass - residualMass)*G4Neutron::Neutron()->GetPDGMass();
276 //080730c
277  if ( availableEnergy < 0 )
278  {
279  //G4cout << "080730c Adjust availavleEnergy " << G4endl;
280  availableEnergy = 0;
281  }
282  G4int nothingWasKnownOnHadron = 0;
283  G4int dummy;
284  G4double eGamm = 0;
285  G4int iLevel=it-1;
286 
287 // TK without photon has it = 0
288  if( 50 == it )
289  {
290 
291 // TK Excitation level is not determined
292  iLevel=-1;
293  aHadron.SetKineticEnergy(availableEnergy*residualMass*G4Neutron::Neutron()->GetPDGMass()/
294  (aHadron.GetMass()+residualMass*G4Neutron::Neutron()->GetPDGMass()));
295 
296  //aHadron.SetMomentum(theNeutron.GetMomentum()*(1./theNeutron.GetTotalMomentum())*
297  // std::sqrt(aHadron.GetTotalEnergy()*aHadron.GetTotalEnergy()-
298  // aHadron.GetMass()*aHadron.GetMass()));
299 
300  //TK add safty 100909
301  G4double p2 = ( aHadron.GetTotalEnergy()*aHadron.GetTotalEnergy() - aHadron.GetMass()*aHadron.GetMass() );
302  G4double p = 0.0;
303  if ( p2 > 0.0 ) p = std::sqrt( p );
304 
305  aHadron.SetMomentum(theNeutron.GetMomentum()*(1./theNeutron.GetTotalMomentum())*p );
306 
307  }
308  else
309  {
310  while( iLevel!=-1 && theGammas.GetLevel(iLevel) == 0 ) { iLevel--; }
311  }
312 
313 
314  if ( theAngularDistribution[it] != 0 ) // MF4
315  {
316  if(theEnergyDistribution[it]!=0) // MF5
317  {
318  //************************************************************
319  /*
320  aHadron.SetKineticEnergy(theEnergyDistribution[it]->Sample(eKinetic, dummy));
321  G4double eSecN = aHadron.GetKineticEnergy();
322  */
323  //************************************************************
324  //EMendoza --> maximum allowable energy should be taken into account.
325  G4double dqi = 0.0;
326  if ( QI[it] < 0 || 849 < QI[it] ) dqi = QI[it]; //For backword compatibility QI introduced since G4NDL3.15
327  G4double MaxEne=eKinetic+dqi;
328  G4double eSecN;
329  do{
330  eSecN=theEnergyDistribution[it]->Sample(eKinetic, dummy);
331  }while(eSecN>MaxEne);
332  aHadron.SetKineticEnergy(eSecN);
333  //************************************************************
334  eGamm = eKinetic-eSecN;
335  for(iLevel=theGammas.GetNumberOfLevels()-1; iLevel>=0; iLevel--)
336  {
337  if(theGammas.GetLevelEnergy(iLevel)<eGamm) break;
338  }
339  G4double random = 2*G4UniformRand();
340  iLevel+=G4int(random);
341  if(iLevel>theGammas.GetNumberOfLevels()-1)iLevel = theGammas.GetNumberOfLevels()-1;
342  }
343  else
344  {
345  G4double eExcitation = 0;
346  if(iLevel>=0) eExcitation = theGammas.GetLevel(iLevel)->GetLevelEnergy();
347  while (eKinetic-eExcitation < 0 && iLevel>0)
348  {
349  iLevel--;
350  eExcitation = theGammas.GetLevel(iLevel)->GetLevelEnergy();
351  }
352  //110610TK BEGIN
353  //Use QI value for calculating excitation energy of residual.
354  G4bool useQI=false;
355  G4double dqi = QI[it];
356  if ( dqi < 0 || 849 < dqi ) useQI = true; //Former libraies does not have values of this range
357 
358  if ( useQI )
359  {
360  // QI introudced since G4NDL3.15
361  eExcitation = -QI[it];
362  //Re-evluate iLevel based on this eExcitation
363  iLevel = 0;
364  G4bool find = false;
365  G4int imaxEx = 0;
366  while ( theGammas.GetLevel(iLevel+1) != 0 )
367  {
368  G4double maxEx = 0.0;
369  if ( maxEx < theGammas.GetLevel(iLevel)->GetLevelEnergy() )
370  {
371  maxEx = theGammas.GetLevel(iLevel)->GetLevelEnergy();
372  imaxEx = iLevel;
373  }
374  if ( eExcitation < theGammas.GetLevel(iLevel)->GetLevelEnergy() )
375  {
376  find = true;
377  iLevel--;
378  // very small eExcitation, iLevel becomes -1, this is protected below.
379  if ( iLevel == -1 ) iLevel = 0; // But cause energy trouble.
380  break;
381  }
382  iLevel++;
383  }
384  // In case, cannot find proper level, then use the maximum level.
385  if ( !find ) iLevel = imaxEx;
386  }
387  //110610TK END
388 
389  if(getenv("InelasticCompFSLogging") && eKinetic-eExcitation < 0)
390  {
391  throw G4HadronicException(__FILE__, __LINE__, "SEVERE: InelasticCompFS: Consistency of data not good enough, please file report");
392  }
393  if(eKinetic-eExcitation < 0) eExcitation = 0;
394  if(iLevel!= -1) aHadron.SetKineticEnergy(eKinetic - eExcitation);
395 
396  }
398 
399  if( theFinalStatePhotons[it] == 0 )
400  {
401  //G4cout << "110610 USE Gamma Level" << G4endl;
402 // TK comment Most n,n* eneter to this
403  thePhotons = theGammas.GetDecayGammas(iLevel);
404  eGamm -= theGammas.GetLevelEnergy(iLevel);
405  if(eGamm>0) // @ ok for now, but really needs an efficient way of correllated sampling @
406  {
407  G4ReactionProduct * theRestEnergy = new G4ReactionProduct;
408  theRestEnergy->SetDefinition(G4Gamma::Gamma());
409  theRestEnergy->SetKineticEnergy(eGamm);
410  G4double costh = 2.*G4UniformRand()-1.;
411  G4double phi = twopi*G4UniformRand();
412  theRestEnergy->SetMomentum(eGamm*std::sin(std::acos(costh))*std::cos(phi),
413  eGamm*std::sin(std::acos(costh))*std::sin(phi),
414  eGamm*costh);
415  if(thePhotons == 0) { thePhotons = new G4ReactionProductVector; }
416  thePhotons->push_back(theRestEnergy);
417  }
418  }
419  }
420  else if(theEnergyAngData[it] != 0) // MF6
421  {
422  theParticles = theEnergyAngData[it]->Sample(eKinetic);
423 
424  //141017 Fix BEGIN
425  //Adjust A and Z in the case of miss much between selected data and target nucleus
426  if ( theParticles != NULL ) {
427  G4int sumA = 0;
428  G4int sumZ = 0;
429  G4int maxA = 0;
430  G4int jAtMaxA = 0;
431  for ( G4int j = 0 ; j != (G4int)theParticles->size() ; j++ ) {
432  if ( theParticles->at(j)->GetDefinition()->GetBaryonNumber() > maxA ) {
433  maxA = theParticles->at(j)->GetDefinition()->GetBaryonNumber();
434  jAtMaxA = j;
435  }
436  sumA += theParticles->at(j)->GetDefinition()->GetBaryonNumber();
437  sumZ += G4int( theParticles->at(j)->GetDefinition()->GetPDGCharge() + eps );
438  }
439  G4int dA = (G4int)theBaseA + incidentParticle->GetDefinition()->GetBaryonNumber() - sumA;
440  G4int dZ = (G4int)theBaseZ + G4int( incidentParticle->GetDefinition()->GetPDGCharge() + eps ) - sumZ;
441  if ( dA < 0 || dZ < 0 ) {
442  G4int newA = theParticles->at(jAtMaxA)->GetDefinition()->GetBaryonNumber() + dA ;
443  G4int newZ = G4int( theParticles->at(jAtMaxA)->GetDefinition()->GetPDGCharge() + eps ) + dZ;
444  G4ParticleDefinition* pd = G4IonTable::GetIonTable()->GetIon ( newZ , newA );
445  theParticles->at( jAtMaxA )->SetDefinition( pd );
446  }
447  }
448  //141017 Fix END
449 
450  }
451  else
452  {
453  // @@@ what to do, if we have photon data, but no info on the hadron itself
454  nothingWasKnownOnHadron = 1;
455  }
456 
457  //G4cout << "theFinalStatePhotons it " << it << G4endl;
458  //G4cout << "theFinalStatePhotons[it] " << theFinalStatePhotons[it] << G4endl;
459  //G4cout << "theFinalStatePhotons it " << it << G4endl;
460  //G4cout << "theFinalStatePhotons[it] " << theFinalStatePhotons[it] << G4endl;
461  //G4cout << "thePhotons " << thePhotons << G4endl;
462 
463  if ( theFinalStatePhotons[it] != 0 )
464  {
465  // the photon distributions are in the Nucleus rest frame.
466  // TK residual rest frame
467  G4ReactionProduct boosted_tmp;
468  boosted_tmp.Lorentz(theNeutron, theTarget);
469  G4double anEnergy = boosted_tmp.GetKineticEnergy();
470  thePhotons = theFinalStatePhotons[it]->GetPhotons(anEnergy);
471  G4double aBaseEnergy = theFinalStatePhotons[it]->GetLevelEnergy();
472  G4double testEnergy = 0;
473  if(thePhotons!=0 && thePhotons->size()!=0)
474  { aBaseEnergy-=thePhotons->operator[](0)->GetTotalEnergy(); }
475  if(theFinalStatePhotons[it]->NeedsCascade())
476  {
477  while(aBaseEnergy>0.01*keV)
478  {
479  // cascade down the levels
480  G4bool foundMatchingLevel = false;
481  G4int closest = 2;
482  G4double deltaEold = -1;
483  for(G4int j=1; j<it; j++)
484  {
485  if(theFinalStatePhotons[j]!=0)
486  {
487  testEnergy = theFinalStatePhotons[j]->GetLevelEnergy();
488  }
489  else
490  {
491  testEnergy = 0;
492  }
493  G4double deltaE = std::abs(testEnergy-aBaseEnergy);
494  if(deltaE<0.1*keV)
495  {
496  G4ReactionProductVector * theNext =
497  theFinalStatePhotons[j]->GetPhotons(anEnergy);
498  thePhotons->push_back(theNext->operator[](0));
499  aBaseEnergy = testEnergy-theNext->operator[](0)->GetTotalEnergy();
500  delete theNext;
501  foundMatchingLevel = true;
502  break; // ===>
503  }
504  if(theFinalStatePhotons[j]!=0 && ( deltaE<deltaEold||deltaEold<0.) )
505  {
506  closest = j;
507  deltaEold = deltaE;
508  }
509  } // <=== the break goes here.
510  if(!foundMatchingLevel)
511  {
512  G4ReactionProductVector * theNext =
513  theFinalStatePhotons[closest]->GetPhotons(anEnergy);
514  thePhotons->push_back(theNext->operator[](0));
515  aBaseEnergy = aBaseEnergy-theNext->operator[](0)->GetTotalEnergy();
516  delete theNext;
517  }
518  }
519  }
520  }
521  unsigned int i0;
522  if(thePhotons!=0)
523  {
524  for(i0=0; i0<thePhotons->size(); i0++)
525  {
526  // back to lab
527  thePhotons->operator[](i0)->Lorentz(*(thePhotons->operator[](i0)), -1.*theTarget);
528  }
529  }
530  //G4cout << "nothingWasKnownOnHadron " << nothingWasKnownOnHadron << G4endl;
531  if(nothingWasKnownOnHadron)
532  {
533 // TKDB 100405
534 // In this case, hadron should be isotropic in CM
535 // mu and p should be correlated
536 //
537  G4double totalPhotonEnergy = 0.0;
538  if ( thePhotons != 0 )
539  {
540  unsigned int nPhotons = thePhotons->size();
541  unsigned int ii0;
542  for ( ii0=0; ii0<nPhotons; ii0++)
543  {
544  //thePhotons has energies at LAB system
545  totalPhotonEnergy += thePhotons->operator[](ii0)->GetTotalEnergy();
546  }
547  }
548 
549  //isotropic distribution in CM
550  G4double mu = 1.0 - 2 * G4UniformRand();
551 
552  // need momentums in target rest frame;
553  G4LorentzVector target_in_LAB ( theTarget.GetMomentum() , theTarget.GetTotalEnergy() );
554  G4ThreeVector boostToTargetRest = -target_in_LAB.boostVector();
555  G4LorentzVector proj_in_LAB = incidentParticle->Get4Momentum();
556 
557  G4DynamicParticle* proj = new G4DynamicParticle( G4Neutron::Neutron() , proj_in_LAB.boost( boostToTargetRest ) );
558  G4DynamicParticle* targ = new G4DynamicParticle( G4IonTable::GetIonTable()->GetIon ( (G4int)theBaseZ , (G4int)theBaseA , totalPhotonEnergy ) , G4ThreeVector(0) );
559  G4DynamicParticle* hadron = new G4DynamicParticle( aHadron.GetDefinition() , G4ThreeVector(0) ); // will be fill momentum
560 
561  two_body_reaction ( proj , targ , hadron , mu );
562 
563  G4LorentzVector hadron_in_trag_rest = hadron->Get4Momentum();
564  G4LorentzVector hadron_in_LAB = hadron_in_trag_rest.boost ( -boostToTargetRest );
565  aHadron.SetMomentum( hadron_in_LAB.v() );
566  aHadron.SetKineticEnergy ( hadron_in_LAB.e() - hadron_in_LAB.m() );
567 
568  delete proj;
569  delete targ;
570  delete hadron;
571 
572 //TKDB 100405
573 /*
574  G4double totalPhotonEnergy = 0;
575  if(thePhotons!=0)
576  {
577  unsigned int nPhotons = thePhotons->size();
578  unsigned int i0;
579  for(i0=0; i0<nPhotons; i0++)
580  {
581  totalPhotonEnergy += thePhotons->operator[](i0)->GetTotalEnergy();
582  }
583  }
584  availableEnergy -= totalPhotonEnergy;
585  residualMass += totalPhotonEnergy/G4Neutron::Neutron()->GetPDGMass();
586  aHadron.SetKineticEnergy(availableEnergy*residualMass*G4Neutron::Neutron()->GetPDGMass()/
587  (aHadron.GetMass()+residualMass*G4Neutron::Neutron()->GetPDGMass()));
588  G4double CosTheta = 1.0 - 2.0*G4UniformRand();
589  G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta);
590  G4double Phi = twopi*G4UniformRand();
591  G4ThreeVector Vector(std::cos(Phi)*SinTheta, std::sin(Phi)*SinTheta, CosTheta);
592  //aHadron.SetMomentum(Vector* std::sqrt(aHadron.GetTotalEnergy()*aHadron.GetTotalEnergy()-
593  // aHadron.GetMass()*aHadron.GetMass()));
594  G4double p2 = aHadron.GetTotalEnergy()*aHadron.GetTotalEnergy()- aHadron.GetMass()*aHadron.GetMass();
595 
596  G4double p = 0.0;
597  if ( p2 > 0.0 )
598  p = std::sqrt ( p2 );
599 
600  aHadron.SetMomentum( Vector*p );
601 */
602 
603  }
604 
605 // fill the result
606 // Beware - the recoil is not necessarily in the particles...
607 // Can be calculated from momentum conservation?
608 // The idea is that the particles ar emitted forst, and the gammas only once the
609 // recoil is on the residual; assumption is that gammas do not contribute to
610 // the recoil.
611 // This needs more design @@@
612 
613  G4int nSecondaries = 2; // the hadron and the recoil
614  G4bool needsSeparateRecoil = false;
615  G4int totalBaryonNumber = 0;
616  G4int totalCharge = 0;
617  G4ThreeVector totalMomentum(0);
618  if(theParticles != 0)
619  {
620  nSecondaries = theParticles->size();
621  const G4ParticleDefinition * aDef;
622  unsigned int ii0;
623  for(ii0=0; ii0<theParticles->size(); ii0++)
624  {
625  aDef = theParticles->operator[](ii0)->GetDefinition();
626  totalBaryonNumber+=aDef->GetBaryonNumber();
627  totalCharge+=G4int(aDef->GetPDGCharge()+eps);
628  totalMomentum += theParticles->operator[](ii0)->GetMomentum();
629  }
630  if(totalBaryonNumber!=G4int(theBaseA+eps+incidentParticle->GetDefinition()->GetBaryonNumber()))
631  {
632  needsSeparateRecoil = true;
633  nSecondaries++;
634  residualA = G4int(theBaseA+eps+incidentParticle->GetDefinition()->GetBaryonNumber()
635  -totalBaryonNumber);
636  residualZ = G4int(theBaseZ+eps+incidentParticle->GetDefinition()->GetPDGCharge()
637  -totalCharge);
638  }
639  }
640 
641  G4int nPhotons = 0;
642  if(thePhotons!=0) { nPhotons = thePhotons->size(); }
643  nSecondaries += nPhotons;
644 
645  G4DynamicParticle * theSec;
646 
647  if( theParticles==0 )
648  {
649  theSec = new G4DynamicParticle;
650  theSec->SetDefinition(aHadron.GetDefinition());
651  theSec->SetMomentum(aHadron.GetMomentum());
652  theResult.Get()->AddSecondary(theSec);
653 
654  aHadron.Lorentz(aHadron, theTarget);
655  G4ReactionProduct theResidual;
657  ->GetIon(static_cast<G4int>(residualZ), static_cast<G4int>(residualA), 0));
658  theResidual.SetKineticEnergy(aHadron.GetKineticEnergy()*aHadron.GetMass()/theResidual.GetMass());
659 
660  //080612TK contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #6
661  //theResidual.SetMomentum(-1.*aHadron.GetMomentum());
662  G4ThreeVector incidentNeutronMomentum = theNeutron.GetMomentum();
663  theResidual.SetMomentum(incidentNeutronMomentum - aHadron.GetMomentum());
664 
665  theResidual.Lorentz(theResidual, -1.*theTarget);
666  G4ThreeVector totalPhotonMomentum(0,0,0);
667  if(thePhotons!=0)
668  {
669  for(i=0; i<nPhotons; i++)
670  {
671  totalPhotonMomentum += thePhotons->operator[](i)->GetMomentum();
672  }
673  }
674  theSec = new G4DynamicParticle;
675  theSec->SetDefinition(theResidual.GetDefinition());
676  theSec->SetMomentum(theResidual.GetMomentum()-totalPhotonMomentum);
677  theResult.Get()->AddSecondary(theSec);
678  }
679  else
680  {
681  for(i0=0; i0<theParticles->size(); i0++)
682  {
683  theSec = new G4DynamicParticle;
684  theSec->SetDefinition(theParticles->operator[](i0)->GetDefinition());
685  theSec->SetMomentum(theParticles->operator[](i0)->GetMomentum());
686  theResult.Get()->AddSecondary(theSec);
687  delete theParticles->operator[](i0);
688  }
689  delete theParticles;
690  if(needsSeparateRecoil && residualZ!=0)
691  {
692  G4ReactionProduct theResidual;
694  ->GetIon(static_cast<G4int>(residualZ), static_cast<G4int>(residualA), 0));
695  G4double resiualKineticEnergy = theResidual.GetMass()*theResidual.GetMass();
696  resiualKineticEnergy += totalMomentum*totalMomentum;
697  resiualKineticEnergy = std::sqrt(resiualKineticEnergy) - theResidual.GetMass();
698 // cout << "Kinetic energy of the residual = "<<resiualKineticEnergy<<endl;
699  theResidual.SetKineticEnergy(resiualKineticEnergy);
700 
701  //080612TK contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #4
702  //theResidual.SetMomentum(-1.*totalMomentum);
703  //G4ThreeVector incidentNeutronMomentum = theNeutron.GetMomentum();
704  //theResidual.SetMomentum(incidentNeutronMomentum - aHadron.GetMomentum());
705 //080717 TK Comment still do NOT include photon's mometum which produce by thePhotons
706  theResidual.SetMomentum( theNeutron.GetMomentum() + theTarget.GetMomentum() - totalMomentum );
707 
708  theSec = new G4DynamicParticle;
709  theSec->SetDefinition(theResidual.GetDefinition());
710  theSec->SetMomentum(theResidual.GetMomentum());
711  theResult.Get()->AddSecondary(theSec);
712  }
713  }
714  if(thePhotons!=0)
715  {
716  for(i=0; i<nPhotons; i++)
717  {
718  theSec = new G4DynamicParticle;
719  //Bug reported Chao Zhang (Chao.Zhang@usd.edu), Dongming Mei(Dongming.Mei@usd.edu) Feb. 25, 2009
720  //theSec->SetDefinition(G4Gamma::Gamma());
721  theSec->SetDefinition( thePhotons->operator[](i)->GetDefinition() );
722  //But never cause real effect at least with G4NDL3.13 TK
723  theSec->SetMomentum(thePhotons->operator[](i)->GetMomentum());
724  theResult.Get()->AddSecondary(theSec);
725  delete thePhotons->operator[](i);
726  }
727 // some garbage collection
728  delete thePhotons;
729  }
730 
731 //080721
733  G4LorentzVector targ_4p_lab ( theTarget.GetMomentum() , std::sqrt( targ_pd->GetPDGMass()*targ_pd->GetPDGMass() + theTarget.GetMomentum().mag2() ) );
734  G4LorentzVector proj_4p_lab = theTrack.Get4Momentum();
735  G4LorentzVector init_4p_lab = proj_4p_lab + targ_4p_lab;
736  adjust_final_state ( init_4p_lab );
737 
738 // clean up the primary neutron
740 }
741 
742 
743 
744 #include "G4RotationMatrix.hh"
746 {
747 
748 // Target rest flame
749 // 4vector in targ rest frame;
750 // targ could have excitation energy (photon energy will be emiited) tricky but,,,
751 
752  G4LorentzVector before = proj->Get4Momentum() + targ->Get4Momentum();
753 
754  G4ThreeVector p3_proj = proj->GetMomentum();
755  G4ThreeVector d = p3_proj.unit();
756  G4RotationMatrix rot;
757  G4RotationMatrix rot1;
758  rot1.setPhi( pi/2 + d.phi() );
759  G4RotationMatrix rot2;
760  rot2.setTheta( d.theta() );
761  rot=rot2*rot1;
762  proj->SetMomentum( rot*p3_proj );
763 
764 // Now proj only has pz component;
765 
766 // mu in CM system
767 
768  //Valid only for neutron incidence
769  G4DynamicParticle* residual = new G4DynamicParticle ( G4IonTable::GetIonTable()->GetIon ( (G4int)( targ->GetDefinition()->GetPDGCharge() - hadron->GetDefinition()->GetPDGCharge() ) , (G4int)(targ->GetDefinition()->GetBaryonNumber() - hadron->GetDefinition()->GetBaryonNumber()+1) , 0 ) , G4ThreeVector(0) );
770 
771  G4double Q = proj->GetDefinition()->GetPDGMass() + targ->GetDefinition()->GetPDGMass()
772  - ( hadron->GetDefinition()->GetPDGMass() + residual->GetDefinition()->GetPDGMass() );
773 
774  // Non Relativistic Case
775  G4double A = targ->GetDefinition()->GetPDGMass() / proj->GetDefinition()->GetPDGMass();
776  G4double AA = hadron->GetDefinition()->GetPDGMass() / proj->GetDefinition()->GetPDGMass();
777  G4double E1 = proj->GetKineticEnergy();
778 
779 // 101111
780 // In _nat_ data (Q+E1) could become negative value, following line is safty for this case.
781  //if ( (Q+E1) < 0 )
782  if ( ( 1 + (1+A)/A*Q/E1 ) < 0 )
783  {
784 // 1.0e-6 eV is additional safty for numeric precision
785  Q = -( A/(1+A)*E1 ) + 1.0e-6*eV;
786  }
787 
788  G4double beta = std::sqrt ( A*(A+1-AA)/AA*( 1 + (1+A)/A*Q/E1 ) );
789  //G4double gamma = AA/(A+1-AA)*beta;
790  G4double E3 = AA/std::pow((1+A),2)*(beta*beta+1+2*beta*mu)*E1;
791  G4double omega3 = (1+beta*mu)/std::sqrt(beta*beta+1+2*beta*mu);
792  if ( omega3 > 1.0 ) omega3 = 1.0;
793 
794  //G4double E4 = (A+1-AA)/std::pow((1+A),2)*(gamma*gamma+1-2*gamma*mu)*E1;
795  //G4double omega4 = (1-gamma*mu)/std::sqrt(gamma*gamma+1-2*gamma*mu);
796  //if ( omega4 > 1.0 ) omega4 = 1.0;
797 
798  hadron->SetKineticEnergy ( E3 );
799 
800  G4double M = hadron->GetDefinition()->GetPDGMass();
801  G4double pmag = std::sqrt ((E3+M)*(E3+M)-M*M) ;
802  G4ThreeVector p ( 0 , pmag*std::sqrt(1-omega3*omega3), pmag*omega3 );
803 
804  //G4double M4 = residual->GetDefinition()->GetPDGMass();
805  //G4double pmag4 = std::sqrt ((E4+M4)*(E4+M4)-M4*M4) ;
806  //G4ThreeVector p4 ( 0 , -pmag4*std::sqrt(1-omega4*omega4), pmag4*omega4 );
807 
808 // Rotate to orginal target rest flame.
809  p *= rot.inverse();
810  hadron->SetMomentum( p );
811 // Now hadron had 4 momentum in target rest flame
812 
813 // TypeA
814  //p4 *= rot.inverse();
815  //residual->SetMomentum ( p4 );
816 
817 //TypeB1
818  //residual->Set4Momentum ( p4_residual );
819 //TypeB2
820  //residual->SetMomentum ( p4_residual.v() );
821 
822 // Type A make difference in Momenutum
823 // Type B1 make difference in Mass of residual
824 // Type B2 make difference in total energy.
825 
826  delete residual;
827 
828 }
G4ReactionProductVector * GetPhotons(G4double anEnergy)
static G4double GetNuclearMass(const G4double A, const G4double Z)
void SetMomentum(const G4ThreeVector &momentum)
void two_body_reaction(G4DynamicParticle *, G4DynamicParticle *, G4DynamicParticle *, G4double mu)
G4NeutronHPLevel * GetLevel(G4int i)
void Lorentz(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
G4double GetKineticEnergy() const
G4Cache< G4HadFinalState * > theResult
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
void SetKineticEnergy(const G4double en)
static G4NeutronHPManager * GetInstance()
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:463
const G4double pi
void Init(std::istream &aDataFile)
value_type & Get() const
Definition: G4Cache.hh:253
G4double Sample(G4double anEnergy, G4int &it)
virtual G4NeutronHPVector * GetXsec()
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
static const G4double eps
G4ParticleDefinition * GetDefinition() const
void GetDataStream(G4String, std::istringstream &iss)
G4NeutronHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
int G4int
Definition: G4Types.hh:78
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetStatusChange(G4HadFinalStateStatus aS)
std::vector< G4ReactionProduct * > G4ReactionProductVector
void InitAngular(std::istream &aDataFile)
const G4ParticleDefinition * GetDefinition() const
G4ReactionProduct GetBiasedThermalNucleus(G4double aMass, G4ThreeVector aVelocity, G4double temp=-1) const
Definition: G4Nucleus.cc:108
#define G4UniformRand()
Definition: Randomize.hh:95
G4GLOB_DLL std::ostream G4cout
G4NeutronHPEnergyDistribution * theEnergyDistribution[51]
const G4ParticleDefinition * GetDefinition() const
void CompositeApply(const G4HadProjectile &theTrack, G4ParticleDefinition *aHadron)
bool G4bool
Definition: G4Types.hh:79
G4double GetKineticEnergy() const
G4int SelectExitChannel(G4double eKinetic)
G4ErrorTarget * theTarget
Definition: errprop.cc:59
void InitEnergies(std::istream &aDataFile)
void Init(std::istream &aDataFile)
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
static const G4double A[nN]
const G4LorentzVector & Get4Momentum() const
void InitGammas(G4double AR, G4double ZR)
void SetKineticEnergy(G4double aEnergy)
G4NeutronHPEnAngCorrelation * theEnergyAngData[51]
G4LorentzVector Get4Momentum() const
static G4IonTable * GetIonTable()
Definition: G4IonTable.hh:78
G4double GetKineticEnergy() const
void SampleAndUpdate(G4ReactionProduct &aNeutron)
G4NeutronHPAngular * theAngularDistribution[51]
static const double eV
Definition: G4SIunits.hh:194
G4double GetTotalEnergy() const
G4bool InitMean(std::istream &aDataFile)
G4double total(Particle const *const p1, Particle const *const p2)
G4double GetPDGMass() const
G4double GetLevelEnergy(G4int aLevel)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4NeutronHPPhotonDist * theFinalStatePhotons[51]
G4ThreeVector GetMomentum() const
G4double GetTemperature() const
Definition: G4Material.hh:182
#define G4endl
Definition: G4ios.hh:61
const G4Material * GetMaterial() const
G4ReactionProductVector * Sample(G4double anEnergy)
void AddSecondary(G4DynamicParticle *aP, G4int mod=-1)
void Init(G4double A, G4double Z, G4int M, G4String &dirName, G4String &aSFType)
static const double keV
Definition: G4SIunits.hh:195
G4ReactionProductVector * GetDecayGammas(G4int aLevel)
void SetAZMs(G4double anA, G4double aZ, G4int aM, G4NeutronHPDataUsed used)
double G4double
Definition: G4Types.hh:76
void InitDistributionInitialState(G4ReactionProduct &aNeutron, G4ReactionProduct &aTarget, G4int it)
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void adjust_final_state(G4LorentzVector)
G4double GetPDGCharge() const
void Put(const value_type &val) const
Definition: G4Cache.hh:257
G4double GetLevelEnergy()
G4double GetMass() const
void InitPartials(std::istream &aDataFile)
void Init(std::istream &aDataFile)
G4ThreeVector GetMomentum() const
CLHEP::HepLorentzVector G4LorentzVector