Skip to content
Snippets Groups Projects
Commit c9bcc6d1 authored by Marilena Bandieramonte's avatar Marilena Bandieramonte
Browse files

Merge branch 'gmclash-threshold' into 'master'

Add a tolerance threshold optional flag to gmclash - ignore clashes below the threshold

See merge request !123
parents 737b9324 fbb1d1c9
No related branches found
No related tags found
1 merge request!123Add a tolerance threshold optional flag to gmclash - ignore clashes below the threshold
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment