Geant4-11
Public Member Functions | Private Attributes | Static Private Attributes
G4ParticleHPChannelList Class Reference

#include <G4ParticleHPChannelList.hh>

Public Member Functions

G4HadFinalStateApplyYourself (const G4Element *theElement, const G4HadProjectile &aTrack)
 
void DumpInfo ()
 
 G4ParticleHPChannelList ()
 
 G4ParticleHPChannelList (G4int n, G4ParticleDefinition *projectile)
 
G4int GetNumberOfChannels ()
 
G4double GetXsec (G4double anEnergy)
 
G4bool HasDataInAnyFinalState ()
 
void Init (G4Element *anElement, const G4String &dirName, G4ParticleDefinition *projectile)
 
void Init (G4int n)
 
void Register (G4ParticleHPFinalState *theFS, const G4String &aName)
 
void RestartRegistration ()
 
 ~G4ParticleHPChannelList ()
 

Private Attributes

G4bool allChannelsCreated
 
G4int nChannels
 
G4ParticleHPChannel ** theChannels
 
G4String theDir
 
G4ElementtheElement
 
G4int theInitCount
 
G4ParticleDefinitiontheProjectile
 
G4StableIsotopes theStableOnes
 
G4HadFinalState unChanged
 

Static Private Attributes

static G4ThreadLocal G4int trycounter = 0
 

Detailed Description

Definition at line 47 of file G4ParticleHPChannelList.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPChannelList() [1/2]

G4ParticleHPChannelList::G4ParticleHPChannelList ( G4int  n,
G4ParticleDefinition projectile 
)

◆ G4ParticleHPChannelList() [2/2]

G4ParticleHPChannelList::G4ParticleHPChannelList ( )

Definition at line 53 of file G4ParticleHPChannelList.cc.

54 {
55 nChannels = 0;
56 theChannels = 0;
57 allChannelsCreated = false;
58 theInitCount = 0;
59 theElement = NULL;
61 }
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103

References allChannelsCreated, nChannels, G4Neutron::Neutron(), theChannels, theElement, theInitCount, and theProjectile.

◆ ~G4ParticleHPChannelList()

G4ParticleHPChannelList::~G4ParticleHPChannelList ( )

Definition at line 63 of file G4ParticleHPChannelList.cc.

64 {
65 if(theChannels!=0)
66 {
67 for(G4int i=0;i<nChannels; i++)
68 {
69 delete theChannels[i];
70 }
71 delete [] theChannels;
72 }
73 }
int G4int
Definition: G4Types.hh:85

References nChannels, and theChannels.

Member Function Documentation

◆ ApplyYourself()

G4HadFinalState * G4ParticleHPChannelList::ApplyYourself ( const G4Element theElement,
const G4HadProjectile aTrack 
)

Definition at line 77 of file G4ParticleHPChannelList.cc.

