From 1c934e4ba53efc4b0c12a4fcc5788bf68bca340c Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Tue, 30 Oct 2018 18:37:47 +0100 Subject: [PATCH] Add copyright notices, make ddeve a program --- DDEve/CMakeLists.txt | 3 ++ DDEve/DDEve/DDEve.C | 8 ++-- DDEve/DDEve/DDEve.cpp | 48 +++++++++++++++++++ DDEve/include/DDEve/Dictionary.h | 4 +- .../include/DDG4/Geant4DetectorConstruction.h | 2 + .../Geant4DetectorGeometryConstruction.cpp | 2 +- DDG4/python/DDG4.py | 4 ++ DDG4/src/Geant4ActionContainer.cpp | 2 +- DDG4/src/Geant4DetectorConstruction.cpp | 13 ++++- DDG4/src/Geant4VolumeManager.cpp | 2 +- examples/ClientTests/compact/Assemblies.xml | 11 +++++ .../compact/Bitfield_SidesTest.xml | 12 +++++ .../compact/Bitfield_SidesTest2.xml | 12 +++++ examples/ClientTests/compact/BoxTrafos.xml | 12 +++++ .../ClientTests/compact/Check_Handles.xml | 12 +++++ examples/DDCodex/compact/CODEX-b-alone.xml | 12 +++++ examples/DDCodex/compact/CODEX-b.xml | 13 +++++ examples/DDCodex/eve/DDEve.xml | 11 +++++ 18 files changed, 174 insertions(+), 9 deletions(-) create mode 100644 DDEve/DDEve/DDEve.cpp diff --git a/DDEve/CMakeLists.txt b/DDEve/CMakeLists.txt index d686047d3..0d81534ca 100644 --- a/DDEve/CMakeLists.txt +++ b/DDEve/CMakeLists.txt @@ -39,6 +39,9 @@ if(DD4HEP_USE_GEANT4) OPTIONAL DDG4 ) endif() +#----------------------------------------------------------------------------------- +dd4hep_add_executable( ddeve DDEve/DDEve.cpp ) +#----------------------------------------------------------------------------------- #---Package installation procedure(s) ------------------------------------- dd4hep_install_dir ( DDEve DESTINATION examples ) diff --git a/DDEve/DDEve/DDEve.C b/DDEve/DDEve/DDEve.C index d76fe9dd2..08f2464d8 100644 --- a/DDEve/DDEve/DDEve.C +++ b/DDEve/DDEve/DDEve.C @@ -20,7 +20,7 @@ #include "TSystem.h" #include "TInterpreter.h" -void DDEve(const char* xmlConfig=0) { +void DDEve(const char* xmlConfig=0, const char* evtData=0) { Long_t result; char text[1024]; const char* dd4hep = gSystem->Getenv("DD4hepINSTALL"); @@ -74,8 +74,10 @@ void DDEve(const char* xmlConfig=0) { gSystem->Exit(gSystem->GetErrno()); } #endif - if ( xmlConfig ) - ::snprintf(text,sizeof(text),"dd4hep::DDEve::run(\"%s\")",xmlConfig); + if ( xmlConfig && evtData ) + ::snprintf(text,sizeof(text),"dd4hep::DDEve::run(\"%s\",\"%s\")", xmlConfig, evtData); + else if ( xmlConfig ) + ::snprintf(text,sizeof(text),"dd4hep::DDEve::run(\"%s\")", xmlConfig); else ::snprintf(text,sizeof(text),"dd4hep::DDEve::run(0)"); gInterpreter->ProcessLine(text); diff --git a/DDEve/DDEve/DDEve.cpp b/DDEve/DDEve/DDEve.cpp new file mode 100644 index 000000000..13c5f1699 --- /dev/null +++ b/DDEve/DDEve/DDEve.cpp @@ -0,0 +1,48 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// C/C++ include files +#include <string> +#include <iostream> + +// ROOT include files +#include "TRint.h" +#include "DDEve.C" + +int main(int argc, char** argv) { + std::string config, data; + for(int i=1; i<argc; ++i) { + if ( 0 == ::strncmp(argv[i],"-config",4) ) + config = argv[++i]; + else if ( 0 == ::strncmp(argv[i],"--config",5) ) + config = argv[++i]; + else if ( 0 == ::strncmp(argv[i],"-data",4) ) + data = argv[++i]; + else if ( 0 == ::strncmp(argv[i],"--data",5) ) + data = argv[++i]; + else { + std::cout << + "ddeve -opt [-opt] \n" + " -config <file> XML configuration file \n" + " -data <file> Event data file file \n" + << std::endl; + exit(0); + } + } + std::pair<int, char**> a(0,0); + const char* config_xml = config.empty() ? 0 : config.c_str(); + gApplication = new TRint("DDEve", &a.first, a.second); + DDEve(config_xml); + gApplication->Run(); + return 0; +} diff --git a/DDEve/include/DDEve/Dictionary.h b/DDEve/include/DDEve/Dictionary.h index 4ddeaa49d..65086e374 100644 --- a/DDEve/include/DDEve/Dictionary.h +++ b/DDEve/include/DDEve/Dictionary.h @@ -53,8 +53,8 @@ namespace dd4hep { */ struct DDEve { /// ROOT interactive entry point for running DDEve - static void run(const char* xmlFile) { - EveDisplay(xmlFile, nullptr); + static void run(const char* xmlFile, const char* evtData=0) { + EveDisplay(xmlFile, evtData); } }; } diff --git a/DDG4/include/DDG4/Geant4DetectorConstruction.h b/DDG4/include/DDG4/Geant4DetectorConstruction.h index 1df4ec316..ab6eaef05 100644 --- a/DDG4/include/DDG4/Geant4DetectorConstruction.h +++ b/DDG4/include/DDG4/Geant4DetectorConstruction.h @@ -143,6 +143,8 @@ namespace dd4hep { virtual void updateContext(Geant4Context* ctxt); /// Add an actor responding to all callbacks. Sequence takes ownership. void adopt(Geant4DetectorConstruction* action); + /// Access an actor by name + Geant4DetectorConstruction* get(const std::string& nam) const; /// Geometry construction callback. Called at "Construct()" virtual void constructGeo(Geant4DetectorConstructionContext* ctxt); /// Electromagnetic field construction callback. Called at "ConstructSDandField()" diff --git a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp index e67ad7114..cf122dc68 100644 --- a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp +++ b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp @@ -128,7 +128,7 @@ void Geant4DetectorGeometryConstruction::constructGeo(Geant4DetectorConstruction conv.debugRegions = m_debugRegions; ctxt->geometry = conv.create(world).detach(); - ctxt->geometry->printLevel = PrintLevel(m_geoInfoPrintLevel); + ctxt->geometry->printLevel = outputLevel(); g4map.attach(ctxt->geometry); G4VPhysicalVolume* w = ctxt->geometry->world(); // Create Geant4 volume manager only if not yet available diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index 0b46d18ea..0c850fe36 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -402,6 +402,10 @@ class Geant4: init_seq.adopt(init_action) return init_seq,init_action + def detectorConstruction(self): + seq = self.master().detectorConstruction(True) + return seq + """ Configure Geant4 user initialization for optionasl multi-threading mode diff --git a/DDG4/src/Geant4ActionContainer.cpp b/DDG4/src/Geant4ActionContainer.cpp index 94b2a51da..d6b23c73c 100644 --- a/DDG4/src/Geant4ActionContainer.cpp +++ b/DDG4/src/Geant4ActionContainer.cpp @@ -131,7 +131,7 @@ Geant4StackingActionSequence* Geant4ActionContainer::stackingAction(bool create) /// Access detector construcion action sequence (geometry+sensitives+field) Geant4DetectorConstructionSequence* Geant4ActionContainer::detectorConstruction(bool create) { if (!m_constructionAction && create) - registerSequence(m_constructionAction, "StackingAction"); + registerSequence(m_constructionAction, "DetectorConstructionAction"); return m_constructionAction; } diff --git a/DDG4/src/Geant4DetectorConstruction.cpp b/DDG4/src/Geant4DetectorConstruction.cpp index 286e477f3..1a74a2a26 100644 --- a/DDG4/src/Geant4DetectorConstruction.cpp +++ b/DDG4/src/Geant4DetectorConstruction.cpp @@ -81,7 +81,18 @@ void Geant4DetectorConstructionSequence::adopt(Geant4DetectorConstruction* actio m_actors.add(action); return; } - throw runtime_error("Geant4RunActionSequence: Attempt to add invalid actor!"); + except("Geant4RunActionSequence","++ Attempt to add an invalid actor!"); +} + +/// Access an actor by name +Geant4DetectorConstruction* Geant4DetectorConstructionSequence::get(const std::string& nam) const { + for(auto* i : m_actors) { + if ( i->name() == nam ) { + return i; + } + } + except("Geant4RunActionSequence","++ Attempt to access invalid actor %s!",nam.c_str()); + return 0; } /// Geometry construction callback. Called at "Construct()" diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index b5d7f6741..c7d395d18 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -168,7 +168,7 @@ namespace { int(control.size()),detail::tools::placementPath(control,true).c_str()); goto Err; } - printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: %X" + printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: 0x%X" " [THIS SHOULD NEVER HAPPEN]", code); Err: diff --git a/examples/ClientTests/compact/Assemblies.xml b/examples/ClientTests/compact/Assemblies.xml index f8e27000f..ac3d30718 100644 --- a/examples/ClientTests/compact/Assemblies.xml +++ b/examples/ClientTests/compact/Assemblies.xml @@ -1,6 +1,17 @@ <lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> <info name="Assemblies_v01" title="Assembly Detector Toy model" diff --git a/examples/ClientTests/compact/Bitfield_SidesTest.xml b/examples/ClientTests/compact/Bitfield_SidesTest.xml index 9d8986875..43ab5550d 100644 --- a/examples/ClientTests/compact/Bitfield_SidesTest.xml +++ b/examples/ClientTests/compact/Bitfield_SidesTest.xml @@ -3,6 +3,18 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> + <includes> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> diff --git a/examples/ClientTests/compact/Bitfield_SidesTest2.xml b/examples/ClientTests/compact/Bitfield_SidesTest2.xml index f22f4a758..0c7976231 100644 --- a/examples/ClientTests/compact/Bitfield_SidesTest2.xml +++ b/examples/ClientTests/compact/Bitfield_SidesTest2.xml @@ -3,6 +3,18 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> + <includes> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> diff --git a/examples/ClientTests/compact/BoxTrafos.xml b/examples/ClientTests/compact/BoxTrafos.xml index c09dd0499..edbd8c01a 100644 --- a/examples/ClientTests/compact/BoxTrafos.xml +++ b/examples/ClientTests/compact/BoxTrafos.xml @@ -2,6 +2,18 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> + <info name="alignment_boxes" title="Alignment test with 2 simple boxes" author="Markus Frank" diff --git a/examples/ClientTests/compact/Check_Handles.xml b/examples/ClientTests/compact/Check_Handles.xml index 2468d394a..cc697cf9f 100644 --- a/examples/ClientTests/compact/Check_Handles.xml +++ b/examples/ClientTests/compact/Check_Handles.xml @@ -3,6 +3,18 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> + <includes> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> diff --git a/examples/DDCodex/compact/CODEX-b-alone.xml b/examples/DDCodex/compact/CODEX-b-alone.xml index 6edf57471..0f5351c10 100644 --- a/examples/DDCodex/compact/CODEX-b-alone.xml +++ b/examples/DDCodex/compact/CODEX-b-alone.xml @@ -2,6 +2,18 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> + <!-- Have the materials --> <includes> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> diff --git a/examples/DDCodex/compact/CODEX-b.xml b/examples/DDCodex/compact/CODEX-b.xml index af7261f72..753673d85 100644 --- a/examples/DDCodex/compact/CODEX-b.xml +++ b/examples/DDCodex/compact/CODEX-b.xml @@ -1,6 +1,19 @@ <lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> + <!-- <includes> <gdmlFile ref="elements.xml"/> diff --git a/examples/DDCodex/eve/DDEve.xml b/examples/DDCodex/eve/DDEve.xml index 7b3776419..8b4ce6888 100644 --- a/examples/DDCodex/eve/DDEve.xml +++ b/examples/DDCodex/eve/DDEve.xml @@ -1,4 +1,15 @@ <ddeve> +<!-- #========================================================================== + # AIDA Detector description implementation + #-------------------------------------------------------------------------- + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== +--> <display visLevel="12" loadLevel="12"/> <collection name="CodexHits" hits="PointSet" color="kRed" size="0.8" type="20"/> -- GitLab