Geant4-11
Public Member Functions
CompareMaterial Struct Reference

Materials can be described as a derivation of existing "parent" materials in order to alter few of their features, such as density. CompareMaterial compare materials taking into account their possible "affiliation". More...

#include <G4DNAMolecularMaterial.hh>

Public Member Functions

bool operator() (const G4Material *mat1, const G4Material *mat2) const
 

Detailed Description

Materials can be described as a derivation of existing "parent" materials in order to alter few of their features, such as density. CompareMaterial compare materials taking into account their possible "affiliation".

Definition at line 63 of file G4DNAMolecularMaterial.hh.

Member Function Documentation

◆ operator()()

bool CompareMaterial::operator() ( const G4Material mat1,
const G4Material mat2 
) const

Definition at line 51 of file G4DNAMolecularMaterial.cc.

53{
54 if (mat1 == nullptr && mat2 == nullptr) return false; //(mat1 == mat2)
55 if (mat1 == nullptr) return true; // mat1 < mat2
56 if (mat2 == nullptr) return false; //mat2 < mat1
57
58 const G4Material* baseMat1 = mat1->GetBaseMaterial();
59 const G4Material* baseMat2 = mat2->GetBaseMaterial();
60
61 if (((baseMat1 != nullptr) || (baseMat2 != nullptr)) == false){
62 // None of the materials derives from a base material
63 return mat1 < mat2;
64 }
65 else if ((baseMat1 != nullptr) && (baseMat2 != nullptr)){
66 // Both materials derive from a base material
67 return baseMat1 < baseMat2;
68 }
69
70 else if ((baseMat1 != nullptr) && (baseMat2 == nullptr)){
71 // Only the material 1 derives from a base material
72 return baseMat1 < mat2;
73 }
74 // only case baseMat1==nullptr && baseMat2 remains
75 return mat1 < baseMat2;
76}
const G4Material * GetBaseMaterial() const
Definition: G4Material.hh:229

References G4Material::GetBaseMaterial().


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