4 modified files
lcdd/include
diff -u -r1.9 -r1.10
--- GeometryManager.hh 17 Nov 2006 04:42:59 -0000 1.9
+++ GeometryManager.hh 22 Nov 2006 02:24:48 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/GeometryManager.hh,v 1.9 2006/11/17 04:42:59 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/GeometryManager.hh,v 1.10 2006/11/22 02:24:48 jeremy Exp $
#ifndef GEOMETRYMANAGER_HH
#define GEOMETRYMANAGER_HH 1
@@ -23,27 +23,44 @@
public:
+ /**
+ * Retrieve the world's logical volume from Geant4.
+ */
G4LogicalVolume* getWorldLogicalVolume() const;
+
+ /**
+ * Retrieve the world's physical volume from Geant4.
+ */
G4VPhysicalVolume* getWorldPhysicalVolume() const;
- void beginRun(const G4Run*);
+
+ /**
+ * Hook for beginning the run.
+ */
+ void beginRun(const G4Run*);
+
+ /**
+ * Attach the RegionInformation to the world's region.
+ */
void setupWorldRegionInformation();
/**
- * Check overlaps on all logical volumes registered with Geant4.
+ * Check overlaps starting with the world volume
+ * and recursing to daughters.
*/
void checkOverlaps() const;
/**
* Check for overlaps by calling CheckOverlaps on all daughters
- * of a given logical volume.
+ * of a given logical volume, with possible recursion to
+ * daughters.
*/
- void checkOverlaps(G4LogicalVolume*) const;
+ void checkOverlaps(G4LogicalVolume*, bool recurse=true) const;
/**
* Check for overlaps of a named logical volume by looking it
- * up in the volume store.
+ * up in the volume store, with possible recursion to daughters.
*/
- void checkOverlaps(const G4String&) const;
+ void checkOverlaps(const G4String&, bool recurse=true) const;
private:
lcdd/include
diff -u -r1.3 -r1.4
--- LCDDMessenger.hh 17 Nov 2006 02:16:36 -0000 1.3
+++ LCDDMessenger.hh 22 Nov 2006 02:24:49 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/LCDDMessenger.hh,v 1.3 2006/11/17 02:16:36 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/LCDDMessenger.hh,v 1.4 2006/11/22 02:24:49 jeremy Exp $
#ifndef LCDDMessenger_h
#define LCDDMessenger_h 1
@@ -38,5 +38,6 @@
G4UIcommand* m_setSetupNameCmd;
G4UIcommand* m_setVersionCmd;
G4UIcommand* m_checkOverlapsCmd;
+ G4UIcommand* m_checkOverlapsRecurseCmd;
}; // class
#endif
lcdd/src
diff -u -r1.10 -r1.11
--- GeometryManager.cc 17 Nov 2006 04:43:00 -0000 1.10
+++ GeometryManager.cc 22 Nov 2006 02:24:53 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/GeometryManager.cc,v 1.10 2006/11/17 04:43:00 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/GeometryManager.cc,v 1.11 2006/11/22 02:24:53 jeremy Exp $
#include "GeometryManager.hh"
// LCDD
@@ -72,37 +72,45 @@
void GeometryManager::checkOverlaps() const
{
- G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
- for (std::vector<G4LogicalVolume*>::iterator it = store->begin();
- it != store->end();
- it++) {
- G4LogicalVolume* vol = (*it);
- checkOverlaps(vol);
- }
+ checkOverlaps(getWorldLogicalVolume(), true);
}
-void GeometryManager::checkOverlaps(G4LogicalVolume* lvolume) const
+void GeometryManager::checkOverlaps(G4LogicalVolume* lvolume, bool recurse) const
{
if (lvolume==0) return;
+
for (G4int i=0; i<lvolume->GetNoDaughters(); i++) {
+
G4PVPlacement* dau = static_cast<G4PVPlacement*>(lvolume->GetDaughter(i));
+
if (dau) {
+ // Check overlaps of daughters in mother.
dau->CheckOverlaps();
+
+ // Recursively check overlaps of daughters.
+ if (recurse) {
+ checkOverlaps(dau->GetLogicalVolume(), true);
+ }
}
}
}
-void GeometryManager::checkOverlaps(const G4String& name) const
+void GeometryManager::checkOverlaps(const G4String& name, bool recurse) const
{
G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
+ bool found=false;
for (std::vector<G4LogicalVolume*>::iterator it = store->begin();
it != store->end();
it++) {
G4LogicalVolume* vol = (*it);
if (vol->GetName() == name) {
- checkOverlaps(vol);
+ checkOverlaps(vol, recurse);
+ found=true;
+ break;
}
}
- G4cerr << "The volume <" << name << "> was not found!" << G4endl;
+ if (!found) {
+ G4cerr << "WARNING: The logical volume named <" << name << "> was not found in the G4LogicalVolumeStore!" << std::endl;
+ }
}
lcdd/src
diff -u -r1.6 -r1.7
--- LCDDMessenger.cc 17 Nov 2006 04:43:00 -0000 1.6
+++ LCDDMessenger.cc 22 Nov 2006 02:24:53 -0000 1.7
@@ -1,9 +1,10 @@
-// $Header: /cvs/lcd/lcdd/src/LCDDMessenger.cc,v 1.6 2006/11/17 04:43:00 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/LCDDMessenger.cc,v 1.7 2006/11/22 02:24:53 jeremy Exp $
// LCDD
#include "LCDDMessenger.hh"
#include "LCDDParser.hh"
#include "GeometryManager.hh"
+#include "StringUtil.hh"
// Geant4
#include "G4UImessenger.hh"
@@ -33,6 +34,8 @@
G4String singleArg = newVals;
+ std::istringstream is ( ( const char* ) newVals );
+
if (cmd == m_setURICmd ) {
parser->setURI(singleArg);
}
@@ -45,9 +48,6 @@
else if (cmd == m_setupCmd) {
G4String uri, setup, version;
- std::istringstream is ( ( const char* ) newVals );
-
- // means URI cannot have unescaped spaces
is >> uri
>> setup
>> version;
@@ -56,11 +56,26 @@
parser->setSetupName(setup);
parser->setVersion(version);
}
- else if ( cmd == m_checkOverlapsCmd ) {
+ else if ( cmd == m_checkOverlapsCmd || cmd == m_checkOverlapsRecurseCmd ) {
+
+ bool recurse=false;
+
+ if (cmd == m_checkOverlapsRecurseCmd) {
+ recurse=true;
+ }
+
+ G4String vol("");
+ is >> vol;
+
+ G4cout << "vol=" << vol << G4endl;
+ G4cout << "recurse=" << recurse << G4endl;
+
if (newVals != "") {
- GeometryManager::instance()->checkOverlaps(newVals);
+ // Check the named volume with optional recursion.
+ GeometryManager::instance()->checkOverlaps(vol, recurse);
}
else {
+ // No volume. Check the world, which is always done recursively!
GeometryManager::instance()->checkOverlaps();
}
}
@@ -112,9 +127,10 @@
m_setupCmd->AvailableForStates(G4State_PreInit);
p = new G4UIparameter("URI",'s',false);
+ p->SetGuidance("URI is a URL to the input file. It MUST NOT contain unescaped spaces.");
m_setupCmd->SetParameter(p);
- p = new G4UIparameter("SetupName",'s',true);
+ p = new G4UIparameter("SetupName",'s',true);
m_setupCmd->SetParameter(p);
p = new G4UIparameter("Version",'s',true);
@@ -122,8 +138,17 @@
// Check overlaps.
m_checkOverlapsCmd = new G4UIcommand("/lcdd/checkOverlaps",this);
- m_checkOverlapsCmd->SetGuidance("Call CheckOverlaps on a given volume or all volumes (no argument).");
+ m_checkOverlapsCmd->SetGuidance("Call CheckOverlaps on a given volume or the world volume (no arguments).");
- p = new G4UIparameter("Volume",'s',true);
- m_checkOverlapsCmd->SetParameter(p);
+ p = new G4UIparameter("Volume",'s',true);
+ p->SetDefaultValue("");
+ m_checkOverlapsCmd->SetParameter(p);
+
+ // Check overlaps with recursion to daughters.
+ m_checkOverlapsRecurseCmd = new G4UIcommand("/lcdd/checkOverlapsRecurse",this);
+ m_checkOverlapsRecurseCmd->SetGuidance("Call CheckOverlaps on a given volume and recursively check daughters.");
+
+ p = new G4UIparameter("Volume",'s',true);
+ p->SetDefaultValue("");
+ m_checkOverlapsRecurseCmd->SetParameter(p);
}
CVSspam 0.2.8