Commit 7cc1f8fd authored by Javier Galan's avatar Javier Galan
Browse files

GdmlPreprocesser renamed to TRestGDMLParser

parent 1a5a9d60
......@@ -11,7 +11,6 @@
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UImanager.hh"
#include "GdmlPreprocessor.h"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "Randomize.hh"
......@@ -20,6 +19,7 @@
#include "TRestG4Event.h"
#include "TRestG4Metadata.h"
#include "TRestG4Track.h"
#include "TRestGDMLParser.h"
#include "TRestGeometry.h"
#include "TRestPhysicsLists.h"
#include "TRestRun.h"
......@@ -103,7 +103,8 @@ int main(int argc, char** argv) {
// 2. We allow file entities to be http remote files
// 3. We retrieve the GDML and materials versions and associate to the
// corresponding TRestG4Metadata members
GdmlPreprocessor* gdml = new GdmlPreprocessor();
// 4. We support the use of system variables ${}
TRestGDMLParser* gdml = new TRestGDMLParser();
// This call will generate a new single file GDML output
gdml->Load((string)restG4Metadata->Get_GDML_Filename());
......
......@@ -646,7 +646,7 @@ using namespace std;
#include <TGeoManager.h>
#include "GdmlPreprocessor.h"
#include "TRestGDMLParser.h"
namespace g4_metadata_parameters {
string CleanString(string s) {
......@@ -756,7 +756,7 @@ void TRestG4Metadata::InitFromConfigFile() {
if (ToUpper(seedstr) == "RANDOM" || ToUpper(seedstr) == "RAND" || ToUpper(seedstr) == "AUTO" ||
seedstr == "0") {
double* dd = new double();
fSeed = (uintptr_t)dd + (uintptr_t) this;
fSeed = (uintptr_t)dd + (uintptr_t)this;
delete dd;
} else {
fSeed = (Long_t)StringToInteger(seedstr);
......@@ -985,10 +985,10 @@ void TRestG4Metadata::ReadStorage() {
fEnergyRangeStored = Get2DVectorParameterWithUnits("energyRange", storageDefinition);
GdmlPreprocessor* preprocesor = new GdmlPreprocessor();
preprocesor->Load((string)Get_GDML_Filename());
TRestGDMLParser* gdml = new TRestGDMLParser();
gdml->Load((string)Get_GDML_Filename());
TGeoManager::Import((TString)preprocesor->GetOutputGDMLFile());
TGeoManager::Import((TString)gdml->GetOutputGDMLFile());
std::set<std::string> geometryVolumes = {"World_PV"}; // we include the world volume
for (auto node : gGeoManager->GetTopVolume()->GetNodes()[0]) {
string name = node->GetName();
......
#ifndef restG4_GdmlPreprocessor
#define restG4_GdmlPreprocessor
#ifndef restG4_TRestGDMLParser
#define restG4_TRestGDMLParser
#include "TGeoManager.h"
#include "TRestMetadata.h"
......@@ -10,13 +10,13 @@
// we must preprocess gdml file because of a bug in TGDMLParse::Value() in ROOT6
//
class GdmlPreprocessor : public TRestMetadata {
class TRestGDMLParser : public TRestMetadata {
private:
TGeoManager* fGeo;
public:
GdmlPreprocessor() {}
~GdmlPreprocessor() {}
TRestGDMLParser() {}
~TRestGDMLParser() {}
string filestr = "";
string path = "";
string outPath = REST_USER_PATH + "/gdml/";
......@@ -48,7 +48,7 @@ class GdmlPreprocessor : public TRestMetadata {
void ReplaceAttributeWithKeyWord(string keyword);
ClassDef(GdmlPreprocessor, 1);
ClassDef(TRestGDMLParser, 1);
};
#endif
#include "GdmlPreprocessor.h"
#include "TRestGDMLParser.h"
string GdmlPreprocessor::GetEntityVersion(string name) {
string TRestGDMLParser::GetEntityVersion(string name) {
for (auto& i : entityVersion) {
if (i.first == name) {
return i.second;
......@@ -10,11 +10,11 @@ string GdmlPreprocessor::GetEntityVersion(string name) {
return "0.0";
}
string GdmlPreprocessor::GetGDMLVersion() { return gdmlVersion; }
string TRestGDMLParser::GetGDMLVersion() { return gdmlVersion; }
string GdmlPreprocessor::GetOutputGDMLFile() { return outfilename; }
string TRestGDMLParser::GetOutputGDMLFile() { return outfilename; }
void GdmlPreprocessor::Load(string file) {
void TRestGDMLParser::Load(string file) {
file = TRestTools::ToAbsoluteName(file);
if (TRestTools::fileExists(file)) {
fConfigFileName = file;
......@@ -75,7 +75,7 @@ void GdmlPreprocessor::Load(string file) {
}
}
TGeoManager* GdmlPreprocessor::CreateGeoM() {
TGeoManager* TRestGDMLParser::CreateGeoM() {
// We must change to the gdml file directory, otherwise ROOT cannot load.
if (outfilename != "") {
char originDirectory[256];
......@@ -89,9 +89,9 @@ TGeoManager* GdmlPreprocessor::CreateGeoM() {
return NULL;
}
void GdmlPreprocessor::PrintContent() { cout << filestr << endl; }
void TRestGDMLParser::PrintContent() { cout << filestr << endl; }
void GdmlPreprocessor::ReplaceEntity() {
void TRestGDMLParser::ReplaceEntity() {
int pos = 0;
while ((pos = filestr.find("<!ENTITY", pos)) != -1) {
int pos1 = filestr.find_first_not_of(" ", pos + 8);
......@@ -149,7 +149,7 @@ void GdmlPreprocessor::ReplaceEntity() {
}
}
void GdmlPreprocessor::ReplaceAttributeWithKeyWord(string keyword) {
void TRestGDMLParser::ReplaceAttributeWithKeyWord(string keyword) {
int n;
while ((n = filestr.find(keyword, 0)) != -1) {
int pos1 = 0, pos2 = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment