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

#include <G4PixeCrossSectionHandler.hh>

Public Member Functions

 G4PixeCrossSectionHandler ()
 
 G4PixeCrossSectionHandler (G4IInterpolator *interpolation, const G4String &modelK="ecpssr", const G4String &modelL="ecpssr", const G4String &modelM="ecpssr", G4double minE=1 *CLHEP::keV, G4double maxE=0.1 *CLHEP::GeV, G4int nBins=200, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn, G4int minZ=6, G4int maxZ=92)
 
virtual ~G4PixeCrossSectionHandler ()
 
void Initialise (G4IInterpolator *interpolation, const G4String &modelK="ecpssr", const G4String &modelL="ecpssr", const G4String &modelM="ecpssr", G4double minE=1 *CLHEP::keV, G4double maxE=0.1 *CLHEP::GeV, G4int nBins=200, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn, G4int minZ=6, G4int maxZ=92)
 
G4int SelectRandomAtom (const G4Material *material, G4double e) const
 
G4int SelectRandomShell (G4int Z, G4double e) const
 
G4double FindValue (G4int Z, G4double e) const
 
G4double FindValue (G4int Z, G4double e, G4int shellIndex) const
 
G4double ValueForMaterial (const G4Material *material, G4double e) const
 
void LoadShellData (const G4String &dataFile)
 
G4double MicroscopicCrossSection (const G4ParticleDefinition *particleDef, G4double kineticEnergy, G4double Z, G4double deltaCut) const
 
void PrintData () const
 
void Clear ()
 

Detailed Description

Definition at line 60 of file G4PixeCrossSectionHandler.hh.

Constructor & Destructor Documentation

◆ G4PixeCrossSectionHandler() [1/2]

G4PixeCrossSectionHandler::G4PixeCrossSectionHandler ( )

Definition at line 61 of file G4PixeCrossSectionHandler.cc.

62{
63 crossSections = 0;
64 interpolation = 0;
65 // Initialise with default values
66 Initialise(0,"","","",1.*keV,0.1*GeV,200,MeV,barn,6,92);
67 ActiveElements();
68}
void Initialise(G4IInterpolator *interpolation, const G4String &modelK="ecpssr", const G4String &modelL="ecpssr", const G4String &modelM="ecpssr", G4double minE=1 *CLHEP::keV, G4double maxE=0.1 *CLHEP::GeV, G4int nBins=200, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn, G4int minZ=6, G4int maxZ=92)

◆ G4PixeCrossSectionHandler() [2/2]

G4PixeCrossSectionHandler::G4PixeCrossSectionHandler ( G4IInterpolator interpolation,
const G4String modelK = "ecpssr",
const G4String modelL = "ecpssr",
const G4String modelM = "ecpssr",
G4double  minE = 1*CLHEP::keV,
G4double  maxE = 0.1*CLHEP::GeV,
G4int  nBins = 200,
G4double  unitE = CLHEP::MeV,
G4double  unitData = CLHEP::barn,
G4int  minZ = 6,
G4int  maxZ = 92 
)

Definition at line 71 of file G4PixeCrossSectionHandler.cc.

82 : interpolation(algorithm), eMin(minE), eMax(maxE), nBins(bins),
83 unit1(unitE), unit2(unitData), zMin(minZ), zMax(maxZ)
84{
85 crossSections = 0;
86
87 crossModel.push_back(modelK);
88 crossModel.push_back(modelL);
89 crossModel.push_back(modelM);
90
91 //std::cout << "PixeCrossSectionHandler constructor - crossModel[0] = "
92 // << crossModel[0]
93 // << std::endl;
94
95 ActiveElements();
96}

◆ ~G4PixeCrossSectionHandler()

G4PixeCrossSectionHandler::~G4PixeCrossSectionHandler ( )
virtual

Definition at line 98 of file G4PixeCrossSectionHandler.cc.

99{
100 delete interpolation;
101 interpolation = 0;
102 std::map<G4int,G4IDataSet*,std::less<G4int> >::iterator pos;
103
104 for (pos = dataMap.begin(); pos != dataMap.end(); ++pos)
105 {
106 // The following is a workaround for STL ObjectSpace implementation,
107 // which does not support the standard and does not accept
108 // the syntax pos->second
109 // G4IDataSet* dataSet = pos->second;
110 G4IDataSet* dataSet = (*pos).second;
111 delete dataSet;
112 }
113
114 if (crossSections != 0)
115 {
116 size_t n = crossSections->size();
117 for (size_t i=0; i<n; i++)
118 {
119 delete (*crossSections)[i];
120 }
121 delete crossSections;
122 crossSections = 0;
123 }
124}

