G4PhysicsTable Class Reference

#include <G4PhysicsTable.hh>


Public Member Functions

 G4PhysicsTable ()
 G4PhysicsTable (size_t cap)
virtual ~G4PhysicsTable ()
G4PhysicsVector *& operator() (size_t)
G4PhysicsVector *const & operator() (size_t) const
void clearAndDestroy ()
void push_back (G4PhysicsVector *)
void insert (G4PhysicsVector *)
void insertAt (size_t, G4PhysicsVector *)
void resize (size_t, G4PhysicsVector *vec=(G4PhysicsVector *)(0))
size_t entries () const
size_t length () const
G4bool isEmpty () const
G4bool ExistPhysicsTable (const G4String &fileName) const
G4bool StorePhysicsTable (const G4String &filename, G4bool ascii=false)
G4bool RetrievePhysicsTable (const G4String &filename, G4bool ascii=false)
void ResetFlagArray ()
G4bool GetFlag (size_t i) const
void ClearFlag (size_t i)

Protected Member Functions

G4PhysicsVectorCreatePhysicsVector (G4int type)

Protected Attributes

G4FlagCollection vecFlag

Friends

std::ostream & operator<< (std::ostream &out, G4PhysicsTable &table)


Detailed Description

Definition at line 66 of file G4PhysicsTable.hh.


Constructor & Destructor Documentation

G4PhysicsTable::G4PhysicsTable (  ) 

Definition at line 51 of file G4PhysicsTable.cc.

00052   : G4PhysCollection()
00053 {
00054 }

G4PhysicsTable::G4PhysicsTable ( size_t  cap  )  [explicit]

Definition at line 56 of file G4PhysicsTable.cc.

References vecFlag.

00057   : G4PhysCollection()
00058 {
00059   reserve(cap);
00060   vecFlag.reserve(cap);
00061 }

G4PhysicsTable::~G4PhysicsTable (  )  [virtual]

Definition at line 85 of file G4PhysicsTable.cc.

References vecFlag.

00086 {
00087   G4PhysCollection::clear();
00088   vecFlag.clear();
00089 }


Member Function Documentation

void G4PhysicsTable::clearAndDestroy (  )  [inline]

Definition at line 39 of file G4PhysicsTable.icc.

References vecFlag.

Referenced by G4VEnergyLoss::BuildInverseRangeTable(), G4VeLowEnergyLoss::BuildInverseRangeTable(), G4VEnergyLoss::BuildLabTimeTable(), G4VeLowEnergyLoss::BuildLabTimeTable(), G4NeutronHPInelasticData::BuildPhysicsTable(), G4NeutronHPFissionData::BuildPhysicsTable(), G4NeutronHPElasticData::BuildPhysicsTable(), G4NeutronHPCaptureData::BuildPhysicsTable(), G4ePolarizedIonisation::BuildPhysicsTable(), G4VEnergyLoss::BuildProperTimeTable(), G4VeLowEnergyLoss::BuildProperTimeTable(), G4VEnergyLoss::BuildRangeCoeffATable(), G4VeLowEnergyLoss::BuildRangeCoeffATable(), G4VEnergyLoss::BuildRangeCoeffBTable(), G4VeLowEnergyLoss::BuildRangeCoeffBTable(), G4VEnergyLoss::BuildRangeCoeffCTable(), G4VeLowEnergyLoss::BuildRangeCoeffCTable(), G4VEnergyLoss::BuildRangeTable(), G4VeLowEnergyLoss::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), G4VRangeToEnergyConverter::operator=(), G4VRangeToEnergyConverter::Reset(), RetrievePhysicsTable(), G4VEnergyLossProcess::SetDEDXTable(), G4Cerenkov::~G4Cerenkov(), G4DiffuseElastic::~G4DiffuseElastic(), G4eplusPolarizedAnnihilation::~G4eplusPolarizedAnnihilation(), G4ePolarizedIonisation::~G4ePolarizedIonisation(), G4hImpactIonisation::~G4hImpactIonisation(), G4hRDEnergyLoss::~G4hRDEnergyLoss(), G4KokoulinMuonNuclearXS::~G4KokoulinMuonNuclearXS(), G4NeutronHPCaptureData::~G4NeutronHPCaptureData(), G4NeutronHPElasticData::~G4NeutronHPElasticData(), G4NeutronHPFissionData::~G4NeutronHPFissionData(), G4NeutronHPInelasticData::~G4NeutronHPInelasticData(), G4NuclNuclDiffuseElastic::~G4NuclNuclDiffuseElastic(), G4OpRayleigh::~G4OpRayleigh(), G4OpWLS::~G4OpWLS(), G4PAIModel::~G4PAIModel(), G4PAIPhotonModel::~G4PAIPhotonModel(), G4PenelopeCrossSection::~G4PenelopeCrossSection(), G4PolarizedCompton::~G4PolarizedCompton(), G4Scintillation::~G4Scintillation(), G4UPiNuclearCrossSection::~G4UPiNuclearCrossSection(), G4VEmModel::~G4VEmModel(), G4VEmProcess::~G4VEmProcess(), and G4VEnergyLossProcess::~G4VEnergyLossProcess().

00040 {
00041   G4PhysicsVector* a=0;
00042   while (size()>0)
00043   {
00044     a = G4PhysCollection::back();
00045     G4PhysCollection::pop_back();
00046     if ( a )  { delete a; }
00047   } 
00048 
00049   vecFlag.clear();
00050 }

void G4PhysicsTable::ClearFlag ( size_t  i  )  [inline]

Definition at line 115 of file G4PhysicsTable.icc.

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable(), G4PhysicsTableHelper::RetrievePhysicsTable(), and G4PhysicsTableHelper::SetPhysicsVector().

00116 {
00117   vecFlag[i] = false;
00118 }

G4PhysicsVector * G4PhysicsTable::CreatePhysicsVector ( G4int  type  )  [protected]

Definition at line 283 of file G4PhysicsTable.cc.

References T_G4LPhysicsFreeVector, T_G4PhysicsFreeVector, T_G4PhysicsLinearVector, T_G4PhysicsLnVector, T_G4PhysicsLogVector, and T_G4PhysicsOrderedFreeVector.

Referenced by RetrievePhysicsTable().

00284 {
00285   G4PhysicsVector* pVector=0;
00286   switch (type)
00287   {
00288   case T_G4PhysicsLinearVector: 
00289     pVector = new G4PhysicsLinearVector();
00290     break;
00291 
00292   case T_G4PhysicsLogVector: 
00293     pVector = new G4PhysicsLogVector();
00294     break;
00295 
00296   case T_G4PhysicsLnVector: 
00297     pVector = new G4PhysicsLnVector();
00298     break;
00299 
00300   case T_G4PhysicsFreeVector: 
00301     pVector = new G4PhysicsFreeVector();
00302     break;
00303 
00304   case T_G4PhysicsOrderedFreeVector: 
00305     pVector = new G4PhysicsOrderedFreeVector();
00306     break;
00307 
00308   case T_G4LPhysicsFreeVector: 
00309     pVector = new G4LPhysicsFreeVector();
00310     break;
00311   
00312   default:
00313     break;
00314   }
00315   return pVector;
00316 }

size_t G4PhysicsTable::entries (  )  const [inline]

Definition at line 91 of file G4PhysicsTable.icc.

Referenced by G4Scintillation::DumpPhysicsTable(), G4OpWLS::DumpPhysicsTable(), G4OpRayleigh::DumpPhysicsTable(), and G4Cerenkov::DumpPhysicsTable().

00092 {
00093   return G4PhysCollection::size();
00094 }

G4bool G4PhysicsTable::ExistPhysicsTable ( const G4String fileName  )  const

Definition at line 149 of file G4PhysicsTable.cc.

00150 {
00151   std::ifstream fIn;  
00152   G4bool value=true;
00153   // open input file
00154   fIn.open(fileName,std::ios::in);
00155 
00156   // check if the file has been opened successfully 
00157   if (!fIn)
00158   {
00159     value = false;
00160   }
00161   fIn.close();
00162   return value;
00163 }

