#include #include #include #include #include using namespace RAT; #include #include using namespace std; void Geometry::ConstructGeometries( const std::string& table, const bool checkOverlaps ) { // ConstructGeometries logic: // Loop over the geometries in the DBLinkGropu for the table, then remove (from local) copy those built or not enabled. // Every time a geometry is built, break and start the loop again. // If the loop reaches the end without being empty then a geometry cannot be built, probably a circular dependence. DBLinkGroup geometries = DB::Get()->GetLinkGroup( table ); while( !geometries.empty() ) // Loop until ALL geometric volumes are constructed { DBLinkGroup::iterator iGeometry; for( iGeometry = geometries.begin(); iGeometry != geometries.end(); ++iGeometry ) { DBLinkPtr dbTable = iGeometry->second; // First must check this geometry is enabled try { const bool enabled = dbTable->GetI( "enable" ); if( !enabled ) { geometries.erase( iGeometry ); // Not enabled, skip this geometry break; } } catch( DBNotFoundError& e ) { geometries.erase( iGeometry ); // Not enabled, skip this geometry break; } // Now check if this geometries' mother has been built string mother = dbTable->GetS( "mother" ); string relative; try { relative = dbTable->GetS( "relative" ); } catch( DBNotFoundError& e ) { /* Optional, not a problem */ } if( mother.empty() && Detector::GetWorld() == NULL ) // This is the mother volume, go ahead and build { Log::Assert( dbTable->GetIndex() == string( "world" ), "Geometry::ConstructGeometries: World geometry is miss named." ); GeoFactory::ConstructVolume( dbTable->GetS( "factory" ), dbTable, checkOverlaps ); // Geometry built geometries.erase( iGeometry ); break; } // Now build if this volumes' mother and relative exist if( Detector::FindPhysicalVolume( mother, false ) != NULL ) { if( relative.empty() || ( !relative.empty() && Detector::FindPhysicalVolume( relative, false ) != NULL ) ) // This volume has a relative AND it exists { GeoFactory::ConstructVolume( dbTable->GetS( "factory" ), dbTable, checkOverlaps ); // Geometry built geometries.erase( iGeometry ); break; } else // Can't build, relative hasn't been built continue; } else // Can't build, mother hasn't been built continue; } // Check for circular dependencies if( iGeometry == geometries.end() ) Log::Die( "Geometry::ConstructGeometries: Circular dependency detected." ); } } // Solids #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Factories #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include Geometry::Geometry() { // Solids new geo::Box(); new geo::Cone(); new geo::Polycone(); new geo::SnoVessel(); new geo::Sphere(); new geo::Torus(); new geo::Tube(); new geo::HoldUpRope(); new geo::HoldDownRope(); new geo::InternalRope(); new geo::AVPipe(); new geo::NCDRing(); new geo::BellyPlate(); new geo::SNOMANBellyPlate(); new geo::BellyGroove(); new geo::NeckBoss(); new geo::SNOAVGeoSolid(); new geo::SNOSVGeoSolid(); new geo::SNORopeGeoSolid(); // Factories new GeoSolidFactory(); new GeoSolidArrayFactory(); new GeoSolidCollectionFactory(); new GeoSolidUnionFactory(); new GeoBucketSourceFactory(); new GeoCanSourceFactory(); new GeoCerenkovSourceFactory(); new GeoCerenkovSourceNewFactory(); new GeoN16SourceFactory(); new GeoN16SNOMANSourceFactory(); new GeoAmBeSourceFactory(); new GeoSc48SourceFactory(); new GeoCo57SourceFactory(); new GeoTaggedSourceFactory(); new AcrylicVesselFactory(); new AcrylicTileFactory(); new GeoPMTFactory(); new GeoPanelFactory(); } #include #include Geometry::~Geometry() { GeoFactory::Destruct(); GeoSolid::Destruct(); }