Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4NeutronHPDeExGammas Class Reference

#include <G4NeutronHPDeExGammas.hh>

Public Member Functions

 G4NeutronHPDeExGammas ()
 
 ~G4NeutronHPDeExGammas ()
 
void Init (std::istream &aDataFile)
 
G4ReactionProductVectorGetDecayGammas (G4int aLevel)
 
G4NeutronHPLevelGetLevel (G4int i)
 
G4int GetNumberOfLevels ()
 
G4double GetLevelEnergy (G4int aLevel)
 

Detailed Description

Definition at line 42 of file G4NeutronHPDeExGammas.hh.

Constructor & Destructor Documentation

G4NeutronHPDeExGammas::G4NeutronHPDeExGammas ( )
inline

Definition at line 46 of file G4NeutronHPDeExGammas.hh.

47  {
48  levelStart = 0;
49  levelSize = 0;
50  nLevels = 0;
51  theLevels = 0;
52  }
G4NeutronHPDeExGammas::~G4NeutronHPDeExGammas ( )
inline

Definition at line 53 of file G4NeutronHPDeExGammas.hh.

54  {
55  if(levelStart!=0) delete [] levelStart;
56  if(levelSize!=0) delete [] levelSize;
57  if(theLevels!=0) delete [] theLevels;
58  }

Member Function Documentation

G4ReactionProductVector* G4NeutronHPDeExGammas::GetDecayGammas ( G4int  aLevel)
inline

Definition at line 62 of file G4NeutronHPDeExGammas.hh.

References G4UniformRand, G4ReactionProduct::GetTotalMomentum(), and G4ReactionProduct::SetMomentum().

Referenced by G4NeutronHPInelasticBaseFS::BaseApply(), and G4NeutronHPInelasticCompFS::CompositeApply().

63  {
64  if(aLevel>nLevels-1 || aLevel<0) return 0;
65  if(nLevels==0) return new G4ReactionProductVector();
67  G4DynamicParticleVector * theResult;
68 
69  theResult = theLevels[aLevel]. GetDecayGammas();
70  G4ReactionProduct * theCurrent;
71  unsigned int i;
72  for(i=0; i<theResult->size(); i++)
73  {
74  theCurrent = new G4ReactionProduct;
75  *theCurrent = *(theResult->operator[](i));
76  delete theResult->operator[](i);
77  G4double costheta = 2.*G4UniformRand()-1;
78  G4double theta = std::acos(costheta);
79  G4double phi = CLHEP::twopi*G4UniformRand();
80  G4double sinth = std::sin(theta);
81  G4double en = theCurrent->GetTotalMomentum();
82  G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costheta );
83  theCurrent->SetMomentum( temp ) ;
84  result->push_back(theCurrent);
85  }
86  delete theResult;
87  return result;
88  }
G4double GetTotalMomentum() const
void SetMomentum(const G4double x, const G4double y, const G4double z)
std::vector< G4ReactionProduct * > G4ReactionProductVector
#define G4UniformRand()
Definition: Randomize.hh:87
std::vector< G4DynamicParticle * > G4DynamicParticleVector
G4ReactionProductVector * GetDecayGammas(G4int aLevel)
double G4double
Definition: G4Types.hh:76
G4NeutronHPLevel* G4NeutronHPDeExGammas::GetLevel ( G4int  i)
inline

Definition at line 90 of file G4NeutronHPDeExGammas.hh.

Referenced by G4NeutronHPInelasticCompFS::CompositeApply().

91  {
92  if(i>nLevels-1) return 0;
93  return theLevels+i;
94  }
G4double G4NeutronHPDeExGammas::GetLevelEnergy ( G4int  aLevel)
inline

Definition at line 98 of file G4NeutronHPDeExGammas.hh.

References G4NeutronHPLevel::GetLevelEnergy().

Referenced by G4NeutronHPInelasticBaseFS::BaseApply(), G4NeutronHPInelasticCompFS::CompositeApply(), and Init().

99  {
100  if(aLevel>nLevels-1 || aLevel<0) return 0;
101  G4double result = theLevels[aLevel].GetLevelEnergy();
102  return result;
103  }
double G4double
Definition: G4Types.hh:76
G4double GetLevelEnergy()
G4int G4NeutronHPDeExGammas::GetNumberOfLevels ( )
inline

Definition at line 96 of file G4NeutronHPDeExGammas.hh.

Referenced by G4NeutronHPInelasticBaseFS::BaseApply(), and G4NeutronHPInelasticCompFS::CompositeApply().

96 { return nLevels; }
void G4NeutronHPDeExGammas::Init ( std::istream &  aDataFile)

Definition at line 35 of file G4NeutronHPDeExGammas.cc.

