Skip to content
Snippets Groups Projects
Commit 574b00dc authored by Andreas Salzburger's avatar Andreas Salzburger
Browse files

framework-v0.09.00 with MaterialMapping

parent 4f017890
No related branches found
No related tags found
No related merge requests found
#file (GLOB_RECURSE src_files "src/GenericMaterialValidationExample.cpp") set(_common_libraries
ActsCore
ACTFramework
ACTFWExamplesCommon
${Boost_LIBRARIES})
set(_plugin_libraries
ACTFWRootPlugin
ACTFWJsonPlugin
ACTFWBFieldPlugin)
add_executable(ACTFWGenericMaterialValidationExample src/GenericMaterialValidation.cpp) add_executable(ACTFWGenericMaterialValidationExample src/GenericMaterialValidation.cpp)
target_include_directories(ACTFWGenericMaterialValidationExample PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(ACTFWGenericMaterialValidationExample PRIVATE
target_link_libraries(ACTFWGenericMaterialValidationExample PRIVATE ActsCore) ${Boost_INCLUDE_DIRS})
target_link_libraries(ACTFWGenericMaterialValidationExample PRIVATE ACTFramework ACTFWExamplesCommon ACTFWGeometryInterfaces ACTFWPropagation ACTFWGenericDetector) target_link_libraries(ACTFWGenericMaterialValidationExample PRIVATE
target_link_libraries(ACTFWGenericMaterialValidationExample PRIVATE ACTFWRootPlugin ACTFWJsonPlugin ACTFWBFieldPlugin) ${_common_libraries} ${_plugin_libraries})
target_link_libraries(ACTFWGenericMaterialValidationExample PRIVATE ${Boost_LIBRARIES}) target_link_libraries(ACTFWGenericMaterialValidationExample PRIVATE
ACTFWPropagation ACTFWGenericDetector)
install(TARGETS ACTFWGenericMaterialValidationExample RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR})
install(TARGETS ACTFWGenericMaterialValidationExample RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) add_executable(ACTFWGenericMaterialMappingExample src/GenericMaterialMapping.cpp)
target_include_directories(ACTFWGenericMaterialMappingExample PRIVATE
${Boost_INCLUDE_DIRS})
target_link_libraries(ACTFWGenericMaterialMappingExample PRIVATE
${_common_libraries} ${_plugin_libraries})
target_link_libraries(ACTFWGenericMaterialMappingExample PRIVATE
ACTFWMaterialMapping ACTFWGenericDetector)
install(TARGETS ACTFWGenericMaterialMappingExample RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR})
#add_executable(ACTFWGenericMaterialMappingExample src/GenericMaterialMapping.cpp)
#target_include_directories(ACTFWGenericMaterialMappingExample PRIVATE ${Boost_INCLUDE_DIRS})
#target_link_libraries(ACTFWGenericMaterialMappingExample PRIVATE ActsCore ActsMaterialMappingPlugin)
#target_link_libraries(ACTFWGenericMaterialMappingExample PRIVATE ACTFramework ACTFWExamplesCommon ACTFWMaterialMapping ACTFWGenericDetector)
#target_link_libraries(ACTFWGenericMaterialMappingExample PRIVATE ACTFWRootPlugin ACTFWJsonPlugin)
#target_link_libraries(ACTFWGenericMaterialMappingExample PRIVATE ${Boost_LIBRARIES})
#
#install(TARGETS ACTFWGenericMaterialMappingExample RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
#if (USE_GEANT4 AND USE_DD4HEP) if (USE_GEANT4 AND USE_DD4HEP)
# include(${Geant4_USE_FILE}) include(${Geant4_USE_FILE})
#
# add_executable(ACTFWGeantinoRecordingExample src/GeantinoRecordingExample.cpp) add_executable(ACTFWGeantinoRecordingExample src/GeantinoRecordingExample.cpp)
# target_include_directories(ACTFWGeantinoRecordingExample PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(ACTFWGeantinoRecordingExample PRIVATE
# target_include_directories(ACTFWGeantinoRecordingExample PRIVATE ${DD4hep_INCLUDE_DIRS}) ${Boost_INCLUDE_DIRS} ${DD4hep_INCLUDE_DIRS})
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ACTFWDD4hepG4Plugin) target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ACTFWExamplesCommon) ACTFWExamplesCommon ACTFWMaterialMapping ACTFWDD4hepG4Plugin ACTFWRootPlugin)
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ACTFWDD4hepDetector) target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ACTFWMaterialMapping) ACTFWDD4hepDetector ${DD4hep_LIBRARIES} ${Geant4_LIBRARIES} ${Boost_LIBRARIES})
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ACTFWRootPlugin)
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ${DD4hep_LIBRARIES}) install(TARGETS ACTFWGeantinoRecordingExample RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ${Geant4_LIBRARIES}) endif()
# target_link_libraries(ACTFWGeantinoRecordingExample PRIVATE ${Boost_LIBRARIES})
#
# install(TARGETS ACTFWGeantinoRecordingExample RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
#endif()
...@@ -7,17 +7,15 @@ ...@@ -7,17 +7,15 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include "ACTFW/Common/CommonOptions.hpp"
#include "ACTFW/Common/OutputOptions.hpp"
#include "ACTFW/DD4hepDetector/DD4hepDetectorOptions.hpp" #include "ACTFW/DD4hepDetector/DD4hepDetectorOptions.hpp"
#include "ACTFW/DD4hepDetector/DD4hepGeometryService.hpp" #include "ACTFW/DD4hepDetector/DD4hepGeometryService.hpp"
#include "ACTFW/Framework/Sequencer.hpp" #include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/MaterialMapping/GeantinoRecording.hpp" #include "ACTFW/MaterialMapping/GeantinoRecording.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Plugins/DD4hepG4/DD4hepToG4Svc.hpp" #include "ACTFW/Plugins/DD4hepG4/DD4hepToG4Svc.hpp"
#include "ACTFW/Plugins/Root/RootMaterialTrackWriter.hpp" #include "ACTFW/Plugins/Root/RootMaterialTrackWriter.hpp"
#include "ACTFW/Random/RandomNumbersSvc.hpp" #include "ACTFW/Random/RandomNumbersSvc.hpp"
#include "ACTFW/Utilities/Paths.hpp" #include "ACTFW/Utilities/Paths.hpp"
#include "ACTFW/Writers/IWriterT.hpp"
#include "Acts/Detector/TrackingGeometry.hpp" #include "Acts/Detector/TrackingGeometry.hpp"
#include "Acts/Utilities/GeometryContext.hpp" #include "Acts/Utilities/GeometryContext.hpp"
...@@ -27,24 +25,19 @@ int ...@@ -27,24 +25,19 @@ int
main(int argc, char* argv[]) main(int argc, char* argv[])
{ {
// Declare the supported program options. // Declare the supported program options.
po::options_description desc("Allowed options"); // Setup and parse options
// Add the standard/common options auto desc = FW::Options::makeDefaultOptions();
FW::Options::addCommonOptions<po::options_description>(desc); FW::Options::addSequencerOptions(desc);
// Add the output options FW::Options::addOutputOptions(desc);
FW::Options::addOutputOptions<po::options_description>(desc); FW::Options::addDD4hepOptions(desc);
// Add the detector options
FW::Options::addDD4hepOptions<po::options_description>(desc); // Parse the options
po::variables_map vm; auto vm = FW::Options::parse(desc, argc, argv);
// Get all options from contain line and store it into the map if (vm.empty()) {
po::store(po::parse_command_line(argc, argv, desc), vm); return EXIT_FAILURE;
po::notify(vm);
// print help if requested
if (vm.count("help")) {
std::cout << desc << std::endl;
return 1;
} }
// Now read the standard options
auto nEvents = FW::Options::readNumberOfEvents<po::variables_map>(vm); FW::Sequencer g4sequencer(FW::Options::readSequencerConfig(vm));
size_t nTracks = 100; size_t nTracks = 100;
int randomSeed1 = 536235167; int randomSeed1 = 536235167;
...@@ -87,13 +80,6 @@ main(int argc, char* argv[]) ...@@ -87,13 +80,6 @@ main(int argc, char* argv[])
auto g4rAlgorithm auto g4rAlgorithm
= std::make_shared<FW::GeantinoRecording>(g4rConfig, Acts::Logging::INFO); = std::make_shared<FW::GeantinoRecording>(g4rConfig, Acts::Logging::INFO);
// Geant4 job - these can be many Geant4 jobs, indeed
//
// create the config object for the sequencer
FW::Sequencer::Config g4SeqConfig;
// now create the sequencer
FW::Sequencer g4Sequencer(g4SeqConfig);
// Output directory // Output directory
std::string outputDir = vm["output-dir"].template as<std::string>(); std::string outputDir = vm["output-dir"].template as<std::string>();
std::string matCollection = g4rConfig.geantMaterialCollection; std::string matCollection = g4rConfig.geantMaterialCollection;
...@@ -107,12 +93,10 @@ main(int argc, char* argv[]) ...@@ -107,12 +93,10 @@ main(int argc, char* argv[])
auto matTrackWriterRoot auto matTrackWriterRoot
= std::make_shared<FW::Root::RootMaterialTrackWriter>( = std::make_shared<FW::Root::RootMaterialTrackWriter>(
matTrackWriterRootConfig); matTrackWriterRootConfig);
if (g4Sequencer.addWriters({matTrackWriterRoot}) g4sequencer.addWriter(matTrackWriterRoot);
!= FW::ProcessCode::SUCCESS)
return -1;
} }
// Append the algorithm and run // Append the algorithm and run
g4Sequencer.appendEventAlgorithms({g4rAlgorithm}); g4sequencer.addAlgorithm(g4rAlgorithm);
g4Sequencer.run(nEvents); g4sequencer.run();
} }
...@@ -13,17 +13,20 @@ ...@@ -13,17 +13,20 @@
#include "ACTFW/Framework/Sequencer.hpp" #include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/Geometry/CommonGeometry.hpp" #include "ACTFW/Geometry/CommonGeometry.hpp"
#include "ACTFW/MaterialMapping/MaterialMapping.hpp" #include "ACTFW/MaterialMapping/MaterialMapping.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Plugins/Json/JsonGeometryConverter.hpp" #include "ACTFW/Plugins/Json/JsonGeometryConverter.hpp"
#include "ACTFW/Plugins/Json/JsonMaterialWriter.hpp" #include "ACTFW/Plugins/Json/JsonMaterialWriter.hpp"
#include "ACTFW/Plugins/Root/RootMaterialTrackReader.hpp" #include "ACTFW/Plugins/Root/RootMaterialTrackReader.hpp"
#include "ACTFW/Plugins/Root/RootMaterialWriter.hpp" #include "ACTFW/Plugins/Root/RootMaterialWriter.hpp"
#include "ACTFW/Propagation/PropagationOptions.hpp"
#include "ACTFW/Utilities/Paths.hpp" #include "ACTFW/Utilities/Paths.hpp"
#include "ACTFW/options/CommonOptions.hpp"
#include "Acts/Detector/TrackingGeometry.hpp" #include "Acts/Detector/TrackingGeometry.hpp"
#include "Acts/Extrapolator/Navigator.hpp" #include "Acts/Extrapolator/Navigator.hpp"
#include "Acts/Plugins/MaterialMapping/SurfaceMaterialMapper.hpp" #include "Acts/Plugins/MaterialMapping/SurfaceMaterialMapper.hpp"
#include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/Propagator.hpp"
#include "Acts/Propagator/StraightLineStepper.hpp" #include "Acts/Propagator/StraightLineStepper.hpp"
#include "Acts/Utilities/GeometryContext.hpp"
#include "Acts/Utilities/MagneticFieldContext.hpp"
namespace po = boost::program_options; namespace po = boost::program_options;
...@@ -51,8 +54,6 @@ materialMappingExample(int argc, ...@@ -51,8 +54,6 @@ materialMappingExample(int argc,
FW::Options::addSequencerOptions(desc); FW::Options::addSequencerOptions(desc);
FW::Options::addGeometryOptions(desc); FW::Options::addGeometryOptions(desc);
FW::Options::addMaterialOptions(desc); FW::Options::addMaterialOptions(desc);
FW::Options::addBFieldOptions(desc);
FW::Options::addRandomNumbersOptions(desc);
FW::Options::addPropagationOptions(desc); FW::Options::addPropagationOptions(desc);
FW::Options::addOutputOptions(desc); FW::Options::addOutputOptions(desc);
...@@ -72,6 +73,10 @@ materialMappingExample(int argc, ...@@ -72,6 +73,10 @@ materialMappingExample(int argc,
auto geometry = FW::Geometry::build(vm, geometrySetup); auto geometry = FW::Geometry::build(vm, geometrySetup);
auto tGeometry = geometry.first; auto tGeometry = geometry.first;
/// Default contexts
Acts::GeometryContext geoContext;
Acts::MagneticFieldContext mfContext;
// Get a Navigator // Get a Navigator
Acts::Navigator navigator(tGeometry); Acts::Navigator navigator(tGeometry);
...@@ -99,8 +104,7 @@ materialMappingExample(int argc, ...@@ -99,8 +104,7 @@ materialMappingExample(int argc,
auto matTrackReaderRoot auto matTrackReaderRoot
= std::make_shared<FW::Root::RootMaterialTrackReader>( = std::make_shared<FW::Root::RootMaterialTrackReader>(
matTrackReaderRootConfig); matTrackReaderRootConfig);
if (sequencer.addReaders({matTrackReaderRoot}) != FW::ProcessCode::SUCCESS) sequencer.addReader(matTrackReaderRoot);
return -1;
} }
/// The material mapper /// The material mapper
...@@ -120,17 +124,17 @@ materialMappingExample(int argc, ...@@ -120,17 +124,17 @@ materialMappingExample(int argc,
if (vm["output-root"].template as<bool>()) { if (vm["output-root"].template as<bool>()) {
/// The writer of the indexed material // The writer of the indexed material
FW::Root::RootMaterialWriter::Config rimConfig("MaterialWriter"); FW::Root::RootMaterialWriter::Config rmwConfig("MaterialWriter");
rimConfig.fileName = materialFileName + ".root"; rmwConfig.fileName = materialFileName + ".root";
auto rimRootWriter FW::Root::RootMaterialWriter rmwImpl(rmwConfig);
= std::make_shared<FW::Root::RootMaterialWriter>(rimConfig); // Fullfill the IMaterialWriter interface
using RootWriter = FW::MaterialWriterT<FW::Root::RootMaterialWriter>;
mmAlgConfig.materialWriters.push_back(rimRootWriter); mmAlgConfig.materialWriters.push_back(
std::make_shared<RootWriter>(std::move(rmwImpl)));
} }
if (vm["output-json"].template as<bool>()) { if (vm["output-json"].template as<bool>()) {
/// The name of the output file /// The name of the output file
std::string fileName = vm["mat-output-file"].template as<std::string>(); std::string fileName = vm["mat-output-file"].template as<std::string>();
// the material writer // the material writer
...@@ -147,17 +151,19 @@ materialMappingExample(int argc, ...@@ -147,17 +151,19 @@ materialMappingExample(int argc,
jmConverterCfg.processVolumes = vm["mat-output-volume"].template as<bool>(); jmConverterCfg.processVolumes = vm["mat-output-volume"].template as<bool>();
jmConverterCfg.writeData = vm["mat-output-data"].template as<bool>(); jmConverterCfg.writeData = vm["mat-output-data"].template as<bool>();
// The writer // The writer
auto jimJsonWriter = std::make_shared<FW::Json::JsonMaterialWriter>( FW::Json::JsonMaterialWriter jmwImpl(jmConverterCfg,
jmConverterCfg, materialFileName + ".json";); materialFileName + ".json");
// Fullfill the IMaterialWriter interface
mmAlgConfig.materialWriters.push_back(jimJsonWriter); using JsonWriter = FW::MaterialWriterT<FW::Json::JsonMaterialWriter>;
mmAlgConfig.materialWriters.push_back(
std::make_shared<JsonWriter>(std::move(jmwImpl)));
} }
// Create the material mapping // Create the material mapping
auto mmAlg = std::make_shared<FW::MaterialMapping>(mmAlgConfig); auto mmAlg = std::make_shared<FW::MaterialMapping>(mmAlgConfig);
// Apend the Algorithm // Append the Algorithm
sequencer.appendAlgorithm(mmAlg); sequencer.addAlgorithm(mmAlg);
// Initiate the run // Initiate the run
sequencer.run(); sequencer.run();
......
Subproject commit 8626adb803ee140810198595f7d731bf8b7e03c5 Subproject commit a8f31303ee8720ed2946bfe2d59e81d0f70e307e
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment