31{
33
34
36
39 SG::ReadHandle<McEventCollection> bkgContainer(
m_bkgInputKey, ctx);
40 if (!bkgContainer.isValid()) {
41 ATH_MSG_ERROR(
"Could not get background McEventCollection container " << bkgContainer.name() <<
" from store " << bkgContainer.store());
42 return StatusCode::FAILURE;
43 }
44 bkgContainerPtr = bkgContainer.cptr();
45
46 ATH_MSG_DEBUG(
"Found background McEventCollection container " << bkgContainer.name() <<
" in store " << bkgContainer.store());
47 }
48
50 if (!signalContainer.isValid()) {
51 ATH_MSG_ERROR(
"Could not get signal McEventCollection container " << signalContainer.name() <<
" from store " << signalContainer.store());
52 return StatusCode::FAILURE;
53 }
54 ATH_MSG_DEBUG(
"Found signal McEventCollection container " << signalContainer.name() <<
" in store " << signalContainer.store());
55
56
57 SG::WriteHandle<McEventCollection> outputContainer(
m_outputKey, ctx);
58 ATH_CHECK(outputContainer.record(std::make_unique<McEventCollection>()));
59 if (!outputContainer.isValid()) {
60 ATH_MSG_ERROR(
"Could not record output McEventCollection container " << outputContainer.name() <<
" to store " << outputContainer.store());
61 return StatusCode::FAILURE;
62 }
63 ATH_MSG_DEBUG(
"Recorded output McEventCollection container " << outputContainer.name() <<
" in store " << outputContainer.store());
64
65 unsigned int droppedSeparatorGenEvents{0};
66 int backupPileUpType{0};
67 int backupBunchCrossingTime{0};
68
70 if ( (*it)->event_number() == -1 ) {
71 ++droppedSeparatorGenEvents;
72 ATH_MSG_VERBOSE(
"Signal: Skipping a separator GenEvent. " << droppedSeparatorGenEvents <<
" skipped so far.");
73 backupBunchCrossingTime+=25;
74 continue;
75 }
78 auto bunchCrossingTime = (*it)->attribute<HepMC3::IntAttribute>(HepMCStr::BunchCrossingTime);
79 if (bunchCrossingTime) {
80 copiedEvent->add_attribute(HepMCStr::BunchCrossingTime,std::make_shared<HepMC3::IntAttribute>(bunchCrossingTime->value()));
81 }
82 else {
83 copiedEvent->add_attribute(HepMCStr::BunchCrossingTime,std::make_shared<HepMC3::IntAttribute>(backupBunchCrossingTime));
84 }
85 auto pileupType = (*it)->attribute<HepMC3::IntAttribute>(HepMCStr::PileUpType);
86 if (pileupType) {
87 copiedEvent->add_attribute(HepMCStr::PileUpType,std::make_shared<HepMC3::IntAttribute>(pileupType->value()));
88 }
89 else {
90 copiedEvent->add_attribute(HepMCStr::PileUpType,std::make_shared<HepMC3::IntAttribute>(backupPileUpType));
91 if (backupPileUpType == 0) { backupPileUpType = 1; }
92 }
93 if (!copiedEvent->heavy_ion() && (*it)->heavy_ion()) {
94
95
97 copiedEvent->set_heavy_ion(std::move(hinew));
98 }
99 outputContainer->push_back(copiedEvent);
100 }
101
102 backupBunchCrossingTime = 0;
103
107
109 }
110 for ( ;
it != bkgContainerPtr->
end(); ++
it) {
111 if ( (*it)->event_number() == -1 ) {
112 ++droppedSeparatorGenEvents;
113 ATH_MSG_VERBOSE(
"Background: Skipping a separator GenEvent. " << droppedSeparatorGenEvents <<
" skipped so far.");
114 backupBunchCrossingTime+=25;
115 continue;
116 }
119 auto bunchCrossingTime = (*it)->attribute<HepMC3::IntAttribute>(HepMCStr::BunchCrossingTime);
120 if (bunchCrossingTime) {
121 copiedEvent->add_attribute(HepMCStr::BunchCrossingTime,std::make_shared<HepMC3::IntAttribute>(bunchCrossingTime->value()));
122 }
123 else {
124 copiedEvent->add_attribute(HepMCStr::BunchCrossingTime,std::make_shared<HepMC3::IntAttribute>(backupBunchCrossingTime));
125 }
126 auto pileupType = (*it)->attribute<HepMC3::IntAttribute>(HepMCStr::PileUpType);
127 if (pileupType) {
128 copiedEvent->add_attribute(HepMCStr::PileUpType,std::make_shared<HepMC3::IntAttribute>(pileupType->value()));
129 }
130 else {
131 copiedEvent->add_attribute(HepMCStr::PileUpType,std::make_shared<HepMC3::IntAttribute>(backupPileUpType));
132 if (backupPileUpType == 0) { backupPileUpType = 1; }
133 }
134 if (!copiedEvent->heavy_ion() && (*it)->heavy_ion()) {
135
136
138 copiedEvent->set_heavy_ion(std::move(hinew));
139 }
140 outputContainer->push_back(copiedEvent);
141 }
142 }
143 ATH_MSG_VERBOSE(
"output size: " << outputContainer->size() <<
", Signal Input size: " << signalContainer->size() <<
", Bkg Input size: " << bkgContainerPtr->
size() <<
", dropped neutrino GenEvents: " << (
m_removeBkgHardScatterTruth ? 1 : 0) <<
" , dropped Separator GenEvents: " << droppedSeparatorGenEvents);
144
146 if (!outputContainer->empty()) {
150 }
151 }
152 }
153
155 return StatusCode::SUCCESS;
156}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool msgLvl(const MSG::Level lvl) const
Gaudi::Property< bool > m_removeBkgHardScatterTruth
SG::ReadHandleKey< McEventCollection > m_bkgInputKey
SG::WriteHandleKey< McEventCollection > m_outputKey
SG::ReadHandleKey< McEventCollection > m_signalInputKey
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
int signal_process_id(const GenEvent &evt)
HepMC3::GenHeavyIonPtr GenHeavyIonPtr
void fillBarcodesAttribute(GenEvent *e)
HepMC3::GenEvent GenEvent