Skip to content

Commit

Permalink
Do not call edm::RefVector<>::product in Associators
Browse files Browse the repository at this point in the history
The call to edm::RefVector<>::product is being deprecated. Instead
of getting the full container, we now loop over the RefVector and
fill a new container. This (argueably) better matches the API of
the function call anyway.
This may lead to differences is results because we might be looping
over a restricted set of entries. If this is a problem then the calling
module should pass in the full container and not a RefVector.
  • Loading branch information
Dr15Jones committed Jan 22, 2015
1 parent 2f349b2 commit 417f6e0
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 18 deletions.
10 changes: 8 additions & 2 deletions SimMuon/MCTruth/src/MuonAssociatorByHitsHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ MuonAssociatorByHitsHelper::associateRecoToSimIndices(const TrackHitsCollection
bool printRtS(true);

TrackingParticleCollection tPC;
if (TPCollectionH.size()!=0) tPC = *(TPCollectionH.product());
tPC.reserve(TPCollectionH.size());
for(auto const& ref: TPCollectionH) {
tPC.push_back(*ref);
}

if(resources.diagnostics_) {
resources.diagnostics_(tC,tPC);
Expand Down Expand Up @@ -362,7 +365,10 @@ MuonAssociatorByHitsHelper::associateSimToRecoIndices( const TrackHitsCollection
bool printRtS(true);

TrackingParticleCollection tPC;
if (TPCollectionH.size()!=0) tPC = *(TPCollectionH.product());
tPC.reserve(TPCollectionH.size());
for(auto const& ref: TPCollectionH) {
tPC.push_back(*ref);
}

bool any_trackingParticle_matched = false;

Expand Down
10 changes: 8 additions & 2 deletions SimTracker/TrackAssociation/src/TrackAssociatorByChi2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ RecoToSimCollection TrackAssociatorByChi2::associateRecoToSim(const edm::RefToBa
RecoToSimCollection outputCollection;

TrackingParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tindex=0;
for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
Expand Down Expand Up @@ -186,7 +189,10 @@ SimToRecoCollection TrackAssociatorByChi2::associateSimToReco(const edm::RefToBa
SimToRecoCollection outputCollection;

TrackingParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tpindex =0;
for (TrackingParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
Expand Down
14 changes: 10 additions & 4 deletions SimTracker/TrackAssociation/src/TrackAssociatorByHits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ TrackAssociatorByHits::associateRecoToSim(const edm::RefToBaseVector<reco::Track

TrackerHitAssociator * associate = new TrackerHitAssociator(*e, conf_);

const TrackingParticleCollection emptyCollection;
const TrackingParticleCollection& tPC = ( TPCollectionH.size() != 0 ? *(TPCollectionH.product()) : emptyCollection);
TrackingParticleCollection tPC;
tPC.reserve(TPCollectionH.size());
for(auto const& ref: TPCollectionH) {
tPC.push_back(*ref);
}

//get the ID of the recotrack by hits
int tindex=0;
Expand Down Expand Up @@ -165,8 +168,11 @@ TrackAssociatorByHits::associateSimToReco(const edm::RefToBaseVector<reco::Track

TrackerHitAssociator * associate = new TrackerHitAssociator(*e, conf_);

const TrackingParticleCollection emptyCollection;
const TrackingParticleCollection& tPC = ( TPCollectionH.size() != 0 ? *(TPCollectionH.product()) : emptyCollection);
TrackingParticleCollection tPC;
tPC.reserve(TPCollectionH.size());
for(auto const& ref: TPCollectionH) {
tPC.push_back(*ref);
}

//for (TrackingParticleCollection::const_iterator t = tPC.begin(); t != tPC.end(); ++t) {
// LogTrace("TrackAssociator") << "NEW TP DUMP";
Expand Down
10 changes: 8 additions & 2 deletions SimTracker/TrackAssociation/src/TrackGenAssociatorByChi2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ RecoToGenCollection TrackGenAssociatorByChi2::associateRecoToGen(const edm::RefT
RecoToGenCollection outputCollection;

GenParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tindex=0;
for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
Expand Down Expand Up @@ -87,7 +90,10 @@ GenToRecoCollection TrackGenAssociatorByChi2::associateGenToReco(const edm::RefT
GenToRecoCollection outputCollection;

GenParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tpindex =0;
for (GenParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ RecoToSimCollection TrackAssociatorByChi2Impl::associateRecoToSim(const edm::Ref
RecoToSimCollection outputCollection;

TrackingParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tindex=0;
for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
Expand Down Expand Up @@ -179,7 +182,10 @@ SimToRecoCollection TrackAssociatorByChi2Impl::associateSimToReco(const edm::Ref
SimToRecoCollection outputCollection;

TrackingParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tpindex =0;
for (TrackingParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ TrackAssociatorByHitsImpl::associateRecoToSim(const edm::RefToBaseVector<reco::T
std::vector< SimHitIdpr> matchedIds;
RecoToSimCollection outputCollection;

const TrackingParticleCollection emptyCollection;
const TrackingParticleCollection& tPC = ( TPCollectionH.size() != 0 ? *(TPCollectionH.product()) : emptyCollection);
TrackingParticleCollection tPC;
tPC.reserve(tPC.size());
for(auto const& ref: TPCollectionH) {
tPC.push_back(*ref);
}

//get the ID of the recotrack by hits
int tindex=0;
Expand Down Expand Up @@ -174,8 +177,11 @@ TrackAssociatorByHitsImpl::associateSimToReco(const edm::RefToBaseVector<reco::T
std::vector< SimHitIdpr> matchedIds;
SimToRecoCollection outputCollection;

const TrackingParticleCollection emptyCollection;
const TrackingParticleCollection& tPC = ( TPCollectionH.size() != 0 ? *(TPCollectionH.product()) : emptyCollection);
TrackingParticleCollection tPC;
tPC.reserve(tPC.size());
for(auto const& ref: TPCollectionH) {
tPC.push_back(*ref);
}

//for (TrackingParticleCollection::const_iterator t = tPC.begin(); t != tPC.end(); ++t) {
// LogTrace("TrackAssociator") << "NEW TP DUMP";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ RecoToGenCollection TrackGenAssociatorByChi2Impl::associateRecoToGen(const edm::
RecoToGenCollection outputCollection;

GenParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tindex=0;
for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
Expand Down Expand Up @@ -78,7 +81,10 @@ GenToRecoCollection TrackGenAssociatorByChi2Impl::associateGenToReco(const edm::
GenToRecoCollection outputCollection;

GenParticleCollection tPC;
if (tPCH.size()!=0) tPC = *tPCH.product();
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
}

int tpindex =0;
for (GenParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
Expand Down

0 comments on commit 417f6e0

Please sign in to comment.