diff --git a/CMakeLists.txt b/CMakeLists.txt index de027c57fd8cf34f84b4ba4dbb2f7a28f5bdd617..762b6ad35ea5c51c59f08404fc439e1804aff9ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ option(DD4HEP_USE_GEAR "Build gear wrapper for backward compatibility" OFF) option(DD4HEP_USE_LCIO "Build lcio extensions" OFF) option(BUILD_TESTING "Enable and build tests" ON) option(DD4HEP_USE_CXX11 "Build DD4hep using c++11" OFF) +option(DD4HEP_USE_CXX14 "Build DD4hep using c++14" OFF) # #----------------------------------------------------------------------------------------------------- # @@ -45,12 +46,7 @@ if ( ${ROOT_VERSION_MAJOR} GREATER 5 ) endif() #--------------------------------------------------------------------------------------------------- #fg: moved to here from DD4hep.cmake to not force CMAKE_CXX_FLAGS upon dependent packages -if ( DD4HEP_USE_CXX11 ) - set ( CMAKE_CXX_FLAGS "-std=c++11 -ftls-model=global-dynamic -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") - add_definitions(-DDD4HEP_USE_CXX11) -else() - set( CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") -endif() +dd4hep_set_compiler_flags() #---DD4hep functions and macros ------------------------------------------------------- include(DD4hep) diff --git a/DDCore/include/DD4hep/Dictionary.h b/DDCore/include/DD4hep/Dictionary.h index 2b8e6cfa89d82f6b75ab17b7a5f42aa0945f2cd9..e478f930839b16afb35447f7060c855a66f269cc 100644 --- a/DDCore/include/DD4hep/Dictionary.h +++ b/DDCore/include/DD4hep/Dictionary.h @@ -50,7 +50,7 @@ namespace DD4hep { // ------------------------------------------------------------------------- // Regular DD4hep dictionaries // ------------------------------------------------------------------------- -#ifdef __CINT__ +#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__) #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; @@ -64,24 +64,26 @@ namespace DD4hep { #pragma link C++ namespace DD4hep::Geometry; #pragma link C++ namespace DD4hep::DDSegmentation; -template pair<unsigned int, string>; -#pragma link C++ class pair<unsigned int,string>+; - +#ifndef __ROOTCLING__ +template std::pair<unsigned int, std::string>; template class DD4hep::Geometry::Handle<DD4hep::NamedObject>; -template class pair< string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >; -template class map< string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >; +template class std::pair< std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >; +template class std::map< std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >; +#endif + +#pragma link C++ class std::pair<unsigned int,std::string>+; #pragma link C++ class DD4hep::NamedObject+; #pragma link C++ class DD4hep::Geometry::Ref_t+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::NamedObject>+; -#pragma link C++ class pair<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >+; -#pragma link C++ class map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >+; -#pragma link C++ class map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator; -#pragma link C++ class map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::const_iterator; +#pragma link C++ class std::pair<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >+; +#pragma link C++ class std::map<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >+; +#pragma link C++ class std::map<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator; +#pragma link C++ class std::map<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::const_iterator; #ifdef R__MACOSX // We only need these declarations for the clang compiler -#pragma link C++ function operator==( const map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator&,const map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator& ); -#pragma link C++ function operator!=( const map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator&,const map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator& ); +#pragma link C++ function operator==( const std::map<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator&,const std::map<string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator& ); +#pragma link C++ function operator!=( const std::map<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator&,const std::map<std::string, DD4hep::Geometry::Handle<DD4hep::NamedObject> >::iterator& ); #endif #pragma link C++ class DD4hep::ObjectExtensions+; @@ -90,17 +92,17 @@ template class DD4hep::Geometry::Handle<TNamed>; #pragma link C++ class DD4hep::Geometry::LCDD+; #pragma link C++ class DD4hep::Geometry::LCDDData+; -#pragma link C++ class DD4hep::Geometry::LCDDData::ObjectHandleMap+; +#pragma link C++ class DD4hep::Geometry::LCDDData::ObjectHandleStd::Map+; #pragma link C++ class DD4hep::Geometry::LCDD::PropertyValues+; #pragma link C++ class DD4hep::Geometry::LCDD::Properties+; #pragma link C++ class DD4hepRootPersistency+; // These below are the Namedobject instances to be generated .... -//#pragma link C++ class DD4hep::Geometry::LCDD::HandleMap+; -//#pragma link C++ class DD4hep::Geometry::LCDD::HandleMap::iterator; -//#pragma link C++ class DD4hep::Geometry::LCDD::HandleMap::const_iterator; -//#pragma link C++ class DD4hep::Geometry::LCDD::HandleMap::key_type; // == std::string -//#pragma link C++ class DD4hep::Geometry::LCDD::HandleMap::value_type+; +//#pragma link C++ class DD4hep::Geometry::LCDD::HandleStd::Map+; +//#pragma link C++ class DD4hep::Geometry::LCDD::HandleStd::Map::iterator; +//#pragma link C++ class DD4hep::Geometry::LCDD::HandleStd::Map::const_iterator; +//#pragma link C++ class DD4hep::Geometry::LCDD::HandleStd::Map::key_type; // == std::string +//#pragma link C++ class DD4hep::Geometry::LCDD::HandleStd::Map::value_type+; #pragma link C++ class DD4hep::Geometry::VolumeManager+; #pragma link C++ class DD4hep::Geometry::VolumeManagerObject+; @@ -128,7 +130,7 @@ template class DD4hep::Geometry::Handle<TNamed>; // Objects.h #pragma link C++ class DD4hep::Geometry::Author+; -#pragma link C++ class vector<DD4hep::Geometry::Author>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Author>+; #pragma link C++ class DD4hep::Geometry::Header+; #pragma link C++ class DD4hep::Geometry::HeaderObject+; @@ -137,50 +139,50 @@ template class DD4hep::Geometry::Handle<TNamed>; #pragma link C++ class DD4hep::Geometry::Constant+; #pragma link C++ class DD4hep::Geometry::ConstantObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::ConstantObject>+; -#pragma link C++ class vector<DD4hep::Geometry::Constant>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Constant>+; #pragma link C++ class DD4hep::Geometry::Atom+; -#pragma link C++ class vector<DD4hep::Geometry::Atom>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Atom>+; #pragma link C++ class DD4hep::Geometry::Handle<TGeoElement>+; #pragma link C++ class DD4hep::Geometry::Material+; -#pragma link C++ class vector<DD4hep::Geometry::Material>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Material>+; #pragma link C++ class DD4hep::Geometry::Handle<TGeoMedium>+; #pragma link C++ class DD4hep::Geometry::VisAttr+; -#pragma link C++ class vector<DD4hep::Geometry::VisAttr>+; +#pragma link C++ class std::vector<DD4hep::Geometry::VisAttr>+; #pragma link C++ class DD4hep::Geometry::VisAttrObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::VisAttrObject>+; #pragma link C++ class DD4hep::Geometry::AlignmentEntry+; #pragma link C++ class DD4hep::Geometry::Limit+; -#pragma link C++ class set<DD4hep::Geometry::Limit>+; -#pragma link C++ class vector<DD4hep::Geometry::Limit>+; +#pragma link C++ class std::set<DD4hep::Geometry::Limit>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Limit>+; #pragma link C++ class DD4hep::Geometry::LimitSet+; -#pragma link C++ class vector<DD4hep::Geometry::LimitSet>+; +#pragma link C++ class std::vector<DD4hep::Geometry::LimitSet>+; #pragma link C++ class DD4hep::Geometry::LimitSetObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::LimitSetObject>+; #pragma link C++ class DD4hep::Geometry::Region+; #pragma link C++ class DD4hep::Geometry::RegionObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::RegionObject>+; -#pragma link C++ class vector<DD4hep::Geometry::Region>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Region>+; // Readout.h -#pragma link C++ class vector<pair<size_t,string> >+; +#pragma link C++ class std::vector<std::pair<size_t,std::string> >+; #pragma link C++ class DD4hep::Geometry::Segmentation+; #pragma link C++ class DD4hep::Geometry::SegmentationObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::SegmentationObject>+; #pragma link C++ class DD4hep::Geometry::Readout+; #pragma link C++ class DD4hep::Geometry::ReadoutObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::ReadoutObject>+; -#pragma link C++ class vector<DD4hep::Geometry::Readout>+; -#pragma link C++ class vector<DD4hep::Geometry::IDDescriptor>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Readout>+; +#pragma link C++ class std::vector<DD4hep::Geometry::IDDescriptor>+; #pragma link C++ class DD4hep::Geometry::Alignment+; #pragma link C++ class DD4hep::Geometry::Handle<TGeoPhysicalNode>+; #pragma link C++ class DD4hep::Geometry::Condition+; -#pragma link C++ class vector<DD4hep::Geometry::Condition>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Condition>+; #pragma link C++ class DD4hep::Geometry::ConditionsInterna::ConditionObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::ConditionsInterna::ConditionObject>+; @@ -192,40 +194,42 @@ template class DD4hep::Geometry::Handle<TNamed>; #pragma link C++ class DD4hep::Geometry::DetElement+; #pragma link C++ class DD4hep::Geometry::DetElementObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::DetElementObject>+; -#pragma link C++ class vector<DD4hep::Geometry::DetElement>+; -#pragma link C++ class pair<string,DD4hep::Geometry::DetElement>+; -#pragma link C++ class map<string,DD4hep::Geometry::DetElement>+; -#pragma link C++ class map<string,DD4hep::Geometry::DetElement>::iterator; -#pragma link C++ class map<string,DD4hep::Geometry::DetElement>::const_iterator; +#pragma link C++ class std::vector<DD4hep::Geometry::DetElement>+; +#pragma link C++ class std::pair<std::string,DD4hep::Geometry::DetElement>+; +#pragma link C++ class std::map<std::string,DD4hep::Geometry::DetElement>+; +#pragma link C++ class std::map<std::string,DD4hep::Geometry::DetElement>::iterator; +#pragma link C++ class std::map<std::string,DD4hep::Geometry::DetElement>::const_iterator; #ifdef R__MACOSX // We only need these declarations for the clang compiler -#pragma link C++ function operator==( const map<string, DD4hep::Geometry::DetElement >::iterator&,const map<string, DD4hep::Geometry::DetElement >::iterator& ); -#pragma link C++ function operator!=( const map<string, DD4hep::Geometry::DetElement >::iterator&,const map<string, DD4hep::Geometry::DetElement >::iterator& ); +#pragma link C++ function operator==( const std::map<std::string, DD4hep::Geometry::DetElement >::iterator&,const std::map<std::string, DD4hep::Geometry::DetElement >::iterator& ); +#pragma link C++ function operator!=( const std::map<std::string, DD4hep::Geometry::DetElement >::iterator&,const std::map<std::string, DD4hep::Geometry::DetElement >::iterator& ); #endif #pragma link C++ class DD4hep::Geometry::SensitiveDetector+; #pragma link C++ class DD4hep::Geometry::SensitiveDetectorObject+; #pragma link C++ class DD4hep::Geometry::Handle<DD4hep::Geometry::SensitiveDetectorObject>+; -#pragma link C++ class vector<DD4hep::Geometry::SensitiveDetector>+; +#pragma link C++ class std::vector<DD4hep::Geometry::SensitiveDetector>+; // Volume.h #pragma link C++ class DD4hep::Geometry::Volume+; #pragma link C++ class DD4hep::Geometry::VolumeExtension+; -#pragma link C++ class vector<DD4hep::Geometry::Volume>+; +#pragma link C++ class std::vector<DD4hep::Geometry::Volume>+; #pragma link C++ class DD4hep::Geometry::Handle<TGeoVolume>+; #pragma link C++ class DD4hep::Geometry::PlacedVolume+; -template vector<pair<string, int> >; -template vector<pair<string, int> >::iterator; -#pragma link C++ class vector<pair<string, int> >+; -#pragma link C++ class vector<pair<string, int> >::iterator; +#ifndef __ROOTCLING__ +template std::vector<std::pair<std::string, int> >; +template std::vector<std::pair<std::string, int> >::iterator; +#endif +#pragma link C++ class std::vector<std::pair<std::string, int> >+; +#pragma link C++ class std::vector<std::pair<std::string, int> >::iterator; #pragma link C++ class DD4hep::Geometry::PlacedVolumeExtension::VolIDs+; #pragma link C++ class DD4hep::Geometry::PlacedVolumeExtension+; -#pragma link C++ class vector<DD4hep::Geometry::PlacedVolume>+; +#pragma link C++ class std::vector<DD4hep::Geometry::PlacedVolume>+; #pragma link C++ class DD4hep::Geometry::Handle<TGeoNode>+; -#pragma link C++ class vector<TGeoNode*>+; -#pragma link C++ class vector<TGeoVolume*>+; +#pragma link C++ class std::vector<TGeoNode*>+; +#pragma link C++ class std::vector<TGeoVolume*>+; // Shapes.h @@ -292,32 +296,32 @@ template vector<pair<string, int> >::iterator; #pragma link C++ class DD4hep::Geometry::UnionSolid+; #pragma link C++ class DD4hep::Geometry::IntersectionSolid+; -#pragma link C++ class pair<string, string>+; -#pragma link C++ class map<string, string>+; -#pragma link C++ class map<string, string>::iterator; -#pragma link C++ class map<string, string>::const_iterator; +#pragma link C++ class pair<std::string, std::string>+; +#pragma link C++ class std::map<std::string, std::string>+; +#pragma link C++ class std::map<std::string, std::string>::iterator; +#pragma link C++ class std::map<std::string, std::string>::const_iterator; #ifdef R__MACOSX // We only need these declarations for the clang compiler -#pragma link C++ function operator==( const map<string, string>::iterator&, const map<string, string>::iterator& ); -#pragma link C++ function operator!=( const map<string, string>::iterator&, const map<string, string>::iterator& ); +#pragma link C++ function operator==( const std::map<std::string, std::string>::iterator&, const std::map<std::string, std::string>::iterator& ); +#pragma link C++ function operator!=( const std::map<std::string, std::string>::iterator&, const std::map<std::string, std::string>::iterator& ); #endif -#pragma link C++ class pair<string, map<string, string> >+; -#pragma link C++ class map<string, map<string, string> >+; -#pragma link C++ class map<string, map<string,string>>::iterator; -#pragma link C++ class map<string, map<string,string>>::const_iterator; +#pragma link C++ class std::pair<std::string, std::map<std::string, std::string> >+; +#pragma link C++ class std::map<std::string, std::map<std::string, std::string> >+; +#pragma link C++ class std::map<std::string, std::map<std::string,std::string>>::iterator; +#pragma link C++ class std::map<std::string, std::map<std::string,std::string>>::const_iterator; #ifdef R__MACOSX // We only need these declarations for the clang compiler -#pragma link C++ function operator==( const map<string, map<string,string>>::iterator&, const map<string, map<string,string>>::iterator& ); -#pragma link C++ function operator!=( const map<string, map<string,string>>::iterator&, const map<string, map<string,string>>::iterator& ); +#pragma link C++ function operator==( const std::map<std::string, std::map<std::string,std::string>>::iterator&, const std::map<std::string, std::map<std::string,std::string>>::iterator& ); +#pragma link C++ function operator!=( const std::map<std::string, std::map<std::string,std::string>>::iterator&, const std::map<std::string, std::map<std::string,std::string>>::iterator& ); #endif #pragma link C++ class DD4hep::Geometry::LCDD+; #pragma link C++ function DD4hep::run_interpreter(const std::string& name); -#pragma link C++ function DD4hep::Geometry::_toDictionary(const string&, const string&); +#pragma link C++ function DD4hep::Geometry::_toDictionary(const std::string&, const std::string&); #endif // __CINT__ @@ -339,13 +343,13 @@ template vector<pair<string, int> >::iterator; typedef DD4hep::DDSegmentation::VolumeID VolumeID; typedef DD4hep::DDSegmentation::CellID CellID; -#ifdef __CINT__ +#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLANG__) || defined(__ROOTCLING__) #pragma link C++ class DD4hep::DDSegmentation::SegmentationParameter+; #pragma link C++ class DD4hep::DDSegmentation::TypedSegmentationParameter<int>+; #pragma link C++ class DD4hep::DDSegmentation::TypedSegmentationParameter<float>+; #pragma link C++ class DD4hep::DDSegmentation::TypedSegmentationParameter<double>+; -#pragma link C++ class DD4hep::DDSegmentation::TypedSegmentationParameter<string>+; +#pragma link C++ class DD4hep::DDSegmentation::TypedSegmentationParameter<std::string>+; #if 0 /// Severe problem due to template specialization! #pragma link C++ class DD4hep::DDSegmentation::TypedSegmentationParameter<std::vector<int> >+; diff --git a/examples/ClientTests/src/ZylinderShell_geo.cpp b/DDDetectors/src/CylinderShell_geo.cpp similarity index 52% rename from examples/ClientTests/src/ZylinderShell_geo.cpp rename to DDDetectors/src/CylinderShell_geo.cpp index 1068358e6d740d46afdde909330eaaea09f43005..43b39fee8f15204f5d8d763998e7d11e45012ebb 100644 --- a/examples/ClientTests/src/ZylinderShell_geo.cpp +++ b/DDDetectors/src/CylinderShell_geo.cpp @@ -1,11 +1,45 @@ -// $Id: PolyconeSupport_geo.cpp 941 2013-12-12 18:47:03Z markus.frank@cern.ch $ +// $Id$ //==================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------- // +// Generic cylindric shell detector to be used to measure +// e.g. escape energy from calorimeters. +// // Author : M.Frank // //==================================================================== + +/* + Example XML: + + <detector id="2" name="ContainmentShell" type="ZylinderShell" vis="VisibleRed" readout="ContainmentHits" > + <comment>Containment shell to measure calorimeter escapes</comment> + <material name="Air"/> + <module name="Barrel" id="0" vis="VisibleRed"> + <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="-2*HcalBarrel_zmax"/> + <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax"/> + </module> + <module name="SideA" id="1" vis="VisibleRed"> + <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+10*cm"/> + <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+20*cm"/> + </module> + <module name="SideB" id="2" vis="VisibleRed"> + <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+10*cm)"/> + <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+20*cm)"/> + </module> + </detector> + </detectors> + +to be joined by a sensitive detector: + <readouts> + <readout name="ContainmentHits"> + <id>system:8,barrel:3</id> + </readout> + </readouts> + + +*/ #include "DD4hep/DetFactoryHelper.h" using namespace std; @@ -20,6 +54,7 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sensitive) Material mat (lcdd.material(x_det.materialStr())); PlacedVolume pv; + sensitive.setType("escape_counter"); for(xml_coll_t m(e,_U(module)); m; ++m) { xml_comp_t mod = m; vector<double> rmin,rmax,z; @@ -47,4 +82,4 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sensitive) return sdet; } -DECLARE_DETELEMENT(ZylinderShell,create_detector) +DECLARE_DETELEMENT(DD4hep_CylinderShell,create_detector) diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt index 5a19eab7fa46a3fcc300908fc1095b6870364231..98ad8f0e677ae7b75f9a5a9e8048ff17cec80cb8 100644 --- a/DDG4/CMakeLists.txt +++ b/DDG4/CMakeLists.txt @@ -26,9 +26,11 @@ dd4hep_add_plugin(DDG4Plugins GENERATED G__DDG4.cxx SOURCES plugins/*.cpp) #--------------------------- Plugin library for the simulation framework --------- -dd4hep_add_dictionary(G__DDG4Python SOURCES src/python/DDG4Python.C ) +dd4hep_add_dictionary(G__DDG4Python SOURCES src/python/DDG4Python.C + OPTIONAL [PYTHON REQUIRED] ) #--------------------------- Plugin library for the simulation framework --------- -dd4hep_add_dictionary(G__DDPython SOURCES tpython/DDPython.C ) +dd4hep_add_dictionary(G__DDPython SOURCES tpython/DDPython.C + OPTIONAL [PYTHON REQUIRED] ) #--------------------------- Specialized python plugins -------------------------- dd4hep_add_regular_library(DDPython GENERATED G__DDPython.cxx diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index 605270ec2404768499776ff6bcdc4b8bec461975..050e104ab951e1728d0f0cc29104091f9a47f63d 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -1,5 +1,6 @@ #include "TInterpreter.h" #include "TSystem.h" +#include "RVersion.h" #include <iostream> #include <string> @@ -13,19 +14,45 @@ string make_str(const char* data) { return string(data); } +void processMacro(const char* macro, bool end_process) { + string cmd = ".X "; + cmd += macro; + cmd += ".C+()"; + int status = gInterpreter->ProcessLine(cmd.c_str()); + ::printf("Status(%s) = %d\n",cmd.c_str(),status); + if ( end_process ) { + gInterpreter->ProcessLine("gSystem->Exit(0)"); + } +} + int initAClick(const char* command=0) { string rootsys = make_str(gSystem->Getenv("ROOTSYS")); string g4_base = make_str(gSystem->Getenv("G4INSTALL")); string dd4hep = make_str(gSystem->Getenv("DD4hepINSTALL")); - string inc = " -I"+dd4hep+"/include -I"+g4_base+"/include/Geant4 -Wno-shadow -g -O0"; string libs = (" -L"+rootsys+"/lib"); - libs += " -lCore -lCint -lMathCore -L"+dd4hep+"/lib -lDDCore -lDDG4 -lDDSegmentation"; + string inc = " -I"+dd4hep+"/examples/DDG4/examples" + + " -I"+dd4hep + + " -I"+dd4hep+"/include" + + " -I"+g4_base+"/include/Geant4" + + " -Wno-shadow -g -O0"; + if ( ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) ) + libs += " -lCore -lMathCore"; + else + libs += " -lCore -lCint -lMathCore"; + libs += " -pthread -lm -ldl -rdynamic"; + libs += " -L"+dd4hep+"/lib -lDDCore -lDDG4 -lDDSegmentation"; libs += (" -L"+g4_base+"/lib -L"+g4_base+"/lib64 -lG4event -lG4tracking -lG4particles"); gSystem->AddIncludePath(inc.c_str()); gSystem->AddLinkedLibs(libs.c_str()); cout << "Includes: " << gSystem->GetIncludePath() << endl; cout << "Linked libs:" << gSystem->GetLinkedLibs() << endl; int ret = gSystem->Load("libDDG4Plugins"); + if ( 0 == ret ) { + if ( command ) { + gInterpreter->ProcessLine(command); + gInterpreter->ProcessLine("gSystem->Exit(0)"); + } + } return ret; } diff --git a/DDG4/examples/run.C b/DDG4/examples/run.C index ac61809cd02f7d8e64306d0180547e595f695846..763b4ac86c122c93c49a7ef83317c435d9b746b1 100644 --- a/DDG4/examples/run.C +++ b/DDG4/examples/run.C @@ -1,13 +1,19 @@ #include "TInterpreter.h" -void run() { - gInterpreter->ProcessLine(".X initAClick.C"); - //gInterpreter->ProcessLine(".L exampleAClick.C+"); - gInterpreter->ProcessLine(".L xmlAClick.C+"); - //gInterpreter->ProcessLine(".L TEve.C+"); - //gSystem->Load("libDDCore"); - //gSystem->Load("libDDG4"); - //gInterpreter->ProcessLine(".L FCC_Hcal.C+"); - //gInterpreter->ProcessLine(".X DDG4Dump.C+"); - //gInterpreter->ProcessLine(".X a.C++"); +#include <string> +void run(const char* macro) { + char cmd[1024]; + const char* dd4hep_install = getenv("DD4hepINSTALL"); + if ( dd4hep_install ) { + ::sprintf(cmd,".L %s/examples/DDG4/examples/initAClick.C+",dd4hep_install); + } + else { + ::sprintf(cmd,".L examples/DDG4/examples/initAClick.C+"); + } + int status = gInterpreter->ProcessLine(cmd); + ::printf("Status(%s) = %d\n",cmd,status); + status = gInterpreter->ProcessLine("initAClick()"); + ::printf("Status(%s) = %d\n",cmd,status); + ::sprintf(cmd,"processMacro(\"%s\",true)",macro); + status = gInterpreter->ProcessLine(cmd); + ::printf("Status(%s) = %d\n",cmd,status); } - diff --git a/DDG4/examples/xmlAClick.C b/DDG4/examples/xmlAClick.C deleted file mode 100644 index d5be709131c4664c561a354456810316e9857d0f..0000000000000000000000000000000000000000 --- a/DDG4/examples/xmlAClick.C +++ /dev/null @@ -1,44 +0,0 @@ -// $Id: Geant4Data.h 513 2013-04-05 14:31:53Z gaede $ -//==================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------- -// -// Run Geant4 using DDG4 from root prompt with test objects for -// Run/Event/Sensitive actions. -// -// The Geant4 setup is programmed in the xml files to be parsed. Only -// the commands to parse these xml files is executed by root. -// -// Usage: -// $> root.exe -// root[0] .x <installation-directory>/examples/DDG4/examples/initAClick.C -// root[1] .L <installation-directory>/examples/DDG4/examples/CLICSidAClick.C+ -// root[2] CLICSidAClick() -// -// -// Author : M.Frank -// -//==================================================================== -#include "DDG4/Geant4Config.h" -#include <iostream> - -using namespace DD4hep::Simulation::Setup; - -void setupG4_XML() { - std::string prefix = "file:../DD4hep"; - Kernel& kernel = Kernel::instance(Kernel::LCDD::getInstance()); - kernel.loadGeometry((prefix+"/examples/CLICSiD/compact/compact.xml").c_str()); - kernel.loadXML((prefix+"/examples/DDG4/examples/DDG4_field.xml").c_str()); - kernel.loadXML((prefix+"/examples/DDG4/examples/sequences.xml").c_str()); - kernel.loadXML((prefix+"/examples/DDG4/examples/physics.xml").c_str()); - kernel.property("UI") = "UI"; - kernel.configure(); - kernel.initialize(); - kernel.run(); - std::cout << "Successfully executed application .... " << std::endl; - kernel.terminate(); -} - -void xmlAClick() { - setupG4_XML(); -} diff --git a/DDG4/include/DDG4/DDG4Dict.h b/DDG4/include/DDG4/DDG4Dict.h index 06d5614186a3e71819ea39ad8cf25e23bc2c87b7..8f3bd36658e30ddbdc6ae58e3592f6b00ccedc8c 100644 --- a/DDG4/include/DDG4/DDG4Dict.h +++ b/DDG4/include/DDG4/DDG4Dict.h @@ -29,7 +29,7 @@ namespace DD4hep { } // CINT configuration -#if defined(__MAKECINT__) +#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__) #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; diff --git a/DDG4/include/DDG4/Geant4DataDump.h b/DDG4/include/DDG4/Geant4DataDump.h index 06860665bcdb835fde12e148e1b1275e2156551e..5b8dff9101e166d783fb672c3c494c7a3d4ab6dd 100644 --- a/DDG4/include/DDG4/Geant4DataDump.h +++ b/DDG4/include/DDG4/Geant4DataDump.h @@ -55,9 +55,10 @@ namespace DD4hep { Geant4DataDump(const std::string& tag); /// Standard destructor virtual ~Geant4DataDump(); - +#if !(defined(G__DICTIONARY) || defined(__CLANG__) || defined(__CINT__) || defined(__MAKECINT__)) /// Print a single particle to the output logging using the specified print level void print(PrintLevel level, Geant4ParticleHandle p) const; +#endif /// Print the particle container to the output logging using the specified print level void print(PrintLevel level, const std::string& container, const Particles* parts); diff --git a/DDG4/include/DDG4/Geant4Kernel.h b/DDG4/include/DDG4/Geant4Kernel.h index 8f61c40512229684eac8f8b2ced2d7c87cf5b52c..1c5ecce55d85fdbb470ebdf768b4006d36649dd1 100644 --- a/DDG4/include/DDG4/Geant4Kernel.h +++ b/DDG4/include/DDG4/Geant4Kernel.h @@ -50,14 +50,16 @@ namespace DD4hep { protected: /// Reference to the run manager - G4RunManager* m_runManager; + G4RunManager* m_runManager; /// Top level control directory - G4UIdirectory* m_control; - /// Property pool - PropertyManager m_properties; - + G4UIdirectory* m_control; /// Reference to Geant4 track manager G4TrackingManager* m_trackMgr; + /// Detector description object + LCDD* m_lcdd; + /// Property pool + PropertyManager m_properties; + /// Action phases Phases m_phases; @@ -67,8 +69,6 @@ namespace DD4hep { GlobalActions m_globalActions; /// Globally registered filters of sensitive detectors GlobalActions m_globalFilters; - /// Detector description object - LCDD& m_lcdd; /// Property: Name of the G4UI command tree std::string m_controlName; /// Property: Name of the UI action. Must be member of the global actions @@ -96,7 +96,7 @@ namespace DD4hep { #ifndef __CINT__ /// Standard constructor for workers - Geant4Kernel(LCDD& lcdd, Geant4Kernel* m, unsigned long identifier); + Geant4Kernel(Geant4Kernel* m, unsigned long identifier); #endif public: @@ -146,13 +146,11 @@ namespace DD4hep { #ifndef __CINT__ /// Instance accessor static Geant4Kernel& instance(LCDD& lcdd); - /// Accessof the Geant4Kernel object from the LCDD reference extension (if present and registered) - //static Geant4Kernel& access(LCDD& lcdd); #endif /// Access phase phases const Phases& phases() const { return m_phases; } /// Access to detector description - LCDD& lcdd() const { return m_lcdd; } + LCDD& lcdd() const { return *m_lcdd; } /// Access the tracking manager G4TrackingManager* trackMgr() const { return m_trackMgr; } /// Access the tracking manager @@ -259,7 +257,6 @@ namespace DD4hep { virtual int runEvents(int num_events); /// Run the simulation: Terminate Geant4 virtual int terminate(); - virtual int terminateEx(); }; /// Declare property template <typename T> Geant4Kernel& Geant4Kernel::declareProperty(const std::string& nam, T& val) { diff --git a/DDG4/include/DDG4/Geant4ParticleGenerator.h b/DDG4/include/DDG4/Geant4ParticleGenerator.h index 06d6e30335117d4f37eeebf6328ae4822371a897..6a21056ecfe97df8566685fcdc57a45c0e01efe5 100644 --- a/DDG4/include/DDG4/Geant4ParticleGenerator.h +++ b/DDG4/include/DDG4/Geant4ParticleGenerator.h @@ -33,6 +33,10 @@ namespace DD4hep { * \ingroup DD4HEP_SIMULATION */ class Geant4ParticleGenerator: public Geant4GeneratorAction { + public: + enum { FIRST_INTERACTION = 0UL, + LAST_INTERACTION = ~0UL + }; protected: /// Property: Shooting direction of the gun ROOT::Math::XYZVector m_direction; @@ -61,6 +65,10 @@ namespace DD4hep { */ virtual void getParticleDirection(int num, ROOT::Math::XYZVector& direction, double& momentum) const; + /// Print single particle interaction identified by sequence number in primary event. Default: last one + virtual void printInteraction(size_t which=LAST_INTERACTION) const; + + public: /// Standard constructor Geant4ParticleGenerator(Geant4Context* context, const std::string& name); diff --git a/DDG4/include/DDG4/Geant4ParticleGun.h b/DDG4/include/DDG4/Geant4ParticleGun.h index 71dd77c886490751a7ed1a21ce0dc2d82a57d2e1..5022faf2cbf10a1371e4c936194bbf331d125bd0 100644 --- a/DDG4/include/DDG4/Geant4ParticleGun.h +++ b/DDG4/include/DDG4/Geant4ParticleGun.h @@ -16,11 +16,7 @@ #define DD4HEP_DDG4_GEANT4PARTICLEGUN_H // Framework include files -#include "DDG4/Geant4GeneratorAction.h" -#include "Math/Vector3D.h" - -// Forward declarations -class G4ParticleDefinition; +#include "DDG4/Geant4IsotropeGenerator.h" /// Namespace for the AIDA detector description toolkit namespace DD4hep { @@ -49,27 +45,19 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_SIMULATION */ - class Geant4ParticleGun: public Geant4GeneratorAction { + class Geant4ParticleGun: public Geant4IsotropeGenerator { protected: - /// Property: Position and shooting direction of the gun - ROOT::Math::XYZVector m_position, m_direction; - /// Property: Particle energy - double m_energy; - /// Property: Particle name - std::string m_particleName; - /// Property: Desired multiplicity of the particles to be shot - int m_multiplicity; - /// Property: Interaction mask indentifier - int m_mask; /// Property: Isotrope particles? bool m_isotrop; /// Property: Standalone mode: includes interaction merging and primary generation bool m_standalone; - - /// Pointer to geant4 particle definition - G4ParticleDefinition* m_particle; /// Shot number in sequence int m_shotNo; + /// Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = m_energy) + virtual void getParticleDirection(int, ROOT::Math::XYZVector& direction, double& momentum) const { + direction = m_direction; + momentum = m_energy; + } public: /// Standard constructor Geant4ParticleGun(Geant4Context* context, const std::string& name); diff --git a/DDG4/include/DDG4Python/DDPython.h b/DDG4/include/DDG4Python/DDPython.h index ab4a06220d0bdfa9b479defe7c02b2cf81aabdba..4218a610da4abbd4fe69281a5b3747953ff139b6 100644 --- a/DDG4/include/DDG4Python/DDPython.h +++ b/DDG4/include/DDG4Python/DDPython.h @@ -16,8 +16,26 @@ // C/C++ include files #include <string> + +#if !defined(__MAKECINT__) && !defined(__CINT__) && !defined(G__DICTIONARY) +// ----------------------------------------------------------------------------- +// Python hacks to avoid warnings if outside dictionaries ..... +// ----------------------------------------------------------------------------- +// --> /usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default] +#ifdef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif /* _POSIX_C_SOURCE */ +// --> /usr/include/python2.7/pyconfig.h:1183:0: warning: "_XOPEN_SOURCE" redefined [enabled by default] +#ifdef _XOPEN_SOURCE +#undef _XOPEN_SOURCE +#endif /* _XOPEN_SOURCE */ +#include "Python.h" +#endif + +// ROOT include file(s) #include "TPyReturn.h" + /// Namespace for the AIDA detector description toolkit namespace DD4hep { diff --git a/DDG4/plugins/Geant4FieldTrackingSetup.cpp b/DDG4/plugins/Geant4FieldTrackingSetup.cpp index 937c1e03380681efa56149d08382d31a2b1da51a..b2ad82e30f47713ba927fc891b57586a268034b8 100644 --- a/DDG4/plugins/Geant4FieldTrackingSetup.cpp +++ b/DDG4/plugins/Geant4FieldTrackingSetup.cpp @@ -223,12 +223,12 @@ int Geant4FieldTrackingSetup::execute(Geometry::LCDD& lcdd) { static long setup_fields(lcdd_t& lcdd, const DD4hep::Geometry::GeoHandler& /* cnv */, const map<string,string>& vals) { struct XMLFieldTrackingSetup : public Geant4FieldTrackingSetup { - XMLFieldTrackingSetup(const map<string,string>& vals) : Geant4FieldTrackingSetup() { - Geant4SetupPropertyMap pm(vals); - lcdd_t::PropertyValues::const_iterator iV = vals.find("min_chord_step"); + XMLFieldTrackingSetup(const map<string,string>& values) : Geant4FieldTrackingSetup() { + Geant4SetupPropertyMap pm(values); + lcdd_t::PropertyValues::const_iterator iV = values.find("min_chord_step"); eq_typ = pm.value("equation"); stepper_typ = pm.value("stepper"); - min_chord_step = Geometry::_toDouble((iV==vals.end()) ? string("1e-2 * mm") : (*iV).second); + min_chord_step = Geometry::_toDouble((iV==values.end()) ? string("1e-2 * mm") : (*iV).second); if ( pm["eps_min"] ) eps_min = pm.toDouble("eps_min"); if ( pm["eps_max"] ) eps_max = pm.toDouble("eps_max"); if ( pm["delta_chord"] ) delta_chord = pm.toDouble("delta_chord"); diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 7a3825cbdf95c47c961a6597bf0c0df98a54fd34..5b86e3ea193b85e81fcd584c64b5089e5d41c3d9 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -45,9 +45,7 @@ namespace DD4hep { Position position = mean_direction(prePos,postPos); double hit_len = direction.R(); - if ( step->GetTotalEnergyDeposit() < std::numeric_limits<double>::epsilon() ) - return true; - else if (hit_len > 0) { + if (hit_len > 0) { double new_len = mean_length(h.preMom(),h.postMom())/hit_len; direction *= new_len/hit_len; } @@ -109,10 +107,7 @@ namespace DD4hep { } Hit* hit = coll->find<Hit>(CellIDCompare<Hit>(cell)); - if ( h.totalEnergy() < std::numeric_limits<double>::epsilon() ) { - return true; - } - else if ( !hit ) { + if ( !hit ) { Geant4TouchableHandler handler(step); DDSegmentation::Vector3D pos = m_segmentation.position(cell); Position global = h.localToGlobal(pos); @@ -225,10 +220,7 @@ namespace DD4hep { } Hit* hit = coll->find<Hit>(CellIDCompare<Hit>(cell)); - if ( h.totalEnergy() < std::numeric_limits<double>::epsilon() ) { - return true; - } - else if ( !hit ) { + if ( !hit ) { Geant4TouchableHandler handler(step); DDSegmentation::Vector3D pos = m_segmentation.position(cell); Position global = h.localToGlobal(pos); @@ -356,10 +348,6 @@ namespace DD4hep { if ( mustSaveTrack(h.track) ) { extractHit(coll); } - /// There must be something in. - if ( h.deposit()/CLHEP::keV <= 0 ) { - return false; - } /// Initialize the deposits of the next hit. if ( current < 0 ) { start(step, h.pre); diff --git a/DDG4/plugins/Geant4TrackerWeightedSD.cpp b/DDG4/plugins/Geant4TrackerWeightedSD.cpp index 5257ec52ea949d239d3d608a99768ac38e695487..7f3e05c8d78ea7c1dde1093543d1e5f4a0b73d9a 100644 --- a/DDG4/plugins/Geant4TrackerWeightedSD.cpp +++ b/DDG4/plugins/Geant4TrackerWeightedSD.cpp @@ -13,22 +13,14 @@ //========================================================================== // Framework include files -#include "DD4hep/LCDD.h" #include "DD4hep/DD4hepUnits.h" #include "DDG4/Geant4SensDetAction.inl" #include "DDG4/Geant4SteppingAction.h" #include "DDG4/Geant4TrackingAction.h" #include "DDG4/Geant4EventAction.h" -#include "G4OpticalPhoton.hh" -#include "G4VProcess.hh" #include "G4Event.hh" #include "G4VSolid.hh" -#include "DDRec/Surface.h" -#include "DDRec/DetectorSurfaces.h" -#include "DDRec/SurfaceManager.h" -#include "DDRec/SurfaceHelper.h" - #include <map> #include <limits> #include <sstream> @@ -41,7 +33,6 @@ namespace DD4hep { /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit namespace Simulation { - using namespace DDRec; using namespace Geometry; /// Geant4 sensitive detector combining all deposits of one G4Track within one sensitive element. @@ -168,16 +159,16 @@ namespace DD4hep { void extractHit(Geant4HitCollection* collection, EInside ended) { double deposit = pre.truth.deposit; - if ( current != -1 && deposit/CLHEP::keV > 0 ) { + if ( current != -1 ) { Position pos; Momentum mom = 0.5 * (pre.momentum + post.momentum); - double time = mean_time / deposit; + double time = deposit != 0 ? mean_time / deposit : mean_time; double path = (post.position - pre.position).R(); char dist_in[64], dist_out[64]; switch(hit_position_type) { case POSITION_WEIGHTED: - pos = mean_pos / deposit; + pos = deposit != 0 ? mean_pos / deposit : mean_pos; break; case POSITION_PREPOINT: pos = pre.position; diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index 920ebc7fdc039f95acb002dab6e933b6b4f99c51..6593146f3b05fab54d4909fc11a986dcf1d03f19 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -312,6 +312,7 @@ class Geant4: self.sensitive_types = {} self.sensitive_types['tracker'] = tracker self.sensitive_types['calorimeter'] = calo + self.sensitive_types['escape_counter'] = 'Geant4EscapeCounter' def kernel(self): @@ -504,8 +505,10 @@ class Geant4: phys.dump() return phys - def setupGun(self, name, particle, energy, isotrop=True, multiplicity=1, position=(0.0,0.0,0.0)): + def setupGun(self, name, particle, energy, isotrop=True, multiplicity=1, position=(0.0,0.0,0.0),**args): gun = GeneratorAction(self.kernel(),"Geant4ParticleGun/"+name,True) + for i in args.items(): + setattr(gun,i[0],i[1]) gun.energy = energy gun.particle = particle gun.multiplicity = multiplicity diff --git a/DDG4/python/DDG4Dict.C b/DDG4/python/DDG4Dict.C index 83c00d4bd05a8525a30a7c886943a9ca5f3a43ab..c377cf290550c873a5424462aa0bd7c21009b6d5 100644 --- a/DDG4/python/DDG4Dict.C +++ b/DDG4/python/DDG4Dict.C @@ -20,12 +20,6 @@ #include "DDG4/Geant4Primary.h" #include "DDG4/Geant4Random.h" #include "DDG4/DDG4Dict.h" - - -using namespace std; -using namespace DD4hep; -using namespace DD4hep::Simulation; - #include "DDG4/Geant4Config.h" #include "DDG4/Geant4DataDump.h" #include "DDG4/Geant4InputAction.h" @@ -33,6 +27,8 @@ using namespace DD4hep::Simulation; namespace DD4hep { namespace Simulation { + using std::string; + #define ACTIONHANDLE(x) \ struct x##Handle { \ Geant4##x* action; \ @@ -202,121 +198,121 @@ typedef DD4hep::Simulation::Geant4ActionCreation Geant4ActionCreation; #include "DD4hep/objects/DetectorInterna.h" // CINT configuration -#if defined(__MAKECINT__) +#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__) #pragma link C++ namespace DDSegmentation; /// Geant4 Vertex dictionaries -#pragma link C++ class Simulation::VertexExtension+; -#pragma link C++ class Simulation::Geant4Vertex+; -#pragma link C++ class std::vector<Simulation::Geant4Vertex*>+; -#pragma link C++ class std::map<int,Simulation::Geant4Vertex*>+; - -#pragma link C++ class Simulation::Geant4ParticleMap+; -#pragma link C++ class Simulation::PrimaryExtension+; -#pragma link C++ class Simulation::Geant4PrimaryInteraction+; -#pragma link C++ class std::map<int,Simulation::Geant4PrimaryInteraction*>+; -#pragma link C++ class Simulation::Geant4PrimaryEvent+; - -#pragma link C++ class PropertyResult; +#pragma link C++ class DD4hep::Simulation::VertexExtension+; +#pragma link C++ class DD4hep::Simulation::Geant4Vertex+; +#pragma link C++ class std::vector<DD4hep::Simulation::Geant4Vertex*>+; +#pragma link C++ class std::map<int,DD4hep::Simulation::Geant4Vertex*>+; + +#pragma link C++ class DD4hep::Simulation::Geant4ParticleMap+; +#pragma link C++ class DD4hep::Simulation::PrimaryExtension+; +#pragma link C++ class DD4hep::Simulation::Geant4PrimaryInteraction+; +#pragma link C++ class std::map<int,DD4hep::Simulation::Geant4PrimaryInteraction*>+; +#pragma link C++ class DD4hep::Simulation::Geant4PrimaryEvent+; + +#pragma link C++ class DD4hep::PropertyResult; #pragma link C++ class Geant4InputAction::Particles; #if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0) namespace { struct bla { - dd4hep_ptr<Geant4InputAction::Particles> __m1; - dd4hep_ptr<ParticleExtension> __m2; - dd4hep_ptr<DataExtension> __m3; + dd4hep_ptr<DD4hep::Simulation::Geant4InputAction::Particles> __m1; + dd4hep_ptr<DD4hep::Simulation::ParticleExtension> __m2; + dd4hep_ptr<DD4hep::Simulation::DataExtension> __m3; }; } -#pragma link C++ class dd4hep_ptr<Simulation::VertexExtension>+; -#pragma link C++ class dd4hep_ptr<Simulation::PrimaryExtension>+; -#pragma link C++ class dd4hep_ptr<Geant4InputAction::Particles>; -#pragma link C++ class dd4hep_ptr<Geant4InputAction::Particles>::base_t; #endif +#pragma link C++ class dd4hep_ptr<DD4hep::Simulation::VertexExtension>+; +#pragma link C++ class dd4hep_ptr<DD4hep::Simulation::PrimaryExtension>+; +#pragma link C++ class dd4hep_ptr<DD4hep::Simulation::Geant4InputAction::Particles>; +#pragma link C++ class dd4hep_ptr<DD4hep::Simulation::Geant4InputAction::Particles>::base_t; // Basic stuff -#pragma link C++ class Geant4ActionCreation; -#pragma link C++ class Geant4Kernel; -#pragma link C++ class Geant4Kernel::PhaseSelector; -#pragma link C++ class Geant4Context; -#pragma link C++ class KernelHandle; -#pragma link C++ class Geant4ActionContainer; - -#pragma link C++ class Geant4Action; -#pragma link C++ class ActionHandle; - -#pragma link C++ class RunActionSequenceHandle; -#pragma link C++ class Geant4RunActionSequence; -#pragma link C++ class RunActionHandle; -#pragma link C++ class Geant4SharedRunAction; -#pragma link C++ class Geant4RunAction; - -#pragma link C++ class EventActionSequenceHandle; -#pragma link C++ class Geant4EventActionSequence; -#pragma link C++ class EventActionHandle; -#pragma link C++ class Geant4SharedEventAction; -#pragma link C++ class Geant4EventAction; - -#pragma link C++ class SteppingActionSequenceHandle; -#pragma link C++ class Geant4SteppingActionSequence; -#pragma link C++ class SteppingActionHandle; -#pragma link C++ class Geant4SharedSteppingAction; -#pragma link C++ class Geant4SteppingAction; - -#pragma link C++ class StackingActionHandle; -#pragma link C++ class Geant4StackingAction; -#pragma link C++ class StackingActionSequenceHandle; -#pragma link C++ class Geant4StackingActionSequence; - -#pragma link C++ class TrackingActionHandle; -#pragma link C++ class Geant4TrackingAction; -#pragma link C++ class TrackingActionSequenceHandle; -#pragma link C++ class Geant4TrackingActionSequence; - -#pragma link C++ class GeneratorActionHandle; -#pragma link C++ class GeneratorActionSequenceHandle; -#pragma link C++ class Geant4GeneratorActionSequence; -#pragma link C++ class Geant4GeneratorAction; - -#pragma link C++ class Geant4InputAction; -#pragma link C++ class Geant4EventReader; - -#pragma link C++ class PhysicsListHandle; -#pragma link C++ class Geant4PhysicsList; -#pragma link C++ class PhysicsListActionSequenceHandle; -#pragma link C++ class Geant4PhysicsListActionSequence; - -#pragma link C++ class UserInitializationHandle; -#pragma link C++ class UserInitializationSequenceHandle; -#pragma link C++ class Geant4UserInitializationSequence; -#pragma link C++ class Geant4UserInitialization; - -#pragma link C++ class DetectorConstructionHandle; -#pragma link C++ class DetectorConstructionSequenceHandle; -#pragma link C++ class Geant4DetectorConstructionSequence; -#pragma link C++ class Geant4DetectorConstruction; - -#pragma link C++ class SensitiveHandle; -#pragma link C++ class SensDetActionSequenceHandle; -#pragma link C++ class Geant4ActionSD; -#pragma link C++ class Geant4Sensitive; -#pragma link C++ class Geant4SensDetActionSequence; - -#pragma link C++ class FilterHandle; -#pragma link C++ class Geant4Filter; - -#pragma link C++ class PhaseActionHandle; -#pragma link C++ class Geant4ActionPhase; -#pragma link C++ class Geant4PhaseAction; - -#pragma link C++ class Callback; -#pragma link C++ class Callback::mfunc_t; +#pragma link C++ class DD4hep::Simulation::Geant4ActionCreation; +#pragma link C++ class DD4hep::Simulation::Geant4Kernel; +#pragma link C++ class DD4hep::Simulation::Geant4Kernel::PhaseSelector; +#pragma link C++ class DD4hep::Simulation::Geant4Context; +#pragma link C++ class DD4hep::Simulation::KernelHandle; +#pragma link C++ class DD4hep::Simulation::Geant4ActionContainer; + +#pragma link C++ class DD4hep::Simulation::Geant4Action; +#pragma link C++ class DD4hep::Simulation::ActionHandle; + +#pragma link C++ class DD4hep::Simulation::RunActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4RunActionSequence; +#pragma link C++ class DD4hep::Simulation::RunActionHandle; +#pragma link C++ class DD4hep::Simulation::Geant4SharedRunAction; +#pragma link C++ class DD4hep::Simulation::Geant4RunAction; + +#pragma link C++ class DD4hep::Simulation::EventActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4EventActionSequence; +#pragma link C++ class DD4hep::Simulation::EventActionHandle; +#pragma link C++ class DD4hep::Simulation::Geant4SharedEventAction; +#pragma link C++ class DD4hep::Simulation::Geant4EventAction; + +#pragma link C++ class DD4hep::Simulation::SteppingActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4SteppingActionSequence; +#pragma link C++ class DD4hep::Simulation::SteppingActionHandle; +#pragma link C++ class DD4hep::Simulation::Geant4SharedSteppingAction; +#pragma link C++ class DD4hep::Simulation::Geant4SteppingAction; + +#pragma link C++ class DD4hep::Simulation::StackingActionHandle; +#pragma link C++ class DD4hep::Simulation::Geant4StackingAction; +#pragma link C++ class DD4hep::Simulation::StackingActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4StackingActionSequence; + +#pragma link C++ class DD4hep::Simulation::TrackingActionHandle; +#pragma link C++ class DD4hep::Simulation::Geant4TrackingAction; +#pragma link C++ class DD4hep::Simulation::TrackingActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4TrackingActionSequence; + +#pragma link C++ class DD4hep::Simulation::GeneratorActionHandle; +#pragma link C++ class DD4hep::Simulation::GeneratorActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4GeneratorActionSequence; +#pragma link C++ class DD4hep::Simulation::Geant4GeneratorAction; + +#pragma link C++ class DD4hep::Simulation::Geant4InputAction; +#pragma link C++ class DD4hep::Simulation::Geant4EventReader; + +#pragma link C++ class DD4hep::Simulation::PhysicsListHandle; +#pragma link C++ class DD4hep::Simulation::Geant4PhysicsList; +#pragma link C++ class DD4hep::Simulation::PhysicsListActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4PhysicsListActionSequence; + +#pragma link C++ class DD4hep::Simulation::UserInitializationHandle; +#pragma link C++ class DD4hep::Simulation::UserInitializationSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4UserInitializationSequence; +#pragma link C++ class DD4hep::Simulation::Geant4UserInitialization; + +#pragma link C++ class DD4hep::Simulation::DetectorConstructionHandle; +#pragma link C++ class DD4hep::Simulation::DetectorConstructionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4DetectorConstructionSequence; +#pragma link C++ class DD4hep::Simulation::Geant4DetectorConstruction; + +#pragma link C++ class DD4hep::Simulation::SensitiveHandle; +#pragma link C++ class DD4hep::Simulation::SensDetActionSequenceHandle; +#pragma link C++ class DD4hep::Simulation::Geant4ActionSD; +#pragma link C++ class DD4hep::Simulation::Geant4Sensitive; +#pragma link C++ class DD4hep::Simulation::Geant4SensDetActionSequence; + +#pragma link C++ class DD4hep::Simulation::FilterHandle; +#pragma link C++ class DD4hep::Simulation::Geant4Filter; + +#pragma link C++ class DD4hep::Simulation::PhaseActionHandle; +#pragma link C++ class DD4hep::Simulation::Geant4ActionPhase; +#pragma link C++ class DD4hep::Simulation::Geant4PhaseAction; + +#pragma link C++ class DD4hep::Simulation::Callback; +#pragma link C++ class DD4hep::Simulation::Callback::mfunc_t; // Other (specialized) components -#pragma link C++ class Geant4DataDump; -#pragma link C++ class Geant4Random; -#pragma link C++ class Geant4ParticleHandler; -#pragma link C++ class Geant4UserParticleHandler; +#pragma link C++ class DD4hep::Simulation::Geant4DataDump; +#pragma link C++ class DD4hep::Simulation::Geant4Random; +#pragma link C++ class DD4hep::Simulation::Geant4ParticleHandler; +#pragma link C++ class DD4hep::Simulation::Geant4UserParticleHandler; // somehow the symbol Geometry moved into global namespace. Redeclare it here diff --git a/DDG4/python/checkGeometry.py b/DDG4/python/checkGeometry.py index 9e83e77f72b4bd5e72a0f7dcdcb209acbc3ca98b..26ec76d5ddae08f9d529154f15e8e1810728cacf 100755 --- a/DDG4/python/checkGeometry.py +++ b/DDG4/python/checkGeometry.py @@ -11,11 +11,11 @@ # #========================================================================== -import sys, optparse +import sys, errno, optparse parser = optparse.OptionParser() parser.description = "TGeo Geometry checking." -parser.formater.width = 132 +parser.formatter.width = 132 parser.add_option("-c", "--compact", dest="compact", default=None, help="Define LCCDD style compact xml input", metavar="<FILE>") @@ -27,26 +27,26 @@ parser.add_option("-f","--full", parser.add_option("-n", "--ntracks", dest="num_tracks", default=1000000, - help="Number of tracks [requires 'full']", + help="Number of tracks [requires '--full']", metavar="<integer>") parser.add_option("-x", "--vx", dest="vx", default=0.0, - help="X-position of track origine vertex [requires 'full']", + help="X-position of track origine vertex [requires '--full']", metavar="<double>") parser.add_option("-y", "--vy", dest="vy", default=0.0, - help="Y-position of track origine vertex [requires 'full']", + help="Y-position of track origine vertex [requires '--full']", metavar="<double>") parser.add_option("-z", "--vz", dest="vz", default=0.0, - help="Z-position of track origine vertex [requires 'full']", + help="Z-position of track origine vertex [requires '--full']", metavar="<double>") parser.add_option("-o", "--option", dest="option", default='ob', - help="Geometry checking option default:ob", + help="TGeoManager geometry check option default:ob", metavar="<string>") (opts, args) = parser.parse_args() @@ -55,18 +55,35 @@ if opts.compact is None: print " ",parser.format_help() sys.exit(1) +try: + import ROOT + from ROOT import gROOT + gROOT.SetBatch(1) +except ImportError,X: + print 'PyROOT interface not accessible:',X + sys.exit(errno.ENOENT) + try: import DD4hep except ImportError,X: print 'DD4hep python interface not accessible:',X + sys.exit(errno.ENOENT) DD4hep.setPrintLevel(DD4hep.OutputLevel.ERROR) print '+++%s\n+++ Loading compact geometry:%s\n+++%s'%(120*'=',opts.compact,120*'=') lcdd = DD4hep.Geo.LCDD.getInstance() lcdd.fromXML(opts.compact) +opts.num_tracks = int(opts.num_tracks) +opts.vx = float(opts.vx) +opts.vy = float(opts.vy) +opts.vz = float(opts.vz) print '+++%s\n+++ Checking geometry:%s full-check:%s\n+++%s'%(120*'=',opts.compact,opts.full,120*'=') if opts.full: print '+++ # tracks:%d vertex:(%7.3f, %7.3f, %7.3f) [cm]'%(opts.num_tracks,opts.vx,opts.vy,opts.vz,) lcdd.manager().CheckGeometryFull(opts.num_tracks,opts.vx,opts.vy,opts.vz,opts.option) else: lcdd.manager().CheckGeometry() +# +# +print '+++ Execution finished...' +sys.exit(0) diff --git a/DDG4/python/checkOverlaps.py b/DDG4/python/checkOverlaps.py index d3d759cbe12c281e52a70bfcb8f16eb6aefc7b93..641ae538918dcc5f9939fc8e16195727dc1d368b 100755 --- a/DDG4/python/checkOverlaps.py +++ b/DDG4/python/checkOverlaps.py @@ -11,7 +11,7 @@ # #========================================================================== -import sys, optparse +import sys, errno, optparse parser = optparse.OptionParser() parser.formatter.width = 132 @@ -39,19 +39,36 @@ if opts.compact is None: print " ",parser.format_help() sys.exit(1) +try: + import ROOT + from ROOT import gROOT + gROOT.SetBatch(1) +except ImportError,X: + print 'PyROOT interface not accessible:',X + print parser.format_help() + sys.exit(errno.ENOENT) + try: import DD4hep except ImportError,X: print 'DD4hep python interface not accessible:',X print parser.format_help() - sys.exit(1) - + sys.exit(errno.ENOENT) +# +# +opts.tolerance = float(opts.tolerance) DD4hep.setPrintLevel(DD4hep.OutputLevel.ERROR) print '+++%s\n+++ Loading compact geometry:%s\n+++%s'%(120*'=',opts.compact,120*'=') lcdd = DD4hep.Geo.LCDD.getInstance() lcdd.fromXML(opts.compact) print '+++%s\n+++ Checking overlaps of geometry:%s tolerance:%f option:%s\n+++%s'%(120*'=',opts.compact,opts.tolerance,opts.option,120*'=') lcdd.manager().CheckOverlaps(opts.tolerance,opts.option) +# +# if opts.print_overlaps: print '+++%s\n+++ Printing overlaps of geometry:%s\n+++%s'%(120*'=',opts.compact,120*'=') lcdd.manager().PrintOverlaps() +# +# +print '+++ Execution finished...' +sys.exit(0) diff --git a/DDG4/python/g4MaterialScan.py b/DDG4/python/g4MaterialScan.py new file mode 100644 index 0000000000000000000000000000000000000000..2e4850b673c620cd7ec86b5261048f0c4b84ddf4 --- /dev/null +++ b/DDG4/python/g4MaterialScan.py @@ -0,0 +1,119 @@ +#!/bin/python +# $Id: $ +#========================================================================== +# AIDA Detector description implementation for LCD +#-------------------------------------------------------------------------- +# 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. +# +#========================================================================== + +import os, sys, errno, optparse + +def printOpts(opts): + o = eval(str(opts)) + prefix = sys.argv[0].split(os.sep)[-1] + for name,value in o.items(): + print '%s > %-18s %s [%s]'%(prefix,name+':',str(value),str(value.__class__),) + +def materialScan(opts): + kernel = DDG4.Kernel() + install_dir = os.environ['DD4hepINSTALL'] + kernel.loadGeometry(opts.compact) + DDG4.Core.setPrintFormat("%-32s %6s %s") + geant4 = DDG4.Geant4(kernel) + # Configure UI + geant4.setupCshUI(ui=None) + for i in geant4.lcdd.detectors(): + o = DDG4.DetElement(i.second.ptr()) + sd = geant4.lcdd.sensitiveDetector(o.name()) + if sd.isValid(): + typ = sd.type() + if geant4.sensitive_types.has_key(typ): + geant4.setupDetector(o.name(),geant4.sensitive_types[typ]) + sdtyp = geant4.sensitive_types[typ] + else: + print '+++ %-32s type:%-12s --> Unknown Sensitive type: %s'%(o.name(), typ, sdtyp,) + sys.exit(errno.EINVAL) + + gun = geant4.setupGun("Gun", + Standalone=True, + particle='geantino', + energy=20*SystemOfUnits.GeV, + position=opts.position, + direction=opts.direction, + multiplicity=1, + isotrop=False ) + scan = DDG4.SteppingAction(kernel,'Geant4MaterialScanner/MaterialScan') + kernel.steppingAction().adopt(scan) + + # Now build the physics list: + phys = geant4.setupPhysics('QGSP_BERT') + """ + phys = geant4.setupPhysics('') + ph = DDG4.PhysicsList(kernel,'Geant4PhysicsList/Myphysics') + ph.addParticleConstructor('G4Geantino') + ph.addParticleConstructor('G4BosonConstructor') + ph.addParticleConstructor('G4LeptonConstructor') + phys.transportation = True + phys.decays = True + phys.adopt(ph) + """ + + kernel.configure() + kernel.initialize() + kernel.NumEvents = 1 + kernel.run() + kernel.terminate() + return 0 + +parser = optparse.OptionParser() +parser.formatter.width = 132 +parser.description = 'Material scan using Geant4.' +parser.add_option('-c', '--compact', dest='compact', default=None, + help='Define LCCDD style compact xml input', + metavar='<FILE>') +parser.add_option('-P', '--print', + dest='print_level', default=2, + help='Set DD4hep print level.', + metavar='<int>') +parser.add_option('-p', '--position', + dest='position', default='0.0,0.0,0.0', + help='Start position of the material scan. [give tuple "x,y,z" as string]', + metavar='<tuple>') +parser.add_option('-d', '--direction', + dest='direction', default='0.0,1.0,0.0', + help='Direction of the material scan. [give tuple "x,y,z" as string]', + metavar='<tuple>') + +(opts, args) = parser.parse_args() + +if opts.compact is None: + print " ",parser.format_help() + sys.exit(1) + +opts.position=eval('('+opts.position+')') +opts.direction=eval('('+opts.direction+')') +printOpts(opts) + +try: + import ROOT + from ROOT import gROOT + gROOT.SetBatch(1) +except ImportError,X: + print 'PyROOT interface not accessible:',X + print parser.format_help() + sys.exit(errno.ENOENT) + +try: + import DDG4, SystemOfUnits +except ImportError,X: + print 'DDG4 python interface not accessible:',X + print parser.format_help() + sys.exit(errno.ENOENT) +# +ret = materialScan(opts) +sys.exit(ret); diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 86d8b67524d3c69985804e09bcdc551b3a28ec74..2d303ad6cd5873c0b53a17bfd6d29a307aa5682f 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -76,10 +76,10 @@ Geant4ActionPhase& Geant4Kernel::PhaseSelector::operator[](const std::string& na /// Standard constructor Geant4Kernel::Geant4Kernel(LCDD& lcdd_ref) - : Geant4ActionContainer(), m_runManager(0), m_lcdd(lcdd_ref), + : Geant4ActionContainer(), m_runManager(0), m_control(0), m_trackMgr(0), m_lcdd(&lcdd_ref), m_numThreads(0), m_id(Geant4Kernel::thread_self()), m_master(this), m_shared(0), phase(this) { - m_lcdd.addExtension < Geant4Kernel > (this); + m_lcdd->addExtension < Geant4Kernel > (this); m_ident = -1; declareProperty("UI",m_uiName); declareProperty("OutputLevel", m_outputLevel = DEBUG); @@ -95,11 +95,12 @@ Geant4Kernel::Geant4Kernel(LCDD& lcdd_ref) } /// Standard constructor -Geant4Kernel::Geant4Kernel(LCDD& lcdd_ref, Geant4Kernel* m, unsigned long ident) - : Geant4ActionContainer(), m_runManager(0), m_lcdd(lcdd_ref), +Geant4Kernel::Geant4Kernel(Geant4Kernel* m, unsigned long ident) + : Geant4ActionContainer(), m_runManager(0), m_control(0), m_trackMgr(0), m_lcdd(0), m_numThreads(1), m_id(ident), m_master(m), m_shared(0), phase(this) { char text[64]; + m_lcdd = m_master->m_lcdd; m_ident = m_master->m_workers.size(); declareProperty("UI",m_uiName = m_master->m_uiName); declareProperty("OutputLevel", m_outputLevel = m_master->m_outputLevel); @@ -125,9 +126,14 @@ Geant4Kernel::~Geant4Kernel() { destroyPhases(); deletePtr(m_runManager); Geant4ActionContainer::terminate(); - if ( isMaster() ) { - m_lcdd.removeExtension < Geant4Kernel > (false); - m_lcdd.destroyInstance(); + if ( m_lcdd && isMaster() ) { + try { + m_lcdd->removeExtension < Geant4Kernel > (false); + m_lcdd->destroyInstance(); + m_lcdd = 0; + } + catch(...) { + } } InstanceCount::decrement(this); } @@ -144,18 +150,6 @@ Geant4Kernel& Geant4Kernel::instance(LCDD& lcdd) { return *(s_main_instance.get()); } -#if 0 -/// Accessof the Geant4Kernel object from the LCDD reference extension (if present and registered) -Geant4Kernel& Geant4Kernel::access(LCDD& lcdd) { - Geant4Kernel* kernel = lcdd.extension<Geant4Kernel>(); - if (!kernel) { - throw runtime_error(format("Geant4Kernel", "DDG4: The LCDD object has no registered " - "extension of type Geant4Kernel [No-Extension]")); - } - return *kernel; -} -#endif - /// Access thread identifier unsigned long int Geant4Kernel::thread_self() { unsigned long int thr_id = (unsigned long int)::pthread_self(); @@ -166,7 +160,7 @@ unsigned long int Geant4Kernel::thread_self() { Geant4Kernel& Geant4Kernel::createWorker() { if ( isMaster() ) { unsigned long identifier = thread_self(); - Geant4Kernel* w = new Geant4Kernel(m_lcdd, this, identifier); + Geant4Kernel* w = new Geant4Kernel(this, identifier); m_workers[identifier] = w; printout(INFO,"Geant4Kernel","+++ Created worker instance id=%ul",identifier); return *w; @@ -270,14 +264,14 @@ G4RunManager& Geant4Kernel::runManager() { /// Construct detector geometry using lcdd plugin void Geant4Kernel::loadGeometry(const std::string& compact_file) { char* arg = (char*) compact_file.c_str(); - m_lcdd.apply("DD4hepXMLLoader", 1, &arg); + m_lcdd->apply("DD4hepXMLLoader", 1, &arg); //return *this; } // Utility function to load XML files void Geant4Kernel::loadXML(const char* fname) { const char* args[] = { fname, 0 }; - m_lcdd.apply("DD4hepXMLLoader", 1, (char**) args); + m_lcdd->apply("DD4hepXMLLoader", 1, (char**) args); } int Geant4Kernel::configure() { @@ -306,18 +300,24 @@ int Geant4Kernel::runEvents(int num_events) { return Geant4Exec::run(*this); } -int Geant4Kernel::terminateEx() { - return this->terminate(); -} - int Geant4Kernel::terminate() { + const Geant4Kernel* ptr = s_main_instance.get(); printout(INFO,"Geant4Kernel","++ Terminate Geant4 and delete associated actions."); - Geant4Exec::terminate(*this); + if ( ptr == this ) { + Geant4Exec::terminate(*this); + } destroyPhases(); for_each(m_globalFilters.begin(), m_globalFilters.end(), releaseObjects(m_globalFilters)); for_each(m_globalActions.begin(), m_globalActions.end(), releaseObjects(m_globalActions)); - deletePtr (m_runManager); + if ( ptr == this ) { + deletePtr (m_runManager); + } Geant4ActionContainer::terminate(); + if ( ptr == this && m_lcdd ) { + m_lcdd->removeExtension < Geant4Kernel > (false); + m_lcdd->destroyInstance(); + m_lcdd = 0; + } return 1; } diff --git a/DDG4/src/Geant4ParticleGenerator.cpp b/DDG4/src/Geant4ParticleGenerator.cpp index 6f72ebded10447a8836b47a77737693eeec2f9b0..076e05a29a9546b8008a4472e3151e91b42cef90 100644 --- a/DDG4/src/Geant4ParticleGenerator.cpp +++ b/DDG4/src/Geant4ParticleGenerator.cpp @@ -59,6 +59,33 @@ void Geant4ParticleGenerator::getParticleMultiplicity(int& ) const { void Geant4ParticleGenerator::getVertexPosition(ROOT::Math::XYZVector& ) const { } +/// Print single particle interaction identified by sequence number in primary event +void Geant4ParticleGenerator::printInteraction(size_t which) const { + typedef Geant4PrimaryInteraction::VertexMap _V; + int count = 0; + Geant4Event& evt = context()->event(); + Geant4PrimaryEvent* prim = evt.extension<Geant4PrimaryEvent>(); + + if ( which == LAST_INTERACTION && prim->size() > 0 ) + which = prim->size()-1; + if ( which >= prim->size() ) + except("printInteraction: Bad interaction identifier %d must be [0,%d].", + which, prim->size()); + + Geant4PrimaryInteraction* inter = prim->get(which); + for(_V::const_iterator iv=inter->vertices.begin(); iv!=inter->vertices.end(); ++iv) { + Geant4Vertex* v = (*iv).second; + printM1("+-> Interaction [%d] %.3f GeV %s pos:(%.3f %.3f %.3f)[mm]", + count, m_energy/CLHEP::GeV, m_particleName.c_str(), + v->x/CLHEP::mm, v->y/CLHEP::mm, v->z/CLHEP::mm); + ++count; + for(set<int>::const_iterator i=v->out.begin(); i!=v->out.end(); ++i) { + Geant4ParticleHandle p = inter->particles[*i]; + p.dumpWithVertex(outputLevel()-1,name()," +->"); + } + } +} + /// Callback to generate primary particles void Geant4ParticleGenerator::operator()(G4Event*) { typedef Geant4Particle Particle; @@ -100,6 +127,12 @@ void Geant4ParticleGenerator::operator()(G4Event*) { p->psy = unit_direction.Y()*momentum; p->psz = unit_direction.Z()*momentum; p->mass = m_particle->GetPDGMass(); + p->charge = m_particle->GetPDGCharge(); + p->spin[0] = 0; + p->spin[1] = 0; + p->spin[2] = 0; + p->colorFlow[0] = 0; + p->colorFlow[1] = 0; p->vsx = vtx->x; p->vsy = vtx->y; p->vsz = vtx->z; diff --git a/DDG4/src/Geant4ParticleGun.cpp b/DDG4/src/Geant4ParticleGun.cpp index 40bb01e93b8ac0b2476382db3ccd94166acbd57b..1a25ef212dc7d94ff97432afa9d60a11c47e11a5 100644 --- a/DDG4/src/Geant4ParticleGun.cpp +++ b/DDG4/src/Geant4ParticleGun.cpp @@ -16,41 +16,31 @@ #include "DD4hep/Printout.h" #include "DD4hep/InstanceCount.h" #include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Random.h" #include "DDG4/Geant4Primary.h" #include "DDG4/Geant4ParticleGun.h" #include "DDG4/Geant4InputHandling.h" #include "CLHEP/Units/SystemOfUnits.h" -// Geant4 include files -#include "G4ParticleTable.hh" -#include "G4ParticleDefinition.hh" - // C/C++ include files -#include <stdexcept> #include <limits> -#include <cmath> -using CLHEP::MeV; -using CLHEP::GeV; using namespace std; using namespace DD4hep::Simulation; /// Standard constructor Geant4ParticleGun::Geant4ParticleGun(Geant4Context* ctxt, const string& nam) - : Geant4GeneratorAction(ctxt,nam), m_position(0,0,0), m_direction(1,1,0.3), - m_particle(0), m_shotNo(0) + : Geant4IsotropeGenerator(ctxt,nam), m_shotNo(0) { InstanceCount::increment(this); m_needsControl = true; - declareProperty("particle", m_particleName = "e-"); - declareProperty("energy", m_energy = 50 * CLHEP::MeV); - declareProperty("multiplicity", m_multiplicity = 1); - declareProperty("position", m_position); - declareProperty("direction", m_direction); - declareProperty("isotrop", m_isotrop = false); - declareProperty("Mask", m_mask = 1); - declareProperty("Standalone", m_standalone = true); + declareProperty("isotrop", m_isotrop = false); + declareProperty("Standalone", m_standalone = true); + // Backwards compatibility: Un-capitalize + declareProperty("position", m_position); + declareProperty("direction", m_direction); + declareProperty("energy", m_energy); + declareProperty("particle", m_particleName); + declareProperty("multiplicity", m_multiplicity); } /// Default destructor @@ -60,28 +50,9 @@ Geant4ParticleGun::~Geant4ParticleGun() { /// Callback to generate primary particles void Geant4ParticleGun::operator()(G4Event* event) { - typedef DD4hep::ReferenceBitMask<int> PropertyMask; - if ( m_standalone ) { - generationInitialization(this,context()); - } - - Geant4Event& evt = context()->event(); - Geant4PrimaryEvent* prim = evt.extension<Geant4PrimaryEvent>(); - if (0 == m_particle || m_particle->GetParticleName() != m_particleName.c_str()) { - G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); - m_particle = particleTable->FindParticle(m_particleName); - if (0 == m_particle) { - throw runtime_error("Geant4ParticleGun: Bad particle type:"+m_particleName+"!"); - } - } if ( m_isotrop ) { - Geant4Random& rnd = context()->event().random(); - double phi = 2*M_PI*rnd.rndm(); - double theta = M_PI*rnd.rndm(); - double x1 = std::sin(theta)*std::cos(phi); - double x2 = std::sin(theta)*std::sin(phi); - double x3 = std::cos(theta); - m_direction.SetXYZ(x1,x2,x3); + double mom = 0.0; + this->Geant4IsotropeGenerator::getParticleDirection(0,m_direction,mom); } else { double r = m_direction.R(), eps = numeric_limits<float>::epsilon(); @@ -89,52 +60,18 @@ void Geant4ParticleGun::operator()(G4Event* event) { m_direction.SetXYZ(m_direction.X()/r, m_direction.Y()/r, m_direction.Z()/r); } } + + if ( m_standalone ) { + generationInitialization(this,context()); + } + this->Geant4ParticleGenerator::operator()(event); print("Shoot [%d] %.3f GeV %s pos:(%.3f %.3f %.3f)[mm] dir:(%6.3f %6.3f %6.3f)", m_shotNo, m_energy/CLHEP::GeV, m_particleName.c_str(), - m_position.X(), m_position.Y(), m_position.Z(), + m_position.X()/CLHEP::mm, m_position.Y()/CLHEP::mm, m_position.Z()/CLHEP::mm, m_direction.X(),m_direction.Y(), m_direction.Z()); - Geant4PrimaryInteraction* inter = new Geant4PrimaryInteraction(); - Geant4Vertex* vtx = new Geant4Vertex(); - inter->vertices.insert(make_pair(m_mask,vtx)); - prim->add(m_mask, inter); - vtx->mask = m_mask; - vtx->x = m_position.X(); - vtx->y = m_position.Y(); - vtx->z = m_position.Z(); - for(int i=0; i<m_multiplicity; ++i) { - Geant4ParticleHandle p = new Geant4Particle(i); - p->reason = 0; - p->mask = m_mask; - p->pdgID = m_particle->GetPDGEncoding(); - p->psx = m_direction.X()*m_energy; - p->psy = m_direction.Y()*m_energy; - p->psz = m_direction.Z()*m_energy; - p->time = 0; - p->properTime = 0; - p->vsx = vtx->x; - p->vsy = vtx->y; - p->vsz = vtx->z; - p->vex = vtx->x; - p->vey = vtx->y; - p->vez = vtx->z; - //p->definition = m_particle; - //p->process = 0; - p->spin[0] = 0; - p->spin[1] = 0; - p->spin[2] = 0; - p->colorFlow[0] = 0; - p->colorFlow[0] = 0; - p->mass = m_particle->GetPDGMass(); - p->charge = m_particle->GetPDGCharge(); - PropertyMask status(p->status); - status.set(G4PARTICLE_GEN_STABLE); - vtx->out.insert(p->id); - inter->particles.insert(make_pair(p->id,p)); - p.dumpWithVertex(outputLevel()-1,name(),"+->"); - } + this->Geant4ParticleGenerator::printInteraction(); ++m_shotNo; - if ( m_standalone ) { mergeInteractions(this,context()); generatePrimaries(this,context(),event); diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index 7504b04b4ea7308a2d47e884b61888fb1611aeb6..e355aee936917f82bf17f6f5886d73462fb439bc 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -180,7 +180,8 @@ const Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const s if (i != m_processes.end()) { return (*i).second; } - throw runtime_error(format("Geant4PhysicsList", "Failed to access the physics process '%s' [Unknown-Process]", nam.c_str())); + except("Failed to access the physics process '%s' [Unknown-Process]", nam.c_str()); + throw runtime_error("Failed to access the physics process"); // never called anyway } /// Callback to construct the physics list @@ -196,11 +197,11 @@ void Geant4PhysicsList::constructPhysics(Geant4UserPhysics* physics_pointer) { const PhysicsConstructors::value_type& ctor = *i; G4VPhysicsConstructor* p = PluginService::Create<G4VPhysicsConstructor*>(ctor); if (!p) { - throw runtime_error(format("Geant4PhysicsList", "Failed to create the physics entities " - "for the G4VPhysicsConstructor '%s'", ctor.c_str())); + except("Failed to create the physics entities " + "for the G4VPhysicsConstructor '%s'", ctor.c_str()); } physics_pointer->RegisterPhysics(p); - printout(INFO, "Geant4PhysicsList", "%s> registered Geant4 physics %s", name().c_str(), ctor.c_str()); + info("Registered Geant4 physics %s", ctor.c_str()); } } @@ -215,10 +216,10 @@ void Geant4PhysicsList::constructParticles(Geant4UserPhysics* physics_pointer) { /// Check if we have here a particle group constructor long* result = (long*) PluginService::Create<long>(ctor); if (!result || *result != 1L) { - throw runtime_error(format("Geant4PhysicsList", "Failed to create particle type '%s' result=%d", ctor.c_str(), result)); + except("Failed to create particle type '%s' result=%d", ctor.c_str(), result); } } - printout(INFO, "Geant4PhysicsList", "%s> constructed Geant4 particle %s", name().c_str(), ctor.c_str()); + info("Constructed Geant4 particle %s",ctor.c_str()); } } @@ -231,8 +232,7 @@ void Geant4PhysicsList::constructProcesses(Geant4UserPhysics* physics_pointer) { vector<G4ParticleDefinition*> defs; _findDef(part_name, defs); if (defs.empty()) { - throw runtime_error(format("Geant4PhysicsList", "Particle:%s " - "Cannot find the corresponding entry in the particle table.", part_name.c_str())); + except("Particle:%s Cannot find the corresponding entry in the particle table.", part_name.c_str()); } for (vector<G4ParticleDefinition*>::const_iterator id = defs.begin(); id != defs.end(); ++id) { G4ParticleDefinition* particle = *id; @@ -241,13 +241,13 @@ void Geant4PhysicsList::constructProcesses(Geant4UserPhysics* physics_pointer) { const Process& p = (*ip); G4VProcess* g4 = PluginService::Create<G4VProcess*>(p.name); if (!g4) { // Error no factory for this process - throw runtime_error(format("Geant4PhysicsList", "Particle:%s -> [%s] " - "Cannot create physics process %s", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str())); + except("Particle:%s -> [%s] Cannot create physics process %s", + part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str()); } mgr->AddProcess(g4, p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); - printout(INFO, "Geant4PhysicsList", "Particle:%s -> [%s] " - "added process %s with flags (%d,%d,%d)", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), - p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); + info("Particle:%s -> [%s] added process %s with flags (%d,%d,%d)", + part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), + p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); } } } @@ -300,7 +300,7 @@ void Geant4PhysicsListActionSequence::adopt(Geant4PhysicsList* action) { m_actors.add(action); return; } - throw runtime_error("Geant4EventActionSequence: Attempt to add invalid actor!"); + except("Geant4EventActionSequence: Attempt to add invalid actor!"); } /// begin-of-event callback @@ -327,7 +327,7 @@ void Geant4PhysicsListActionSequence::constructDecays(Geant4UserPhysics* physics G4ParticleTable::G4PTblDicIterator* iter = pt->GetIterator(); // Add Decay Process G4Decay* decay = new G4Decay(); - printout(INFO, "Geant4PhysicsList", "%s> constructDecays %p", name().c_str(), physics_pointer); + info("ConstructDecays %p",physics_pointer); iter->reset(); while ((*iter)()) { G4ParticleDefinition* p = iter->value(); diff --git a/GaudiPluginService/interface/DD4hep.cpp b/GaudiPluginService/interface/DD4hep.cpp index be2f89996642961381b983c7fae2fb2fbf42d758..535548a034430dac4b4911e6242e527e606deb62 100644 --- a/GaudiPluginService/interface/DD4hep.cpp +++ b/GaudiPluginService/interface/DD4hep.cpp @@ -11,6 +11,13 @@ // Author : M.Frank // //========================================================================== +#include <string> +#include <sstream> +#include <map> +#include <set> +#include <typeinfo> +#include <utility> + #define private public // This define will give us a version of the gaudi plugin manager, // which will NOT clash with Gaudi! It of course has a correspondance in the diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index 37e86396e92c58c12d5acac087d07d727e1c8171..2737c07d6f98a1a366ff1788b68bbf7ae133dd7c 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -12,7 +12,8 @@ #================================================================================= cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) ###set(DD4HEP_DEBUG_CMAKE 1) -message ( STATUS "INCLUDING DD4hepBuild...." ) +message ( STATUS "INCLUDING DD4hepBuild.... c++11:${DD4HEP_USE_CXX11} c++14:${DD4HEP_USE_CXX14}" ) + include ( CMakeParseArguments ) set ( DD4hepBuild_included ON ) ####set ( DD4HEP_DEBUG_CMAKE ON ) @@ -22,6 +23,20 @@ macro(dd4hep_to_parent_scope val) set ( ${val} ${${val}} PARENT_SCOPE ) endmacro(dd4hep_to_parent_scope) +macro(dd4hep_set_compiler_flags) + if ( DD4HEP_USE_CXX14 ) + set ( CMAKE_CXX_FLAGS "-std=c++14 -ftls-model=global-dynamic -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") + set ( DD4HEP_USE_CXX11 OFF ) + set ( DD4HEP_USE_STDCXX 14 ) + add_definitions(-DDD4HEP_USE_STDCXX=14) + elseif ( DD4HEP_USE_CXX11 ) + set ( CMAKE_CXX_FLAGS "-std=c++11 -ftls-model=global-dynamic -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") + set ( DD4HEP_USE_STDCXX 11 ) + add_definitions(-DDD4HEP_USE_STDCXX=11) + else() + set( CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") + endif() +endmacro(dd4hep_set_compiler_flags) #--------------------------------------------------------------------------------------------------- # dd4hep_debug # @@ -172,6 +187,7 @@ function( dd4hep_print_cmake_options ) dd4hep_print ( "| or LCIO in CMAKE_MODULE_PATH |") dd4hep_print ( "| DD4HEP_USE_GEAR Build gear wrapper for backward compatibility OFF |") dd4hep_print ( "| DD4HEP_USE_CXX11 Build DD4hep using c++11 OFF |") + dd4hep_print ( "| DD4HEP_USE_CXX14 Build DD4hep using c++14 OFF |") dd4hep_print ( "| BUILD_TESTING Enable and build tests ON |") dd4hep_print ( "| DD4HEP_USE_PYROOT Enable 'Detector Builders' based on PyROOT OFF |") dd4hep_print ( "+---------------------------------------------------------------------------+") @@ -1132,12 +1148,34 @@ function( dd4hep_add_dictionary dictionary ) if ( "${enabled}" STREQUAL "OFF" ) dd4hep_skipmsg ( "${tag} DISBALED -- package is not built!" ) else() - cmake_parse_arguments(ARG "" "" "SOURCES;EXCLUDE;LINKDEF;OPTIONS" ${ARGN} ) + cmake_parse_arguments(ARG "" "" "SOURCES;EXCLUDE;LINKDEF;OPTIONS;OPTIONAL" ${ARGN} ) dd4hep_print ( "|++> ${tag} Building dictionary ..." ) if("${ARG_LINKDEF}" STREQUAL "") set(ARG_LINKDEF "${CMAKE_SOURCE_DIR}/DDCore/include/ROOT/LinkDef.h") endif() # + if ( NOT "${ARG_OPTIONAL}" STREQUAL "" ) + dd4hep_handle_optional_sources ( ${tag} "${ARG_OPTIONAL}" optional_missing optional_uses optional_sources ) + endif() + # + if ( NOT "${optional_missing}" STREQUAL "" ) + dd4hep_print ( "|++> ${tag} SKIPPED. Missing optional dependencies: ${optional_missing}" ) + else() + set ( uses ${ARG_USES} ${optional_uses} ) + dd4hep_use_package ( ${tag} PACKAGE LOCAL + USES "${uses}" + OPTIONAL "${ARG_OPTIONAL}" ) + endif() + if ( NOT "${LOCAL_MISSING}" STREQUAL "" ) + dd4hep_print ( "|++> ${tag} skipped. Missing dependency: ${missing} --> FATAL ERROR. Build should fail!" ) + endif() + # + get_property(incs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_INCLUDE_DIRS) + get_property(defs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS) + get_property(opts DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_OPTIONS) + dd4hep_make_unique_list( incs VALUES ${LOCAL_INCLUDE_DIRS} ${incs} ) + dd4hep_make_unique_list( defs VALUES ${LOCAL_DEFINITIONS} ${defs} ) + # file( GLOB headers ${ARG_SOURCES} ) file( GLOB excl_headers ${ARG_EXCLUDE} ) foreach( f ${excl_headers} ) @@ -1145,10 +1183,6 @@ function( dd4hep_add_dictionary dictionary ) dd4hep_print ( "|++ exclude: ${f}" ) endforeach() # - get_property(incs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_INCLUDE_DIRS) - get_property(defs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS) - get_property(opts DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_OPTIONS) - # set ( inc_dirs -I${CMAKE_CURRENT_SOURCE_DIR}/include ) foreach ( inc ${incs} ) file ( GLOB inc ${inc} ) @@ -1176,8 +1210,8 @@ function( dd4hep_add_dictionary dictionary ) if ( ${ROOT_VERSION_MAJOR} GREATER 5 ) ## ${CMAKE_CURRENT_BINARY_DIR}/../lib/${dictionary}_rdict.pcm add_custom_command(OUTPUT ${dictionary}.cxx - COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx - -s ${CMAKE_CURRENT_BINARY_DIR}/../lib/${dictionary} -c -p ${ARG_OPTIONS} ${comp_defs} ${inc_dirs} ${headers} ${linkdefs} + COMMAND ${ROOTCLING_EXECUTABLE} -cint -f ${dictionary}.cxx + -s ${CMAKE_CURRENT_BINARY_DIR}/../lib/${dictionary} -c -p ${ARG_OPTIONS} ${comp_defs} -std=c++${DD4HEP_USE_STDCXX} ${inc_dirs} ${headers} ${linkdefs} DEPENDS ${headers} ${linkdefs} ) # Install the binary to the destination directory #set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/../lib/${dictionary}_rdict.pcm PROPERTIES GENERATED TRUE ) diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in index a5f5b5db0412b451c4c23fa8c90054bc6b49fa4d..612fe7d14b9ebac689035653fce253d6254f7ed7 100644 --- a/cmake/DD4hepConfig.cmake.in +++ b/cmake/DD4hepConfig.cmake.in @@ -20,6 +20,7 @@ set ( DD4HEP_USE_BOOST "@DD4HEP_USE_BOOST@" ) set ( DD4HEP_USE_GEANT4 "@DD4HEP_USE_GEANT4@" ) set ( DD4HEP_USE_XERCESC "@DD4HEP_USE_XERCESC@" ) set ( DD4HEP_USE_CXX11 "@DD4HEP_USE_CXX11@" ) +set ( DD4HEP_USE_CXX14 "@DD4HEP_USE_CXX14@" ) set ( Geant4_DIR "@Geant4_DIR@" ) set ( GEANT4_USE_CLHEP "@GEANT4_USE_CLHEP@" ) @@ -88,7 +89,10 @@ endif() INCLUDE( ${DD4hep_DIR}/cmake/DD4hep_XML_setup.cmake ) # ----------------------------------------- -if( @DD4HEP_USE_CXX11@ ) +if( @DD4HEP_USE_CXX14@ ) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" ) + ADD_DEFINITIONs(-DDD4HEP_USE_CXX14) +elif( @DD4HEP_USE_CXX11@ ) SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" ) ADD_DEFINITIONs(-DDD4HEP_USE_CXX11) else() diff --git a/cmake/FindPYTHON.cmake b/cmake/FindPYTHON.cmake index dca408fb696ddd67e674a17b529b99ccd393ef8a..0052bc7e4c5d8e0af9c0ac865274bb0611b29540 100644 --- a/cmake/FindPYTHON.cmake +++ b/cmake/FindPYTHON.cmake @@ -25,8 +25,8 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. include ( FindPackageHandleStandardArgs ) -find_package(PythonInterp 2.7 REQUIRED) -find_package(PythonLibs 2.7 REQUIRED) +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) if (PYTHONLIBS_FOUND) message(STATUS "DEBUG: ******** PYTHON: PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}") diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index a799a11089576ee9d45399167d5e20c5a1131597..5b5715280a708e4bf37e9dd2d6b9c8bdb240fff9 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -69,12 +69,21 @@ endif() ##message(WARNING "ROOT ${ROOT_VERSION_MAJOR} ${ROOT_VERSION_MINOR} ${ROOT_VERSION_PATCH}") if ( ${ROOT_VERSION_MAJOR} LESS 6 ) set ( ROOT_LIBRARIES ${ROOT_LIBRARIES} -lReflex ) +else() + find_program(ROOTCLING_EXECUTABLE rootcling PATHS ${ROOTSYS}/bin $ENV{ROOTSYS}/bin) + #string(FIND "${CMAKE_CXX_FLAGS}" "-std=c++11" dd4hep_use_cxx11 ) + #string(FIND "${CMAKE_CXX_FLAGS}" "-std=c++14" dd4hep_use_cxx14 ) + #if ( ${dd4hep_use_cxx11} LESS 0 AND ${dd4hep_use_cxx14} LESS 0 ) + # message ( STATUS "*** FindROOT: ROOT version 6 --> Adding C++11 compile flag...") + # set ( CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}" ) + #endif() endif() + if(ROOT_FIND_COMPONENTS) message( STATUS "ROOT[${ROOT_VERSION_STRING}]: Looking for Components: ${ROOT_FIND_COMPONENTS}" ) foreach(comp ${ROOT_FIND_COMPONENTS}) if ( "${comp}" STREQUAL "TEve" ) - set(ROOT_LIBRARIES ${ROOT_LIBRARIES} ${ROOT_EVE_LIBRARIES} FTGL ) + set(ROOT_LIBRARIES ${ROOT_LIBRARIES} ${ROOT_EVE_LIBRARIES} FTGL GLEW) else() set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -l${comp} ) endif() diff --git a/cmake/run_test_package.sh b/cmake/run_test_package.sh index 9ba93c42a8227e23dff659db69ae1716820899fe..e730b666eb0bde7cf855494ccea946562295a8b0 100755 --- a/cmake/run_test_package.sh +++ b/cmake/run_test_package.sh @@ -1,5 +1,4 @@ #!/bin/bash - # # Simple script to run DD4hep tests # - sources this${PackageName}.sh first and then @@ -24,4 +23,4 @@ done #echo " #### LD_LIBRARY_PATH = : ${LD_LIBRARY_PATH}" echo " ### running test : '${command} ${theargs}'" -${command} ${theargs} +exec ${command} ${theargs} diff --git a/doc/CompileAllOptionPermutations.sh b/doc/CompileAllOptionPermutations.sh index a9115964a96f37598740258fbdaec378386a3db0..8c7d604bbaa1778b6e408c609817e3d9f44848e4 100755 --- a/doc/CompileAllOptionPermutations.sh +++ b/doc/CompileAllOptionPermutations.sh @@ -52,21 +52,22 @@ parse_command_line_args() } #cat ${ROOTSYS}/bin/thisroot.sh; # -LINE="===================================================================================================" +LINE="==================================================================================================="; +BARS="===== "; # make_output() { echo "${LINE}"; - echo "${LINE}"; - echo "=============================== `pwd` "; - echo "${LINE}"; - echo "${LINE}"; + echo "${BARS}"; + echo "=====>> `pwd` "; if test -n "${1}"; then echo " +++++ ${1}"; fi; if test -n "${2}"; then echo " +++++ ${2}"; fi; + echo "${BARS}"; + echo "${LINE}"; } make_opt() @@ -90,16 +91,21 @@ make_build() fi make install VERBOSE=1 -j 4; if [ $? -ne 0 ]; then - make_output "DANGER WILL ROBINSON DANGER!" "++++ Failed BUILD:" + make_output "DANGER WILL ROBINSON DANGER!" "++++ Failed BUILD!" echo ${CMD}; exit 1 fi; make test; if [ $? -ne 0 ]; then - make_output "DANGER WILL ROBINSON DANGER!" "++++ Failed TESTS:" + make_output "DANGER WILL ROBINSON DANGER!" "++++ Failed TESTS!" echo ${CMD}; - #exit 1 + exit 1 fi; + echo "${LINE}"; + echo "${BARS}"; + echo "=======>> Successfully build configuration `pwd` "; + echo "${BARS}"; + echo "${LINE}"; } build_all() diff --git a/doc/release.notes b/doc/release.notes index f46c765f8a874415a6a8982152f970f895a24e00..589523993128c4f5c57f1ccc2951a04cffad313e 100644 --- a/doc/release.notes +++ b/doc/release.notes @@ -3,6 +3,16 @@ DD4hep ---- Release Notes ================================= +2015-12-01 M.Frank + DDG4 + - Remove some of the compilation warnings + - Remove energy cut in sensitive detectors + If you though need, use a Geant4Filter to mask the action processing + examples/CLICSiD + - Add a few tests for materialscan and simulation setups using XML or CINT. + examples/ClientTests + - Add a few tests for materialscan and simulation + 2015-11-24 M.Frank DDG4 - Implementation of multi-threading mode. diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt index 88c947029b6e2f81022535b03d5efd11785eae2b..ad71fa533a9782e4e1133cd40feb15687618a412 100644 --- a/examples/CLICSiD/CMakeLists.txt +++ b/examples/CLICSiD/CMakeLists.txt @@ -18,14 +18,81 @@ dd4hep_package ( CLICSiD MAJOR 0 MINOR 0 PATCH 1 USES [ROOT REQUIRED COMPONENTS Geom] [DD4hep REQUIRED COMPONENTS DDCore] ) -dd4hep_install_dir( compact DESTINATION examples/CLICSiD ) +dd4hep_install_dir( compact scripts sim DESTINATION ${DD4hep_DIR}/examples/CLICSiD ) +#-------------------------------------------------------------------------- +dd4hep_add_executable(CLICSiDXML SOURCES scripts/CLICSiDXML.C + USES [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 ) +#-------------------------------------------------------------------------- +dd4hep_add_executable(CLICSiDAClick SOURCES scripts/CLICSiDAClick.C + USES [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 ) #---Testing------------------------------------------------------------------------- dd4hep_configure_scripts ( CLICSiD DEFAULT_SETUP WITH_TESTS ) #----- Tests for CLICSid: here we simply require that at least 100 volumes have been converted foreach ( typ lcdd gdml vis ) - dd4hep_add_test_reg ( "test_converter_CLICSiD_${typ}" + dd4hep_add_test_reg ( "test_CLICSiD_converter_${typ}" COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" - EXEC_ARGS geoConverter -compact2${typ} -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml -output file:CLICSiD.${typ} + EXEC_ARGS geoConverter -compact2${typ} + -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + -output file:CLICSiD.${typ} REGEX_PASS " Handled [1-9][0-9][0-9]+ volumes" ) endforeach() +# +# ROOT Geometry overlap checks +dd4hep_add_test_reg( test_CLICSiD_check_geometry + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/python/checkGeometry.py + --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + # This takes too long --full=true --ntracks=10 --option=o --vx=0 --vy=0 --vz=0 + REGEX_PASS " Execution finished..." ) +# +# ROOT Geometry overlap checks +dd4hep_add_test_reg( test_CLICSiD_check_overlaps + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/python/checkOverlaps.py + --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + --tolerance=0.1 + REGEX_PASS " Execution finished..." ) +# +if (DD4HEP_USE_GEANT4) + # + # Basic DDG4 component/unit tests + foreach(script testDDPython CLICMagField CLICPhysics CLICRandom CLICSiDScan) + dd4hep_add_test_reg( test_CLICSiD_DDG4_${script} + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script}.py + REQUIRES DDG4 Geant4 + REGEX_PASS "TEST_PASSED" + REGEX_FAIL "Exception;EXCEPTION;ERROR" ) + endforeach(script) + # + # Material scan + dd4hep_add_test_reg( test_CLICSiD_DDG4_g4material_scan + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/python/g4MaterialScan.py + --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + "--position=0,0,0" "--direction=0,1,0" + REGEX_PASS " Terminate Geant4 and delete associated actions." ) + # + # Geant4 simulations with initialization using AClick and XMl + foreach(script CLICSiDXML CLICSiDAClick) + # + # Build AClick from the source file + if ( ${ROOT_VERSION_MAJOR} LESS 6 ) + dd4hep_add_test_reg( test_CLICSiD_DDG4_${script}_as_AClick + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS root.exe -b -x -n -q -l "${CMAKE_INSTALL_PREFIX}/examples/DDG4/examples/run.C(\"${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script}\")" + REQUIRES DDG4 Geant4 + REGEX_PASS "UserEvent_1 INFO Geant4TestEventAction> calling end.event_id=9" + REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) + endif() + # + # Execute identical source linked executable + dd4hep_add_test_reg( test_CLICSiD_DDG4_${script}_as_exe + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS ${script} + REQUIRES DDG4 Geant4 + REGEX_PASS "UserEvent_1 INFO Geant4TestEventAction> calling end.event_id=9" + REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) + endforeach(script) +endif() diff --git a/DDG4/examples/CLICMagField.py b/examples/CLICSiD/scripts/CLICMagField.py similarity index 89% rename from DDG4/examples/CLICMagField.py rename to examples/CLICSiD/scripts/CLICMagField.py index 0880dbf3ff7c88809ad60f29a00a534926990c18..0798b26c1badc9d5a012e3f0e3e99564e9644596 100644 --- a/DDG4/examples/CLICMagField.py +++ b/examples/CLICSiD/scripts/CLICMagField.py @@ -9,6 +9,5 @@ if __name__ == "__main__": import CLICSid sid = CLICSid.CLICSid().loadGeometry() # <<-- See this function to know how it's done.... - sid.setupField(quiet=false) + sid.setupField(quiet=False) sid.test_run() - diff --git a/DDG4/examples/CLICPhysics.py b/examples/CLICSiD/scripts/CLICPhysics.py similarity index 100% rename from DDG4/examples/CLICPhysics.py rename to examples/CLICSiD/scripts/CLICPhysics.py diff --git a/DDG4/examples/CLICRandom.py b/examples/CLICSiD/scripts/CLICRandom.py similarity index 100% rename from DDG4/examples/CLICRandom.py rename to examples/CLICSiD/scripts/CLICRandom.py diff --git a/DDG4/examples/CLICSidAClick.C b/examples/CLICSiD/scripts/CLICSiDAClick.C similarity index 76% rename from DDG4/examples/CLICSidAClick.C rename to examples/CLICSiD/scripts/CLICSiDAClick.C index ff2a7f3242bf413c6ba470fe07f7f84e3ccc5ccd..9506748ecc063b2a290728b72ebd93e842e760aa 100644 --- a/DDG4/examples/CLICSidAClick.C +++ b/examples/CLICSiD/scripts/CLICSiDAClick.C @@ -1,4 +1,4 @@ -// $Id: Geant4Data.h 513 2013-04-05 14:31:53Z gaede $ +// $Id$ //==================================================================== // AIDA Detector description implementation //-------------------------------------------------------------------- @@ -21,7 +21,8 @@ #include "DDG4/Geant4Config.h" #include "DDG4/Geant4TestActions.h" - +#include "CLHEP/Units/SystemOfUnits.h" +#include "TSystem.h" #include <iostream> using namespace std; @@ -33,37 +34,38 @@ using namespace DD4hep::Simulation::Setup; SensitiveSeq::handled_type* setupDetector(Geant4Kernel& kernel, const std::string& name) { SensitiveSeq sd = SensitiveSeq(kernel,name); Sensitive sens = Sensitive(kernel,"Geant4TestSensitive/"+name+"Handler",name); - sens["OutputLevel"] = 4; + sens["OutputLevel"] = 2; sd->adopt(sens); sens = Sensitive(kernel,"Geant4TestSensitive/"+name+"Monitor",name); sd->adopt(sens); return sd; } -void setupG4_CINT() { - //Geant4Kernel& kernel = Geant4Kernel::instance(Geometry::LCDD::getInstance()); - Geant4Kernel kernel(Geometry::LCDD::getInstance()); +int setupG4_CINT(bool interactive) { + Geant4Kernel& kernel = Geant4Kernel::instance(Geometry::LCDD::getInstance()); string install_dir = getenv("DD4hepINSTALL"); string ddg4_examples = install_dir+"/examples/DDG4/examples"; Phase p; kernel.loadGeometry(("file:"+install_dir+"/examples/CLICSiD/compact/compact.xml").c_str()); - kernel.loadXML(("file:"+ddg4_examples+"/DDG4_field.xml").c_str()); + kernel.loadXML(("file:"+install_dir+"/examples/CLICSiD/sim/field.xml").c_str()); - kernel.property("UI") = "UI"; - setPrintLevel(DEBUG); + if ( interactive ) { + kernel.property("UI") = "UI"; + setPrintLevel(DEBUG); - Action ui(kernel,"Geant4UIManager/UI"); - ui["HaveVIS"] = true; - ui["HaveUI"] = true; - ui["SessionType"] = "csh"; - kernel.registerGlobalAction(ui); + Action ui(kernel,"Geant4UIManager/UI"); + ui["HaveVIS"] = true; + ui["HaveUI"] = true; + ui["SessionType"] = "csh"; + kernel.registerGlobalAction(ui); + } GenAction gun(kernel,"Geant4ParticleGun/Gun"); - gun["energy"] = 25*GeV; - gun["particle"] = "e-"; + gun["energy"] = 10*CLHEP::GeV; + gun["particle"] = "e-"; gun["multiplicity"] = 1; - gun["OutputLevel"] = 5; + gun["OutputLevel"] = 3; kernel.generatorAction().adopt(gun); RunAction run_init(kernel,"Geant4TestRunAction/RunInit"); @@ -75,7 +77,7 @@ void setupG4_CINT() { EventAction evt_1(kernel,"Geant4TestEventAction/UserEvent_1"); evt_1["Property_int"] = 12345; evt_1["Property_string"] = "Events"; - evt_1["OutputLevel"] = 5; + evt_1["OutputLevel"] = 3; kernel.eventAction().adopt(evt_1); p = kernel.addPhase<const G4Run*>("BeginRun"); @@ -109,8 +111,15 @@ void setupG4_CINT() { kernel.run(); std::cout << "Successfully executed application .... " << std::endl; kernel.terminate(); + std::cout << "TEST_PASSED" << std::endl; + return 0; } -void CLICSidAClick() { - setupG4_CINT(); +#if defined(G__DICTIONARY) || defined(__CLING__) || defined(__CINT__) || defined(__MAKECINT__) // CINT script +int CLICSiDAClick() +#else +int main(int, char**) // Main program if linked standalone +#endif +{ + return setupG4_CINT(false); } diff --git a/examples/CLICSiD/scripts/CLICSiDScan.py b/examples/CLICSiD/scripts/CLICSiDScan.py new file mode 100644 index 0000000000000000000000000000000000000000..c627ae9704b758e312fde971ff11c7403e4c0dc4 --- /dev/null +++ b/examples/CLICSiD/scripts/CLICSiDScan.py @@ -0,0 +1,47 @@ +""" + + Perform a material scan using Geant4 shotting geantinos + + @author M.Frank + @version 1.0 + +""" +def run(): + import os, sys, DDG4, SystemOfUnits + kernel = DDG4.Kernel() + install_dir = os.environ['DD4hepINSTALL'] + kernel.loadGeometry("file:"+install_dir+"/DDDetectors/compact/SiD.xml") + DDG4.Core.setPrintFormat("%-32s %6s %s") + geant4 = DDG4.Geant4(kernel) + # Configure UI + geant4.setupCshUI(ui=None) + gun = geant4.setupGun("Gun", + Standalone=True, + particle='geantino', + energy=20*SystemOfUnits.GeV, + position=(0,0,0), + multiplicity=1, + isotrop=False ) + scan = DDG4.SteppingAction(kernel,'Geant4MaterialScanner/MaterialScan') + kernel.steppingAction().adopt(scan) + + # Now build the physics list: + phys = geant4.setupPhysics('QGSP_BERT') + kernel.configure() + kernel.initialize() + kernel.NumEvents = 1 + + # 3 shots in different directions: + gun.direction = (0,1,0) + kernel.run() + gun.direction = (1,0,0) + kernel.run() + gun.direction = (1,1,1) + kernel.run() + + kernel.terminate() + print 'End of run. Terminating .......' + print 'TEST_PASSED' + +if __name__ == "__main__": + run() diff --git a/DDG4/examples/CLICSidXML.C b/examples/CLICSiD/scripts/CLICSiDXML.C similarity index 59% rename from DDG4/examples/CLICSidXML.C rename to examples/CLICSiD/scripts/CLICSiDXML.C index c9803c453a375f3baee5199f25209a2a81e5fa38..bf0c580f84b0b7f4535bcfc1cd78b0053b2aed31 100644 --- a/DDG4/examples/CLICSidXML.C +++ b/examples/CLICSiD/scripts/CLICSiDXML.C @@ -1,4 +1,4 @@ -// $Id: Geant4Data.h 513 2013-04-05 14:31:53Z gaede $ +// $Id$ //==================================================================== // AIDA Detector description implementation //-------------------------------------------------------------------- @@ -22,29 +22,34 @@ #include "DDG4/Geant4Config.h" #include <iostream> +using namespace std; using namespace DD4hep::Simulation::Setup; -void setupG4_XML() { - std::string prefix = "file:../DD4hep"; +int setupG4_XML(bool interactive) { + string install_dir = getenv("DD4hepINSTALL"); + string prefix = "file:"+install_dir+"/examples/"; Kernel& kernel = Kernel::instance(Kernel::LCDD::getInstance()); - kernel.loadGeometry((prefix+"/examples/CLICSiD/compact/compact.xml").c_str()); - kernel.loadXML((prefix+"/examples/DDG4/examples/DDG4_field.xml").c_str()); - kernel.loadXML((prefix+"/examples/DDG4/examples/sequences.xml").c_str()); - kernel.loadXML((prefix+"/examples/DDG4/examples/physics.xml").c_str()); - kernel.property("UI") = "UI"; + kernel.loadGeometry((prefix+"CLICSiD/compact/compact.xml").c_str()); + kernel.loadXML((prefix+"CLICSiD/sim/field.xml").c_str()); + kernel.loadXML((prefix+"CLICSiD/sim/sequences.xml").c_str()); + kernel.loadXML((prefix+"CLICSiD/sim/physics.xml").c_str()); + if ( interactive ) { + kernel.property("UI") = "UI"; + } kernel.configure(); kernel.initialize(); kernel.run(); - std::cout << "Successfully executed application .... " << std::endl; + cout << "Successfully executed application .... " << endl; kernel.terminate(); + cout << "TEST_PASSED" << endl; + return 0; } -#if defined(G__DICTIONARY) || defined(__CINT__) || defined(__MAKECINT__) // Cint script -int CLICSidXML() +#if defined(G__DICTIONARY) || defined(__CLING__) || defined(__CINT__) || defined(__MAKECINT__) // CINT script +int CLICSiDXML() #else int main(int, char**) // Main program if linked standalone #endif { - setupG4_XML(); - return 1; + return setupG4_XML(false); } diff --git a/DDG4/examples/CLICSid.py b/examples/CLICSiD/scripts/CLICSid.py similarity index 98% rename from DDG4/examples/CLICSid.py rename to examples/CLICSiD/scripts/CLICSid.py index e581d9fd36b146419a8d8c0b58b3410d43facbf9..4d949735d4393de9ff4257ee75b02e2fb3e1c3d6 100644 --- a/DDG4/examples/CLICSid.py +++ b/examples/CLICSiD/scripts/CLICSid.py @@ -75,4 +75,5 @@ class CLICSid: self.kernel.NumEvents = 0 self.kernel.run() self.kernel.terminate() + print '+++++ All Done....\n\nTEST_PASSED' sys.exit(0) diff --git a/DDG4/examples/testDDPython.py b/examples/CLICSiD/scripts/testDDPython.py similarity index 94% rename from DDG4/examples/testDDPython.py rename to examples/CLICSiD/scripts/testDDPython.py index 09de2e3ee758ad1e21e4c7ddb63db986cce66c7d..0d382fe87d9abd6f77e0e9fff6be303796ec46b8 100644 --- a/DDG4/examples/testDDPython.py +++ b/examples/CLICSiD/scripts/testDDPython.py @@ -21,7 +21,7 @@ class a_class: return 1 def fcn_except(self,args,aa): print 'Hello world from member function fcn1 a1=',args,' a2=',aa - raise RuntimeError('Exception from python test object a_class') + raise RuntimeError('Except from python test object a_class') return 6 @@ -61,6 +61,7 @@ except: traceback.print_exc() print '\n' print '+++++ All Done....\n\n' +print 'TEST_PASSED' #py.instance().prompt() diff --git a/DDG4/examples/DDG4_field.xml b/examples/CLICSiD/sim/field.xml similarity index 100% rename from DDG4/examples/DDG4_field.xml rename to examples/CLICSiD/sim/field.xml diff --git a/DDG4/examples/physics.xml b/examples/CLICSiD/sim/physics.xml similarity index 100% rename from DDG4/examples/physics.xml rename to examples/CLICSiD/sim/physics.xml diff --git a/DDG4/examples/sequences.xml b/examples/CLICSiD/sim/sequences.xml similarity index 98% rename from DDG4/examples/sequences.xml rename to examples/CLICSiD/sim/sequences.xml index 9b455edcef3e9e667063bb60a9767800fbf76841..139e852c7bd2f8bc0e566db1b6f1f33c4194bfd1 100644 --- a/DDG4/examples/sequences.xml +++ b/examples/CLICSiD/sim/sequences.xml @@ -12,7 +12,7 @@ To run batch: set UI="" --> - <kernel UI="UI" NumEvents="5"/> + <kernel UI="" NumEvents="10"/> <!-- List of globally known actions. These actions will be registered with the Geant4Kernel object and may be retrieved by there using the action name. @@ -60,16 +60,16 @@ <phase type="RunAction/begin"> <action name="RunInit"/> <action name="Geant4TestRunAction/UserRunInit"> - <properties Conrol="true" + <properties Control="true" Property_int="1234" Property_double="5e15" Property_string="'Hello_2'"/> </action> </phase> - <phase type="EventAction/begin"> + <phase type="EventAction/end"> <action name="UserEvent_2"/> </phase> - <phase type="EventAction/end"> + <phase type="EventAction/begin"> <action name="UserEvent_2"/> </phase> </phases> @@ -107,7 +107,8 @@ <properties Control="true"/> <action name="Geant4TestEventAction/UserEvent_1"> <properties Control="true" - Property_int="01234" + OutputLevel="3" + Property_int="901234" Property_double="1e11" Property_string="'Hello_1'"/> </action> @@ -124,6 +125,7 @@ <sequence name="Geant4GeneratorActionSequence/GeneratorAction"> <action name="Geant4ParticleGun/Gun"> <properties Control="true" + OutputLevel="3" energy="500*MeV" particle="'e-'" multiplicity="1" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 33cc7a0a62ea7e8e89476d8c84fde8cba5b5804b..6ddbd107502d38f1cf7c11467d56a2192b75481e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,6 +29,7 @@ find_package ( DD4hep REQUIRED ) include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) # find_package ( ROOT REQUIRED COMPONENTS Geom GenVector ) +dd4hep_set_compiler_flags() # dd4hep_configure_output() dd4hep_package ( DD4hepExample MAJOR 0 MINOR 0 PATCH 1 diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index e055f108a58c1a0955b1e1f77f0f10a9bf7ea04c..049925a80ab13065e30a526c3e5d7e340670348d 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -23,20 +23,65 @@ dd4hep_package (ClientTests MAJOR 0 MINOR 0 PATCH 1 dd4hep_add_plugin( ClientTests SOURCES src/*.cpp ) dd4hep_install_dir( compact scripts DESTINATION ${DD4hep_DIR}/examples/ClientTests ) #-------------------------------------------------------------------------- -dd4hep_configure_scripts( ClientTests DEFAULT_SETUP WITH_TESTS) +#-------------------------------------------------------------------------- +dd4hep_configure_scripts( ClientTests DEFAULT_SETUP WITH_TESTS) #--- Testing ------------------------------------------------------------ +# +# +# foreach (test Assemblies BoxTrafos IronCylinder LheD_tracker MagnetFields MaterialTester MiniTel SectorBarrelCalorimeter SiliconBlock NestedSimple NestedDetectors ) + # Test format conversions foreach( type lcdd gdml vis ) - dd4hep_add_test_reg( ClientTests_converter_${type}_${test} + dd4hep_add_test_reg( ClientTests_${test}_converter_${type} COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS geoConverter -compact2${type} -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml -output file:${test}.${type} REGEX_PASS " Handled [1-9][0-9]* volumes" ) endforeach(type) endforeach() # +# +# +foreach (test Assemblies BoxTrafos IronCylinder LheD_tracker MagnetFields MiniTel SiliconBlock NestedSimple NestedDetectors ) + # + # Test material scans in [origine to 10 meters in y] + dd4hep_add_test_reg( ClientTests_${test}_material_scan + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" + EXEC_ARGS materialScan file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml 0 0 0 0 10000 0 + REGEX_PASS " Average Material " ) + # + # Geant4 material scan. From position=0,0,0 to end-of-world + if (DD4HEP_USE_GEANT4) + dd4hep_add_test_reg( ClientTests_${test}_g4material_scan + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/python/g4MaterialScan.py --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml "--position=0,0,0" "--direction=0,1,0" + REGEX_PASS " Terminate Geant4 and delete associated actions." ) + endif(DD4HEP_USE_GEANT4) +endforeach() +# +# +# +foreach (test BoxTrafos IronCylinder MiniTel SiliconBlock NestedSimple ) + # + # ROOT Geometry checks + dd4hep_add_test_reg( ClientTests_${test}_check_geometry + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/python/checkGeometry.py --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml --full=true --ntracks=10 + REGEX_PASS " Execution finished..." ) + # + # ROOT Geometry overlap checks + dd4hep_add_test_reg( ClientTests_${test}_check_overlaps + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/python/checkOverlaps.py --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml --tolerance=0.1 + REGEX_PASS " Execution finished..." ) +endforeach() +# +# EXEC_ARGS test_with_root.sh ${script} +# if (DD4HEP_USE_GEANT4) - foreach(script MiniTel LheD_tracker ) + # + # Geant4 full simulation checks of simple detectors + foreach(script MiniTel LheD_tracker) dd4hep_add_test_reg( ClientTests_sim_${script} COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script}.py batch @@ -44,4 +89,4 @@ if (DD4HEP_USE_GEANT4) REGEX_PASS NONE REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) endforeach(script) -endif() +endif(DD4HEP_USE_GEANT4) diff --git a/examples/ClientTests/compact/IronCylinder.xml b/examples/ClientTests/compact/IronCylinder.xml index 36c9b0ab1a641e258cb48dca3b1f203fe557806a..99d248d088c1981ce144282262b7d7d7f0b34975 100644 --- a/examples/ClientTests/compact/IronCylinder.xml +++ b/examples/ClientTests/compact/IronCylinder.xml @@ -41,7 +41,7 @@ <dimensions rmin="HcalBarrel_rmin" rmax="HcalBarrel_rmax" z="HcalBarrel_zmax" phiBins="64" /> </detector> - <detector id="2" name="ContainmentShell" type="ZylinderShell" vis="VisibleRed" readout="ContainmentHits" > + <detector id="2" name="ContainmentShell" type="DD4hep_CylinderShell" vis="VisibleRed" readout="ContainmentHits" > <comment>Containment shell to measure calorimeter escapes</comment> <material name="Air"/> <module name="Barrel" id="0" vis="VisibleRed"> diff --git a/examples/ClientTests/scripts/MiniTel.py b/examples/ClientTests/scripts/MiniTel.py index 82839d2a35ca8c4a8193bd9b076fd723a79a446e..c4d393e65578bf2efaad46626cc336c69cdba3e5 100644 --- a/examples/ClientTests/scripts/MiniTel.py +++ b/examples/ClientTests/scripts/MiniTel.py @@ -14,34 +14,42 @@ from SystemOfUnits import * def run(): kernel = DDG4.Kernel() install_dir = os.environ['DD4hepINSTALL'] - example_dir = install_dir+'/examples/DDG4/examples'; kernel.setOutputLevel('Geant4Converter',Output.DEBUG) kernel.setOutputLevel('Gun',Output.INFO) kernel.loadGeometry("file:"+install_dir+"/examples/ClientTests/compact/MiniTel.xml") - kernel.loadXML("file:"+example_dir+"/DDG4_field.xml") - simple = DDG4.Simple(kernel) - simple.printDetectors() - simple.setupCshUI() + geant4 = DDG4.Geant4(kernel) + geant4.printDetectors() + geant4.setupCshUI() if len(sys.argv) >= 2 and sys.argv[1] =="batch": kernel.UI = '' + # Configure field + field = geant4.addConfig('Geant4FieldTrackingSetupAction/MagFieldTrackingSetup') + field.stepper = "HelixSimpleRunge" + field.equation = "Mag_UsualEqRhs" + field.eps_min = 5e-05*mm + field.eps_max = 0.001*mm + field.min_chord_step = 0.01*mm + field.delta_chord = 0.25*mm + field.delta_intersection = 1e-05*mm + field.delta_one_step = 0.001*mm # Configure I/O - evt_root = simple.setupROOTOutput('RootOutput','MiniTel_'+time.strftime('%Y-%m-%d_%H-%M'),mc_truth=True) + evt_root = geant4.setupROOTOutput('RootOutput','MiniTel_'+time.strftime('%Y-%m-%d_%H-%M'),mc_truth=True) # Setup particle gun - simple.setupGun("Gun",particle='pi-',energy=100*GeV,multiplicity=1) + geant4.setupGun("Gun",particle='pi-',energy=100*GeV,multiplicity=1) # Now the calorimeters - seq,act = simple.setupTracker('MyLHCBdetector1') - seq,act = simple.setupTracker('MyLHCBdetector2') - seq,act = simple.setupTracker('MyLHCBdetector3') - seq,act = simple.setupTracker('MyLHCBdetector4') + seq,act = geant4.setupTracker('MyLHCBdetector1') + seq,act = geant4.setupTracker('MyLHCBdetector2') + seq,act = geant4.setupTracker('MyLHCBdetector3') + seq,act = geant4.setupTracker('MyLHCBdetector4') act.OutputLevel = 4 - seq,act = simple.setupTracker('MyLHCBdetector5') - seq,act = simple.setupTracker('MyLHCBdetector6') - seq,act = simple.setupTracker('MyLHCBdetector7') - seq,act = simple.setupTracker('MyLHCBdetector8') - seq,act = simple.setupTracker('MyLHCBdetector9') - seq,act = simple.setupTracker('MyLHCBdetector10') + seq,act = geant4.setupTracker('MyLHCBdetector5') + seq,act = geant4.setupTracker('MyLHCBdetector6') + seq,act = geant4.setupTracker('MyLHCBdetector7') + seq,act = geant4.setupTracker('MyLHCBdetector8') + seq,act = geant4.setupTracker('MyLHCBdetector9') + seq,act = geant4.setupTracker('MyLHCBdetector10') # And handle the simulation particles. part = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler") @@ -56,7 +64,7 @@ def run(): phys.extends = 'QGSP_BERT' phys.enableUI() # and run - simple.execute() + geant4.execute() if __name__ == "__main__": run()