27 return StatusCode::SUCCESS;
41 ATH_MSG_ERROR(
"Could not get background McEventCollection container " << bkgContainer.
name() <<
" from store " << bkgContainer.
store());
42 return StatusCode::FAILURE;
44 bkgContainerPtr = bkgContainer.
cptr();
46 ATH_MSG_DEBUG(
"Found background McEventCollection container " << bkgContainer.
name() <<
" in store " << bkgContainer.
store());
50 if (!signalContainer.
isValid()) {
51 ATH_MSG_ERROR(
"Could not get signal McEventCollection container " << signalContainer.
name() <<
" from store " << signalContainer.
store());
52 return StatusCode::FAILURE;
54 ATH_MSG_DEBUG(
"Found signal McEventCollection container " << signalContainer.
name() <<
" in store " << signalContainer.
store());
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;
63 ATH_MSG_DEBUG(
"Recorded output McEventCollection container " << outputContainer.
name() <<
" in store " << outputContainer.
store());
65 unsigned int droppedSeparatorGenEvents{0};
67 int backupPileUpType{0};
68 int backupBunchCrossingTime{0};
73 if ( (*it)->event_number() == -1 ) {
74 ++droppedSeparatorGenEvents;
75 ATH_MSG_VERBOSE(
"Signal: Skipping a separator GenEvent. " << droppedSeparatorGenEvents <<
" skipped so far.");
76 backupBunchCrossingTime+=25;
80 HepMC::GenEvent* copiedEvent =
new HepMC::GenEvent(**
it);
83 auto bunchCrossingTime = (*it)->attribute<HepMC3::IntAttribute>(
"BunchCrossingTime");
84 if (bunchCrossingTime) {
85 copiedEvent->add_attribute(
"BunchCrossingTime",std::make_shared<HepMC3::IntAttribute>(bunchCrossingTime->value()));
88 copiedEvent->add_attribute(
"BunchCrossingTime",std::make_shared<HepMC3::IntAttribute>(backupBunchCrossingTime));
90 auto pileupType = (*it)->attribute<HepMC3::IntAttribute>(
"PileUpType");
92 copiedEvent->add_attribute(
"PileUpType",std::make_shared<HepMC3::IntAttribute>(pileupType->value()));
95 copiedEvent->add_attribute(
"PileUpType",std::make_shared<HepMC3::IntAttribute>(backupPileUpType));
96 if (backupPileUpType == 0) { backupPileUpType = 1; }
99 if (!copiedEvent->heavy_ion() && (*it)->heavy_ion()) {
103 HepMC::GenHeavyIonPtr hinew=std::make_shared<HepMC::GenHeavyIon>(*((*it)->heavy_ion()));
104 copiedEvent->set_heavy_ion(hinew);
106 copiedEvent->set_heavy_ion(*((*it)->heavy_ion()));
113 backupBunchCrossingTime = 0;
122 for ( ;
it != bkgContainerPtr->
end(); ++
it) {
124 if ( (*it)->event_number() == -1 ) {
125 ++droppedSeparatorGenEvents;
126 ATH_MSG_VERBOSE(
"Background: Skipping a separator GenEvent. " << droppedSeparatorGenEvents <<
" skipped so far.");
127 backupBunchCrossingTime+=25;
131 HepMC::GenEvent* copiedEvent =
new HepMC::GenEvent(**
it);
134 auto bunchCrossingTime = (*it)->attribute<HepMC3::IntAttribute>(
"BunchCrossingTime");
135 if (bunchCrossingTime) {
136 copiedEvent->add_attribute(
"BunchCrossingTime",std::make_shared<HepMC3::IntAttribute>(bunchCrossingTime->value()));
139 copiedEvent->add_attribute(
"BunchCrossingTime",std::make_shared<HepMC3::IntAttribute>(backupBunchCrossingTime));
141 auto pileupType = (*it)->attribute<HepMC3::IntAttribute>(
"PileUpType");
143 copiedEvent->add_attribute(
"PileUpType",std::make_shared<HepMC3::IntAttribute>(pileupType->value()));
146 copiedEvent->add_attribute(
"PileUpType",std::make_shared<HepMC3::IntAttribute>(backupPileUpType));
147 if (backupPileUpType == 0) { backupPileUpType = 1; }
150 if (!copiedEvent->heavy_ion() && (*it)->heavy_ion()) {
154 HepMC::GenHeavyIonPtr hinew=std::make_shared<HepMC::GenHeavyIon>(*((*it)->heavy_ion()));
155 copiedEvent->set_heavy_ion(hinew);
157 copiedEvent->set_heavy_ion(*((*it)->heavy_ion()));
163 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);
166 if (!outputContainer->
empty()) {
168 for (
const HepMC::GenEvent *
event : *outputContainer) {
175 return StatusCode::SUCCESS;