Skip to content

Commit

Permalink
Take random seed from Gaudi Random Service
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Nov 16, 2021
1 parent 25ca380 commit 80f9fa0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* or submit itself to any jurisdiction.
*
*/
#include "GaudiKernel/IRndmEngine.h"

#include "k4MarlinWrapper/MarlinProcessorWrapper.h"

Expand Down Expand Up @@ -132,7 +133,7 @@ StatusCode MarlinProcessorWrapper::instantiateProcessor(std::shared_ptr<marlin::
Gaudi::Property<std::string>& processorTypeStr) {
auto processorType = marlin::ProcessorMgr::instance()->getProcessor(processorTypeStr);
if (not processorType) {
error() << " Failed to instantiate " << name() << endmsg;
error() << " Failed to instantiate " << name() << " because processor type could not be determined" << endmsg;
return StatusCode::FAILURE;
}
m_processor = processorType->newProcessor();
Expand All @@ -155,8 +156,25 @@ StatusCode MarlinProcessorWrapper::initialize() {
streamlog::out.init(std::cout, "k4MarlinWrapper");
marlin::Global::parameters = new marlin::StringParameters();
marlin::Global::parameters->add("AllowToModifyEvent", {"true"});
marlin::Global::parameters->add("RandomSeed", {"123456"});
// marlin::Global::EVENTSEEDER = new marlin::ProcessorEventSeeder() ;

// From GaudiExamples/EvtColAlg
Assert(randSvc() != 0, "Random Service not available");
std::vector<long> rngSeeds;
if (randSvc()->engine()->seeds(rngSeeds).isFailure()) {
error() << "Cannot get seeds from Random Service" << endmsg;
return StatusCode::FAILURE;
}
debug() << "Got the following seeds from the random service: ";
for (const auto s : rngSeeds) {
debug() << s << " ";
}
debug() << endmsg;

if (!rngSeeds.empty()) {
info() << "Setting global Marlin random seed to " << rngSeeds[0] << endmsg;
marlin::Global::parameters->add("RandomSeed", {std::to_string(rngSeeds[0])});
}

if (loadProcessorLibraries().isFailure()) {
return StatusCode::FAILURE;
}
Expand Down

0 comments on commit 80f9fa0

Please sign in to comment.