Skip to content

Commit

Permalink
Merge pull request #43987 from wddgit/removeOwnVectorSiStripMatchedRe…
Browse files Browse the repository at this point in the history
…cHit2D

Remove or replace ```OwnVector<SiStripMatchedRecHit2D>```
  • Loading branch information
cmsbuild authored Feb 19, 2024
2 parents 450661c + 1c639d2 commit 08a010d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
#define DATAFORMATS_SISTRIPMATCHEDRECHIT2DCOLLECTION_H

#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
#include "DataFormats/Common/interface/RangeMap.h"
#include "DataFormats/Common/interface/ClonePolicy.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/Common/interface/OwnVector.h"
#include <vector>

typedef edm::RangeMap<DetId, edm::OwnVector<SiStripMatchedRecHit2D> > SiStripMatchedRecHit2DCollectionOld;

#include "DataFormats/Common/interface/DetSetVectorNew.h"

typedef edmNew::DetSetVector<SiStripMatchedRecHit2D> SiStripMatchedRecHit2DCollection;
typedef SiStripMatchedRecHit2DCollection SiStripMatchedRecHit2DCollectionNew;

Expand Down
9 changes: 0 additions & 9 deletions DataFormats/TrackerRecHit2D/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,9 @@
<version ClassVersion="10" checksum="414205262"/>
</class>

<class name="std::vector<SiStripMatchedRecHit2D*>"/>
<class name="edm::OwnVector<SiStripMatchedRecHit2D,edm::ClonePolicy<SiStripMatchedRecHit2D> >"/>
<class name="edm::OwnVector<SiStripMatchedRecHit2D,edm::ClonePolicy<SiStripMatchedRecHit2D> >::const_iterator"/>

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

<class name="edm::RangeMap<DetId, edm::OwnVector<SiStripMatchedRecHit2D, edm::ClonePolicy<SiStripMatchedRecHit2D> >, edm::ClonePolicy<SiStripMatchedRecHit2D> >"/>
<class name="edm::RangeMap<DetId, edm::OwnVector<SiStripMatchedRecHit2D, edm::ClonePolicy<SiStripMatchedRecHit2D> >, edm::ClonePolicy<SiStripMatchedRecHit2D> >::id_iterator"/>

<class name="edm::Wrapper<edm::RangeMap<DetId, edm::OwnVector<SiStripMatchedRecHit2D, edm::ClonePolicy<SiStripMatchedRecHit2D> >, edm::ClonePolicy<SiStripMatchedRecHit2D> > >"/>

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

<class name="std::vector<SiStripRecHit2D>"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"

#include <memory>

