21 using rng_t = std::mt19937_64;
22 using seed_t = rng_t::result_type;
24 seed_t eventSeed(
const EventIDBase& eventID,
const std::string&
name) {
25 uint64_t evtNum = eventID.event_number();
29 return static_cast<seed_t
>(
seed);
32 rng_t& threadLocalGenerator() {
33 static thread_local std::random_device rd;
34 static thread_local rng_t
generator(rd());
38 template<
typename T>
T randomRealNumber(
const T min,
const T max) {
39 std::uniform_real_distribution<T> distribution(
min,
max);
40 return distribution(threadLocalGenerator());
43 template<
typename T>
T randomInteger(
const T min,
const T max) {
44 std::uniform_int_distribution<T> distribution(
min,
max);
45 return distribution(threadLocalGenerator());
48 bool randomAccept(
const double acceptRate) {
49 return (randomRealNumber(0.0, 1.0) < acceptRate);
54 std::ostringstream
ss;
56 ss <<
"---> ROB ID = 0x" << std::hex << robf->rob_source_id() << std::dec << std::endl
57 <<
" ROD ID = 0x" << std::hex << robf->rod_source_id() << std::dec << std::endl
58 <<
" ROD Level-1 ID = " << robf->rod_lvl1_id() << std::endl;
63 template<
typename Container>
65 std::ostringstream
str;
67 str <<
"0x" << std::hex <<
id << std::dec <<
" ";
72 std::set<uint32_t> robIDsToAdd,
73 std::set<uint32_t> subDetIDsToAdd) {
75 std::vector<uint32_t> previousRobs;
77 robIDsToAdd.insert(previousRobs.begin(), previousRobs.end());
81 std::vector<uint32_t> previousSubDets;
83 subDetIDsToAdd.insert(previousSubDets.begin(), previousSubDets.end());
87 std::vector<uint32_t> robVec(robIDsToAdd.begin(), robIDsToAdd.end());
89 return StatusCode::FAILURE;
91 std::vector<uint32_t> subDetVec(subDetIDsToAdd.begin(), subDetIDsToAdd.end());
93 return StatusCode::FAILURE;
95 return StatusCode::SUCCESS;
99 unsigned int nObjects = randomInteger<unsigned int>(0, maxElements);
100 for (
unsigned int iObj=0; iObj<nObjects; ++iObj) {
102 data.push_back(
object);
104 unsigned int nAuxDataVec = randomInteger<unsigned int>(0, maxElements);
105 for (
unsigned int iAuxDataVec=0; iAuxDataVec<nAuxDataVec; ++iAuxDataVec) {
107 unsigned int nValues = randomInteger<unsigned int>(0, maxElements);
108 std::vector<float>
values;
109 for (
unsigned int iValue=0; iValue<nValues; ++iValue)
values.push_back( randomRealNumber<float>(0,1) );
110 floatVec(*
object) =
values;
140 [](
const auto&
p){return p.first;});
148 return StatusCode::FAILURE;
153 ATH_MSG_DEBUG(
name() <<
" will execute the following ROB request instructions:");
163 return StatusCode::SUCCESS;
173 return StatusCode::SUCCESS;
180 const seed_t seed = eventSeed(
input.eventContext.eventID(),
name());
181 ATH_MSG_DEBUG(
"Using seed " << seed <<
" for event " <<
input.eventContext.eventID());
182 threadLocalGenerator().seed(seed);
190 ATH_MSG_ERROR(
"Timeout reached in CPU time burning cycle # " << iCycle+1);
196 ATH_MSG_VERBOSE(
"CPU time burning cycle # " << iCycle+1 <<
", burn time [ms] = " << burnTime);
198 else std::this_thread::sleep_for(std::chrono::milliseconds(burnTime));
212 ATH_MSG_DEBUG(
"Processing instruction " << instr.toString());
213 std::vector<uint32_t>
robs;
214 if (instr.isRandom && instr.nRandom < robVec.size()) {
216 std::back_inserter(
robs),
218 threadLocalGenerator());
224 if (instr.type ==
ReqType::ADD || instr.type == ReqType::ADDGET) {
229 if (instr.type ==
ReqType::GET || instr.type == ReqType::ADDGET) {
235 ATH_MSG_DEBUG(
"Number of ROBs retrieved: " << robFragments.size());
236 if (!robFragments.empty()) {
242 if (!rob->check_rob() || !rob->check_rod()) {
247 ATH_MSG_ERROR(
"Data consistency check failed: " << ex.what());
249 ATH_MSG_DEBUG(
"Data consistency check passed for ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
253 if (instr.type == ReqType::COL) {
260 ATH_MSG_ERROR(
"Invalid ROB request instruction " << instr.toString());
261 return StatusCode::FAILURE;
276 std::unique_ptr<DataCont>
data = std::make_unique<DataCont>();
277 std::unique_ptr<AuxCont> aux = std::make_unique<AuxCont>();
278 data->setStore(aux.get());
282 ATH_MSG_DEBUG(
"Recorded TrigCompositeContainer " << handleKey.key() <<
" in event store");
285 fillRandomData(*handle,maxElements);
295 return StatusCode::SUCCESS;
302 ATH_MSG_VERBOSE(
"Not configured to write any PEBInfo, nothing will be attached to the decision");
310 return StatusCode::SUCCESS;
316 #if __clang_major__ == 9
317 std::string
str (strv.begin(), strv.end());
319 const std::string_view&
str = strv;
325 if (
size_t pos=
str.find(
":RND");
pos!=std::string_view::npos) {
326 size_t firstDigit=
pos+4;
327 size_t lastDigit=
str.find_first_of(
":",firstDigit);
328 size_t num = std::stoul(
str.substr(firstDigit,lastDigit).data());
341 else if (
type==ADDGET)
s+=
"ADDGET";
342 else if (
type==COL)
s+=
"COL";