G4bool G4PhysicsTable::GetFlag ( size_t  i  )  const [inline]

Definition at line 109 of file G4PhysicsTable.icc.

References vecFlag.

Referenced by G4PolarizedCompton::BuildAsymmetryTable(), G4eplusPolarizedAnnihilation::BuildAsymmetryTable(), G4VEnergyLossProcess::BuildDEDXTable(), G4LossTableBuilder::InitialiseBaseMaterials(), and operator<<().

00110 {
00111   return vecFlag[i];
00112 }

void G4PhysicsTable::insert ( G4PhysicsVector  )  [inline]

Definition at line 72 of file G4PhysicsTable.icc.

References vecFlag.

Referenced by G4hRDEnergyLoss::BuildDEDXTable(), G4VEnergyLoss::BuildInverseRangeTable(), G4VeLowEnergyLoss::BuildInverseRangeTable(), G4VEnergyLoss::BuildLabTimeTable(), G4VeLowEnergyLoss::BuildLabTimeTable(), G4VRangeToEnergyConverter::BuildLossTable(), G4VEnergyLoss::BuildProperTimeTable(), G4VeLowEnergyLoss::BuildProperTimeTable(), G4VEnergyLoss::BuildRangeCoeffATable(), G4VeLowEnergyLoss::BuildRangeCoeffATable(), G4VEnergyLoss::BuildRangeCoeffBTable(), G4VeLowEnergyLoss::BuildRangeCoeffBTable(), G4VEnergyLoss::BuildRangeCoeffCTable(), G4VeLowEnergyLoss::BuildRangeCoeffCTable(), G4VEnergyLoss::BuildRangeTable(), G4VeLowEnergyLoss::BuildRangeTable(), and G4VRangeToEnergyConverter::operator=().

00073 {
00074   G4PhysCollection::push_back(pvec);
00075   vecFlag.push_back(true);
00076 }

void G4PhysicsTable::insertAt ( size_t  ,
G4PhysicsVector  
) [inline]

Definition at line 79 of file G4PhysicsTable.icc.

References vecFlag.

Referenced by G4VXTRenergyLoss::BuildAngleForEnergyBank(), G4VXTRenergyLoss::BuildAngleTable(), G4NuclNuclDiffuseElastic::BuildAngleTable(), G4DiffuseElastic::BuildAngleTable(), G4KokoulinMuonNuclearXS::BuildCrossSectionTable(), G4VXTRenergyLoss::BuildEnergyTable(), G4VXTRenergyLoss::BuildGlobalAngleTable(), G4PAIPhotonModel::BuildPAIonisationTable(), G4PAIModel::BuildPAIonisationTable(), G4ePolarizedIonisation::BuildPhysicsTable(), G4Scintillation::BuildThePhysicsTable(), G4ForwardXrayTR::BuildXrayTRtables(), G4NuclNuclDiffuseElastic::TestAngleTable(), and G4DiffuseElastic::TestAngleTable().

00080 {
00081   G4PhysicsTableIterator itr=begin();
00082   for (size_t i=0; i<idx; ++i) { itr++; }
00083   G4PhysCollection::insert(itr, pvec);
00084 
00085   G4FlagCollection::iterator itrF=vecFlag.begin();
00086   for (size_t j=0; j<idx; ++j) { itrF++; }
00087   vecFlag.insert(itrF, true);
00088 }

G4bool G4PhysicsTable::isEmpty (  )  const [inline]

Definition at line 103 of file G4PhysicsTable.icc.

00104 {
00105   return G4PhysCollection::empty();
00106 }

size_t G4PhysicsTable::length (  )  const [inline]

Definition at line 97 of file G4PhysicsTable.icc.

