File indexing completed on 2025-02-23 09:19:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "CCalAMaterial.hh"
0032
0033 CCalAMaterial::CCalAMaterial(G4String mat, G4double dens, G4int nconst,
0034 CCalAMaterial** constituents, G4double* weights) {
0035 name=mat;
0036 nElem=0;
0037 G4int i=0;
0038 for (i=0; i<nconst; i++)
0039 nElem += (constituents[i]->NElements());
0040
0041 theElements = new G4String[nElem];
0042 theWeights = new G4double[nElem];
0043
0044 G4double factor;
0045 G4int nelem=0;
0046 for (i=0; i<nconst; i++) {
0047 factor=constituents[i]->Aeff();
0048 for (G4int j=0; j<constituents[i]->NElements(); j++) {
0049 theElements[nelem] = constituents[i]->Element(j);
0050 theWeights[nelem] = constituents[i]->Weight(j)* weights[i] * factor;
0051 nelem++;
0052 }
0053 }
0054
0055 if (dens>0)
0056 density=dens;
0057 else
0058 computeDensity(nconst,(CCalMaterial**)constituents, weights, FTVolume);
0059
0060 computeAeff(nconst, constituents, weights);
0061 closeMaterial();
0062 }
0063
0064 CCalAMaterial::CCalAMaterial(G4String elemat, G4double eff, G4double dens) {
0065 name=elemat;
0066 density=dens;
0067 nElem=1;
0068 theElements = new G4String[nElem];
0069 theWeights = new G4double[nElem];
0070
0071 theElements[0] = elemat;
0072 theWeights[0] = 1;
0073
0074 aEff=eff;
0075 }
0076
0077 CCalAMaterial::~CCalAMaterial() {
0078
0079 }
0080
0081 CCalAMaterial::CCalAMaterial(const CCalAMaterial& mat)
0082 : CCalMaterial( mat ) {
0083 name = mat.name;
0084 density = mat.density;
0085 nElem = mat.nElem;
0086 theElements = new G4String[nElem];
0087 theWeights = new G4double[nElem];
0088 for (G4int i=0; i<nElem; i++){
0089 theElements[i]=mat.theElements[i];
0090 theWeights[i]=mat.theWeights[i];
0091 }
0092 }
0093
0094 CCalAMaterial& CCalAMaterial::operator=(const CCalAMaterial& mat){
0095 if(theElements)
0096 delete[] theElements;
0097 if(theWeights)
0098 delete[] theWeights;
0099
0100 name=mat.name;
0101 density=mat.density;
0102 nElem=mat.nElem;
0103 aEff=mat.aEff;
0104
0105 theElements = new G4String[nElem];
0106 theWeights = new G4double[nElem];
0107 for (G4int i=0; i<nElem; i++){
0108 theElements[i]=mat.theElements[i];
0109 theWeights[i]=mat.theWeights[i];
0110 }
0111 return *this;
0112 }
0113
0114 void CCalAMaterial::computeAeff(G4int nconst,
0115 CCalAMaterial** constituents,
0116 G4double* weights){
0117 aEff=0;
0118 for (G4int i=0; i<nconst; i++)
0119 aEff += weights[i] * constituents[i]->Aeff();
0120 }
0121
0122 std::ostream& operator<<(std::ostream& os, const CCalAMaterial& mat) {
0123 os << mat.name << G4endl;
0124 os << "Density= " << mat.density << " g/cm3. Number of Elements: "
0125 << mat.nElem
0126 << ". Aeff= " << mat.aEff << G4endl;
0127 for (G4int i=0; i<mat.nElem; i++)
0128 os << '\t' << mat.theElements[i] << '\t' << mat.theWeights[i] << G4endl;
0129 return os;
0130 }