Member Function Documentation

◆ Clear()

void G4PixeCrossSectionHandler::Clear ( )

Definition at line 210 of file G4PixeCrossSectionHandler.cc.

211{
212 // Reset the map of data sets: remove the data sets from the map
213 std::map<G4int,G4IDataSet*,std::less<G4int> >::iterator pos;
214
215 if(! dataMap.empty())
216 {
217 for (pos = dataMap.begin(); pos != dataMap.end(); ++pos)
218 {
219 // The following is a workaround for STL ObjectSpace implementation,
220 // which does not support the standard and does not accept
221 // the syntax pos->first or pos->second
222 // G4IDataSet* dataSet = pos->second;
223 G4IDataSet* dataSet = (*pos).second;
224 delete dataSet;
225 dataSet = 0;
226 G4int i = (*pos).first;
227 dataMap[i] = 0;
228 }
229 dataMap.clear();
230 }
231
232 activeZ.clear();
233 ActiveElements();
234}
int G4int
Definition: G4Types.hh:66

◆ FindValue() [1/2]

G4double G4PixeCrossSectionHandler::FindValue ( G4int  Z,
G4double  e 
) const

Definition at line 236 of file G4PixeCrossSectionHandler.cc.

237{
238 G4double value = 0.;
239
240 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
241 pos = dataMap.find(Z);
242 if (pos!= dataMap.end())
243 {
244 // The following is a workaround for STL ObjectSpace implementation,
245 // which does not support the standard and does not accept
246 // the syntax pos->first or pos->second
247 // G4IDataSet* dataSet = pos->second;
248 G4IDataSet* dataSet = (*pos).second;
249 value = dataSet->FindValue(energy);
250 }
251 else
252 {
253 G4cout << "WARNING: G4PixeCrossSectionHandler::FindValue(Z,e) did not find Z = "
254 << Z << G4endl;
255 }
256 return value;
257}
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
virtual G4double FindValue(G4double x, G4int componentId=0) const =0

Referenced by SelectRandomShell(), and ValueForMaterial().

◆ FindValue() [2/2]

G4double G4PixeCrossSectionHandler::FindValue ( G4int  Z,
G4double  e,
G4int  shellIndex 
) const

Definition at line 259 of file G4PixeCrossSectionHandler.cc.

261{
262 G4double value = 0.;
263
264 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
265 pos = dataMap.find(Z);
266 if (pos!= dataMap.end())
267 {
268 // The following is a workaround for STL ObjectSpace implementation,
269 // which does not support the standard and does not accept
270 // the syntax pos->first or pos->second
271 // G4IDataSet* dataSet = pos->second;
272 G4IDataSet* dataSet = (*pos).second;
273 if (shellIndex >= 0)
274 {
275 G4int nComponents = dataSet->NumberOfComponents();
276 if(shellIndex < nComponents)
277 // The value is the cross section for shell component at given energy
278 value = dataSet->GetComponent(shellIndex)->FindValue(energy);
279 else
280 {
281 G4cout << "WARNING: G4PixeCrossSectionHandler::FindValue(Z,e,shell) did not find"
282 << " shellIndex= " << shellIndex
283 << " for Z= "
284 << Z << G4endl;
285 }
286 } else {
287 value = dataSet->FindValue(energy);
288 }
289 }
290 else
291 {
292 G4cout << "WARNING: G4PixeCrossSectionHandler::FindValue did not find Z = "
293 << Z << G4endl;
294 }
295 return value;
296}
virtual const G4IDataSet * GetComponent(G4int componentId) const =0
virtual size_t NumberOfComponents(void) const =0

◆ Initialise()

void G4PixeCrossSectionHandler::Initialise ( G4IInterpolator interpolation,
const G4String modelK = "ecpssr",
const G4String modelL = "ecpssr",
const G4String modelM = "ecpssr",
G4double  minE = 1*CLHEP::keV,
G4double  maxE = 0.1*CLHEP::GeV,
G4int  nBins = 200,
G4double  unitE = CLHEP::MeV,
G4double  unitData = CLHEP::barn,
G4int  minZ = 6,
G4int  maxZ = 92 
)

Definition at line 126 of file G4PixeCrossSectionHandler.cc.