78 {
80 G4int i, ii;
81 // decide on the isotope
82 G4int numberOfIsos(0);
83 for(ii=0; ii<nChannels; ii++)
84 {
85 numberOfIsos = theChannels[ii]->GetNiso();
86 if(numberOfIsos!=0) break;
87 }
88 G4double * running= new G4double [numberOfIsos];
89 running[0] = 0;
90 for(i=0;i<numberOfIsos; i++)
91 {
92 if(i!=0) running[i] = running[i-1];
93 for(ii=0; ii<nChannels; ii++)
94 {
95 if(theChannels[ii]->HasAnyData(i))
96 {
97 running[i] +=theChannels[ii]->GetWeightedXsec(aThermalE.GetThermalEnergy(aTrack,
98 theChannels[ii]->GetN(i),
99 theChannels[ii]->GetZ(i),
100 aTrack.GetMaterial()->GetTemperature()),
101 i);
102 }
103 }
104 }
105 G4int isotope=nChannels-1;
106 G4double random=G4UniformRand();
107 for(i=0;i<numberOfIsos; i++)
108 {
109 isotope = i;
110 //if(random<running[i]/running[numberOfIsos-1]) break;
111 if(running[numberOfIsos-1] != 0) if(random<running[i]/running[numberOfIsos-1]) break;
112 }
113 delete [] running;
114
115 // decide on the channel
116 running = new G4double[nChannels];
117 running[0]=0;
118 G4int targA=-1; // For production of unChanged
119 G4int targZ=-1;
120 for(i=0; i<nChannels; i++)
121 {
122 if(i!=0) running[i] = running[i-1];
123 if(theChannels[i]->HasAnyData(isotope))
124 {
125 targA=(G4int)theChannels[i]->GetN(isotope); //Will be simply used the last valid value
126 targZ=(G4int)theChannels[i]->GetZ(isotope);
127 running[i] += theChannels[i]->GetFSCrossSection(aThermalE.GetThermalEnergy(aTrack,
128 targA,
129 targZ,
130 aTrack.GetMaterial()->GetTemperature()),
131 isotope);
132 targA=(G4int)theChannels[i]->GetN(isotope); //Will be simply used the last valid value
133 targZ=(G4int)theChannels[i]->GetZ(isotope);
134 // G4cout << " G4ParticleHPChannelList " << i << " targA " << targA << " targZ " << targZ << " running " << running[i] << G4endl;
135 }
136 }
137
138 //TK120607
139 if ( running[nChannels-1] == 0 )
140 {
141 //This happened usually by the miss match between the cross section data and model
142 if ( targA == -1 && targZ == -1 ) {
143 throw G4HadronicException(__FILE__, __LINE__, "ParticleHP model encounter lethal discrepancy with cross section data");
144 }
145
146 //TK121106
147 G4cout << "Warning from NeutronHP: could not find proper reaction channel. This may cause by inconsistency between cross section and model. Unchanged final states are returned." << G4endl;
149
150 //For Ep Check create unchanged final state including rest target
151 G4ParticleDefinition* targ_pd = G4IonTable::GetIonTable()->GetIon ( targZ , targA , 0.0 );
152 G4DynamicParticle* targ_dp = new G4DynamicParticle( targ_pd , G4ThreeVector(1,0,0), 0.0 );
155 unChanged.AddSecondary(targ_dp);
156 //TK121106
159 delete [] running;
160 return &unChanged;
161 }
162 //TK120607
163
164
165 G4int lChan=0;
166 random=G4UniformRand();
167 for(i=0; i<nChannels; i++)
168 {
169 lChan = i;
170 if(running[nChannels-1] != 0) if(random<running[i]/running[nChannels-1]) break;
171 }
172 delete [] running;
173#ifdef G4PHPDEBUG
174 if( std::getenv("G4ParticleHPDebug") ) G4cout << " G4ParticleHPChannelList SELECTED ISOTOPE " << isotope << " SELECTED CHANNEL " << lChan << G4endl;
175#endif
176 return theChannels[lChan]->ApplyYourself(aTrack, isotope);
177 }
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
Hep3Vector unit() const
Hep3Vector vect() const
void AddSecondary(G4DynamicParticle *aP, G4int mod=-1)
void SetEnergyChange(G4double anEnergy)
void SetMomentumChange(const G4ThreeVector &aV)
const G4Material * GetMaterial() const
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:522
static G4IonTable * GetIonTable()
Definition: G4IonTable.cc:170
G4double GetTemperature() const
Definition: G4Material.hh:178
G4HadFinalState * ApplyYourself(const G4HadProjectile &theTrack, G4int isoNumber=-1)
G4double GetWeightedXsec(G4double energy, G4int isoNumber)
G4double GetN(G4int i)
G4double GetZ(G4int i)
G4double GetFSCrossSection(G4double energy, G4int isoNumber)
static G4ParticleHPManager * GetInstance()
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
G4double GetThermalEnergy(const G4HadProjectile &aP, const G4Element *anE, G4double aT)

