ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgbMaterialMixtureByNoAtoms.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgbMaterialMixtureByNoAtoms.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // class G4tgbMaterialMixtureByNoAtoms
30 
31 // History:
32 // - Created. P.Arce, CIEMAT (November 2007)
33 // -------------------------------------------------------------------------
34 
36 
37 #include "G4SystemOfUnits.hh"
38 #include "G4tgbMaterial.hh"
39 #include "G4tgbMaterialMgr.hh"
40 #include "G4tgrMessenger.hh"
41 
42 
43 // -------------------------------------------------------------------------
45 {
46 }
47 
48 
49 // -------------------------------------------------------------------------
51 {
52 }
53 
54 
55 // -------------------------------------------------------------------------
58 {
59  theTgrMate = hg;
60 }
61 
62 
63 // -------------------------------------------------------------------------
65 {
66  //----- construct new G4Material with components materials (a mixture)
67 
68  G4Material* mate = new G4Material( theTgrMate->GetName(),
74  #ifdef G4VERBOSE
76  {
77  G4cout << " G4tgbMaterialMixtureByNoAtoms::BuildG4Material() -"
78  << " Constructing new G4Material:"
79  << " " << theTgrMate->GetName()
80  << " " << theTgrMate->GetDensity()/g*cm3
82  << " " << theTgrMate->GetState()
83  << " " << theTgrMate->GetTemperature()
84  << " " << theTgrMate->GetPressure() << G4endl;
85  }
86 #endif
87 
88  //--- add components
89 
90  G4Element* compElem;
92  for( G4int ii = 0; ii < theTgrMate->GetNumberOfComponents(); ii++)
93  {
94  // look if this component is an element
95  compElem = mf->FindOrBuildG4Element( GetComponent(ii), false );
96  if( compElem != 0 )
97  {
98 #ifdef G4VERBOSE
100  {
101  G4cout << " G4tgbMaterialMixtureByNoAtoms::BuildG4Material() -"
102  << " Adding component element ..." << G4endl;
103  }
104 #endif
105  // add it by number of atoms
106  G4cout << compElem->GetName() << " BY NATOMS ele "
107  << ii << " " << G4int(GetFraction(ii)) << G4endl;
108  mate->AddElement( compElem, G4int(GetFraction(ii)) );
109  // if it is not an element look if it is a material
110  }
111  else
112  {
113  G4String ErrMessage = "Component " + GetComponent(ii)
114  + " of material " + theTgrMate->GetName()
115  + "\n" + "is not an element !";
116  G4Exception("G4tgbMaterialMixtureByWeight::buildG4Material()",
117  "InvalidSetup", FatalException, ErrMessage);
118  }
119  }
120 
121 #ifdef G4VERBOSE
123  {
124  G4cout << " Constructing new G4Material by number of atoms: "
125  << *mate << G4endl;
126  }
127 #endif
128 
129  return mate;
130 }
131 
132 
133 // -------------------------------------------------------------------------
135 {
136 }