G4tgbMaterialMixtureByNoAtoms.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4tgbMaterialMixtureByNoAtoms.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgbMaterialMixtureByNoAtoms
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include "G4tgbMaterialMixtureByNoAtoms.hh"
00037 
00038 #include "G4SystemOfUnits.hh"
00039 #include "G4tgbMaterial.hh"
00040 #include "G4tgbMaterialMgr.hh"
00041 #include "G4tgrMessenger.hh"
00042 
00043 
00044 // -------------------------------------------------------------------------
00045 G4tgbMaterialMixtureByNoAtoms::G4tgbMaterialMixtureByNoAtoms()
00046 {
00047 }
00048 
00049 
00050 // -------------------------------------------------------------------------
00051 G4tgbMaterialMixtureByNoAtoms::~G4tgbMaterialMixtureByNoAtoms()
00052 {
00053 }
00054 
00055 
00056 // -------------------------------------------------------------------------
00057 G4tgbMaterialMixtureByNoAtoms::
00058 G4tgbMaterialMixtureByNoAtoms( G4tgrMaterial* hg)
00059 {
00060   theTgrMate = hg;
00061 }
00062 
00063 
00064 // -------------------------------------------------------------------------
00065 G4Material* G4tgbMaterialMixtureByNoAtoms::BuildG4Material()
00066 { 
00067   //----- construct new G4Material with components materials (a mixture)
00068 
00069   G4Material* mate = new G4Material( theTgrMate->GetName(),
00070                                      theTgrMate->GetDensity(),
00071                                      theTgrMate->GetNumberOfComponents(),
00072                                      theTgrMate->GetState(),
00073                                      theTgrMate->GetTemperature(),
00074                                      theTgrMate->GetPressure() );
00075  #ifdef G4VERBOSE
00076   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00077   {
00078     G4cout << " G4tgbMaterialMixtureByNoAtoms::BuildG4Material() -"
00079            << " Constructing new G4Material:"
00080            << " " << theTgrMate->GetName()
00081            << " " << theTgrMate->GetDensity()/g*cm3
00082            << " " << theTgrMate->GetNumberOfComponents()
00083            << " " << theTgrMate->GetState()
00084            << " " << theTgrMate->GetTemperature()
00085            << " " << theTgrMate->GetPressure() << G4endl;
00086   }
00087 #endif
00088 
00089   //--- add components
00090 
00091   G4Element* compElem;
00092   G4tgbMaterialMgr* mf = G4tgbMaterialMgr::GetInstance();
00093   for( G4int ii = 0; ii < theTgrMate->GetNumberOfComponents(); ii++)
00094   {
00095     // look if this component is an element
00096     compElem = mf->FindOrBuildG4Element( GetComponent(ii), false );
00097     if( compElem != 0 )
00098     {
00099 #ifdef G4VERBOSE
00100       if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00101       {
00102         G4cout << " G4tgbMaterialMixtureByNoAtoms::BuildG4Material() -"
00103                << " Adding component element ..." << G4endl;
00104       }
00105 #endif
00106       // add it by number of atoms
00107       G4cout << compElem->GetName() << " BY NATOMS ele "
00108              << ii << " " << G4int(GetFraction(ii)) << G4endl;
00109       mate->AddElement( compElem, G4int(GetFraction(ii)) );
00110       // if it is not an element look if it is a material
00111     }
00112     else
00113     { 
00114       G4String ErrMessage = "Component " + GetComponent(ii)
00115                           + " of material " +  theTgrMate->GetName()
00116                           + "\n" + "is not an element !";
00117       G4Exception("G4tgbMaterialMixtureByWeight::buildG4Material()",
00118                   "InvalidSetup", FatalException, ErrMessage);
00119     } 
00120   }
00121 
00122 #ifdef G4VERBOSE
00123   if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00124   {
00125     G4cout << " Constructing new G4Material by number of atoms: "
00126            << *mate << G4endl; 
00127   }
00128 #endif      
00129 
00130   return mate;
00131 }
00132 
00133 
00134 // -------------------------------------------------------------------------
00135 void G4tgbMaterialMixtureByNoAtoms::TransformToFractionsByWeight() 
00136 {
00137 }

Generated on Mon May 27 17:49:58 2013 for Geant4 by  doxygen 1.4.7