crash the run if event number gets above 32bit int.
64 {
65
70
72 if (newnum<=0){
73 ATH_MSG_ERROR(
"Event number must be positive-definite; " << newnum <<
" is not allowed");
74 return StatusCode::FAILURE;
75 }
76
77#ifndef HEPMC3
79 constexpr long long int max32 = std::pow(2, 31) - 1;
80 if (newnum >= max32) {
81 ATH_MSG_ERROR(
"Event number " << newnum <<
" exceeds 32bit limit. In HepMC2 it is not allowed.");
82 return StatusCode::FAILURE;
83 }
84#else
85
86
88 ATH_MSG_INFO(
"After " <<
m_nPass <<
" events we switch off HepMC3 warnings to avoid blowing up logs.");
89 HepMC3::Setup::set_print_warnings(false);
90 }
91#endif
92
95
100 HepMC::GenEvent* hepMC = *
evt;
103 }
104 else{
106 return StatusCode::SUCCESS;
107 }
108 }
109
111 int inpRunNumber{-1};
115 ATH_CHECK(outputEvtInfoHandle.record(std::make_unique<xAOD::EventInfo>(), std::make_unique<xAOD::EventAuxInfo>()));
116
117 outputEvtInfo = outputEvtInfoHandle.ptr();
118 *outputEvtInfo = *inputEvtInfoHandle;
119
120
121
122
124
125 inpRunNumber = inputEvtInfoHandle->runNumber();
127 SG::ReadDecorHandle<xAOD::EventInfo,std::vector<float>> mcWeights(
m_mcWeightsKey);
129 }
130 }
131
133
136 assert(pInputEvt);
137 EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
138 eventID->set_event_number(newnum);
140 } else {
142 return StatusCode::SUCCESS;
143 }
144
146 }
147
148
149
151
154 assert(pInputEvt);
155
156 unsigned int run_number = pInputEvt->event_ID()->run_number();
157
158 EventType* eventType = const_cast<EventType*>(pInputEvt->event_type());
161
162 ATH_MSG_DEBUG(
"Copied run number into mc channel number: " << run_number);
163 } else {
165 return StatusCode::FAILURE;
166 }
167
168
172 }
173
174
176
178 unsigned int oldRunNumber = 0;
180 assert(pInputEvt);
181 EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
182 oldRunNumber = eventID->run_number();
185
186
187 EventType* event_type = const_cast<EventType*>(pInputEvt->event_type());
190 } else {
192 return StatusCode::SUCCESS;
193 }
194
195 oldRunNumber = outputEvtInfo->
runNumber();
198
199 {
200
201 auto newChannelNumber =
203 auto oldChannelNumber =
205
206 const char*
key =
"/Generation/Parameters";
207 const IOVMetaDataContainer * iovContainer = nullptr;
209 && iovContainer) {
210
213
214
215 for (CondAttrListCollection* collection : *payloadContainer) {
216 for(
unsigned int index = 0;
index < collection->size(); ++
index) {
217 if (collection->chanNum(index) != oldChannelNumber) {
218 ATH_MSG_INFO(
"Not updating \"" << key <<
"\" on channel number "
219 << collection->chanNum(index));
220 continue;
221 }
222
223 if (collection->fixChanNum(oldChannelNumber, newChannelNumber))
224 ATH_MSG_INFO(
"Updated \"" << key <<
"\" channel number from "
225 << oldChannelNumber << " to " << newChannelNumber);
226 else
227 ATH_MSG_ERROR(
"Channel number update from " << oldChannelNumber
228 << " to " << newChannelNumber << " on \"" << key
229 << "\" FAILED");
230 }
231 }
232
233 {
234
235 const char*
key =
"/TagInfo";
236 const IOVMetaDataContainer * iovContainer = nullptr;
238 && iovContainer) {
239
242
243
244 for (CondAttrListCollection* collection : *payloadContainer) {
245 for (auto pair : *collection) {
246
247 if (pair.second.exists("mc_channel_number")) {
248 try {
249 pair.second["mc_channel_number"].setValue(
251 ATH_MSG_INFO(
"Updated \"" << key <<
"\" mc_channel_number"
253 } catch (std::exception&) {
254 try {
256 ATH_MSG_INFO(
"Updated \"" << key <<
"\" mc_channel_number"
258 } catch (std::exception&) {
261 << "\" FAILED");
262 }
263 }
264 }
265 }
266 }
267 }
268 }
269 } else {
270 ATH_MSG_INFO(
"Could not retrieve \"" << key <<
"\" from MetaDataStore");
271 }
272 }
273 }
274
275
278
279 SmartIF<IEventProcessor> apm(serviceLocator()->service("AthMpEvtLoopMgr", false));
280 if(apm) {
282 }
283 else {
284 apm = serviceLocator()->service("AthenaEventLoopMgr", false);
285 if (apm) {
287 }
288 else {
290 }
291 }
292 }
293
294 return StatusCode::SUCCESS;
295}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
ServiceHandle< StoreGateSvc > & evtStore()
SG::ReadDecorHandleKey< xAOD::EventInfo > m_mcWeightsKey
SG::ReadHandleKey< xAOD::EventInfo > m_inputEvtInfoKey
ServiceHandle< StoreGateSvc > m_metaDataStore
SG::WriteHandleKey< xAOD::EventInfo > m_outputEvtInfoKey
DataModel_detail::iterator< DataVector > iterator
void set_mc_channel_number(number_type chan)
Add in the MC generator channel number (aka gen run number)
number_type mc_channel_number() const
Access to the MC generator channel number (was used as run number for generator events)
void set_mc_event_number(uint64_t evt)
Add in the MC generator event number.
void setMCEventNumber(uint64_t value)
Set the MC generator's event number.
void setEventNumber(uint64_t value)
Set the current event's event number.
void setMCChannelNumber(uint32_t value)
Set the MC generator's channel number.
void setMCEventWeights(const std::vector< float > &value)
Set the weights of all the MC events used in the simulation.
void setRunNumber(uint32_t value)
Set the current event's run number.
uint32_t runNumber() const
The current event's run number.
bool set_ll_event_number(HepMC::GenEvent *e, long long int num)
retrieve(aClass, aKey=None)
EventInfo_v1 EventInfo
Definition of the latest event info version.