diff --git a/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h b/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h index 8c3954a4b30feaa8b468d6f1c0774b9283e74ea2..407483ee2055a9f99100d6810b2d5abe1db808d6 100644 --- a/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h +++ b/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h @@ -166,7 +166,6 @@ public: virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin> particleTruthClassifier(HepMC::ConstGenParticlePtr,Info* info = nullptr) const override; - bool compareTruthParticles(const HepMC::ConstGenParticlePtr& genPart, const xAOD::TruthParticle* truthPart) const; #endif #ifndef GENERATIONBASE /*These can not run in Generation only release*/ diff --git a/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx b/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx index 856ef238bc355424541bfbf46803edccf8ef516c..632295a07886d7d15a8a448f7799db27e9b28e06 100644 --- a/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx +++ b/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx @@ -36,10 +36,8 @@ MCTruthClassifier::particleTruthClassifier(const HepMcParticleLink& theLink, Inf return std::make_pair(Unknown, NonDefined); } - std::pair<ParticleType, ParticleOrigin> MCTruthClassifier::particleTruthClassifier(HepMC::ConstGenParticlePtr thePart, Info* info /*= nullptr*/) const { - //--------------------------------------------------------------------------------------- ParticleType partType = Unknown; ParticleOrigin partOrig = NonDefined; @@ -53,32 +51,20 @@ MCTruthClassifier::particleTruthClassifier(HepMC::ConstGenParticlePtr thePart, I ATH_MSG_WARNING( " Invalid ReadHandle for xAODTruthParticleLinkVector with key: " << truthParticleLinkVecReadHandle.key()); return std::make_pair(partType, partOrig); } - int theBC = HepMC::barcode(thePart); for (const auto *const entry : *truthParticleLinkVecReadHandle) { if (entry->first.isValid() && entry->second.isValid() && entry->first.barcode() == theBC) { const xAOD::TruthParticle* truthParticle = *entry->second; - if (!compareTruthParticles(thePart, truthParticle)) { - // if the barcode/pdg id / status of the pair does not match - // return default - return std::make_pair(partType, partOrig); + // if the barcode/pdg id / status of the pair does not match return default + if ( !thePart || !truthParticle || thePart->pdg_id() != truthParticle->pdgId() || thePart->status() != truthParticle->status() || HepMC::barcode(thePart) != truthParticle->barcode()){ + ATH_MSG_DEBUG("HepMC::GenParticle and xAOD::TruthParticle do not match"); + return std::make_pair(partType, partOrig); } return particleTruthClassifier(truthParticle, info); } } - return std::make_pair(partType, partOrig); } -//------------------------------------------------------------------------ -bool -MCTruthClassifier::compareTruthParticles(const HepMC::ConstGenParticlePtr& genPart, const xAOD::TruthParticle* truthPart) const { - if (!genPart || !truthPart) return false; - if (genPart->pdg_id() != truthPart->pdgId() || genPart->status() != truthPart->status() || HepMC::barcode(genPart) != truthPart->barcode()) { - ATH_MSG_DEBUG("HepMC::GenParticle and xAOD::TruthParticle do not match"); - return false; - } - return true; -} #endif std::pair<ParticleType, ParticleOrigin>