References G4HadFinalState::AddSecondary(), G4ParticleHPChannel::ApplyYourself(), G4HadFinalState::Clear(), G4cout, G4endl, G4UniformRand, G4HadProjectile::Get4Momentum(), G4ParticleHPChannel::GetFSCrossSection(), G4ParticleHPManager::GetInstance(), G4IonTable::GetIon(), G4IonTable::GetIonTable(), G4HadProjectile::GetKineticEnergy(), G4HadProjectile::GetMaterial(), G4ParticleHPChannel::GetN(), G4ParticleHPChannel::GetNiso(), G4ParticleHPManager::GetReactionWhiteBoard(), G4Material::GetTemperature(), G4ParticleHPThermalBoost::GetThermalEnergy(), G4ParticleHPChannel::GetWeightedXsec(), G4ParticleHPChannel::GetZ(), nChannels, G4HadFinalState::SetEnergyChange(), G4HadFinalState::SetMomentumChange(), G4ParticleHPReactionWhiteBoard::SetTargA(), G4ParticleHPReactionWhiteBoard::SetTargZ(), theChannels, unChanged, CLHEP::Hep3Vector::unit(), and CLHEP::HepLorentzVector::vect().

◆ DumpInfo()

void G4ParticleHPChannelList::DumpInfo ( )

Definition at line 223 of file G4ParticleHPChannelList.cc.

223 {
224
225 G4cout<<"================================================================"<<G4endl;
226 G4cout<<" Element: "<<theElement->GetName()<<G4endl;
227 G4cout<<" Number of channels: "<<nChannels<<G4endl;
228 G4cout<<" Projectile: "<<theProjectile->GetParticleName()<<G4endl;
229 G4cout<<" Directory name: "<<theDir<<G4endl;
230 for(int i=0;i<nChannels;i++){
232 G4cout<<"----------------------------------------------------------------"<<G4endl;
233 theChannels[i]->DumpInfo();
234 G4cout<<"----------------------------------------------------------------"<<G4endl;
235 }
236 }
237 G4cout<<"================================================================"<<G4endl;
238
239}
const G4String & GetName() const
Definition: G4Element.hh:127
const G4String & GetParticleName() const

References G4ParticleHPChannel::DumpInfo(), G4cout, G4endl, G4Element::GetName(), G4ParticleDefinition::GetParticleName(), HasDataInAnyFinalState(), nChannels, theChannels, theDir, theElement, and theProjectile.

◆ GetNumberOfChannels()

G4int G4ParticleHPChannelList::GetNumberOfChannels ( )
inline

Definition at line 77 of file G4ParticleHPChannelList.hh.

77{ return nChannels; }

References nChannels.

◆ GetXsec()

G4double G4ParticleHPChannelList::GetXsec ( G4double  anEnergy)
inline

Definition at line 66 of file G4ParticleHPChannelList.hh.

67 {
68 G4double result=0;
69 G4int i;
70 for(i=0; i<nChannels; i++)
71 {
72 result+=std::max(0., theChannels[i]->GetXsec(anEnergy));
73 }
74 return result;
75 }
G4double GetXsec(G4double anEnergy)
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References GetXsec(), G4INCL::Math::max(), nChannels, and theChannels.

Referenced by GetXsec().

◆ HasDataInAnyFinalState()

G4bool G4ParticleHPChannelList::HasDataInAnyFinalState ( )
inline

Definition at line 79 of file G4ParticleHPChannelList.hh.

80 {
81 G4bool result = false;
82 G4int i;
83 for(i=0; i<nChannels; i++)
84 {
85 if(theChannels[i]->HasDataInAnyFinalState()) result = true;
86 }
87 return result;
88 }
bool G4bool
Definition: G4Types.hh:86

References HasDataInAnyFinalState(), nChannels, and theChannels.

