Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions geom/gdml/inc/TGDMLWrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class TGDMLWrite : public TObject {
XMLDocPointer_t fGdmlFile; //pointer storing xml file
TString fDefault_lunit; //Default unit of length (depends on ROOT unit system)
TString fTopVolumeName; //name of top volume
TGeoVolume *fTopVolume = nullptr; //top volume of the tree being written
TXMLEngine *fGdmlE; //xml engine pointer

XMLNodePointer_t fDefineNode; //main <define> node...
Expand Down
10 changes: 10 additions & 0 deletions geom/gdml/src/TGDMLParse.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,8 @@ TGeoTranslation *TGDMLParse::GetPosition(const char *name)
if (!pos && fposmap.find(name) != fposmap.end())
pos = fposmap[name];

if (!pos)
Error("GetPosition", "Position %s not defined", name);
return pos;
}

Expand All @@ -1698,6 +1700,8 @@ TGeoRotation *TGDMLParse::GetRotation(const char *name)
if (!rot && frotmap.find(name) != frotmap.end())
rot = frotmap[name];

if (!rot)
Error("GetRotation", "Rotation %s not defined", name);
return rot;
}

Expand All @@ -1715,6 +1719,8 @@ TGeoScale *TGDMLParse::GetScaleObj(const char *name)
if (!scl && fsclmap.find(name) != fsclmap.end())
scl = fsclmap[name];

if (!scl)
Error("GetScale", "Scale %s not defined", name);
return scl;
}

Expand All @@ -1732,6 +1738,8 @@ TGeoShape *TGDMLParse::GetSolid(const char *name)
if (!sol && fsolmap.find(name) != fsolmap.end())
sol = fsolmap[name];

if (!sol)
Error("GetSolid", "Solid %s not defined", name);
return sol;
}

Expand All @@ -1749,6 +1757,8 @@ TGeoVolume *TGDMLParse::GetVolume(const char *name)
if (!vol && fvolmap.find(name) != fvolmap.end())
vol = fvolmap[name];

if (!vol)
Error("GetVolume", "Volume %s not defined", name);
return vol;
}

Expand Down
9 changes: 6 additions & 3 deletions geom/gdml/src/TGDMLWrite.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ void TGDMLWrite::WriteGDMLfile(TGeoManager * geomanager, const char* filename, T
Info("WriteGDMLfile", "Top volume does not exist!");
return;
}
fTopVolumeName = "";
fTopVolume = node->GetVolume();
fTopVolumeName = fTopVolume->GetName();
WriteGDMLfile(geomanager, node, materials, filename, option);
}