Referenced by G4VEnergyLoss::BuildInverseRangeTable(), G4VEnergyLoss::BuildLabTimeTable(), G4VEnergyLoss::BuildProperTimeTable(), G4VEnergyLoss::BuildRangeCoeffATable(), G4VEnergyLoss::BuildRangeCoeffBTable(), G4VEnergyLoss::BuildRangeCoeffCTable(), G4VEnergyLoss::BuildRangeTable(), G4VeLowEnergyLoss::BuildRangeTable(), G4VEmProcess::PrintInfoDefinition(), G4VEmProcess::RetrievePhysicsTable(), G4VEnergyLossProcess::SetCSDARangeTable(), G4VEnergyLossProcess::SetDEDXTable(), and G4VEnergyLossProcess::SetLambdaTable().

00098 {
00099   return G4PhysCollection::size();
00100 }

G4PhysicsVector *const & G4PhysicsTable::operator() ( size_t   )  const [inline]

Definition at line 59 of file G4PhysicsTable.icc.

00060 { 
00061   return (*this)[i]; 
00062 }

G4PhysicsVector *& G4PhysicsTable::operator() ( size_t   )  [inline]

Definition at line 53 of file G4PhysicsTable.icc.

00054 {
00055   return (*this)[i]; 
00056 }

void G4PhysicsTable::push_back ( G4PhysicsVector  )  [inline]

Definition at line 65 of file G4PhysicsTable.icc.

References vecFlag.

Referenced by G4NeutronHPorLEInelasticData::BuildPhysicsTable(), G4NeutronHPInelasticData::BuildPhysicsTable(), G4NeutronHPFissionData::BuildPhysicsTable(), G4NeutronHPElasticData::BuildPhysicsTable(), G4NeutronHPCaptureData::BuildPhysicsTable(), and G4PenelopeCrossSection::G4PenelopeCrossSection().

00066 {
00067   G4PhysCollection::push_back(pvec);
00068   vecFlag.push_back(true);
00069 }

void G4PhysicsTable::ResetFlagArray (  ) 

Definition at line 273 of file G4PhysicsTable.cc.

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

00274 {
00275   size_t tableSize = G4PhysCollection::size(); 
00276   vecFlag.clear();
00277   for (size_t idx=0; idx<tableSize; idx++)
00278   {
00279     vecFlag.push_back(true);
00280   }
00281 }

void G4PhysicsTable::resize ( size_t  ,
G4PhysicsVector vec = (G4PhysicsVector *)(0) 
)

Definition at line 91 of file G4PhysicsTable.cc.

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

00092 {
00093   G4PhysCollection::resize(siz, vec);
00094   vecFlag.resize(siz, true);
00095 }

G4bool G4PhysicsTable::RetrievePhysicsTable ( const G4String filename,
G4bool  ascii = false 
)

Definition at line 165 of file G4PhysicsTable.cc.

References clearAndDestroy(), CreatePhysicsVector(), G4cerr, G4endl, G4PhysicsVector::Retrieve(), and vecFlag.

Referenced by G4PhysicsTableHelper::RetrievePhysicsTable().

00167 {
00168   std::ifstream fIn;  
00169   // open input file
00170   if (ascii)
00171     { fIn.open(fileName,std::ios::in|std::ios::binary); }
00172   else
00173     { fIn.open(fileName,std::ios::in);} 
00174 
00175   // check if the file has been opened successfully 
00176   if (!fIn)
00177   {
00178 #ifdef G4VERBOSE  
00179     G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
00180     G4cerr << " Cannot open file: " << fileName << G4endl;
00181 #endif
00182     fIn.close();
00183     return false;
00184   }
00185 
00186   // clear 
00187   clearAndDestroy();
00188   
00189   // Number of elements
00190   size_t tableSize=0; 
00191   if (!ascii)
00192   {
00193     fIn.read((char*)(&tableSize), sizeof tableSize); 
00194   }
00195   else
00196   {
00197     fIn >> tableSize;
00198   }
00199   reserve(tableSize); 
00200   vecFlag.clear();
00201 
00202   // Physics Vector
00203   for (size_t idx=0; idx<tableSize; ++idx)
00204   {
00205     G4int vType=0;
00206     if (!ascii)
00207     {
00208       fIn.read( (char*)(&vType), sizeof vType); 
00209     }
00210     else
00211     {
00212       fIn >>  vType;
00213     }
00214     G4PhysicsVector* pVec = CreatePhysicsVector(vType);
00215     if (pVec==0)
00216     {
00217 #ifdef G4VERBOSE  
00218       G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
00219       G4cerr << " Illegal Physics Vector type: " << vType << " in: ";
00220       G4cerr << fileName << G4endl;
00221 #endif          
00222       fIn.close();
00223       return false;
00224     }
00225 
00226     if (! (pVec->Retrieve(fIn,ascii)) )
00227     {
00228 #ifdef G4VERBOSE  
00229       G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
00230       G4cerr << " Rrror in retreiving " << idx
00231              << "-th Physics Vector from file: ";
00232       G4cerr << fileName << G4endl;
00233 #endif          
00234       fIn.close();
00235       return false;
00236     }
00237 
00238     // add a PhysicsVector to this PhysicsTable
00239     G4PhysCollection::push_back(pVec);
00240     vecFlag.push_back(true);
00241     
00242   } 
00243   fIn.close();
00244   return true;
00245 }