namespace edm {
class ConsumesCollector;
class ParameterSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class GluedGeomDet;
#include <cfloat>
#include <functional>
#include <memory>
#include <vector>

class SiStripRecHitMatcher {
public:
Expand Down Expand Up @@ -88,7 +89,7 @@ class SiStripRecHitMatcher {
void match(const SiStripRecHit2D* monoRH,
SimpleHitIterator begin,
SimpleHitIterator end,
edm::OwnVector<SiStripMatchedRecHit2D>& collector,
std::vector<std::unique_ptr<SiStripMatchedRecHit2D>>& collector,
const GluedGeomDet* gluedDet,
LocalVector trackdirection) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <vector>

SiStripRecHitConverterAlgorithm::SiStripRecHitConverterAlgorithm(const edm::ParameterSet& conf,
edm::ConsumesCollector iC)
: useQuality(conf.getParameter<bool>("useSiStripQuality")),
Expand Down Expand Up @@ -50,11 +52,11 @@ void SiStripRecHitConverterAlgorithm::initialize(const edm::EventSetup& es) {
}
}

void SiStripRecHitConverterAlgorithm::run(edm::Handle<edmNew::DetSetVector<SiStripCluster> > input, products& output) {
void SiStripRecHitConverterAlgorithm::run(edm::Handle<edmNew::DetSetVector<SiStripCluster>> input, products& output) {
run(input, output, LocalVector(0., 0., 0.));
}

void SiStripRecHitConverterAlgorithm::run(edm::Handle<edmNew::DetSetVector<SiStripCluster> > inputhandle,
void SiStripRecHitConverterAlgorithm::run(edm::Handle<edmNew::DetSetVector<SiStripCluster>> inputhandle,
products& output,
LocalVector trackdirection) {
for (auto const& DS : *inputhandle) {
Expand Down Expand Up @@ -90,7 +92,7 @@ namespace {
struct CollectorHelper {
size_t nmatch;

typedef edm::OwnVector<SiStripMatchedRecHit2D> CollectorMatched;
using CollectorMatched = std::vector<std::unique_ptr<SiStripMatchedRecHit2D>>;
typedef SiStripMatchedRecHit2DCollection::FastFiller Collector;

Collector& m_collector;
Expand All @@ -104,15 +106,9 @@ namespace {

static inline SiStripRecHit2D const& monoHit(edmNew::DetSet<SiStripRecHit2D>::const_iterator iter) { return *iter; }

struct Add {
Add(CollectorHelper& ih) : h(ih) {}
CollectorHelper& h;
void operator()(SiStripMatchedRecHit2D const& rh) { h.m_collectorMatched.push_back(rh); }
};

CollectorHelper& collector() { return *this; }

void operator()(SiStripMatchedRecHit2D const& rh) { m_collectorMatched.push_back(rh); }
void operator()(SiStripMatchedRecHit2D const& rh) { m_collectorMatched.emplace_back(rh.clone()); }

CollectorHelper(Collector& i_collector,
CollectorMatched& i_collectorMatched,
Expand All @@ -127,10 +123,7 @@ namespace {
void closure(edmNew::DetSet<SiStripRecHit2D>::const_iterator it) {
if (!m_collectorMatched.empty()) {
nmatch += m_collectorMatched.size();
for (edm::OwnVector<SiStripMatchedRecHit2D>::const_iterator itm = m_collectorMatched.begin(),
edm = m_collectorMatched.end();
itm != edm;
++itm) {
for (auto const& itm : m_collectorMatched) {
m_collector.push_back(*itm);
// mark the stereo hit cluster as used, so that the hit won't go in the unmatched stereo ones
m_matchedSteroClusters.push_back(itm->stereoClusterRef().key());
Expand All @@ -146,7 +139,7 @@ namespace {

void SiStripRecHitConverterAlgorithm::match(products& output, LocalVector trackdirection) const {
int nmatch = 0;
edm::OwnVector<SiStripMatchedRecHit2D> collectorMatched; // gp/FIXME: avoid this
std::vector<std::unique_ptr<SiStripMatchedRecHit2D>> collectorMatched;

// Remember the ends of the collections, as we will use them a lot
SiStripRecHit2DCollection::const_iterator edStereoDet = output.stereo->end();
Expand Down Expand Up @@ -218,10 +211,7 @@ void SiStripRecHitConverterAlgorithm::match(products& output, LocalVector trackd
&(*it), stereoSimpleHits.begin(), stereoSimpleHits.end(), collectorMatched, gluedDet, trackdirection);
if (collectorMatched.size() > 0) {
nmatch += collectorMatched.size();
for (edm::OwnVector<SiStripMatchedRecHit2D>::const_iterator itm = collectorMatched.begin(),
edm = collectorMatched.end();
itm != edm;
++itm) {
for (auto const& itm : collectorMatched) {
collector.push_back(*itm);
// mark the stereo hit cluster as used, so that the hit won't go in the unmatched stereo ones
matchedSteroClusters.push_back(itm->stereoClusterRef().key());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ namespace {
void SiStripRecHitMatcher::match(const SiStripRecHit2D* monoRH,
SimpleHitIterator begin,
SimpleHitIterator end,
edm::OwnVector<SiStripMatchedRecHit2D>& collector,
std::vector<std::unique_ptr<SiStripMatchedRecHit2D>>& collector,
const GluedGeomDet* gluedDet,
LocalVector trackdirection) const {
std::vector<SiStripMatchedRecHit2D*> result;
result.reserve(end - begin);
match(monoRH, begin, end, result, gluedDet, trackdirection);
for (std::vector<SiStripMatchedRecHit2D*>::iterator p = result.begin(); p != result.end(); p++)
collector.push_back(*p);
collector.emplace_back(*p);
}

void SiStripRecHitMatcher::match(const SiStripRecHit2D* monoRH,
Expand Down
4 changes: 0 additions & 4 deletions SLHCUpgradeSimulations/Geometry/test/StdHitNtuplizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// USER INCLUDES
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/OwnVector.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
Expand Down Expand Up @@ -635,9 +634,6 @@ void StdHitNtuplizer::analyze(const edm::Event& e, const edm::EventSetup& es) {
// now matched hits
if (rechitsmatched.product()->dataSize() > 0) {
//Loop over all rechits in RPHI collection (can also loop only over DetId)
//SiStripMatchedRecHit2DCollectionOld::const_iterator theRecHitRangeIteratorBegin = rechitsmatched->begin();
//SiStripMatchedRecHit2DCollectionOld::const_iterator theRecHitRangeIteratorEnd = rechitsmatched->end();
//SiStripMatchedRecHit2DCollectionOld::const_iterator iterRecHit;
SiStripMatchedRecHit2DCollection::const_iterator recHitIdIterator = (rechitsmatched.product())->begin();
SiStripMatchedRecHit2DCollection::const_iterator recHitIdIteratorEnd = (rechitsmatched.product())->end();

Expand Down

0 comments on commit 08a010d

Please sign in to comment.