Skip to content

Commit 3d7ce8b

Browse files
authored
Merge pull request #49522 from Dr15Jones/fixHepMC3GenEventOwnership
Fix ownership of HepMC3::GenEvent
2 parents 8f052f5 + fc0b62c commit 3d7ce8b

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

GeneratorInterface/Core/interface/GeneratorFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ namespace edm {
261261
ev.put(std::move(genEventInfo3));
262262

263263
std::unique_ptr<HepMC3Product> bare_product(new HepMC3Product());
264-
bare_product->addHepMCData(event3.release());
264+
bare_product->addHepMCData(*event3);
265265
ev.put(std::move(bare_product), "unsmeared");
266266
}
267267

GeneratorInterface/Core/interface/HadronizerFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ namespace edm {
340340
ev.put(std::move(finalGenEventInfo3));
341341

342342
std::unique_ptr<HepMC3Product> bare_product(new HepMC3Product());
343-
bare_product->addHepMCData(finalEvent3.release());
343+
bare_product->addHepMCData(*finalEvent3);
344344
ev.put(std::move(bare_product), "unsmeared");
345345
}
346346

GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet
240240
}
241241

242242
// Finalize HepMC event record
243-
auto hepmc_product = std::make_unique<edm::HepMC3Product>(&hepmc_event);
243+
auto hepmc_product = std::make_unique<edm::HepMC3Product>(hepmc_event);
244244
event.put(std::move(hepmc_product), "unsmeared");
245245
}
246246

IOMC/EventVertexGenerators/src/BaseEvtVtxGenerator.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ void BaseEvtVtxGenerator::produce(Event& evt, const EventSetup&) {
6969
if (!found)
7070
throw cms::Exception("ProductAbsent") << "No HepMCProduct, tried to get HepMC3Product, but it is also absent.";
7171

72-
HepMC3::GenEvent* genevt3 = new HepMC3::GenEvent();
73-
genevt3->read_data(*HepUnsmearedMCEvt3->GetEvent());
74-
HepMC3Product* productcopy3 = new HepMC3Product(genevt3);
72+
HepMC3::GenEvent genevt3;
73+
genevt3.read_data(*HepUnsmearedMCEvt3->GetEvent());
74+
auto productcopy3 = std::make_unique<HepMC3Product>(genevt3);
7575
ROOT::Math::XYZTVector VertexShift = vertexShift(engine);
7676
productcopy3->applyVtxGen(HepMC3::FourVector(VertexShift.x(), VertexShift.y(), VertexShift.z(), VertexShift.t()));
7777

@@ -91,8 +91,7 @@ void BaseEvtVtxGenerator::produce(Event& evt, const EventSetup&) {
9191
}
9292
}
9393

94-
std::unique_ptr<edm::HepMC3Product> HepMC3Evt(productcopy3);
95-
evt.put(std::move(HepMC3Evt));
94+
evt.put(std::move(productcopy3));
9695
}
9796

9897
return;

SimDataFormats/GeneratorProducts/interface/HepMC3Product.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ namespace edm {
2323
public:
2424
HepMC3Product() : isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) {}
2525

26-
explicit HepMC3Product(const HepMC3::GenEvent *evt);
26+
explicit HepMC3Product(const HepMC3::GenEvent &evt);
2727
~HepMC3Product();
2828

29-
void addHepMCData(const HepMC3::GenEvent *evt);
29+
void addHepMCData(const HepMC3::GenEvent &evt);
3030

3131
void applyVtxGen(HepMC3::FourVector const *vtxShift) { applyVtxGen(*vtxShift); }
3232
void applyVtxGen(HepMC3::FourVector const &vtxShift);

SimDataFormats/GeneratorProducts/src/HepMC3Product.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
using namespace edm;
1717
using namespace std;
1818

19-
HepMC3Product::HepMC3Product(const HepMC3::GenEvent* evt)
19+
HepMC3Product::HepMC3Product(const HepMC3::GenEvent& evt)
2020
: isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) {
2121
addHepMCData(evt);
2222
}
2323

2424
HepMC3Product::~HepMC3Product() = default;
2525

26-
void HepMC3Product::addHepMCData(const HepMC3::GenEvent* evt) { evt->write_data(evt_); }
26+
void HepMC3Product::addHepMCData(const HepMC3::GenEvent& evt) { evt.write_data(evt_); }
2727

2828
void HepMC3Product::applyVtxGen(HepMC3::FourVector const& vtxShift) {
2929
//std::cout<< " applyVtxGen called " << isVtxGenApplied_ << endl;

0 commit comments

Comments
 (0)