diff --git a/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h b/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h index 5bf4a46d2cfbc59824ce30c48352fe3781b8381d..e2de74607f3602235ec00104dfa8835abc09d1ef 100644 --- a/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h +++ b/PhysicsAnalysis/MCTruthClassifier/MCTruthClassifier/MCTruthClassifier.h @@ -254,8 +254,6 @@ private: double fracParticleInJet(const xAOD::TruthParticle*, const xAOD::Jet*, bool DR, bool nparts) const; void findJetConstituents(const xAOD::Jet*, std::set<const xAOD::TruthParticle*>& constituents, bool DR) const; #endif - // Now that we use TLorentzVector for the momentum base class, this is straightforward - template <class A, class B> inline double deltaR(A& v1, B& v2) const {return v1.p4().DeltaR(v2.p4());} static MCTruthPartClassifier::ParticleOrigin defJetOrig(const std::set<const xAOD::TruthParticle*>&) ; diff --git a/PhysicsAnalysis/MCTruthClassifier/Root/MCRecoToTruth.cxx b/PhysicsAnalysis/MCTruthClassifier/Root/MCRecoToTruth.cxx index 301c8e0c4436b7ff6886beef5c330300de22acc3..088b08f6a50d23e0c6d2f4725c5d98578b884836 100644 --- a/PhysicsAnalysis/MCTruthClassifier/Root/MCRecoToTruth.cxx +++ b/PhysicsAnalysis/MCTruthClassifier/Root/MCRecoToTruth.cxx @@ -6,27 +6,22 @@ #include "AsgDataHandles/ReadHandle.h" #include "MCTruthClassifier/MCTruthClassifier.h" using namespace MCTruthPartClassifier; -using std::abs; std::pair<ParticleType, ParticleOrigin> MCTruthClassifier::particleTruthClassifier(const xAOD::TrackParticle* trkPtr, Info* info /*= nullptr*/) const { ATH_MSG_DEBUG("Executing trackClassifier"); - ParticleType parttype = Unknown; ParticleOrigin partorig = NonDefined; - const xAOD::TruthParticle* genPart = getGenPart(trkPtr); if (info) { info->genPart = genPart; } - if (!genPart) return std::make_pair(parttype, partorig); ATH_MSG_DEBUG("trackClassifier succeeded "); return particleTruthClassifier(genPart, info); } -//----------------------------------------------------------------------------------------- // Not const due to ITruthParticlesInConeTool::particlesInCone // called via egammaClusMatch. std::pair<ParticleType, ParticleOrigin> @@ -63,7 +58,6 @@ MCTruthClassifier::particleTruthClassifier(const xAOD::Electron* elec, Info* inf return particleTruthClassifier(genPart, info); } -//----------------------------------------------------------------------------------------- // Not const due to ITruthParticlesInConeTool::particlesInCone // called via egammaClusMatch. std::pair<ParticleType, ParticleOrigin> @@ -275,7 +269,7 @@ MCTruthClassifier::getGenPart(const xAOD::TrackParticle* trk, Info* info /*= nul ATH_MSG_WARNING("track matched to the truth with status " << theGenParticle->status()); } - if (MC::isDecayed(theGenParticle) && (abs(theGenParticle->pdgId()) == 11 || abs(theGenParticle->pdgId()) == 13)) { + if (MC::isDecayed(theGenParticle) && (std::abs(theGenParticle->pdgId()) == 11 || std::abs(theGenParticle->pdgId()) == 13)) { const xAOD::TruthVertex* EndVrtx = theGenParticle->decayVtx(); const xAOD::TruthParticle* theGenPartTmp(nullptr); @@ -359,7 +353,7 @@ MCTruthClassifier::findJetConstituents(const xAOD::Jet* jet, // find the matching truth particles for (const auto *const thePart : *truthParticleContainerReadHandle) { // match truth particles to the jet - if (MC::isStable(thePart) && deltaR((*thePart), (*jet)) < m_jetPartDRMatch) { + if (MC::isStable(thePart) && thePart->p4().DeltaR(jet->p4()) < m_jetPartDRMatch) { constituents.insert(thePart); } } diff --git a/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx b/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx index 7375a6347f9cfbce1000b2f278b76fb4dd5af6b1..712d5420767b0baf8a648a8ba681a1aeb15386bc 100644 --- a/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx +++ b/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx @@ -318,7 +318,6 @@ ParticleType MCTruthClassifier::defTypeOfElectron(ParticleOrigin EleOrig, bool i return BkgElectron; } -//------------------------------------------------------------------------------- ParticleOrigin MCTruthClassifier::defOrigOfElectron(const xAOD::TruthParticleContainer* mcTruthTES, const xAOD::TruthParticle* thePart, @@ -361,7 +360,6 @@ MCTruthClassifier::defOrigOfElectron(const xAOD::TruthParticleContainer* mcTruth } const xAOD::TruthVertex* mothOriVert = mother->hasProdVtx() ? mother->prodVtx() : nullptr; - // to exclude interactions mu(barcode<10^6)->mu(barcode10^6)+e bool samePart = false; for (const auto & theDaug: partOriVert->particles_out()) { if (!theDaug) continue; diff --git a/PhysicsAnalysis/MCTruthClassifier/src/MCTruthClassifierAthena.cxx b/PhysicsAnalysis/MCTruthClassifier/src/MCTruthClassifierAthena.cxx index 9c4e28fec073ee8e81bebdd294ac72cbf8a2d216..8074ffecf462421aa8e3e5b51fe30dad285783a4 100644 --- a/PhysicsAnalysis/MCTruthClassifier/src/MCTruthClassifierAthena.cxx +++ b/PhysicsAnalysis/MCTruthClassifier/src/MCTruthClassifierAthena.cxx @@ -3,17 +3,13 @@ */ #if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE) // Can only be used in Athena - -// #include "MCTruthClassifier/MCTruthClassifier.h" -// // xAOD EDM includes #include "xAODCaloEvent/CaloCluster.h" #include "xAODEgamma/EgammaxAODHelpers.h" #include "xAODTracking/TrackParticle.h" #include "xAODTruth/TruthParticle.h" #include "xAODTruth/TruthParticleContainer.h" -// // Athena only includes #include "AthenaKernel/Units.h" #include "AtlasHepMC/GenParticle.h" @@ -24,7 +20,6 @@ #include <cmath> -using Athena::Units::GeV; using namespace MCTruthPartClassifier; namespace { @@ -51,13 +46,9 @@ std::unique_ptr<Trk::CurvilinearParameters> extractParamFromTruth(const xAOD::Tr } // Methods using directly the extrapolator usable only from Athena -//----------------------------------------------------------------------------------------- const xAOD::TruthParticle* MCTruthClassifier::egammaClusMatch(const xAOD::CaloCluster* clus, bool isFwrdEle, Info* info) const { - //----------------------------------------------------------------------------------------- - ATH_MSG_DEBUG("Executing egammaClusMatch "); - const xAOD::TruthParticle* theMatchPart = nullptr; const EventContext& ctx = info ? info->eventContext : Gaudi::Hive::currentContext(); @@ -114,7 +105,7 @@ const xAOD::TruthParticle* MCTruthClassifier::egammaClusMatch(const xAOD::CaloCl // excluding neutrino if (std::abs(iParticlePDG) == 12 || std::abs(iParticlePDG) == 14 || std::abs(iParticlePDG) == 16) continue; - double pt = thePart->pt() / GeV; + double pt = thePart->pt() / Athena::Units::GeV; double q = thePart?thePart->charge():0.0; // exclude charged particles with pT<1 GeV if (q != 0 && pt < m_pTChargePartCut) continue; @@ -184,7 +175,7 @@ const xAOD::TruthParticle* MCTruthClassifier::egammaClusMatch(const xAOD::CaloCl BestPartdR = dR; }; } - } // end cycle for Gen particle + } if (theEgamma != nullptr) { theMatchPart = MC::find_matching(truthParticleContainerReadHandle.ptr(), theEgamma); @@ -226,7 +217,7 @@ const xAOD::TruthParticle* MCTruthClassifier::egammaClusMatch(const xAOD::CaloCl if (std::hypot( detPhi(phiClus, thePart->phi())/m_partExtrConePhi, detEta(etaClus, thePart->eta())/m_partExtrConeEta ) > 1.0) continue; - double pt = thePart->pt() / GeV; + double pt = thePart->pt() / Athena::Units::GeV; double q = thePart->charge(); // exclude charged particles with pT<1 GeV if (q != 0 && pt < m_pTChargePartCut) continue; @@ -293,9 +284,7 @@ const xAOD::TruthParticle* MCTruthClassifier::egammaClusMatch(const xAOD::CaloCl return theMatchPart; } -//-------------------------------------------------------------- -bool -MCTruthClassifier::genPartToCalo(const EventContext& ctx, +bool MCTruthClassifier::genPartToCalo(const EventContext& ctx, const xAOD::CaloCluster* clus, const xAOD::TruthParticle* thePart, bool isFwrdEle, @@ -348,8 +337,7 @@ MCTruthClassifier::genPartToCalo(const EventContext& ctx, // create extension to sample std::vector<CaloSampling::CaloSample> samples = { sample }; - std::vector<std::pair<CaloSampling::CaloSample, std::unique_ptr<const Trk::TrackParameters>>> - extension = m_caloExtensionTool->layersCaloExtension(ctx, *params, samples, etaClus, caloDDMgr); + auto extension = m_caloExtensionTool->layersCaloExtension(ctx, *params, samples, etaClus, caloDDMgr); bool extensionOK = (!extension.empty()); if (!extensionOK) { ATH_MSG_WARNING("extrapolation of Truth Particle with eta " << thePart->eta() << " , charge " << thePart->charge() << " , Pt " << thePart->pt() << " to calo failed"); @@ -363,9 +351,7 @@ MCTruthClassifier::genPartToCalo(const EventContext& ctx, dRmatch = std::hypot(dPhi, dEta); if ((!isFwrdEle && dRmatch > m_phtdRtoTrCut) || (isFwrdEle && dRmatch > m_fwrdEledRtoTrCut)) return false; - if (!isFwrdEle && std::hypot( dPhi/m_phtClasConePhi, dEta/m_phtClasConeEta ) <= 1.0) isNarrowCone = true; - return true; } #endif