134{
135 if (algorithm != 0)
136 {
137 delete interpolation;
138 interpolation = algorithm;
139 }
140 else
141 {
142 interpolation = CreateInterpolation();
143 }
144
145 eMin = minE;
146 eMax = maxE;
147 nBins = numberOfBins;
148 unit1 = unitE;
149 unit2 = unitData;
150 zMin = minZ;
151 zMax = maxZ;
152
153 crossModel.push_back(modelK);
154 crossModel.push_back(modelL);
155 crossModel.push_back(modelM);
156
157}

Referenced by G4PixeCrossSectionHandler().

◆ LoadShellData()

void G4PixeCrossSectionHandler::LoadShellData ( const G4String dataFile)

Definition at line 180 of file G4PixeCrossSectionHandler.cc.

181{
182 size_t nZ = activeZ.size();
183 for (size_t i=0; i<nZ; i++)
184 {
185 G4int Z = (G4int) activeZ[i];
186 G4IInterpolator* algo = interpolation->Clone();
187 G4IDataSet* dataSet = new G4PixeShellDataSet(Z, algo,crossModel[0],crossModel[1],crossModel[2]);
188
189 // Degug printing
190 //std::cout << "PixeCrossSectionHandler::Load - "
191 // << Z
192 // << ", modelK = "
193 // << crossModel[0]
194 // << " fileName = "
195 // << fileName
196 // << std::endl;
197
198 dataSet->LoadData(fileName);
199 dataMap[Z] = dataSet;
200 }
201
202 // Build cross sections for materials if not already built
203 if (! crossSections)
204 {
205 BuildForMaterials();
206 }
207
208}
virtual G4bool LoadData(const G4String &fileName)=0
virtual G4IInterpolator * Clone() const =0

Referenced by G4hImpactIonisation::PostStepDoIt().

◆ MicroscopicCrossSection()

G4double G4PixeCrossSectionHandler::MicroscopicCrossSection ( const G4ParticleDefinition particleDef,
G4double  kineticEnergy,
G4double  Z,
G4double  deltaCut 
) const

Definition at line 695 of file G4PixeCrossSectionHandler.cc.

699{
700 // Cross section formula is OK for spin=0, 1/2, 1 only !
701 // Calculates the microscopic cross section in Geant4 internal units
702 // Formula documented in Geant4 Phys. Ref. Manual
703 // ( it is called for elements, AtomicNumber = z )
704
705 G4double cross = 0.;
706
707 // Particle mass and energy
708 G4double particleMass = particleDef->GetPDGMass();
709 G4double energy = kineticEnergy + particleMass;
710
711 // Some kinematics
712 G4double gamma = energy / particleMass;
713 G4double beta2 = 1. - 1. / (gamma * gamma);
714 G4double var = electron_mass_c2 / particleMass;
715 G4double tMax = 2. * electron_mass_c2 * (gamma*gamma - 1.) / (1. + 2.*gamma*var + var*var);
716
717 // Calculate the total cross section
718
719 if ( tMax > deltaCut )
720 {
721 var = deltaCut / tMax;
722 cross = (1. - var * (1. - beta2 * std::log(var))) / deltaCut;
723
724 G4double spin = particleDef->GetPDGSpin() ;
725
726 // +term for spin=1/2 particle
727 if (spin == 0.5)
728 {
729 cross += 0.5 * (tMax - deltaCut) / (energy*energy);
730 }
731 // +term for spin=1 particle
732 else if (spin > 0.9 )
733 {
734 cross += -std::log(var) / (3.*deltaCut) + (tMax-deltaCut) *
735 ((5.+1./var)*0.25 /(energy*energy) - beta2 / (tMax*deltaCut))/3.;
736 }
737 cross *= twopi_mc2_rcl2 * Z / beta2 ;
738 }
739
740 //std::cout << "Microscopic = " << cross/barn
741 // << ", e = " << kineticEnergy/MeV <<std:: endl;
742
743 return cross;
744}

◆ PrintData()

void G4PixeCrossSectionHandler::PrintData ( ) const

Definition at line 159 of file G4PixeCrossSectionHandler.cc.

160{
161 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
162
163 for (pos = dataMap.begin(); pos != dataMap.end(); pos++)
164 {
165 // The following is a workaround for STL ObjectSpace implementation,
166 // which does not support the standard and does not accept
167 // the syntax pos->first or pos->second
168 // G4int z = pos->first;
169 // G4IDataSet* dataSet = pos->second;
170 G4int z = (*pos).first;
171 G4IDataSet* dataSet = (*pos).second;
172 G4cout << "---- Data set for Z = "
173 << z
174 << G4endl;
175 dataSet->PrintData();
176 G4cout << "--------------------------------------------------" << G4endl;
177 }
178}
virtual void PrintData(void) const =0

