61 SmartIF<IProperty> propMgr(serviceLocator());
62 std::string evt_sel_name{};
63 ATH_CHECK(propMgr->getProperty(
"EvtSel", evt_sel_name));
64 if (evt_sel_name.empty()) {
69 return StatusCode::SUCCESS;
71 auto sg = serviceLocator()->service<
StoreGateSvc>(
"StoreGateSvc/StoreGateSvc",
73 auto evtSel = serviceLocator()->service<IEvtSelector>(evt_sel_name,
false);
74 if (!sg.isValid() || !evtSel.isValid()) {
76 return StatusCode::FAILURE;
80 "EvtIdModifierSvc/EvtIdModifierSvc",
false);
82 std::vector<EvtId> modifier_evts{};
83 if (modSvc.isValid()) {
86 evts_skipped_before_mod =
87 getProp<std::uint64_t&>(modSvc,
"SkipEvents").value();
89 <<
" events before modifying");
90 std::vector<std::uint64_t> lst =
91 getProp<std::vector<std::uint64_t>&>(modSvc,
"Modifiers").
value();
93 << lst.size() / 6 <<
" entries.");
94 std::string config_str{};
95 auto config_str_iter = std::back_inserter(config_str);
98 rv::for_each([&config_str_iter](
const auto& rec) {
99 const int mod_bitset = rec[5];
100 const bool mod_run_num = mod_bitset & 1;
101 const bool mod_evt_num = mod_bitset & (1 << 1);
102 const bool mod_lb_num = mod_bitset & (1 << 3);
109 fmt::format_to(config_str_iter,
110 "Run: {} [{:c}] LB: {} [{:c}] EVT: {} [{:c}] "
112 runNum, mod_run_num ?
'Y' :
'N', lbNum,
113 mod_lb_num ?
'Y' :
'N', evtNum,
114 mod_evt_num ?
'Y' :
'N', numEvts);
115 return ranges::yield_from(
117 static_cast<uint32_t>(lbNum), evtNum},
122 }
catch (
const std::bad_cast&) {
123 ATH_MSG_ERROR(
"Wrong type for property of EvtIdModifierSvc.");
130 ATH_CHECK(setProp(evtSel,
"SkipEvents",
"0"));
131 IEvtSelector::Context* ctx =
nullptr;
136 ATH_CHECK(
dynamic_cast<Service*
>(evtSel.get())->start());
137 while (evtSel->next(*ctx).isSuccess()) {
140 IOpaqueAddress* addr =
nullptr;
141 ATH_CHECK(evtSel->createAddress(*ctx, addr));
148 std::vector<std::string> attr_lists;
152 const auto* attr_list_p =
154 if (attr_list_p !=
nullptr && attr_list_p->size() > 6) {
157 const auto runNum = attr_list[
"RunNumber"].data<
unsigned>();
158 const auto evtNum = attr_list[
"EventNumber"].data<
unsigned long long>();
159 const auto lbNum = attr_list[
"LumiBlockN"].data<
unsigned>();
160 evt_id = EvtId{
runNum, lbNum, evtNum};
165 if (
idx >= evts_skipped_before_mod && !modifier_evts.empty()) {
166 const std::size_t mod_idx =
167 (
idx - evts_skipped_before_mod) % modifier_evts.size();
168 evt_id.runNum = modifier_evts[mod_idx].runNum != 0U
169 ? modifier_evts[mod_idx].runNum
171 evt_id.lbNum = modifier_evts[mod_idx].lbNum != 0U
172 ? modifier_evts[mod_idx].lbNum
174 evt_id.evtNum = modifier_evts[mod_idx].evtNum != 0U
175 ? modifier_evts[mod_idx].evtNum
185 <<
" and rewinding");
194 incident_svc->addListener(
this,
"BeginRun");
195 incident_svc->addListener(
this,
"SkipEvents");
196 return StatusCode::SUCCESS;