References buffer, G4NeutronHPGamma::GetGammaEnergy(), G4NeutronHPLevel::GetLevelEnergy(), G4NeutronHPGamma::GetLevelEnergy(), GetLevelEnergy(), G4NeutronHPGamma::Init(), python.hepunit::keV, G4INCL::Math::min(), G4NeutronHPLevel::SetGamma(), G4NeutronHPGamma::SetNext(), and G4NeutronHPLevel::SetNumberOfGammas().

Referenced by G4NeutronHPInelasticBaseFS::InitGammas(), and G4NeutronHPInelasticCompFS::InitGammas().

36 {
37  G4NeutronHPGamma ** theGammas = new G4NeutronHPGamma * [50];
38  G4int nGammas = 0;
39  G4int nBuff = 50;
40  for(;;)
41  {
42  G4NeutronHPGamma * theNew = new G4NeutronHPGamma;
43  if(!theNew->Init(aDataFile))
44  {
45  delete theNew;
46  break;
47  }
48  else
49  {
50  if(nGammas==nBuff)
51  {
52  nBuff+=50;
53  G4NeutronHPGamma ** buffer = new G4NeutronHPGamma * [nBuff];
54  for(G4int i=0;i<nGammas;i++) buffer[i] = theGammas[i];
55  delete [] theGammas;
56  theGammas = buffer;
57  }
58  theGammas[nGammas] = theNew;
59  nGammas++;
60  }
61  }
62  // all gammas are in. Now sort them into levels.
63 
64  // count the levels
65 
66  G4double currentE = 0;
67  G4double nextE = 0;
68  G4int i;
69  G4double epsilon = 0.01*keV;
70  for(i=0; i<nGammas; i++)
71  {
72  nextE = theGammas[i]->GetLevelEnergy();
73  if(std::abs(currentE-nextE)>epsilon) nLevels++;
74  currentE = nextE;
75  }
76 
77  // Build the levels
78 
79  theLevels = new G4NeutronHPLevel[nLevels];
80  levelStart = new G4int [nLevels];
81  levelSize = new G4int [nLevels];
82 
83  // fill the levels
84 
85  currentE = 0;
86  nextE = 0;
87  G4int levelCounter=-1;
88  for(i=0; i<nGammas; i++)
89  {
90  nextE = theGammas[i]->GetLevelEnergy();
91  if(std::abs(currentE-nextE)>epsilon)
92  {
93  levelCounter++;
94  levelStart[levelCounter] = i;
95  levelSize[levelCounter] = 0;
96  }
97  levelSize[levelCounter]++;
98  currentE = nextE;
99  }
100 
101  for(i=0; i<nLevels; i++)
102  {
103  theLevels[i].SetNumberOfGammas(levelSize[i]);
104  for(G4int ii=levelStart[i]; ii<levelStart[i]+levelSize[i]; ii++)
105  {
106  theLevels[i].SetGamma(ii-levelStart[i], theGammas[ii]);
107  }
108  }
109 
110 // set the next relation in the gammas.
111  G4double levelE, gammaE, currentLevelE;
112  G4double min;
113  for(i=0; i<nGammas; i++)
114  {
115  G4int it=-1;
116  gammaE = theGammas[i]->GetGammaEnergy();
117  currentLevelE = theGammas[i]->GetLevelEnergy();
118  min = currentLevelE-gammaE-epsilon;
119  for(G4int ii=0; ii<nLevels; ii++)
120  {
121  levelE = theLevels[ii].GetLevelEnergy();
122  if(std::abs(currentLevelE-(levelE+gammaE))<min)
123  {
124  min = std::abs(currentLevelE-(levelE+gammaE));
125  it = ii;
126  }
127  }
128 //080728
129  if ( it != -1 && currentLevelE == theLevels[it].GetLevelEnergy() )
130  {
131  //TK Comment; Some data file in /Inelastic/Gammas has inconsistent level data (no level to transit)
132  //G4cout << "DeExGammas Transition level error: it " << it << " " << currentLevelE << " " << gammaE << " " << theLevels[it-1].GetLevelEnergy() << " " << currentLevelE - theLevels[it-1].GetLevelEnergy() << G4endl;
133  // Forced to connect the next(previous) level
134  it +=-1;
135  }
136 //080728
137  if(it!=-1) theGammas[i]->SetNext(&theLevels[it]);
138  }
139  // some garbage collection
140 
141  delete [] theGammas;
142 
143  // and we are Done.
144 }
void SetNumberOfGammas(G4int aGammas)
G4double GetGammaEnergy()
void SetNext(G4NeutronHPLevel *aLevel)
#define buffer
Definition: xmlparse.cc:611
int G4int
Definition: G4Types.hh:78
G4double GetLevelEnergy()
G4double GetLevelEnergy(G4int aLevel)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
double G4double
Definition: G4Types.hh:76
void SetGamma(G4int i, G4NeutronHPGamma *aGamma)
G4bool Init(std::istream &aDataFile)
G4double GetLevelEnergy()

The documentation for this class was generated from the following files: