Geant4  10.02.p03
G4PixeCrossSectionHandler Class Reference

#include <G4PixeCrossSectionHandler.hh>

Collaboration diagram for G4PixeCrossSectionHandler:

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 ()
 

Private Member Functions

 G4PixeCrossSectionHandler (const G4PixeCrossSectionHandler &)
 
G4PixeCrossSectionHandleroperator= (const G4PixeCrossSectionHandler &right)
 
G4int NumberOfComponents (G4int Z) const
 
void ActiveElements ()
 
void BuildForMaterials ()
 
std::vector< G4IDataSet * > * BuildCrossSectionsForMaterials (const G4DataVector &energyVector)
 
G4IInterpolatorCreateInterpolation ()
 
const G4IInterpolatorGetInterpolation () const
 

Private Attributes

G4IInterpolatorinterpolation
 
G4double eMin
 
G4double eMax
 
G4int nBins
 
G4double unit1
 
G4double unit2
 
G4int zMin
 
G4int zMax
 
G4DataVector activeZ
 
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
 
std::vector< G4IDataSet * > * crossSections
 
std::vector< G4StringcrossModel
 

Detailed Description

Definition at line 60 of file G4PixeCrossSectionHandler.hh.

Constructor & Destructor Documentation

◆ G4PixeCrossSectionHandler() [1/3]

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);
68 }
static const double MeV
Definition: G4SIunits.hh:211
static const double GeV
Definition: G4SIunits.hh:214
std::vector< G4IDataSet * > * crossSections
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)
static const double barn
Definition: G4SIunits.hh:104
static const double keV
Definition: G4SIunits.hh:213
Here is the call graph for this function:

◆ G4PixeCrossSectionHandler() [2/3]

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 
96 }
double maxE
Definition: plot_hist.C:8
std::vector< G4IDataSet * > * crossSections
std::vector< G4String > crossModel
double minE
Definition: plot_hist.C:7
Here is the call graph for this function:

◆ ~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 }
Char_t n[5]
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
std::vector< G4IDataSet * > * crossSections
static const G4double pos

◆ G4PixeCrossSectionHandler() [3/3]

G4PixeCrossSectionHandler::G4PixeCrossSectionHandler ( const G4PixeCrossSectionHandler )
private

Member Function Documentation

◆ ActiveElements()

void G4PixeCrossSectionHandler::ActiveElements ( )
private

Definition at line 576 of file G4PixeCrossSectionHandler.cc.

577 {
578  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
579  if (materialTable == 0)
580  G4Exception("G4PixeCrossSectionHandler::ActiveElements",
581  "pii00000220",
583  "no MaterialTable found");
584 
586 
587  for (G4int mat=0; mat<nMaterials; mat++)
588  {
589  const G4Material* material= (*materialTable)[mat];
590  const G4ElementVector* elementVector = material->GetElementVector();
591  const G4int nElements = material->GetNumberOfElements();
592 
593  for (G4int iEl=0; iEl<nElements; iEl++)
594  {
595  G4Element* element = (*elementVector)[iEl];
596  G4double Z = element->GetZ();
597  if (!(activeZ.contains(Z)) && Z >= zMin && Z <= zMax)
598  {
599  activeZ.push_back(Z);
600  }
601  }
602  }
603 }
std::vector< G4Element * > G4ElementVector
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
std::vector< G4Material * > G4MaterialTable
int G4int
Definition: G4Types.hh:78
Float_t mat
string material
Definition: eplot.py:19
Float_t Z
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:596
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool contains(const G4double &) const
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
double G4double
Definition: G4Types.hh:76
G4double GetZ() const
Definition: G4Element.hh:131
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildCrossSectionsForMaterials()

std::vector< G4IDataSet * > * G4PixeCrossSectionHandler::BuildCrossSectionsForMaterials ( const G4DataVector energyVector)
private

Definition at line 633 of file G4PixeCrossSectionHandler.cc.

634 {
635  G4DataVector* energies;
636  G4DataVector* data;
637 
638  std::vector<G4IDataSet*>* matCrossSections = new std::vector<G4IDataSet*>;
639 
640  //const G4ProductionCutsTable* theCoupleTable=G4ProductionCutsTable::GetProductionCutsTable();
641  //size_t numOfCouples = theCoupleTable->GetTableSize();
642 
643  size_t nOfBins = energyVector.size();
644  const G4IInterpolator* interpolationAlgo = CreateInterpolation();
645 
646  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
647  if (materialTable == 0)
648  G4Exception("G4PixeCrossSectionHandler::BuildCrossSectionsForMaterials",
649  "pii00000230",
651  "no MaterialTable found");
652 
654 
655  for (G4int mat=0; mat<nMaterials; mat++)
656  {
657  const G4Material* material = (*materialTable)[mat];
658  G4int nElements = material->GetNumberOfElements();
659  const G4ElementVector* elementVector = material->GetElementVector();
660  const G4double* nAtomsPerVolume = material->GetAtomicNumDensityVector();
661 
662  G4IInterpolator* algo = interpolationAlgo->Clone();
663 
664  G4IDataSet* setForMat = new G4CompositeDataSet(algo,1.,1.);
665 
666  for (G4int i=0; i<nElements; i++) {
667 
668  G4int Z = (G4int) (*elementVector)[i]->GetZ();
669  G4double density = nAtomsPerVolume[i];
670 
671  energies = new G4DataVector;
672  data = new G4DataVector;
673 
674 
675  for (size_t bin=0; bin<nOfBins; bin++)
676  {
677  G4double e = energyVector[bin];
678  energies->push_back(e);
679  G4double cross = 0.;
680  if (Z >= zMin && Z <= zMax) cross = density*FindValue(Z,e);
681  data->push_back(cross);
682  }
683 
684  G4IInterpolator* algo1 = interpolationAlgo->Clone();
685  G4IDataSet* elSet = new G4DataSet(i,energies,data,algo1,1.,1.);
686  setForMat->AddComponent(elSet);
687  }
688 
689  matCrossSections->push_back(setForMat);
690  }
691  return matCrossSections;
692 }
virtual void AddComponent(G4IDataSet *dataSet)=0
std::vector< G4Element * > G4ElementVector
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
std::vector< G4Material * > G4MaterialTable
float bin[41]
Definition: plottest35.C:14
int G4int
Definition: G4Types.hh:78
Float_t mat
string material
Definition: eplot.py:19
G4double density
Definition: TRTMaterials.hh:39
const G4double * GetAtomicNumDensityVector() const
Definition: G4Material.hh:216
Float_t Z
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:596
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double FindValue(G4int Z, G4double e) const
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
double G4double
Definition: G4Types.hh:76
virtual G4IInterpolator * Clone() const =0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildForMaterials()

void G4PixeCrossSectionHandler::BuildForMaterials ( )
private

Definition at line 406 of file G4PixeCrossSectionHandler.cc.

407 {
408  // Builds a CompositeDataSet containing the mean free path for each material
409  // in the material table
410 
411  G4DataVector energyVector;
412  G4double dBin = std::log10(eMax/eMin) / nBins;
413 
414  for (G4int i=0; i<nBins+1; i++)
415  {
416  energyVector.push_back(std::pow(10., std::log10(eMin)+i*dBin));
417  }
418 
419  if (crossSections != 0)
420  { // Reset the list of cross sections
421  std::vector<G4IDataSet*>::iterator mat;
422  if (! crossSections->empty())
423  {
424  for (mat = crossSections->begin(); mat!= crossSections->end(); ++mat)
425  {
426  G4IDataSet* set = *mat;
427  delete set;
428  set = 0;
429  }
430  crossSections->clear();
431  delete crossSections;
432  crossSections = 0;
433  }
434  }
435 
437 
438  if (crossSections == 0)
439  G4Exception("G4PixeCrossSectionHandler::BuildForMaterials",
440  "pii00000210",
442  ", crossSections = 0");
443 
444  return;
445 }
int G4int
Definition: G4Types.hh:78
Float_t mat
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::vector< G4IDataSet * > * crossSections
std::vector< G4IDataSet * > * BuildCrossSectionsForMaterials(const G4DataVector &energyVector)
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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:78
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
static const G4double pos
Here is the call graph for this function:

◆ CreateInterpolation()

G4IInterpolator * G4PixeCrossSectionHandler::CreateInterpolation ( )
private

Definition at line 605 of file G4PixeCrossSectionHandler.cc.

606 {
607  G4IInterpolator* algorithm = new G4LogLogInterpolator;
608  return algorithm;
609 }
Here is the caller graph for this function:

◆ 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 }
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
G4GLOB_DLL std::ostream G4cout
double energy
Definition: plottest35.C:25
Float_t Z
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
G4int nComponents
Definition: TRTMaterials.hh:41
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
virtual size_t NumberOfComponents(void) const =0
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
double energy
Definition: plottest35.C:25
Float_t Z
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const G4double pos
Here is the call graph for this function:

◆ GetInterpolation()

const G4IInterpolator* G4PixeCrossSectionHandler::GetInterpolation ( ) const
inlineprivate

Definition at line 131 of file G4PixeCrossSectionHandler.hh.

131 { return interpolation; }

