48const G4String G4LatticeReader::fDataDir =
49 std::getenv(
"G4LATTICEDATA") ? (
const char*)std::getenv(
"G4LATTICEDATA") :
"./CrystalMaps";
55 : verboseLevel(vb), psLatfile(0), pLattice(0), fMapPath(
""),
56 fToken(
""), fValue(0.), fMap(
""), fsPol(
""), fPol(-1), fNX(0), fNY(0) {;}
59 delete psLatfile; psLatfile = 0;
66 if (verboseLevel)
G4cout <<
"G4LatticeReader " << filename <<
G4endl;
70 msg <<
"Unable to open " << filename;
71 G4Exception(
"G4LatticeReader::MakeLattice",
"Lattice001",
79 while (!psLatfile->eof()) {
86 msg <<
"Error reading lattice from " << filename;
87 G4Exception(
"G4LatticeReader::MakeLattice",
"Lattice002",
101 G4cout <<
"G4LatticeReader::OpenFile " << filename <<
G4endl;
104 psLatfile =
new std::ifstream(filepath);
105 if (!psLatfile->good()) {
106 filepath = fDataDir +
"/" + filename;
107 psLatfile->open(filepath);
108 if (!psLatfile->good()) {
112 if (verboseLevel>1)
G4cout <<
" Found file " << filepath <<
G4endl;
116 size_t lastdir = filepath.
last(
'/');
117 if (lastdir == std::string::npos) fMapPath =
".";
118 else fMapPath = filepath(0,lastdir);
126 if (psLatfile) psLatfile->close();
136 *psLatfile >> fToken;
137 if (fToken.empty() || psLatfile->eof())
return true;
139 if (verboseLevel>1)
G4cout <<
" ProcessToken " << fToken <<
G4endl;
152 psLatfile->ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
159 *psLatfile >> fValue;
160 if (verboseLevel>1)
G4cout <<
" ProcessValue " << fValue <<
G4endl;
173 else if (name ==
"ldos") pLattice->
SetLDOS(fValue);
174 else if (name ==
"stdos") pLattice->
SetSTDOS(fValue);
175 else if (name ==
"ftdos") pLattice->
SetFTDOS(fValue);
177 G4cerr <<
"G4LatticeReader: Unrecognized token " << name <<
G4endl;
185 G4double beta=0., gamma=0., lambda=0., mu=0.;
186 *psLatfile >> beta >> gamma >> lambda >> mu;
188 G4cout <<
" ProcessConstants " << beta <<
" " << gamma
189 <<
" " << lambda <<
" " << mu <<
G4endl;
192 return psLatfile->good();
198 *psLatfile >> fMap >> fsPol >> fNX >> fNY;
200 G4cout <<
" ReadMapInfo " << fMap <<
" " << fsPol
201 <<
" " << fNX <<
" " << fNY <<
G4endl;
204 G4cerr <<
"G4LatticeReader: Invalid map theta dimension " << fNX <<
G4endl;
209 G4cerr <<
"G4LatticeReader: Invalid map phi dimension " << fNY <<
G4endl;
214 fMap = fMapPath +
"/" + fMap;
218 fPol = ( (fsPol==
"l") ? 0 :
223 if (fPol<0 || fPol>2) {
224 G4cerr <<
"G4LatticeReader: Invalid polarization code " << fsPol <<
G4endl;
233 G4cerr <<
"G4LatticeReader: Unable to process mapfile directive." <<
G4endl;
237 return pLattice->
LoadMap(fNX, fNY, fPol, fMap);
242 G4cerr <<
"G4LatticeReader: Unable to process mapfile directive." <<
G4endl;
246 return pLattice->
Load_NMap(fNX, fNY, fPol, fMap);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
Definition of the G4LatticeLogical class.
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void SetLDOS(G4double LDOS)
void SetAnhDecConstant(G4double a)
void SetFTDOS(G4double FTDOS)
G4bool LoadMap(G4int, G4int, G4int, G4String)
void SetSTDOS(G4double STDOS)
void SetDynamicalConstants(G4double Beta, G4double Gamma, G4double Lambda, G4double Mu)
void SetScatteringConstant(G4double b)
G4bool Load_NMap(G4int, G4int, G4int, G4String)
G4bool ProcessValue(const G4String &name)
G4LatticeLogical * MakeLattice(const G4String &filepath)
G4LatticeReader(G4int vb=0)
G4bool OpenFile(const G4String &filepath)
G4bool ProcessConstants()
std::size_t last(char) const