Skip to content

Commit

Permalink
feat: Switching SteppingLogger to sterile when no output requested (#746
Browse files Browse the repository at this point in the history
)

This PR switches the SteppingLogger to sterile when no persistent output is requested in the PropgationExample. This aides the time measurement of the propagation, as otherwise the getSharedPtr(...) within the logger is a signficant factor.
  • Loading branch information
asalzburger committed Mar 14, 2021
1 parent 4b3509d commit e705d2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class PropagationAlgorithm : public BareAlgorithm {

/// proapgation mode
int mode = 0;
/// Switch the logger to sterile
bool sterileLogger = false;
/// debug output
bool debugOutput = false;
/// Modify the behavior of the material interaction: energy loss
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ PropagationOutput PropagationAlgorithm<propagator_t>::executeTest(
mInteractor.energyLoss = m_cfg.energyLoss;
mInteractor.recordInteractions = m_cfg.recordMaterialInteractions;

// Switch the logger to sterile, e.g. for timing checks
auto& sLogger = options.actionList.get<SteppingLogger>();
sLogger.sterile = m_cfg.sterileLogger;
// Set a maximum step size
options.maxStepSize = m_cfg.maxStepSize;

Expand Down
10 changes: 8 additions & 2 deletions Examples/Run/Common/src/PropagationExampleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ int propagationExample(int argc, char* argv[],
ActsExamples::Options::setupMagneticFieldServices(vm, sequencer);
auto bField = ActsExamples::Options::readMagneticField(vm);

// Check what output exists, if none exists, the SteppingLogger
// will switch to sterile.
bool rootOutput = vm["output-root"].template as<bool>();
bool objOutput = vm["output-obj"].template as<bool>();

auto setupPropagator = [&](auto&& stepper) {
using Stepper = std::decay_t<decltype(stepper)>;
using Propagator = Acts::Propagator<Stepper, Acts::Navigator>;
Expand All @@ -82,6 +87,7 @@ int propagationExample(int argc, char* argv[],
auto pAlgConfig =
ActsExamples::Options::readPropagationConfig(vm, propagator);
pAlgConfig.randomNumberSvc = randomNumberSvc;
pAlgConfig.sterileLogger = not rootOutput and not objOutput;
sequencer.addAlgorithm(
std::make_shared<ActsExamples::PropagationAlgorithm<Propagator>>(
pAlgConfig, logLevel));
Expand All @@ -101,7 +107,7 @@ int propagationExample(int argc, char* argv[],
std::string outputDir = vm["output-dir"].template as<std::string>();
auto psCollection = vm["prop-step-collection"].as<std::string>();

if (vm["output-root"].template as<bool>()) {
if (rootOutput) {
// Write the propagation steps as ROOT TTree
ActsExamples::RootPropagationStepsWriter::Config pstepWriterRootConfig;
pstepWriterRootConfig.collection = psCollection;
Expand All @@ -112,7 +118,7 @@ int propagationExample(int argc, char* argv[],
pstepWriterRootConfig));
}

if (vm["output-obj"].template as<bool>()) {
if (objOutput) {
using PropagationSteps = Acts::detail::Step;
using ObjPropagationStepsWriter =
ActsExamples::ObjPropagationStepsWriter<PropagationSteps>;
Expand Down

0 comments on commit e705d2f

Please sign in to comment.