◆ SelectRandomAtom()

G4int G4PixeCrossSectionHandler::SelectRandomAtom ( const G4Material material,
G4double  e 
) const

Definition at line 448 of file G4PixeCrossSectionHandler.cc.

450{
451 // Select randomly an element within the material, according to the weight
452 // determined by the cross sections in the data set
453
454 G4int nElements = material->GetNumberOfElements();
455
456 // Special case: the material consists of one element
457 if (nElements == 1)
458 {
459 G4int Z = (G4int) material->GetZ();
460 return Z;
461 }
462
463 // Composite material
464
465 const G4ElementVector* elementVector = material->GetElementVector();
466 size_t materialIndex = material->GetIndex();
467
468 G4IDataSet* materialSet = (*crossSections)[materialIndex];
469 G4double materialCrossSection0 = 0.0;
470 G4DataVector cross;
471 cross.clear();
472 for ( G4int i=0; i < nElements; i++ )
473 {
474 G4double cr = materialSet->GetComponent(i)->FindValue(e);
475 materialCrossSection0 += cr;
476 cross.push_back(materialCrossSection0);
477 }
478
479 G4double random = G4UniformRand() * materialCrossSection0;
480
481 for (G4int k=0 ; k < nElements ; k++ )
482 {
483 if (random <= cross[k]) return (G4int) (*elementVector)[k]->GetZ();
484 }
485 // It should never get here
486 return 0;
487}
std::vector< G4Element * > G4ElementVector
#define G4UniformRand()
Definition: Randomize.hh:53
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:189
G4double GetZ() const
Definition: G4Material.cc:604
size_t GetNumberOfElements() const
Definition: G4Material.hh:185
size_t GetIndex() const
Definition: G4Material.hh:261

Referenced by G4hImpactIonisation::PostStepDoIt().

◆ SelectRandomShell()

G4int G4PixeCrossSectionHandler::SelectRandomShell ( G4int  Z,
G4double  e 
) const

Definition at line 538 of file G4PixeCrossSectionHandler.cc.

539{
540 // Select randomly a shell, according to the weight determined by the cross sections
541 // in the data set
542
543 // Note for later improvement: it would be useful to add a cache mechanism for already
544 // used shells to improve performance
545
546 G4int shell = 0;
547
548 G4double totCrossSection = FindValue(Z,e);
549 G4double random = G4UniformRand() * totCrossSection;
550 G4double partialSum = 0.;
551
552 G4IDataSet* dataSet = 0;
553 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
554 pos = dataMap.find(Z);
555 // The following is a workaround for STL ObjectSpace implementation,
556 // which does not support the standard and does not accept
557 // the syntax pos->first or pos->second
558 // if (pos != dataMap.end()) dataSet = pos->second;
559 if (pos != dataMap.end()) dataSet = (*pos).second;
560
561 size_t nShells = dataSet->NumberOfComponents();
562 for (size_t i=0; i<nShells; i++)
563 {
564 const G4IDataSet* shellDataSet = dataSet->GetComponent(i);
565 if (shellDataSet != 0)
566 {
567 G4double value = shellDataSet->FindValue(e);
568 partialSum += value;
569 if (random <= partialSum) return i;
570 }
571 }
572 // It should never get here
573 return shell;
574}
G4double FindValue(G4int Z, G4double e) const

Referenced by G4hImpactIonisation::PostStepDoIt().

◆ ValueForMaterial()

G4double G4PixeCrossSectionHandler::ValueForMaterial ( const G4Material material,
G4double  e 
) const

Definition at line 299 of file G4PixeCrossSectionHandler.cc.

301{
302 G4double value = 0.;
303
304 const G4ElementVector* elementVector = material->GetElementVector();
305 const G4double* nAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
306 G4int nElements = material->GetNumberOfElements();
307
308 for (G4int i=0 ; i<nElements ; i++)
309 {
310 G4int Z = (G4int) (*elementVector)[i]->GetZ();
311 G4double elementValue = FindValue(Z,energy);
312 G4double nAtomsVol = nAtomsPerVolume[i];
313 value += nAtomsVol * elementValue;
314 }
315
316 return value;
317}
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:205

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