diff --git a/FullSimLight/geoModelClash.cc b/FullSimLight/geoModelClash.cc index b27996691115b0d124d985c74052c629598dd9ef..c2d6072e18801a3080b1061026bf81f764e45be3 100644 --- a/FullSimLight/geoModelClash.cc +++ b/FullSimLight/geoModelClash.cc @@ -4,6 +4,8 @@ //-------------------------------------------------------- #include "G4Version.hh" +#include "G4SystemOfUnits.hh" +#include "G4UnitsTable.hh" #include "Randomize.hh" #include "MyDetectorConstruction.hh" @@ -15,6 +17,7 @@ G4bool gmclash_verbose =false; static G4String geometryFileName ; static G4String reportFileName = "gmclash_report.json"; +G4double tolerance=0.0; void GetInputArguments(int argc, char** argv); void Help(); @@ -28,6 +31,7 @@ int main(int argc, char** argv) { << " =================== Running GeoModelClash =================== " << G4endl << " Geometry file name = " << geometryFileName << G4endl << " Output clashes report file name = " << reportFileName << G4endl + << " Tolerance threshold value = " << G4BestUnit(tolerance, "Length")<< G4endl << " Verbose output = " << gmclash_verbose << G4endl << " ============================================================== " << G4endl; @@ -67,6 +71,7 @@ int main(int argc, char** argv) { detector->SetGeometryFileName (geometryFileName); detector->SetReportFileName (reportFileName); detector->SetGMClashVerbosity(gmclash_verbose); + detector->SetTolerance(tolerance); detector->Construct(); delete detector; @@ -77,6 +82,7 @@ static struct option options[] = { {"geometry file name " , required_argument, 0, 'g'}, {"output clashes report file name " , required_argument, 0, 'o'}, {"verbose output " , no_argument , 0, 'v'}, + {"tolerance threshold value " , required_argument, 0, 't'}, {"help" , no_argument , 0, 'h'}, {0, 0, 0, 0} }; @@ -89,6 +95,7 @@ void Help() { <<" **** Parameters: \n\n" <<" -g : [MANDATORY] the Geometry file name [.db/.gdml/.dylib/.so] \n" <<" -o : [OPTIONAL] clashes report file name (default: gmclash_report)\n" + <<" -t : [OPTIONAL] tolerance threshold value in mm (default: 0)\n" <<" -v : [OPTIONAL] verbose output (default: off)\n" << std::endl; std::cout <<"\nUsage: ./gmclash [OPTIONS]\n" <<std::endl; @@ -109,7 +116,7 @@ void GetInputArguments(int argc, char** argv) { } while (true) { int c, optidx = 0; - c = getopt_long(argc, argv, "g:o:vh", options, &optidx); + c = getopt_long(argc, argv, "g:o:t:vh", options, &optidx); if (c == -1) break; // @@ -126,6 +133,9 @@ void GetInputArguments(int argc, char** argv) { case 'v': gmclash_verbose = true; break; + case 't': + tolerance = atof(optarg)*mm; + break; case 'h': Help(); exit(0); diff --git a/FullSimLight/include/MyDetectorConstruction.hh b/FullSimLight/include/MyDetectorConstruction.hh index 6e6db704e57968dce9538bece9b8fa1594019122..53b2931186eca522b92a05168962e6f62a0ee7d2 100644 --- a/FullSimLight/include/MyDetectorConstruction.hh +++ b/FullSimLight/include/MyDetectorConstruction.hh @@ -51,6 +51,7 @@ public: void SetMaterial(const G4String &material) { fMaterial = material; } void SetReportFileName(const G4String &reportFileName) { fReportFileName = reportFileName; } void SetGMClashVerbosity(const G4bool flag) { fGmclashVerbosity = flag; } + void SetTolerance (const G4double tolerance){fTolerance=tolerance;} void SetOutputGDMLFileName(const G4String &outputGDMLFileName) { fOutputGDMLFileName = outputGDMLFileName; } void SetDumpGDML(const bool dumpGDML) {fDumpGDML=dumpGDML;} /// Common method to construct a driver with a stepper of requested type. @@ -66,6 +67,7 @@ public: } static G4double GetFieldValue() { return gFieldValue; } + G4double GetTolerance (){return fTolerance;} void RecursiveMassCalculation (G4VPhysicalVolume* worldg4,GeoPhysVol* worldgeoModel, std::vector<json>& jlist); @@ -123,6 +125,7 @@ private: G4double fFieldValue; G4bool fFieldConstant; G4bool fGmclashVerbosity; + G4double fTolerance; //tolerance value for gmclash G4GDMLParser fParser; G4VPhysicalVolume *fWorld; MyDetectorMessenger *fDetectorMessenger; diff --git a/FullSimLight/src/MyDetectorConstruction.cc b/FullSimLight/src/MyDetectorConstruction.cc index 9e3a402aa374751741d1dd27b2a19d93531f1edb..0e4a4826b5fdd2ac7bf1f7b5d79c1d2083b85f90 100644 --- a/FullSimLight/src/MyDetectorConstruction.cc +++ b/FullSimLight/src/MyDetectorConstruction.cc @@ -239,6 +239,7 @@ MyDetectorConstruction::MyDetectorConstruction() : fWorld(nullptr), fDetectorMes fFieldValue = 0.0; fVerbosityFlag = -1; fGmclashVerbosity = false; + fTolerance = 0.0; fFieldConstant = false; fDetectorMessenger = new MyDetectorMessenger(this); fRunOverlapCheck = false; @@ -683,7 +684,7 @@ void MyDetectorConstruction::RecursivelyCheckOverlap(G4LogicalVolume* envelope,s RecursivelyCheckOverlap(daughter->GetLogicalVolume(), jlist); //std::cout<<"Starting Overlaps check on daughter: "<<daughter->GetName()<<std::endl; //std::cout<<"... "<<sampleNo<<std::endl; - myCheckOverlaps(daughter, jlist); + myCheckOverlaps(daughter, jlist, 1000, fTolerance, 1); } }