49 const G4String G4LatticeReader::fDataDir =
50 getenv(
"G4LATTICEDATA") ? (
const char*)getenv(
"G4LATTICEDATA") :
"./CrystalMaps";
56 : verboseLevel(vb), psLatfile(0), pLattice(0), fMapPath(
""),
57 fToken(
""), fValue(0.), fMap(
""), fsPol(
""), fPol(-1), fNX(0), fNY(0) {;}
60 delete psLatfile; psLatfile = 0;
67 if (verboseLevel)
G4cout <<
"G4LatticeReader " << filename <<
G4endl;
71 msg <<
"Unable to open " << filename;
72 G4Exception(
"G4LatticeReader::MakeLattice",
"Lattice001",
80 while (!psLatfile->eof()) {
87 msg <<
"Error reading lattice from " << filename;
88 G4Exception(
"G4LatticeReader::MakeLattice",
"Lattice002",
102 G4cout <<
"G4LatticeReader::OpenFile " << filename <<
G4endl;
105 psLatfile =
new std::ifstream(filepath);
106 if (!psLatfile->good()) {
107 filepath = fDataDir +
"/" + filename;
108 psLatfile->open(filepath);
109 if (!psLatfile->good()) {
113 if (verboseLevel>1)
G4cout <<
" Found file " << filepath <<
G4endl;
117 size_t lastdir = filepath.
last(
'/');
118 if (lastdir == std::string::npos) fMapPath =
".";
119 else fMapPath = filepath(0,lastdir);
127 if (psLatfile) psLatfile->close();
137 *psLatfile >> fToken;
138 if (fToken.empty() || psLatfile->eof())
return true;
140 if (verboseLevel>1)
G4cout <<
" ProcessToken " << fToken <<
G4endl;
160 *psLatfile >> fValue;
161 if (verboseLevel>1)
G4cout <<
" ProcessValue " << fValue <<
G4endl;
174 else if (name ==
"ldos") pLattice->
SetLDOS(fValue);
175 else if (name ==
"stdos") pLattice->
SetSTDOS(fValue);
176 else if (name ==
"ftdos") pLattice->
SetFTDOS(fValue);
178 G4cerr <<
"G4LatticeReader: Unrecognized token " << name <<
G4endl;
187 *psLatfile >> beta >> gamma >>
lambda >> mu;
189 G4cout <<
" ProcessConstants " << beta <<
" " << gamma
193 return psLatfile->good();
199 *psLatfile >> fMap >> fsPol >> fNX >> fNY;
201 G4cout <<
" ReadMapInfo " << fMap <<
" " << fsPol
202 <<
" " << fNX <<
" " << fNY <<
G4endl;
205 G4cerr <<
"G4LatticeReader: Invalid map theta dimension " << fNX <<
G4endl;
210 G4cerr <<
"G4LatticeReader: Invalid map phi dimension " << fNY <<
G4endl;
215 fMap = fMapPath +
"/" + fMap;
219 fPol = ( (fsPol==
"l") ? 0 :
224 if (fPol<0 || fPol>2) {
225 G4cerr <<
"G4LatticeReader: Invalid polarization code " << fsPol <<
G4endl;
234 G4cerr <<
"G4LatticeReader: Unable to process mapfile directive." <<
G4endl;
238 return pLattice->
LoadMap(fNX, fNY, fPol, fMap);
243 G4cerr <<
"G4LatticeReader: Unable to process mapfile directive." <<
G4endl;
247 return pLattice->
Load_NMap(fNX, fNY, fPol, fMap);
void SetFTDOS(G4double FTDOS)
std::ostringstream G4ExceptionDescription
G4bool LoadMap(G4int, G4int, G4int, G4String)
G4bool ProcessConstants()
G4GLOB_DLL std::ostream G4cout
void SetAnhDecConstant(G4double a)
void SetScatteringConstant(G4double b)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetLDOS(G4double LDOS)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void SetSTDOS(G4double STDOS)
G4bool OpenFile(const G4String &filepath)
Definition of the G4LatticeLogical class.
Definition of the G4LatticeReader class.
G4LatticeLogical * MakeLattice(const G4String &filepath)
G4bool Load_NMap(G4int, G4int, G4int, G4String)
void SetDynamicalConstants(G4double Beta, G4double Gamma, G4double Lambda, G4double Mu)
G4LatticeReader(G4int vb=0)
G4GLOB_DLL std::ostream G4cerr
G4bool ProcessValue(const G4String &name)