G4bool G4PhysicsTable::StorePhysicsTable ( const G4String filename,
G4bool  ascii = false 
)

Definition at line 97 of file G4PhysicsTable.cc.

References G4cerr, and G4endl.

Referenced by G4VMultipleScattering::StorePhysicsTable(), and G4VEmProcess::StorePhysicsTable().

00099 {
00100   std::ofstream fOut;  
00101   
00102   // open output file //
00103   if (!ascii)
00104     { fOut.open(fileName, std::ios::out|std::ios::binary); }
00105   else
00106     { fOut.open(fileName, std::ios::out); }
00107 
00108   // check if the file has been opened successfully 
00109   if (!fOut)
00110   {
00111 #ifdef G4VERBOSE  
00112     G4cerr << "G4PhysicsTable::StorePhysicsTable():";
00113     G4cerr << " Cannot open file: " << fileName << G4endl;
00114 #endif
00115     fOut.close();
00116     return false;
00117   }
00118 
00119   // Number of elements
00120   size_t tableSize = size(); 
00121   if (!ascii)
00122   {
00123     fOut.write( (char*)(&tableSize), sizeof tableSize); 
00124   }
00125   else
00126   {
00127     fOut << tableSize << G4endl;
00128   }
00129 
00130   // Physics Vector
00131   for (G4PhysicsTableIterator itr=begin(); itr!=end(); ++itr)
00132   {
00133     G4int vType = (*itr)->GetType();
00134     if (!ascii)
00135     {
00136       fOut.write( (char*)(&vType), sizeof vType); 
00137     }
00138     else
00139     {
00140       fOut << vType << G4endl;
00141     }
00142     (*itr)->Store(fOut,ascii);
00143   }
00144   fOut.close();
00145   return true;
00146 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
G4PhysicsTable table 
) [friend]

Definition at line 247 of file G4PhysicsTable.cc.

00249 {
00250   // Printout Physics Vector
00251   size_t i=0;
00252   for (G4PhysicsTableIterator itr=right.begin(); itr!=right.end(); ++itr)
00253   {
00254     out << std::setw(8) << i << "-th Vector   ";
00255     out << ": Type    " << G4int((*itr)->GetType()) ;
00256     out << ": Flag    ";
00257     if (right.GetFlag(i))
00258     {
00259       out << " T";
00260     } 
00261     else
00262     {
00263       out << " F";
00264     } 
00265     out << G4endl;
00266     out << *(*itr);
00267     i +=1;
00268   }
00269   out << G4endl;
00270   return out; 
00271 }


Field Documentation

G4FlagCollection G4PhysicsTable::vecFlag [protected]

Definition at line 132 of file G4PhysicsTable.hh.

Referenced by clearAndDestroy(), ClearFlag(), G4PhysicsTable(), GetFlag(), insert(), insertAt(), push_back(), ResetFlagArray(), resize(), RetrievePhysicsTable(), and ~G4PhysicsTable().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:54 2013 for Geant4 by  doxygen 1.4.7