20 using rng_t = std::mt19937_64;
21 using seed_t = rng_t::result_type;
23 seed_t eventSeed(
const EventIDBase& eventID,
const std::string&
name) {
24 uint64_t evtNum = eventID.event_number();
28 return static_cast<seed_t
>(
seed);
31 rng_t& threadLocalGenerator() {
32 static thread_local std::random_device rd;
33 static thread_local rng_t
generator(rd());
37 template<
typename T>
T randomRealNumber(
const T min,
const T max) {
38 std::uniform_real_distribution<T> distribution(
min,
max);
39 return distribution(threadLocalGenerator());
42 template<
typename T>
T randomInteger(
const T min,
const T max) {
43 std::uniform_int_distribution<T> distribution(
min,
max);
44 return distribution(threadLocalGenerator());
47 bool randomAccept(
const double acceptRate) {
48 return (randomRealNumber(0.0, 1.0) < acceptRate);
53 std::ostringstream
ss;
55 ss <<
"---> ROB ID = 0x" << std::hex << robf->rob_source_id() << std::dec << std::endl
56 <<
" ROD ID = 0x" << std::hex << robf->rod_source_id() << std::dec << std::endl
57 <<
" ROD Level-1 ID = " << robf->rod_lvl1_id() << std::endl;
62 template<
typename Container>
64 std::ostringstream
str;
66 str <<
"0x" << std::hex <<
id << std::dec <<
" ";
71 std::set<uint32_t> robIDsToAdd,
72 std::set<uint32_t> subDetIDsToAdd) {
74 std::vector<uint32_t> previousRobs;
76 robIDsToAdd.insert(previousRobs.begin(), previousRobs.end());
80 std::vector<uint32_t> previousSubDets;
82 subDetIDsToAdd.insert(previousSubDets.begin(), previousSubDets.end());
86 std::vector<uint32_t> robVec(robIDsToAdd.begin(), robIDsToAdd.end());
88 return StatusCode::FAILURE;
90 std::vector<uint32_t> subDetVec(subDetIDsToAdd.begin(), subDetIDsToAdd.end());
92 return StatusCode::FAILURE;
94 return StatusCode::SUCCESS;
98 unsigned int nObjects = randomInteger<unsigned int>(0, maxElements);
99 for (
unsigned int iObj=0; iObj<nObjects; ++iObj) {
101 data.push_back(
object);
103 unsigned int nAuxDataVec = randomInteger<unsigned int>(0, maxElements);
104 for (
unsigned int iAuxDataVec=0; iAuxDataVec<nAuxDataVec; ++iAuxDataVec) {
106 unsigned int nValues = randomInteger<unsigned int>(0, maxElements);
107 std::vector<float>
values;
108 for (
unsigned int iValue=0; iValue<nValues; ++iValue)
values.push_back( randomRealNumber<float>(0,1) );
109 floatVec(*
object) =
values;
146 return StatusCode::FAILURE;
151 ATH_MSG_DEBUG(
name() <<
" will execute the following ROB request instructions:");
161 return StatusCode::SUCCESS;
171 return StatusCode::SUCCESS;
178 const seed_t seed = eventSeed(
input.eventContext.eventID(),
name());
179 ATH_MSG_DEBUG(
"Using seed " << seed <<
" for event " <<
input.eventContext.eventID());
180 threadLocalGenerator().seed(seed);
188 ATH_MSG_ERROR(
"Timeout reached in CPU time burning cycle # " << iCycle+1);
194 ATH_MSG_VERBOSE(
"CPU time burning cycle # " << iCycle+1 <<
", burn time [ms] = " << burnTime);
196 else std::this_thread::sleep_for(std::chrono::milliseconds(burnTime));
210 ATH_MSG_DEBUG(
"Processing instruction " << instr.toString());
211 std::vector<uint32_t>
robs;
212 if (instr.isRandom && instr.nRandom < robVec.size()) {
214 std::back_inserter(
robs),
216 threadLocalGenerator());
222 if (instr.type ==
ReqType::ADD || instr.type == ReqType::ADDGET) {
227 if (instr.type ==
ReqType::GET || instr.type == ReqType::ADDGET) {
233 ATH_MSG_DEBUG(
"Number of ROBs retrieved: " << robFragments.size());
234 if (!robFragments.empty()) {
240 if (!rob->check_rob() || !rob->check_rod()) {
245 ATH_MSG_ERROR(
"Data consistency check failed: " << ex.what());
247 ATH_MSG_DEBUG(
"Data consistency check passed for ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
251 if (instr.type == ReqType::COL) {
258 ATH_MSG_ERROR(
"Invalid ROB request instruction " << instr.toString());
259 return StatusCode::FAILURE;
274 std::unique_ptr<DataCont>
data = std::make_unique<DataCont>();
275 std::unique_ptr<AuxCont> aux = std::make_unique<AuxCont>();
276 data->setStore(aux.get());
280 ATH_MSG_DEBUG(
"Recorded TrigCompositeContainer " << handleKey.key() <<
" in event store");
283 fillRandomData(*handle,maxElements);
293 return StatusCode::SUCCESS;
300 ATH_MSG_VERBOSE(
"Not configured to write any PEBInfo, nothing will be attached to the decision");
308 return StatusCode::SUCCESS;
314 #if __clang_major__ == 9
315 std::string
str (strv.begin(), strv.end());
317 const std::string_view&
str = strv;
323 if (
size_t pos=
str.find(
":RND");
pos!=std::string_view::npos) {
324 size_t firstDigit=
pos+4;
325 size_t lastDigit=
str.find_first_of(
":",firstDigit);
326 size_t num = std::stoul(
str.substr(firstDigit,lastDigit).data());
339 else if (
type==ADDGET)
s+=
"ADDGET";
340 else if (
type==COL)
s+=
"COL";