Skip to content

Commit

Permalink
get rid of UB in TrackListMerger
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Mar 22, 2022
1 parent 3fc4eb8 commit 9b89f54
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions RecoTracker/FinalTrackSelectors/plugins/TrackListMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class dso_hidden TrackListMerger : public edm::stream::EDProducer<> {
public:
explicit TrackListMerger(const edm::ParameterSet& conf);

~TrackListMerger() override;
~TrackListMerger() override = default;

void produce(edm::Event& e, const edm::EventSetup& c) override;

Expand Down Expand Up @@ -300,9 +300,6 @@ TrackListMerger::TrackListMerger(edm::ParameterSet const& conf) {
}
}

// Virtual destructor needed.
TrackListMerger::~TrackListMerger() {}

// Functions that gets called by framework every event
void TrackListMerger::produce(edm::Event& e, const edm::EventSetup& es) {
// extract tracker geometry
Expand Down Expand Up @@ -336,6 +333,41 @@ void TrackListMerger::produce(edm::Event& e, const edm::EventSetup& es) {
}
}

// output empty collections and early return
if (trackColls.empty()) {
if (trkQualMod_) {
auto vm = std::make_unique<edm::ValueMap<int>>();
e.put(std::move(vm));
auto quals = std::make_unique<QualityMaskCollection>();
e.put(std::move(quals), "QualityMasks");
} else {
auto outputTrks = std::make_unique<reco::TrackCollection>();
e.put(std::move(outputTrks));

if (makeReKeyedSeeds_) {
auto outputSeeds = std::make_unique<TrajectorySeedCollection>();
e.put(std::move(outputSeeds));
}

if (copyExtras_) {
auto outputTrkExtras = std::make_unique<reco::TrackExtraCollection>();
auto outputTrkHits = std::make_unique<TrackingRecHitCollection>();
e.put(std::move(outputTrkExtras));
e.put(std::move(outputTrkHits));
}

auto outputTrajs = std::make_unique<std::vector<Trajectory>>();
outputTTAss = std::make_unique<TrajTrackAssociationCollection>();
e.put(std::move(outputTrajs));
e.put(std::move(outputTTAss));
}
auto vmMVA = std::make_unique<edm::ValueMap<float>>();
e.put(std::move(vmMVA), "MVAVals");
auto mvas = std::make_unique<MVACollection>();
e.put(std::move(mvas), "MVAValues");
return;
}

unsigned int collsSize = trackColls.size();
unsigned int rSize = 0;
unsigned int trackCollSizes[collsSize];
Expand Down

0 comments on commit 9b89f54

Please sign in to comment.