56 {
57
58
60 SmartIF<IProperty> propMgr(serviceLocator());
61 std::string evt_sel_name{};
62 ATH_CHECK(propMgr->getProperty(
"EvtSel", evt_sel_name));
63 if (evt_sel_name.empty()) {
64
65
68 return StatusCode::SUCCESS;
69 }
70 auto sg = serviceLocator()->service<
StoreGateSvc>(
"StoreGateSvc/StoreGateSvc",
71 false);
72 auto evtSel = serviceLocator()->service<IEvtSelector>(std::move(evt_sel_name), false);
73 if (!sg.isValid() || !evtSel.isValid()) {
75 return StatusCode::FAILURE;
76 }
77
78 auto modSvc = serviceLocator()->service<IEvtIdModifierSvc>(
79 "EvtIdModifierSvc/EvtIdModifierSvc", false);
80 std::uint64_t evts_skipped_before_mod = 0;
81 std::vector<EvtId> modifier_evts{};
82 if (modSvc.isValid()) {
83
84 try {
85 evts_skipped_before_mod =
86 getProp<std::uint64_t&>(modSvc, "SkipEvents").value();
88 << " events before modifying");
89 std::vector<std::uint64_t>
lst =
90 getProp<std::vector<std::uint64_t>&>(modSvc,
"Modifiers").
value();
92 <<
lst.size() / 6 <<
" entries.");
93 std::string config_str{};
94 auto config_str_iter = std::back_inserter(config_str);
95 modifier_evts.clear();
96 for (const auto rec : lst | std::views::chunk(6)) {
97 const int mod_bitset = rec[5];
98 const bool mod_run_num = mod_bitset & 1;
99 const bool mod_evt_num = mod_bitset & (1 << 1);
100 const bool mod_lb_num = mod_bitset & (1 << 3);
101
102 const std::uint64_t
runNum = mod_run_num ? rec[0] : 0;
103 const std::uint64_t evtNum = mod_evt_num ? rec[1] : 0;
104 const std::uint64_t lbNum = mod_lb_num ? rec[3] : 0;
105 const std::uint64_t numEvts = rec[4];
106
107 std::format_to(config_str_iter,
108 "Run: {} [{:c}] LB: {} [{:c}] EVT: {} [{:c}] "
109 "NumEvts: {}\n",
110 runNum, mod_run_num ? 'Y' : 'N', lbNum,
111 mod_lb_num ? 'Y' : 'N', evtNum,
112 mod_evt_num ? 'Y' : 'N', numEvts);
114 static_cast<uint32_t>(lbNum), evtNum};
115 for ([[maybe_unused]] const std::uint64_t _ :
116 std::views::iota(std::uint64_t{0}, numEvts)) {
117 modifier_evts.push_back(evt);
118 }
119 }
121 } catch (const std::bad_cast&) {
122 ATH_MSG_ERROR(
"Wrong type for property of EvtIdModifierSvc.");
123 }
124 } else {
126 }
127
129 ATH_CHECK(setProp(evtSel,
"SkipEvents",
"0"));
130 IEvtSelector::Context* ctx = nullptr;
133
134 std::uint64_t
idx = 0;
135 Service* evtSelSvc = dynamic_cast<Service*>(evtSel.get());
136 if (!evtSelSvc) {
138 return StatusCode::FAILURE;
139 }
141 while (evtSel->next(*ctx).isSuccess()) {
142 EvtId evt_id{};
143
144 IOpaqueAddress* addr = nullptr;
145 ATH_CHECK(evtSel->createAddress(*ctx, addr));
148
149
150
151
152 std::vector<std::string> attr_lists;
153 sg->keys<AthenaAttributeList> (attr_lists);
154 const auto* attr_list_p =
155 sg->tryConstRetrieve<AthenaAttributeList>("Input");
156 if (attr_list_p != nullptr && attr_list_p->size() > 6) {
157 try {
158 const AthenaAttributeList& attr_list = *attr_list_p;
159 const auto runNum = attr_list[
"RunNumber"].data<
unsigned>();
160 const auto evtNum = attr_list["EventNumber"].data<unsigned long long>();
161 const auto lbNum = attr_list["LumiBlockN"].data<unsigned>();
162 evt_id = EvtId{
runNum, lbNum, evtNum};
163 } catch (...) {
164 }
165 }
167 if (idx >= evts_skipped_before_mod && !modifier_evts.empty()) {
168 const std::size_t mod_idx =
169 (
idx - evts_skipped_before_mod) % modifier_evts.size();
170 evt_id.runNum = modifier_evts[mod_idx].runNum != 0U
171 ? modifier_evts[mod_idx].runNum
172 : evt_id.runNum;
173 evt_id.lbNum = modifier_evts[mod_idx].lbNum != 0U
174 ? modifier_evts[mod_idx].lbNum
175 : evt_id.lbNum;
176 evt_id.evtNum = modifier_evts[mod_idx].evtNum != 0U
177 ? modifier_evts[mod_idx].evtNum
178 : evt_id.evtNum;
179 }
183 }
184
185
187 << " and rewinding");
192
193
194 ServiceHandle<IIncidentSvc> incident_svc(
"IncidentSvc",
name());
196 incident_svc->addListener(this, "BeginRun");
197 incident_svc->addListener(this, "SkipEvents");
198 return StatusCode::SUCCESS;
199}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
int m_initial_skip_events