Skip to content

Commit

Permalink
Merge pull request #44047 from wddgit/removeOwnVectorBaseTrackerRecHit
Browse files Browse the repository at this point in the history
Migrate away from ```OwnVector<BaseTrackerRecHit>```
  • Loading branch information
cmsbuild authored Feb 29, 2024
2 parents 3c6062f + 84d3ad5 commit 2d3751c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
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

0 comments on commit 2d3751c

Please sign in to comment.