ATLAS Offline Software
Loading...
Searching...
No Matches
RandomErrorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <random>
6
7#include "RandomErrorAlg.h"
8
9RandomErrorAlg::RandomErrorAlg(const std::string& name, ISvcLocator* pSvcLocator)
10 : AthReentrantAlgorithm(name, pSvcLocator) {}
11
12StatusCode RandomErrorAlg::execute(const EventContext& /*eventContext*/) const {
13
14 static thread_local std::random_device rd;
15 static thread_local std::default_random_engine generator (rd());
16 std::uniform_real_distribution<double> distribution (0., 1.);
17
18 if ( distribution(generator) < m_errorProbability ) {
19 ATH_MSG_ERROR("Returning random StatusCode::FAILURE");
20 return StatusCode::FAILURE;
21 }
22
23 return StatusCode::SUCCESS;
24}
#define ATH_MSG_ERROR(x)
An algorithm that can be simultaneously executed in multiple threads.
RandomErrorAlg(const std::string &name, ISvcLocator *svcLoc)
virtual StatusCode execute(const EventContext &eventContext) const override
Gaudi::Property< double > m_errorProbability