From 7c6f17a95b401350fec7b38accf42626efc1a38f Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 11:15:32 +0100 Subject: [PATCH 1/8] Geant4PrimaryHandling: fix issue with multiple vertices in Geant4 GeneralParticleSource --- DDG4/src/Geant4GeneratorWrapper.cpp | 6 ++++-- DDG4/src/Geant4InputHandling.cpp | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DDG4/src/Geant4GeneratorWrapper.cpp b/DDG4/src/Geant4GeneratorWrapper.cpp index 7eb09b3f5..b79bed2f6 100644 --- a/DDG4/src/Geant4GeneratorWrapper.cpp +++ b/DDG4/src/Geant4GeneratorWrapper.cpp @@ -78,10 +78,12 @@ void Geant4GeneratorWrapper::operator()(G4Event* event) { generator()->GeneratePrimaryVertex(event); /// Add all the missing interactions (primary vertices) to the primary event record. + int maskCounter = 100000 + m_mask; for(G4PrimaryVertex* gv=event->GetPrimaryVertex(); gv; gv=gv->GetNext()) { if ( primaries.find(gv) == primaries.end() ) { - Geant4PrimaryInteraction* inter = createPrimary(m_mask, primaryMap, gv); - prim->add(m_mask, inter); + Geant4PrimaryInteraction* inter = createPrimary(maskCounter, primaryMap, gv); + prim->add(maskCounter, inter); + maskCounter += 1; } } } diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index fdc1468f5..e75a4f26f 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -180,13 +180,14 @@ static void appendInteraction(const Geant4Action* caller, } Geant4PrimaryInteraction::VertexMap::iterator ivfnd, iv, ivend; for( iv=input->vertices.begin(), ivend=input->vertices.end(); iv != ivend; ++iv ) { - ivfnd = output->vertices.find((*iv).first) ; //(*iv).second->mask); + int theMask = input->mask; + ivfnd = output->vertices.find(theMask); if ( ivfnd != output->vertices.end() ) { caller->abortRun("Duplicate primary interaction identifier!", "Cannot handle 2 interactions with identical identifiers!"); } for(Geant4Vertex* vtx : (*iv).second ) - output->vertices[(*iv).first].emplace_back( vtx->addRef() ); + output->vertices[theMask].emplace_back( vtx->addRef() ); } } From cc32a6cc0199f78d5b6ff5640361309c2d81a330 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 13:13:22 +0100 Subject: [PATCH 2/8] Geant4InputHandling: refactor one of the createPrimary to deal with multiple sources from GPS --- DDG4/include/DDG4/Geant4InputHandling.h | 2 +- DDG4/src/Geant4GeneratorWrapper.cpp | 12 +++--------- DDG4/src/Geant4InputHandling.cpp | 17 +++++++++-------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/DDG4/include/DDG4/Geant4InputHandling.h b/DDG4/include/DDG4/Geant4InputHandling.h index 3a889b6a5..2498b541e 100644 --- a/DDG4/include/DDG4/Geant4InputHandling.h +++ b/DDG4/include/DDG4/Geant4InputHandling.h @@ -42,7 +42,7 @@ namespace dd4hep { Geant4Particle* createPrimary(int particle_id, const Geant4Vertex* v, const G4PrimaryParticle* g4p); /// Create a DDG4 interaction record from a Geant4 interaction defined by a primary vertex - Geant4PrimaryInteraction* createPrimary(int mask, Geant4PrimaryMap* pm, const G4PrimaryVertex* gv); + Geant4PrimaryInteraction* createPrimary(int mask, Geant4PrimaryMap* pm, std::setconst& primaries); /// Initialize the generation of one event int generationInitialization(const Geant4Action* caller,const Geant4Context* context); diff --git a/DDG4/src/Geant4GeneratorWrapper.cpp b/DDG4/src/Geant4GeneratorWrapper.cpp index b79bed2f6..b40bec032 100644 --- a/DDG4/src/Geant4GeneratorWrapper.cpp +++ b/DDG4/src/Geant4GeneratorWrapper.cpp @@ -77,13 +77,7 @@ void Geant4GeneratorWrapper::operator()(G4Event* event) { // Now generate the new interaction generator()->GeneratePrimaryVertex(event); - /// Add all the missing interactions (primary vertices) to the primary event record. - int maskCounter = 100000 + m_mask; - for(G4PrimaryVertex* gv=event->GetPrimaryVertex(); gv; gv=gv->GetNext()) { - if ( primaries.find(gv) == primaries.end() ) { - Geant4PrimaryInteraction* inter = createPrimary(maskCounter, primaryMap, gv); - prim->add(maskCounter, inter); - maskCounter += 1; - } - } + // Add all the missing interactions (primary vertices) to the primary event record. + Geant4PrimaryInteraction* inter = createPrimary(m_mask, primaryMap, primaries); + prim->add(m_mask, inter); } diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index e75a4f26f..a741179a9 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -121,18 +121,19 @@ static void collectPrimaries(Geant4PrimaryMap* pm, Geant4PrimaryInteraction* dd4hep::sim::createPrimary(int mask, Geant4PrimaryMap* pm, - const G4PrimaryVertex* gv) + std::setconst& primaries) { Geant4PrimaryInteraction* interaction = new Geant4PrimaryInteraction(); - Geant4Vertex* v = createPrimary(gv); - int vid = int(interaction->vertices.size()); interaction->locked = true; interaction->mask = mask; - v->mask = mask; - interaction->vertices[vid].emplace_back(v); - - for (G4PrimaryParticle *gp = gv->GetPrimary(); gp; gp = gp->GetNext() ) - collectPrimaries(pm, interaction, v, gp); + for (auto const& gv: primaries) { + Geant4Vertex* v = createPrimary(gv); + v->mask = mask; + interaction->vertices[mask].emplace_back(v); + for (G4PrimaryParticle *gp = gv->GetPrimary(); gp; gp = gp->GetNext()) { + collectPrimaries(pm, interaction, v, gp); + } + } return interaction; } From a029add2015401ac0aa60a8b655a010bb7e12b03 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 13:16:55 +0100 Subject: [PATCH 3/8] Geant4InputHandling: collectPrimaries: use the mask to place the daughter vertices rather than size of the map Now every place where interaction->vertices map is being used, the mask is used as the key to the map, instead of something else --- DDG4/src/Geant4InputHandling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index a741179a9..279db4b6a 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -103,14 +103,13 @@ static void collectPrimaries(Geant4PrimaryMap* pm, if ( dau ) { Geant4Vertex* dv = new Geant4Vertex(*particle_origine); - int vid = int(interaction->vertices.size()); PropertyMask reason(p->reason); reason.set(G4PARTICLE_HAS_SECONDARIES); dv->mask = mask; dv->in.insert(p->id); - interaction->vertices[vid].emplace_back(dv) ; + interaction->vertices[mask].emplace_back(dv) ; for(; dau; dau = dau->GetNext()) collectPrimaries(pm, interaction, dv, dau); From ec32498bd6712239e3d69c54c552ff9f00004251 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 17:04:40 +0100 Subject: [PATCH 4/8] Geant4GeneratorWrapper: collect vertices before putting them in the set Geant4InputHandling: prevent adding same particle more than once --- DDG4/src/Geant4GeneratorWrapper.cpp | 6 +++--- DDG4/src/Geant4InputHandling.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/DDG4/src/Geant4GeneratorWrapper.cpp b/DDG4/src/Geant4GeneratorWrapper.cpp index b40bec032..858300e5f 100644 --- a/DDG4/src/Geant4GeneratorWrapper.cpp +++ b/DDG4/src/Geant4GeneratorWrapper.cpp @@ -70,13 +70,13 @@ void Geant4GeneratorWrapper::operator()(G4Event* event) { Geant4PrimaryMap* primaryMap = context()->event().extension(); set primaries; + // Now generate the new interaction + generator()->GeneratePrimaryVertex(event); + /// Collect all existing interactions (primary vertices) for(G4PrimaryVertex* v=event->GetPrimaryVertex(); v; v=v->GetNext()) primaries.insert(v); - // Now generate the new interaction - generator()->GeneratePrimaryVertex(event); - // Add all the missing interactions (primary vertices) to the primary event record. Geant4PrimaryInteraction* inter = createPrimary(m_mask, primaryMap, primaries); prim->add(m_mask, inter); diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index 279db4b6a..84c1a7a81 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -88,6 +88,11 @@ static void collectPrimaries(Geant4PrimaryMap* pm, Geant4Vertex* particle_origine, G4PrimaryParticle* gp) { + //if the particle is in the map, we do not have to do anything + if ( pm->get(gp) ) { + return; + } + int pid = int(interaction->particles.size()); Geant4Particle* p = createPrimary(pid,particle_origine,gp); G4PrimaryParticle* dau = gp->GetDaughter(); From 5560eab68e63fe0c80205573f17c841173c04a28 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 19:17:23 +0100 Subject: [PATCH 5/8] Release Notes for v01-27-02 --- doc/ReleaseNotes.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md index 29bf1e213..63ca0772e 100644 --- a/doc/ReleaseNotes.md +++ b/doc/ReleaseNotes.md @@ -1,3 +1,24 @@ +# v01-27-02 + +* 2023-12-15 Andre Sailer ([PR#1205](https://github.com/aidasoft/dd4hep/pull/1205)) + - Geant4PrimaryHandling: fix issue with multiple vertices in Geant4 GeneralParticleSource, fixes #1204 + +* 2023-12-14 Markus Frank ([PR#1201](https://github.com/aidasoft/dd4hep/pull/1201)) + - Incorporate type fix from https://github.com/AIDASoft/DD4hep/pull/1172 + - Propagate polish setting from ROOT surfaces to Geant4 + - Improve debugging capabilities of detector checksums by improved dumping possibilities. + +* 2023-12-14 Andre Sailer ([PR#1196](https://github.com/aidasoft/dd4hep/pull/1196)) + - NestedBoxReflection_geo.cpp: use std::abs instead of abs + - HexGrid: use std::abs instead of abs + - DDSim: better logging of which sensitive detector is used when defaults are used + +* 2023-12-14 Paul Gessinger ([PR#1195](https://github.com/aidasoft/dd4hep/pull/1195)) + - Replace usage of the `imp` module that was removed in Python 3.12 with `importlib` and `types`. + +* 2023-11-24 Andre Sailer ([PR#1192](https://github.com/aidasoft/dd4hep/pull/1192)) + - DetectorChecksum: use fabs to check if values are 0.0, fixes #1188 + # v01-27-01 * 2023-11-20 jmcarcell ([PR#1191](https://github.com/aidasoft/DD4hep/pull/1191)) From 0e8124a7faa95e734290fa8fc01548e4b2a4ef26 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 19:17:24 +0100 Subject: [PATCH 6/8] Updating version to v01-27-02 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e282c31ac..8eac9f14e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DD4hep) SET( DD4hep_VERSION_MAJOR 1 ) SET( DD4hep_VERSION_MINOR 27 ) -SET( DD4hep_VERSION_PATCH 1 ) +SET( DD4hep_VERSION_PATCH 2 ) ####################### # Basic project setup # From e812ea74eaaeae12e395ce29cc80b9eb0b6976b1 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 19 Dec 2023 16:22:46 +0100 Subject: [PATCH 7/8] Coverity: use el9 based stack --- .github/workflows/coverity.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 738701b7b..038869bea 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -17,4 +17,4 @@ jobs: coverity-project: 'AIDASoft%2FDD4hep' coverity-project-token: ${{ secrets.DD4HEP_COVERITY_TOKEN }} github-pat: ${{ secrets.READ_COVERITY_IMAGE }} - release-platform: "LCG_102b/x86_64-centos7-gcc11-opt" + release-platform: "LCG_104a/x86_64-el9-gcc13-opt" From ec1b92a8a06b5759ee4eb891a83d418b6ed1f7d2 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Mon, 8 Jan 2024 13:28:25 +0100 Subject: [PATCH 8/8] Fix teveDisplay: restore behaviour (issue https://github.com/AIDASoft/DD4hep/issues/1208) --- DDCore/src/segmentations/CartesianGridXY.cpp | 26 ++++---- .../CartesianGridXYStaggered.cpp | 41 +++++++------ UtilityApps/src/run_plugin.h | 7 +-- UtilityApps/src/teve_display.cpp | 61 +++++++++++-------- 4 files changed, 75 insertions(+), 60 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index f6cd2087f..371828a6a 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -18,10 +18,10 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : _description = "Cartesian segmentation in the local XY-plane"; // register all necessary parameters - registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); - registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); - registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); - registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); } @@ -35,10 +35,10 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : _description = "Cartesian segmentation in the local XY-plane"; // register all necessary parameters - registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); - registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); - registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); - registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); } @@ -57,14 +57,16 @@ Vector3D CartesianGridXY::position(const CellID& cID) const { } /// determine the cell ID based on the position - CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - CellID cID = vID ; +CellID CartesianGridXY::cellID(const Vector3D& localPosition, + const Vector3D& /* globalPosition */, + const VolumeID& vID) const { + CellID cID = vID; _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); - return cID ; + return cID; } -std::vector CartesianGridXY::cellDimensions(const CellID&) const { + std::vector CartesianGridXY::cellDimensions(const CellID& /* cellID */) const { #if __cplusplus >= 201103L return {_gridSizeX, _gridSizeY}; #else diff --git a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp index 69cf77236..504794d7e 100644 --- a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp +++ b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp @@ -11,8 +11,9 @@ namespace dd4hep { namespace DDSegmentation { /// default constructor using an encoding string -CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncoding) : - CartesianGrid(cellEncoding) { +CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncoding) + : CartesianGrid(cellEncoding) +{ // define type and description _type = "CartesianGridXYStaggered"; _description = "Cartesian segmentation in the local XY-plane, with options for staggering"; @@ -22,14 +23,14 @@ CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncodi registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, true); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", + _staggerX, 0, SegmentationParameter::NoUnit, true); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", + _staggerY, 0, SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", - SegmentationParameter::NoUnit, true); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", + _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } /// Default constructor used by derived classes passing an existing decoder @@ -45,14 +46,14 @@ CartesianGridXYStaggered::CartesianGridXYStaggered(const BitFieldCoder* decode) registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, true); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", + _staggerX, 0, SegmentationParameter::NoUnit, true); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", + _staggerY, 0, SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", - SegmentationParameter::NoUnit, true); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", + _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } /// destructor @@ -73,10 +74,12 @@ Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { } return cellPosition; } - + /// determine the cell ID based on the position - CellID CartesianGridXYStaggered::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - CellID cID = vID ; +CellID CartesianGridXYStaggered::cellID(const Vector3D& localPosition, + const Vector3D& /* globalPosition */, + const VolumeID& vID) const { + CellID cID = vID ; if (_staggerX || _staggerY){ int layer= _decoder->get(cID,_staggerKeyword); _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); @@ -88,11 +91,9 @@ Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { return cID ; } - -std::vector CartesianGridXYStaggered::cellDimensions(const CellID& cellID) const { +std::vector CartesianGridXYStaggered::cellDimensions(const CellID& /* cellID */) const { return {_gridSizeX, _gridSizeY}; } - } /* namespace DDSegmentation */ } /* namespace dd4hep */ diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h index a0c2cf274..cd94a56f0 100644 --- a/UtilityApps/src/run_plugin.h +++ b/UtilityApps/src/run_plugin.h @@ -299,16 +299,15 @@ namespace dd4hep { return 0; } - void usage_plugin_runner() { - std::cout << - "geoPluginRun -opt [-opt] \n" + void usage_plugin_runner(const char* runner="geoPluginRun", bool exit_program=true) { + std::cout << runner << " -opt [-opt] \n" " -input [OPTIONAL] Specify geometry input file. \n" " -plugin [args] [-end-plugin] \n" " [REQUIRED] Plugin to be executed and applied. \n" " -plugin [args] -end-plugin \n" " [OPTIONAL] Next plugin with arguments. \n"; print_default_args() << std::endl; - ::exit(EINVAL); + if ( exit_program ) ::exit(EINVAL); } //______________________________________________________________________________ diff --git a/UtilityApps/src/teve_display.cpp b/UtilityApps/src/teve_display.cpp index 8030b5307..8e70d5025 100644 --- a/UtilityApps/src/teve_display.cpp +++ b/UtilityApps/src/teve_display.cpp @@ -64,24 +64,30 @@ void make_gui(); TEveStraightLineSet* getSurfaces(int col=kRed, const SurfaceType& type=SurfaceType(), TString name="Surfaces" ) ; TEveStraightLineSet* getSurfaceVectors(bool addO=true, bool addU= true, bool addV=true, bool addN=true,TString name="SurfaceVectors",int color=kGreen) ; +//===================================================================================== +static void print_teve_help() { + std::cout << + "Usage: teveDisplay -arg [-arg] \n\n" + " Invoke TEve display using the factory mechanism. \n\n" + " -input [OPTIONAL] Specify geometry input file. \n"; + print_default_args() << std::endl << + " -level Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" + " -visopt Visualization option [TGeoManager::SetVisOption] Default: 0 \n" + " -help Print this help output" << std::endl << std::flush; + ::exit(EINVAL); +} + //===================================================================================== static long teve_display(Detector& description, int argc, char** argv) { int level = 4, visopt = 0, help = 0; - for( int i=0; i Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" - " -visopt Visualization option [TGeoManager::SetVisOption] Default: 0 \n" - " -help Print this help output" << std::endl << std::flush; - ::exit(EINVAL); + print_teve_help(); } TGeoManager* mgr = &description.manager(); @@ -149,20 +155,27 @@ static long teve_display(Detector& description, int argc, char** argv) { } DECLARE_APPLY(DD4hepTEveDisplay,teve_display) - //===================================================================================================================== - int main(int argc,char** argv) { std::vector av; std::string level, visopt, opt; - bool help = false; - for( int i=0; i 2 ) av.emplace_back(argv[i]); + } + if ( !help && argc == 2 ) { // Single argument given --> geometry file + av.emplace_back("-input"); + av.emplace_back(argv[1]); } av.emplace_back("-interactive"); av.emplace_back("-plugin"); @@ -171,22 +184,22 @@ int main(int argc,char** argv) { if ( !opt.empty() ) av.emplace_back("-opt"), av.emplace_back(opt.c_str()); if ( !level.empty() ) av.emplace_back("-level"), av.emplace_back(level.c_str()); if ( !visopt.empty() ) av.emplace_back("-visopt"), av.emplace_back(visopt.c_str()); + if ( help ) { + print_teve_help(); + } return dd4hep::execute::main_plugins("DD4hepTEveDisplay", av.size(), (char**)&av[0]); } //===================================================================================================================== -TEveStraightLineSet* getSurfaceVectors(bool addO, bool addU, bool addV, bool addN, TString name,int color) { +TEveStraightLineSet* getSurfaceVectors(bool addO, bool addU, bool addV, bool addN, TString name,int color) { TEveStraightLineSet* ls = new TEveStraightLineSet(name); Detector& description = Detector::getInstance(); - DetElement world = description.world() ; + DetElement world = description.world(); // create a list of all surfaces in the detector: - SurfaceHelper surfMan( world ) ; - + SurfaceHelper surfMan( world ); const SurfaceList& sL = surfMan.surfaceList() ; - for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){ - ISurface* surf = *it ; const Vector3D& u = surf->u() ; const Vector3D& v = surf->v() ;