49 xercesc::XMLPlatformUtils::Initialize();
54 : urcode(true), strip(true)
60 xercesc::XMLPlatformUtils::Initialize();
66 : urcode(true), uwcode(true), strip(true)
72 xercesc::XMLPlatformUtils::Initialize();
78 xercesc::XMLPlatformUtils::Terminate();
94void G4GDMLParser::ImportRegions()
98 for(
auto iaux = auxInfoList->cbegin(); iaux != auxInfoList->cend(); ++iaux)
100 if(iaux->type !=
"Region")
108 if(G4StrUtil::contains(name,
"DefaultRegionForTheWorld"))
114 "Invalid definition of geometrical region!");
118 G4Region* aRegion =
new G4Region(name);
119 G4ProductionCuts* pcuts =
new G4ProductionCuts();
121 for(
auto raux = iaux->auxList->cbegin();
122 raux != iaux->auxList->cend(); ++raux)
124 const G4String& tag = raux->type;
127 G4String volname = raux->value;
130 reader->StripName(volname);
133 auto pos = store->
GetMap().find(volname);
134 if(pos != store->
GetMap().cend())
141 if (
pos->second.size()>1)
143 std::ostringstream message;
144 message <<
"There exists more than ONE logical volume "
145 <<
"in store named: " << volname <<
"." <<
G4endl
146 <<
"NOTE: assigning all such volumes as root logical "
147 <<
"volumes for region: " <<
name <<
"!";
151 for (
auto vpos =
pos->second.cbegin();
152 vpos !=
pos->second.cend(); ++vpos)
161 std::ostringstream message;
162 message <<
"Volume NOT found in store !" <<
G4endl
163 <<
" Volume " << volname <<
" NOT found in store !"
165 <<
" No region is being set.";
170 else if(tag ==
"pcut")
172 const G4String& cvalue = raux->value;
173 const G4String& cunit = raux->unit;
176 G4Exception(
"G4GDMLParser::ImportRegions()",
"InvalidRead",
183 else if(tag ==
"ecut")
185 const G4String& cvalue = raux->value;
186 const G4String& cunit = raux->unit;
189 G4Exception(
"G4GDMLParser::ImportRegions()",
"InvalidRead",
196 else if(tag ==
"poscut")
198 const G4String& cvalue = raux->value;
199 const G4String& cunit = raux->unit;
202 G4Exception(
"G4GDMLParser::ImportRegions()",
"InvalidRead",
209 else if(tag ==
"gamcut")
211 const G4String& cvalue = raux->value;
212 const G4String& cunit = raux->unit;
215 G4Exception(
"G4GDMLParser::ImportRegions()",
"InvalidRead",
222 else if(tag ==
"ulimits")
225 G4double uekinMin = 0., urangMin = 0.;
226 const G4String& ulname = raux->value;
227 for(
auto uaux = raux->auxList->cbegin();
228 uaux != raux->auxList->cend(); ++uaux)
230 const G4String& ultag = uaux->type;
231 const G4String& uvalue = uaux->value;
232 const G4String& uunit = uaux->unit;
233 G4double ulvalue = eval.Evaluate(uvalue) * eval.Evaluate(uunit);
234 if(ultag ==
"ustepMax")
238 else if(ultag ==
"utrakMax")
242 else if(ultag ==
"utimeMax")
246 else if(ultag ==
"uekinMin")
250 else if(ultag ==
"urangMin")
256 G4Exception(
"G4GDMLParser::ImportRegions()",
"ReadError",
260 G4UserLimits* ulimits =
new G4UserLimits(
261 ulname, ustepMax, utrakMax, utimeMax, uekinMin, urangMin);
272void G4GDMLParser::ExportRegions(
G4bool storeReferences)
276 for(std::size_t i = 0; i < rstore->size(); ++i)
279 const G4String& tname = (*rstore)[i]->GetName();
280 if(G4StrUtil::contains(tname,
"DefaultRegionForParallelWorld"))
282 const G4String& rname = writer->GenerateName(tname, (*rstore)[i]);
284 G4GDMLAuxStructType raux = {
"Region", rname,
"", rlist };
285 auto rlvol_iter = (*rstore)[i]->GetRootLogicalVolumeIterator();
286 for(std::size_t j = 0; j < (*rstore)[i]->GetNumberOfRootVolumes(); ++j)
288 G4LogicalVolume* rlvol = *rlvol_iter;
291 G4String vname = writer->GenerateName(rlvol->
GetName(), rlvol);
294 reader->StripName(vname);
296 G4GDMLAuxStructType rsubaux = {
"volume", vname,
"", 0 };
297 rlist->push_back(rsubaux);
301 = (*rstore)[i]->GetProductionCuts()->GetProductionCut(
"gamma");
302 G4GDMLAuxStructType caux1
303 = {
"gamcut", eval.ConvertToString(gam_cut),
"mm", 0 };
304 rlist->push_back(caux1);
305 G4double e_cut = (*rstore)[i]->GetProductionCuts()->GetProductionCut(
"e-");
306 G4GDMLAuxStructType caux2
307 = {
"ecut", eval.ConvertToString(e_cut),
"mm", 0 };
308 rlist->push_back(caux2);
310 = (*rstore)[i]->GetProductionCuts()->GetProductionCut(
"e+");
311 G4GDMLAuxStructType caux3
312 = {
"poscut", eval.ConvertToString(pos_cut),
"mm", 0 };
313 rlist->push_back(caux3);
315 = (*rstore)[i]->GetProductionCuts()->GetProductionCut(
"proton");
316 G4GDMLAuxStructType caux4
317 = {
"pcut", eval.ConvertToString(p_cut),
"mm", 0 };
318 rlist->push_back(caux4);
319 if((*rstore)[i]->GetUserLimits())
321 const G4Track fake_trk;
323 const G4String& utype = (*rstore)[i]->GetUserLimits()->GetType();
324 G4GDMLAuxStructType uaux = {
"ulimits", utype,
"mm", ullist };
326 = (*rstore)[i]->GetUserLimits()->GetMaxAllowedStep(fake_trk);
327 G4GDMLAuxStructType ulaux1
328 = {
"ustepMax", eval.ConvertToString(max_step),
"mm", 0 };
329 ullist->push_back(ulaux1);
331 = (*rstore)[i]->GetUserLimits()->GetUserMaxTrackLength(fake_trk);
332 G4GDMLAuxStructType ulaux2
333 = {
"utrakMax", eval.ConvertToString(max_trk),
"mm", 0 };
334 ullist->push_back(ulaux2);
336 = (*rstore)[i]->GetUserLimits()->GetUserMaxTime(fake_trk);
337 G4GDMLAuxStructType ulaux3
338 = {
"utimeMax", eval.ConvertToString(max_time),
"mm", 0 };
339 ullist->push_back(ulaux3);
341 = (*rstore)[i]->GetUserLimits()->GetUserMinEkine(fake_trk);
342 G4GDMLAuxStructType ulaux4
343 = {
"uekinMin", eval.ConvertToString(min_ekin),
"mm", 0 };
344 ullist->push_back(ulaux4);
346 = (*rstore)[i]->GetUserLimits()->GetUserMinRange(fake_trk);
347 G4GDMLAuxStructType ulaux5
348 = {
"urangMin", eval.ConvertToString(min_rng),
"mm", 0 };
349 ullist->push_back(ulaux5);
350 rlist->push_back(uaux);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
const G4GDMLAuxListType * GetAuxList() const
void AddAuxiliary(G4GDMLAuxStructType myaux)
void StripName(G4String &) const
const std::map< G4String, std::vector< G4LogicalVolume * > > & GetMap() const
static G4LogicalVolumeStore * GetInstance()
const G4String & GetName() const
void SetProductionCut(G4double cut, G4int index)
G4bool IsReflected(G4LogicalVolume *lv) const
G4LogicalVolume * GetReflectedLV(G4LogicalVolume *lv) const
static G4ReflectionFactory * Instance()
G4bool IsConstituent(G4LogicalVolume *lv) const
static G4RegionStore * GetInstance()
void SetProductionCuts(G4ProductionCuts *cut)
void SetUserLimits(G4UserLimits *ul)
void AddRootLogicalVolume(G4LogicalVolume *lv, G4bool search=true)
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)
const char * name(G4int ptype)