Referenced by DumpInfo(), and HasDataInAnyFinalState().

◆ Init() [1/2]

void G4ParticleHPChannelList::Init ( G4Element anElement,
const G4String dirName,
G4ParticleDefinition projectile 
)

Definition at line 179 of file G4ParticleHPChannelList.cc.

180 {
181 theDir = dirName;
182// G4cout << theDir << G4endl;
183 theElement = anElement;
184// G4cout << theElement << G4endl;
185 theProjectile = projectile;
186 }

References theDir, theElement, and theProjectile.

◆ Init() [2/2]

void G4ParticleHPChannelList::Init ( G4int  n)

◆ Register()

void G4ParticleHPChannelList::Register ( G4ParticleHPFinalState theFS,
const G4String aName 
)

Definition at line 188 of file G4ParticleHPChannelList.cc.

190 {
192 {
193 if(nChannels!=0)
194 {
195 G4ParticleHPChannel ** theBuffer = new G4ParticleHPChannel * [nChannels+1];
196 G4int i;
197 for(i=0; i<nChannels; i++)
198 {
199 theBuffer[i] = theChannels[i];
200 }
201 delete [] theChannels;
202 theChannels = theBuffer;
203 }
204 else
205 {
207 }
209 name = aName+"/";
212 // theChannels[nChannels]->SetProjectile( theProjectile );
213 nChannels++;
214 }
215
216 //110527TKDB Unnessary codes, Detected by gcc4.6 compiler
217 //G4bool result;
218 //result = theChannels[theInitCount]->Register(theFS);
220 theInitCount++;
221 }
void Init(G4Element *theElement, const G4String dirName)
G4bool Register(G4ParticleHPFinalState *theFS)
const char * name(G4int ptype)

References allChannelsCreated, G4ParticleHPChannel::Init(), G4InuclParticleNames::name(), nChannels, G4ParticleHPChannel::Register(), theChannels, theDir, theElement, theInitCount, and theProjectile.

◆ RestartRegistration()

void G4ParticleHPChannelList::RestartRegistration ( )
inline

Definition at line 89 of file G4ParticleHPChannelList.hh.

90 {
91 allChannelsCreated = true;
92 theInitCount = 0;
93 }

References allChannelsCreated, and theInitCount.

Field Documentation

◆ allChannelsCreated

G4bool G4ParticleHPChannelList::allChannelsCreated
private

◆ nChannels

G4int G4ParticleHPChannelList::nChannels
private

◆ theChannels

G4ParticleHPChannel** G4ParticleHPChannelList::theChannels
private

◆ theDir

G4String G4ParticleHPChannelList::theDir
private

Definition at line 103 of file G4ParticleHPChannelList.hh.

Referenced by DumpInfo(), Init(), and Register().

◆ theElement

G4Element* G4ParticleHPChannelList::theElement
private

Definition at line 104 of file G4ParticleHPChannelList.hh.

Referenced by DumpInfo(), G4ParticleHPChannelList(), Init(), and Register().

◆ theInitCount

G4int G4ParticleHPChannelList::theInitCount
private

◆ theProjectile

G4ParticleDefinition* G4ParticleHPChannelList::theProjectile
private

Definition at line 111 of file G4ParticleHPChannelList.hh.

Referenced by DumpInfo(), G4ParticleHPChannelList(), Init(), and Register().

◆ theStableOnes

G4StableIsotopes G4ParticleHPChannelList::theStableOnes
private

Definition at line 109 of file G4ParticleHPChannelList.hh.

◆ trycounter

G4ThreadLocal G4int G4ParticleHPChannelList::trycounter = 0
staticprivate

Definition at line 100 of file G4ParticleHPChannelList.hh.

◆ unChanged

G4HadFinalState G4ParticleHPChannelList::unChanged
private

Definition at line 113 of file G4ParticleHPChannelList.hh.

Referenced by ApplyYourself().


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