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

save 50MB (35pu one thread) by not copying stuff around in TkConvValidator #17484

Merged
merged 1 commit into from Feb 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 19 additions & 20 deletions Validation/RecoEgamma/plugins/TkConvValidator.cc
Expand Up @@ -146,9 +146,9 @@ TkConvValidator::TkConvValidator( const edm::ParameterSet& pset )
edm::InputTag("tpSelecForEfficiency"));
tpSelForFake_Token_ = consumes<TrackingParticleRefVector> (
edm::InputTag("tpSelecForFakeRate"));
hepMC_Token_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
genjets_Token_ = consumes<reco::GenJetCollection>(
edm::InputTag("ak4GenJets"));
//hepMC_Token_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
//genjets_Token_ = consumes<reco::GenJetCollection>(
// edm::InputTag("ak4GenJets"));

trackAssociator_Token_ = consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag("trackAssociatorByHitsForConversionValidation"));
}
Expand Down Expand Up @@ -886,41 +886,42 @@ void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup

//////////////////// Get the MC truth
//get simtrack info
std::vector<SimTrack> theSimTracks;
std::vector<SimVertex> theSimVertices;
//std::vector<SimTrack> theSimTracks;
//std::vector<SimVertex> theSimVertices;

edm::Handle<SimTrackContainer> SimTk;
edm::Handle<SimVertexContainer> SimVtx;
e.getByToken(g4_simTk_Token_, SimTk);
e.getByToken(g4_simVtx_Token_, SimVtx);

bool useTP = parameters_.getParameter<bool>("useTP");
TrackingParticleRefVector tpForEfficiency;
TrackingParticleRefVector tpForFakeRate;
TrackingParticleRefVector dummy;
edm::Handle<TrackingParticleRefVector> TPHandleForEff;
edm::Handle<TrackingParticleRefVector> TPHandleForFakeRate;
if (useTP) {
e.getByToken(tpSelForEff_Token_, TPHandleForEff);
tpForEfficiency = *(TPHandleForEff.product());
e.getByToken(tpSelForFake_Token_, TPHandleForFakeRate);
tpForFakeRate = *(TPHandleForFakeRate.product());
}

const TrackingParticleRefVector &tpForEfficiency= useTP? *(TPHandleForEff.product()) : dummy;
const TrackingParticleRefVector &tpForFakeRate= useTP? *(TPHandleForFakeRate.product()):dummy;

const std::vector<SimTrack> &theSimTracks= *SimTk;
const std::vector<SimVertex> &theSimVertices= *SimVtx;

theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
//theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
//theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks, theSimVertices);

edm::Handle<edm::HepMCProduct> hepMC;
e.getByToken(hepMC_Token_, hepMC);
//edm::Handle<edm::HepMCProduct> hepMC;
//e.getByToken(hepMC_Token_, hepMC);
// const HepMC::GenEvent *myGenEvent = hepMC->GetEvent(); // unused


// get generated jets
edm::Handle<reco::GenJetCollection> GenJetsHandle;
e.getByToken(genjets_Token_, GenJetsHandle);
reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
//edm::Handle<reco::GenJetCollection> GenJetsHandle;
//e.getByToken(genjets_Token_, GenJetsHandle);
//const reco::GenJetCollection &genJetCollection = *(GenJetsHandle.product());

ConversionHitChecker hitChecker;

Expand Down Expand Up @@ -969,7 +970,7 @@ void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup
theConvTP_.clear();
// std::cout << " TkConvValidator TrackingParticles TrackingParticleCollection size "<< trackingParticles.size() << "\n";
//duplicated TP collections for two associations
for(TrackingParticleRef tp: tpForEfficiency) {
for(const TrackingParticleRef tp: tpForEfficiency) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop variable could also be a & which would be a bit faster.

if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
Expand Down Expand Up @@ -1424,13 +1425,11 @@ void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup


theConvTP_.clear();
for(TrackingParticleRef tp: tpForFakeRate) {
for(const TrackingParticleRef tp: tpForFakeRate) {
if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
theConvTP_.push_back( tp );


}
}

Expand Down