Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:19:38

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 ///////////////////////////////////////////////////////////////////////////////
0027 // File: CCalAMaterial.cc
0028 // Description: Specialised class to store information to make G4Material 
0029 //              from atomic proportion
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 //Let's compute density
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   //The base class destructor is called?
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 }