Geant4 11.1.1
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 59 of file G4PixeCrossSectionHandler.hh.

Constructor & Destructor Documentation

◆ G4PixeCrossSectionHandler() [1/2]

G4PixeCrossSectionHandler::G4PixeCrossSectionHandler ( )

Definition at line 60 of file G4PixeCrossSectionHandler.cc.

61{
62 crossSections = 0;
63 interpolation = 0;
64 // Initialise with default values
65 Initialise(0,"","","",1.*keV,0.1*GeV,200,MeV,barn,6,92);
66 ActiveElements();
67}
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 70 of file G4PixeCrossSectionHandler.cc.

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

◆ ~G4PixeCrossSectionHandler()

G4PixeCrossSectionHandler::~G4PixeCrossSectionHandler ( )
virtual

Definition at line 97 of file G4PixeCrossSectionHandler.cc.

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

Member Function Documentation

◆ Clear()

void G4PixeCrossSectionHandler::Clear ( )

Definition at line 209 of file G4PixeCrossSectionHandler.cc.

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

◆ FindValue() [1/2]

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

Definition at line 235 of file G4PixeCrossSectionHandler.cc.

236{
237 G4double value = 0.;
238
239 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
240 pos = dataMap.find(Z);
241 if (pos!= dataMap.end())
242 {
243 // The following is a workaround for STL ObjectSpace implementation,
244 // which does not support the standard and does not accept
245 // the syntax pos->first or pos->second
246 // G4IDataSet* dataSet = pos->second;
247 G4IDataSet* dataSet = (*pos).second;
248 value = dataSet->FindValue(energy);
249 }
250 else
251 {
252 G4cout << "WARNING: G4PixeCrossSectionHandler::FindValue(Z,e) did not find Z = "
253 << Z << G4endl;
254 }
255 return value;
256}
double G4double
Definition: G4Types.hh:83
const G4int Z[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL 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 258 of file G4PixeCrossSectionHandler.cc.

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

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

Referenced by G4PixeCrossSectionHandler().

◆ LoadShellData()

void G4PixeCrossSectionHandler::LoadShellData ( const G4String dataFile)

Definition at line 179 of file G4PixeCrossSectionHandler.cc.

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

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

◆ PrintData()

void G4PixeCrossSectionHandler::PrintData ( ) const

Definition at line 158 of file G4PixeCrossSectionHandler.cc.

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

◆ SelectRandomAtom()

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

Definition at line 447 of file G4PixeCrossSectionHandler.cc.

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

Referenced by G4hImpactIonisation::PostStepDoIt().

◆ SelectRandomShell()

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

Definition at line 537 of file G4PixeCrossSectionHandler.cc.

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

Referenced by G4hImpactIonisation::PostStepDoIt().

◆ ValueForMaterial()

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

Definition at line 298 of file G4PixeCrossSectionHandler.cc.

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

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