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