◆ 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 }
double maxE
Definition: plot_hist.C:8
std::vector< G4String > crossModel
double minE
Definition: plot_hist.C:7
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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];
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  {
206  }
207 
208 }
int G4int
Definition: G4Types.hh:78
Float_t Z
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
virtual G4bool LoadData(const G4String &fileName)=0
std::vector< G4IDataSet * > * crossSections
std::vector< G4String > crossModel
virtual G4IInterpolator * Clone() const =0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 }
int twopi_mc2_rcl2
Definition: hepunit.py:294
double energy
Definition: plottest35.C:25
Float_t Z
float electron_mass_c2
Definition: hepunit.py:274
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ NumberOfComponents()

G4int G4PixeCrossSectionHandler::NumberOfComponents ( G4int  Z) const
private

Definition at line 611 of file G4PixeCrossSectionHandler.cc.

612 {
613  G4int n = 0;
614 
615  std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
616  pos = dataMap.find(Z);
617  if (pos!= dataMap.end())
618  {
619  G4IDataSet* dataSet = (*pos).second;
620  n = dataSet->NumberOfComponents();
621  }
622  else
623  {
624  G4cout << "WARNING: G4PixeCrossSectionHandler::NumberOfComponents did not "
625  << "find Z = "
626  << Z << G4endl;
627  }
628  return n;
629 }
virtual size_t NumberOfComponents(void) const =0
int G4int
Definition: G4Types.hh:78
Char_t n[5]
G4GLOB_DLL std::ostream G4cout
Float_t Z
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
#define G4endl
Definition: G4ios.hh:61
static const G4double pos
Here is the call graph for this function:

◆ operator=()

G4PixeCrossSectionHandler& G4PixeCrossSectionHandler::operator= ( const G4PixeCrossSectionHandler right)
private

◆ PrintData()

void G4PixeCrossSectionHandler::PrintData ( void  ) 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 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
#define G4endl
Definition: G4ios.hh:61
virtual void PrintData(void) const =0
static const G4double pos
Here is the call graph for this function:

◆ 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 }
G4double GetZ() const
Definition: G4Material.cc:625
virtual const G4IDataSet * GetComponent(G4int componentId) const =0
std::vector< G4Element * > G4ElementVector
size_t GetIndex() const
Definition: G4Material.hh:262
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
Float_t Z
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 }
virtual const G4IDataSet * GetComponent(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
virtual size_t NumberOfComponents(void) const =0
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
Float_t Z
std::map< G4int, G4IDataSet *, std::less< G4int > > dataMap
G4double FindValue(G4int Z, G4double e) const
double G4double
Definition: G4Types.hh:76
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 }
std::vector< G4Element * > G4ElementVector
int G4int
Definition: G4Types.hh:78
double energy
Definition: plottest35.C:25
Float_t Z
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:206
G4double FindValue(G4int Z, G4double e) const
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

Member Data Documentation

◆ activeZ

G4DataVector G4PixeCrossSectionHandler::activeZ
private

Definition at line 145 of file G4PixeCrossSectionHandler.hh.

◆ crossModel

std::vector<G4String> G4PixeCrossSectionHandler::crossModel
private

Definition at line 154 of file G4PixeCrossSectionHandler.hh.

◆ crossSections

std::vector<G4IDataSet*>* G4PixeCrossSectionHandler::crossSections
private

Definition at line 152 of file G4PixeCrossSectionHandler.hh.

◆ dataMap

std::map<G4int,G4IDataSet*,std::less<G4int> > G4PixeCrossSectionHandler::dataMap
private

Definition at line 148 of file G4PixeCrossSectionHandler.hh.

◆ eMax

G4double G4PixeCrossSectionHandler::eMax
private

Definition at line 136 of file G4PixeCrossSectionHandler.hh.

◆ eMin

G4double G4PixeCrossSectionHandler::eMin
private

Definition at line 135 of file G4PixeCrossSectionHandler.hh.

◆ interpolation

G4IInterpolator* G4PixeCrossSectionHandler::interpolation
private

Definition at line 133 of file G4PixeCrossSectionHandler.hh.

◆ nBins

G4int G4PixeCrossSectionHandler::nBins
private

Definition at line 137 of file G4PixeCrossSectionHandler.hh.

◆ unit1

G4double G4PixeCrossSectionHandler::unit1
private

Definition at line 139 of file G4PixeCrossSectionHandler.hh.

◆ unit2

G4double G4PixeCrossSectionHandler::unit2
private

Definition at line 140 of file G4PixeCrossSectionHandler.hh.

◆ zMax

G4int G4PixeCrossSectionHandler::zMax
private

Definition at line 143 of file G4PixeCrossSectionHandler.hh.

◆ zMin

G4int G4PixeCrossSectionHandler::zMin
private

Definition at line 142 of file G4PixeCrossSectionHandler.hh.


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