Commit 4f747fab authored by Samuel Van Stroud's avatar Samuel Van Stroud
Browse files

Update track leptonID

parent 71670f23
Pipeline #3871625 failed with stages
in 12 minutes and 52 seconds
......@@ -37,6 +37,7 @@ set(LINK_LIBRARIES
InDetTrackSystematicsToolsLib
xAODHIEvent
MCTruthClassifierLib
ElectronPhotonSelectorToolsLib
)
# anything that is built conditionally goes here
if (NOT XAOD_STANDALONE)
......
......@@ -2,12 +2,21 @@
#include "xAODEgamma/ElectronxAODHelpers.h"
// the constructor just builds the decorator
TrackLeptonDecorator::TrackLeptonDecorator(const std::string& prefix):
m_track_lepton_id(prefix + "leptonID")
{
#include "xAODEgamma/ElectronxAODHelpers.h"
#include "ElectronPhotonSelectorTools/ElectronSelectorHelpers.h"
void check_rc(StatusCode code) {
if (!code.isSuccess()) throw std::runtime_error("bad return code");
}
// the constructor just builds the decorator
TrackLeptonDecorator::TrackLeptonDecorator(const std::string& prefix):
m_track_lepton_id(prefix + "leptonID"),
m_electronID_tool("AsgElectronLikelihoodTool/electronID_tool")
{
check_rc(m_electronID_tool.setProperty("WorkingPoint", m_electronID_wp));
check_rc(m_electronID_tool.initialize());
}
// this call actually does the work on the track
void TrackLeptonDecorator::decorate(const xAOD::TrackParticleContainer& tracks, const xAOD::MuonContainer& muons, const xAOD::ElectronContainer& electrons) const {
......@@ -17,35 +26,38 @@ void TrackLeptonDecorator::decorate(const xAOD::TrackParticleContainer& tracks,
m_track_lepton_id(*track) = 0;
}
// loop over muons
for ( const auto muon : muons ) {
// loop over electrons
for ( const auto electron : electrons ) {
// get associated InDet track link
auto track_link = muon->inDetTrackParticleLink();
if ( !track_link.isValid() ) {
continue;
}
// get associated InDet track (not the GSF track which is likely to have improved parameters,
// more info: https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/EGammaD3PDtoxAOD#TrackParticle)
const xAOD::TrackParticle* track = xAOD::EgammaHelpers::getOriginalTrackParticle(electron);
if ( !track ) { continue; }
// access track
auto track = *track_link;
// apply electron ID requirement
bool LH_selection = (bool)m_electronID_tool.accept(electron);
if (!LH_selection) { continue; }
// decorate the track
m_track_lepton_id(*track) = -13 * muon->charge();
}
// decorate the track
m_track_lepton_id(*track) = -11 * electron->charge();
}
// loop over electrons
for ( const auto electron : electrons ) {
// loop over muons - do it last in case we have a track that was used in the
// reconstruction of an electron and a muon (which can happen in rare cases)
for ( const auto muon : muons ) {
// get associated InDet track link (not the GSF track which is likely to have improved parameters,
// more info: https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/EGammaD3PDtoxAOD#TrackParticle)
const xAOD::TrackParticle* track = xAOD::EgammaHelpers::getOriginalTrackParticle(electron);
// minimal quality requirement: check we have a combined muon
if (muon->muonType() != xAOD::Muon::Combined) { continue; }
if ( !track ) {
continue;
// get associated InDet track
auto track_link = muon->inDetTrackParticleLink();
if ( !track_link.isValid() ) { continue; }
auto track = *track_link;
// decorate the track
m_track_lepton_id(*track) = -13 * muon->charge();
}
// decorate the track
m_track_lepton_id(*track) = -11 * electron->charge();
}
}
......@@ -10,6 +10,7 @@
#include "xAODMuon/MuonContainer.h"
#include "xAODEgamma/ElectronContainer.h"
#include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
#include <string>
......@@ -32,6 +33,9 @@ private:
SG::AuxElement::Decorator<int> m_track_lepton_id;
// electron ID tool
std::string m_electronID_wp = "VeryLooseLHElectron";
AsgElectronLikelihoodTool m_electronID_tool;
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment