-
- // *** material definitions: elements, compound made of G4Elements
- // or made of G4Materials
- for(unsigned int j=0; j<totNumMat; j++) {
- //pointer material, and material data
- ptrMat = (*ptrMatTab)[j];
- size_t numElem = ptrMat->GetNumberOfElements();
- G4double densityMat = (ptrMat->GetDensity())/(g/cm3);
- G4String nameMat = ptrMat->GetName();
- nameMat.toUpper();
- isotPresence = 0;
-
- //fraction vector of compounds of the material
- const G4double* ptrFracVect = ptrMat->GetFractionVector();
-
- //loop on elements of the material
- for(unsigned int el=0; el<numElem; el++) {
- //compute physical data, initialize variables
- const G4Element * ptrElem = ptrMat->GetElement(el);
- size_t indElemTab = ptrElem->GetIndex();
- G4String nameElem = ptrElem->GetName();
- nameElem.toUpper();
- size_t numIsot = ptrElem->GetNumberOfIsotopes();
- G4double A = (ptrElem->GetA())/(g);
-
- if(!numIsot) {
- if(!elemIndexInMATcard[indElemTab]) {
- G4double Z = ptrElem->GetZ();
- G4double density = ptrFracVect[el]*densityMat;
- elemIndexInMATcard[indElemTab] = indexCount;
-
- //write on file MATERIAL card of element
- PrintMaterial(fout, "MATERIAL ",
- Z, A,
- density,
- G4double(indexCount),
- -1,
- nameElem);
- }
- }
-
- else {
- if(numIsot>=2)
- isotPresence = 1;
- //loop on isotopes
- for(unsigned int nis=0; nis<numIsot; nis++) {
- // G4Isotope pointer
- const G4Isotope* ptrIsot = ptrElem->GetIsotope(nis);
- size_t indIsotTab = ptrIsot->GetIndex();
- //initialize variables
- if(!initIsot) {
- totNumIsot = ptrIsot->GetNumberOfIsotopes();
- ptrIsotTab = ptrIsot->GetIsotopeTable();
- isotIndexInMATcard = new G4int[totNumIsot];
- for(unsigned int t=0; t<totNumIsot; t++)
- isotIndexInMATcard[t] = 0;
- initIsot = 1;
- }
- if(!isotIndexInMATcard[indIsotTab]) {
- //compute physical data and counters
- G4int ZIs = ptrIsot->GetZ();
- G4double AIs = (ptrIsot->GetA())/(g);
- G4int NIs = ptrIsot->GetN();
- G4String nameIsot = ptrIsot->GetName();
- nameIsot.toUpper();
- G4double* ptrRelAbVect = ptrElem->GetRelativeAbundanceVector();
- G4double density =
- ptrFracVect[el]*densityMat*ptrRelAbVect[nis]*AIs/A;
- G4int index = indexCount;
- isotIndexInMATcard[indIsotTab] = indexCount;
- indexCount+=1;
-
- //write on file MATERIAL card of isotope
- PrintMaterial(fout, "MATERIAL ",
- G4double(ZIs), AIs,
- density,
- G4double(index),
- NIs,
- nameIsot);
- }
- }
- }
-
- }
-
- if(numElem>1 || isotPresence==1) {
- // write MATERIAL+COMPOUND card specifing the compound
-
- //flags for writing COMPOUND card
- G4int treCount=0;
-
- //make MATERIAL card for compound, start COMPOUND card
- fout <<"*"<<G4endl;
- fout <<"* Define GEANT4 compound " << nameMat << G4endl;
- PrintMaterial(fout, "MATERIAL ",
- -1, -1,
- densityMat,
- G4double(indexMatFluka[j]),
- -1,
- nameMat);
- fout << setw10 << "COMPOUND ";
-
-
- //write elements in COMPOUND card
- for(unsigned int h=0; h<numElem; h++) {
- const G4Element * ptrElemMat = ptrMat->GetElement(h);
- size_t indexElemMat = ptrElemMat->GetIndex();
- size_t numIsotElem = ptrElemMat->GetNumberOfIsotopes();
- if(!numIsotElem) {
- PrintCompound(fout, "COMPOUND ",
- treCount,
- nameMat,
- -ptrFracVect[h],
- G4double(elemIndexInMATcard[indexElemMat]));
-
- if(treCount==3)
- treCount=0;
- treCount+=1;
- }
- else {
- G4double * ptrIsotAbbVect =
- ptrElemMat->GetRelativeAbundanceVector();
-
- for(unsigned int iso=0; iso<numIsotElem; iso++) {
- const G4Isotope * ptrIsotElem =ptrElemMat->GetIsotope(iso);
- size_t indexIsotMat = ptrIsotElem->GetIndex();
- G4double isotAbundPerVol =
- ptrIsotAbbVect[iso]*Avogadro*densityMat*
- ptrFracVect[h]/(ptrElemMat->GetA()/(g));
-
- PrintCompound(fout, "COMPOUND ",
- treCount,
- nameMat,
- isotAbundPerVol,
- G4double(isotIndexInMATcard[indexIsotMat]));
- if(treCount==3)
- treCount=0;
- treCount+=1;
- }
- }
- }
-
- //end COMPOUND card
- if(treCount==1)
- fout << setw10 << " " << setw10 << " "
- << setw10 << " " << setw10 << " "
- << nameMat << G4endl;
- if(treCount==2)
- fout << setw10 << " " << setw10 << " "
- << nameMat << G4endl;
- if(treCount==3)
- fout << nameMat << G4endl;
- fout << "*" << G4endl;
- }
-
-
- } // end for loop
- delete elemIndexInMATcard;
- if(initIsot)
- delete isotIndexInMATcard;