G4MaterialPropertiesTable.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: G4MaterialPropertiesTable.cc 67044 2013-01-30 08:50:06Z gcosmo $
00028 //
00029 // 
00031 // G4MaterialPropertiesTable Implementation
00033 //
00034 // File: G4MaterialPropertiesTable.cc 
00035 // Version:     1.0
00036 // Created:     1996-02-08
00037 // Author:      Juliet Armstrong
00038 // Updated:     2005-05-12 add SetGROUPVEL(), courtesy of
00039 //              Horton-Smith (bug report #741), by P. Gumplinger
00040 //              2002-11-05 add named material constants by P. Gumplinger
00041 //              1999-11-05 Migration from G4RWTPtrHashDictionary to STL
00042 //                         by John Allison
00043 //              1997-03-26 by Peter Gumplinger
00044 //              > cosmetics (only)
00045 // mail:        gum@triumf.ca
00046 //
00048 
00049 #include "globals.hh"
00050 #include "G4MaterialPropertiesTable.hh"
00051 #include "G4PhysicalConstants.hh"
00052 
00054 // Constructors
00056 
00057 G4MaterialPropertiesTable::G4MaterialPropertiesTable()
00058 {
00059 }
00060 
00062 // Destructor
00064 
00065 G4MaterialPropertiesTable::~G4MaterialPropertiesTable()
00066 {
00067   MPTiterator i;
00068   for (i = MPT.begin(); i != MPT.end(); ++i)
00069   {
00070     delete (*i).second;
00071   }
00072   MPT.clear();
00073   MPTC.clear();
00074 }
00075 
00077 // Methods
00079 
00080 void G4MaterialPropertiesTable::DumpTable()
00081 {
00082   MPTiterator i;
00083   for (i = MPT.begin(); i != MPT.end(); ++i)
00084   {
00085     G4cout << (*i).first << G4endl;
00086     if ( (*i).second != 0 )
00087     {
00088       (*i).second->DumpValues();
00089     }
00090     else
00091     {
00092       G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat204",
00093                   JustWarning, "NULL Material Property Vector Pointer.");
00094     }
00095   }
00096   MPTCiterator j;
00097   for (j = MPTC.begin(); j != MPTC.end(); ++j)
00098   {
00099     G4cout << j->first << G4endl;
00100     if ( j->second != 0 )
00101     {
00102       G4cout << j->second << G4endl;
00103     }
00104     else
00105     {
00106       G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat202",
00107                   JustWarning, "No Material Constant Property.");
00108     }
00109   }
00110 }
00111 
00112 G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
00113 {
00114   // fetch RINDEX data, give up if unavailable
00115   //
00116   G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
00117   if (rindex==0)  { return 0; }
00118 
00119   // RINDEX exists but has no entries, give up
00120   //
00121   if ( rindex->GetVectorLength() == 0 ) { return 0; }
00122 
00123   // add GROUPVEL vector
00124   //
00125   G4MaterialPropertyVector* groupvel = new G4MaterialPropertyVector();
00126 
00127   this->AddProperty( "GROUPVEL", groupvel );
00128                                                                                 
00129   // fill GROUPVEL vector using RINDEX values
00130   // rindex built-in "iterator" was advanced to first entry above
00131   //
00132   G4double E0 = rindex->Energy(0);
00133   G4double n0 = (*rindex)[0];
00134 
00135   if (E0 <= 0.)
00136   {
00137     G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
00138                 FatalException, "Optical Photon Energy <= 0");
00139   }
00140                                                                                 
00141   if ( rindex->GetVectorLength() >= 2 )
00142   {
00143     // good, we have at least two entries in RINDEX
00144     // get next energy/value pair
00145 
00146     G4double E1 = rindex->Energy(1);
00147     G4double n1 = (*rindex)[1];
00148 
00149     if (E1 <= 0.)
00150     {
00151       G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
00152                   FatalException, "Optical Photon Energy <= 0");
00153     }
00154 
00155     G4double vg;
00156 
00157     // add entry at first photon energy
00158     //
00159     vg = c_light/(n0+(n1-n0)/std::log(E1/E0));
00160 
00161     // allow only for 'normal dispersion' -> dn/d(logE) > 0
00162     //
00163     if((vg<0) || (vg>c_light/n0))  { vg = c_light/n0; }
00164 
00165     groupvel->InsertValues( E0, vg );
00166 
00167     // add entries at midpoints between remaining photon energies
00168     //
00169 
00170     for (size_t i = 2; i < rindex->GetVectorLength(); i++)
00171     {
00172       vg = c_light/( 0.5*(n0+n1)+(n1-n0)/std::log(E1/E0));
00173 
00174       // allow only for 'normal dispersion' -> dn/d(logE) > 0
00175       //
00176       if((vg<0) || (vg>c_light/(0.5*(n0+n1))))  { vg = c_light/(0.5*(n0+n1)); }
00177       groupvel->InsertValues( 0.5*(E0+E1), vg );
00178 
00179       // get next energy/value pair, or exit loop
00180       //
00181       E0 = E1;
00182       n0 = n1;
00183       E1 = rindex->Energy(i);
00184       n1 = (*rindex)[i];
00185 
00186       if (E1 <= 0.)
00187       {
00188         G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
00189                     FatalException, "Optical Photon Energy <= 0");
00190       }
00191     }
00192 
00193     // add entry at last photon energy
00194     //
00195     vg = c_light/(n1+(n1-n0)/std::log(E1/E0));
00196 
00197     // allow only for 'normal dispersion' -> dn/d(logE) > 0
00198     //
00199     if((vg<0) || (vg>c_light/n1))  { vg = c_light/n1; }
00200     groupvel->InsertValues( E1, vg );
00201   }
00202   else // only one entry in RINDEX -- weird!
00203   {
00204     groupvel->InsertValues( E0, c_light/n0 );
00205   }
00206                                                                                 
00207   return groupvel;
00208 }

Generated on Mon May 27 17:48:51 2013 for Geant4 by  doxygen 1.4.7