Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPChannelList Class Reference

#include <G4ParticleHPChannelList.hh>

Public Member Functions

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

Detailed Description

Definition at line 47 of file G4ParticleHPChannelList.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPChannelList() [1/2]

G4ParticleHPChannelList::G4ParticleHPChannelList ( G4int  n,
G4ParticleDefinition projectile 
)

Definition at line 42 of file G4ParticleHPChannelList.cc.

43 :theProjectile(projectile)
44 {
45 nChannels = n;
46 theChannels = new G4ParticleHPChannel * [n];
47 allChannelsCreated = false;
48 theInitCount = 0;
49 theElement = NULL;
50 }

◆ 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;
60 theProjectile = G4Neutron::Neutron();
61 }
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103

◆ ~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

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;
148 unChanged.Clear();
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 );
153 unChanged.SetEnergyChange(aTrack.GetKineticEnergy());
154 unChanged.SetMomentumChange(aTrack.Get4Momentum().vect().unit() );
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:177
G4HadFinalState * ApplyYourself(const G4HadProjectile &theTrack, G4int isoNumber=-1)
G4double GetWeightedXsec(G4double energy, G4int isoNumber)
G4double GetFSCrossSection(G4double energy, G4int isoNumber)
static G4ParticleHPManager * GetInstance()
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
G4double GetThermalEnergy(const G4HadProjectile &aP, const G4Element *anE, G4double aT)

◆ 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++){
231 if(theChannels[i]->HasDataInAnyFinalState()){
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

◆ GetNumberOfChannels()

G4int G4ParticleHPChannelList::GetNumberOfChannels ( )
inline

Definition at line 77 of file G4ParticleHPChannelList.hh.

77{ return 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)

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

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 }

◆ 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 {
191 if(!allChannelsCreated)
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 {
206 theChannels = new G4ParticleHPChannel * [nChannels+1];
207 }
209 name = aName+"/";
210 theChannels[nChannels] = new G4ParticleHPChannel(theProjectile);
211 theChannels[nChannels]->Init(theElement, theDir, name);
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);
219 theChannels[theInitCount]->Register(theFS);
220 theInitCount++;
221 }
void Init(G4Element *theElement, const G4String dirName)
G4bool Register(G4ParticleHPFinalState *theFS)
const char * name(G4int ptype)

◆ RestartRegistration()

void G4ParticleHPChannelList::RestartRegistration ( )
inline

Definition at line 89 of file G4ParticleHPChannelList.hh.

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

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