Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate away from OwnVector<BaseTrackerRecHit> #44047

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DataFormats/TrackerRecHit2D/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "DataFormats/TrackerRecHit2D/interface/MTDTrackingRecHit.h"
#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h"
#include <memory>
#include <vector>

#endif // SISTRIPRECHIT_CLASSES_H
4 changes: 2 additions & 2 deletions DataFormats/TrackerRecHit2D/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
<version ClassVersion="10" checksum="414205262"/>
</class>

<class name="edm::OwnVector<BaseTrackerRecHit>" persistent="false"/>
<class name="edm::Wrapper<edm::OwnVector<BaseTrackerRecHit> >" persistent="false"/>
<class name="std::vector<std::unique_ptr<BaseTrackerRecHit>>" persistent="false"/>
<class name="edm::Wrapper<std::vector<std::unique_ptr<BaseTrackerRecHit>>>" persistent="false"/>

<class name="std::vector<SiPixelRecHit>"/>

Expand Down
19 changes: 9 additions & 10 deletions RecoTracker/TkSeedGenerator/plugins/MultiHitFromChi2EDProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/EDPutToken.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Utilities/interface/RunningAverage.h"

#include "RecoTracker/TkHitPairs/interface/IntermediateHitDoublets.h"
#include "RecoTracker/TkHitPairs/interface/RegionsSeedingHitSets.h"
#include "DataFormats/Common/interface/OwnVector.h"
#include "RecoTracker/PixelSeeding/interface/LayerTriplets.h"
#include "MultiHitGeneratorFromChi2.h"

#include <memory>
#include <vector>

class MultiHitFromChi2EDProducer : public edm::stream::EDProducer<> {
public:
MultiHitFromChi2EDProducer(const edm::ParameterSet& iConfig);
Expand All @@ -25,6 +28,7 @@ class MultiHitFromChi2EDProducer : public edm::stream::EDProducer<> {

private:
edm::EDGetTokenT<IntermediateHitDoublets> doubletToken_;
edm::EDPutTokenT<std::vector<std::unique_ptr<BaseTrackerRecHit>>> hitsPutToken_;

edm::RunningAverage localRA_;

Expand All @@ -33,9 +37,9 @@ class MultiHitFromChi2EDProducer : public edm::stream::EDProducer<> {

MultiHitFromChi2EDProducer::MultiHitFromChi2EDProducer(const edm::ParameterSet& iConfig)
: doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
hitsPutToken_{produces()},
generator_(iConfig, consumesCollector()) {
produces<RegionsSeedingHitSets>();
produces<edm::OwnVector<BaseTrackerRecHit> >();
}

void MultiHitFromChi2EDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down Expand Up @@ -76,7 +80,7 @@ void MultiHitFromChi2EDProducer::produce(edm::Event& iEvent, const edm::EventSet

OrderedMultiHits multihits;
multihits.reserve(localRA_.upper());
std::vector<std::unique_ptr<BaseTrackerRecHit> > refittedHitStorage;
std::vector<std::unique_ptr<BaseTrackerRecHit>> refittedHitStorage;
refittedHitStorage.reserve(localRA_.upper() * 2);

LogDebug("MultiHitFromChi2EDProducer") << "Creating multihits for " << regionDoublets.regionSize() << " regions, and "
Expand Down Expand Up @@ -137,15 +141,10 @@ void MultiHitFromChi2EDProducer::produce(edm::Event& iEvent, const edm::EventSet
}
localRA_.update(seedingHitSets->size());

auto storage = std::make_unique<edm::OwnVector<BaseTrackerRecHit> >();
storage->reserve(refittedHitStorage.size());
for (auto& ptr : refittedHitStorage)
storage->push_back(ptr.release());

seedingHitSets->shrink_to_fit();
storage->shrink_to_fit();
refittedHitStorage.shrink_to_fit();
iEvent.put(std::move(seedingHitSets));
iEvent.put(std::move(storage));
iEvent.emplace(hitsPutToken_, std::move(refittedHitStorage));
}

#include "FWCore/PluginManager/interface/ModuleDef.h"
Expand Down