Expand All @@ -259,6 +260,7 @@ void TGDMLWrite::WriteGDMLfile(TGeoManager * geomanager, TGeoNode* node, const c
for(TGeoMaterial* m : extract.materials)
materials.Add(m);
fTopVolumeName = volume->GetName();
fTopVolume = volume;
fSurfaceList.clear();
fVolumeList.clear();
fNodeList.clear();
Expand Down Expand Up @@ -569,7 +571,7 @@ void TGDMLWrite::ExtractVolumes(TGeoNode* node)
fNodeList.insert(node);
fVolumeList.insert(volume);
//create the name for volume/assembly
if (volume->IsTopVolume()) {
if (volume == fTopVolume) {
//not needed a special function for generating name
volname = volume->GetName();
fTopVolumeName = volname;
Expand Down Expand Up @@ -2432,6 +2434,7 @@ void TGDMLWrite::WriteGDMLfile(TGeoManager * geomanager, TGeoVolume* volume, con
for(TGeoMaterial* m : extract.materials)
materials.Add(m);
fTopVolumeName = volume->GetName();
fTopVolume = volume;
fSurfaceList.clear();
fVolumeList.clear();
fNodeList.clear();
Expand Down Expand Up @@ -2583,7 +2586,7 @@ void TGDMLWrite::ExtractVolumes(TGeoVolume* volume)
const TString fltPrecision = TString::Format("%%.%dg", fFltPrecision);

//create the name for volume/assembly
if (volume->IsTopVolume()) {
if (volume == fTopVolume) {
//not needed a special function for generating name
volname = volume->GetName();
fTopVolumeName = volname;
Expand Down
14 changes: 8 additions & 6 deletions geom/geom/src/TGeoManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3820,22 +3820,24 @@ TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_
{
if (fgLock) {
::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
return NULL;
return nullptr;
}
if (!filename) return 0;
if (fgVerboseLevel>0) ::Info("TGeoManager::Import","Reading geometry from file: %s",filename);

if (gGeoManager) delete gGeoManager;
gGeoManager = 0;
gGeoManager = nullptr;

if (strstr(filename,".gdml")) {
// import from a gdml file
new TGeoManager("GDMLImport", "Geometry imported from GDML");
TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
TGeoVolume* world = (TGeoVolume*)gROOT->ProcessLineFast(cmd);

if(world == 0) {
::Error("TGeoManager::Import", "Cannot open file");
if(world == nullptr) {
delete gGeoManager;
gGeoManager = nullptr;
::Error("TGeoManager::Import", "Cannot read file %s", filename);
}
else {
gGeoManager->SetTopVolume(world);
Expand All @@ -3847,12 +3849,12 @@ TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_
TDirectory::TContext ctxt;
// in case a web file is specified, use the cacheread option to cache
// this file in the cache directory
TFile *f = 0;
TFile *f = nullptr;
if (strstr(filename,"http")) f = TFile::Open(filename,"CACHEREAD");
else f = TFile::Open(filename);
if (!f || f->IsZombie()) {
::Error("TGeoManager::Import", "Cannot open file");
return 0;
return nullptr;
}
if (name && strlen(name) > 0) {
gGeoManager = (TGeoManager*)f->Get(name);
Expand Down
6 changes: 6 additions & 0 deletions geom/geom/src/TGeoMatrix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ TGeoHMatrix TGeoTranslation::Inverse() const
{
TGeoHMatrix h;
h = *this;
h.ResetBit(kGeoRegistered);
Double_t tr[3];
tr[0] = -fTranslation[0];
tr[1] = -fTranslation[1];
Expand Down Expand Up @@ -977,6 +978,7 @@ TGeoHMatrix TGeoRotation::Inverse() const
{
TGeoHMatrix h;
h = *this;
h.ResetBit(kGeoRegistered);
Double_t newrot[9];
newrot[0] = fRotationMatrix[0];
newrot[1] = fRotationMatrix[3];
Expand Down Expand Up @@ -1527,6 +1529,7 @@ TGeoHMatrix TGeoScale::Inverse() const
{
TGeoHMatrix h;
h = *this;
h.ResetBit(kGeoRegistered);
Double_t scale[3];
scale[0] = 1./fScale[0];
scale[1] = 1./fScale[1];
Expand Down Expand Up @@ -1826,6 +1829,7 @@ TGeoHMatrix TGeoCombiTrans::Inverse() const
{
TGeoHMatrix h;
h = *this;
h.ResetBit(kGeoRegistered);
Bool_t is_tr = IsTranslation();
Bool_t is_rot = IsRotation();
Double_t tr[3];
Expand Down Expand Up @@ -2232,6 +2236,7 @@ void TGeoGenTrans::SetScale(Double_t sx, Double_t sy, Double_t sz)
TGeoHMatrix TGeoGenTrans::Inverse() const
{
TGeoHMatrix h = *this;
h.ResetBit(kGeoRegistered);
return h;
}

Expand Down Expand Up @@ -2458,6 +2463,7 @@ TGeoHMatrix TGeoHMatrix::Inverse() const
{
TGeoHMatrix h;
h = *this;
h.ResetBit(kGeoRegistered);
if (IsTranslation()) {
Double_t tr[3];
tr[0] = -fTranslation[0]*fRotationMatrix[0] - fTranslation[1]*fRotationMatrix[3] - fTranslation[2]*fRotationMatrix[6];
Expand Down