Commit 8eb1debc authored by Oliver Majersky's avatar Oliver Majersky Committed by Walter Lampl
Browse files

AT R22 object selection cleanup

parent 4e5de9d4
......@@ -8,7 +8,6 @@
#include "TopObjectSelectionTools/TopObjectSelection.h"
#include "TopObjectSelectionTools/ElectronLikelihoodMC15.h"
#include "TopObjectSelectionTools/ElectronCutBasedMC15.h"
//#include "TopObjectSelectionTools/FwdElectronMC15.h"
#include "TopObjectSelectionTools/IsolationTools.h"
#include "TopObjectSelectionTools/MuonMC15.h"
......@@ -49,18 +48,8 @@ namespace top {
///-- Electrons --///
if (topConfig->useElectrons()) {
if (topConfig->electronID().find("LH") == std::string::npos &&
topConfig->electronIDLoose().find("LH") == std::string::npos) {
//both the tight and loose user settings do not contain LH -> cut based
objectSelection->electronSelection(new top::ElectronCutBasedMC15(topConfig->electronPtcut(),
topConfig->electronVetoLArCrack(),
topConfig->electronID(),
topConfig->electronIDLoose(),
new top::StandardIsolation(
topConfig->electronIsolation(),
topConfig->electronIsolationLoose())));
} else if (topConfig->electronID().find("LH") != std::string::npos &&
topConfig->electronIDLoose().find("LH") != std::string::npos) {
if (topConfig->electronID().find("LH") != std::string::npos &&
topConfig->electronIDLoose().find("LH") != std::string::npos) {
//user wants likelihood electrons
objectSelection->electronSelection(new top::ElectronLikelihoodMC15(topConfig->electronPtcut(),
topConfig->electronVetoLArCrack(),
......@@ -69,15 +58,16 @@ namespace top {
new top::StandardIsolation(
topConfig->electronIsolation(),
topConfig->electronIsolationLoose()),
topConfig->electrond0Sigcut(),
topConfig->electrondeltaz0cut(),
topConfig->applyTTVACut(),
topConfig->useElectronChargeIDSelection()
));
} else {
ATH_MSG_ERROR("Not sure it makes sense to use a mix of LH and cut-based electrons for the tight/loose definitions\n"
<< "Tight electron definition is " << topConfig->electronID() << "\n"
<< "Loose electron definition is " << topConfig->electronIDLoose() << "\n"
<< "If it does make sense, feel free to fix this");
throw std::runtime_error("Mixing LH and cut-based electron definitions for tight/loose");
ATH_MSG_ERROR("Only likelihood-based electron ID is currently supported. You have selected:\n"
<< "Tight electron definition: " << topConfig->electronID() << "\n"
<< "Loose electron definition: " << topConfig->electronIDLoose());
throw std::runtime_error("Unsupported electron ID option");
}
}
......@@ -95,6 +85,8 @@ namespace top {
else objectSelection->muonSelection(new top::MuonMC15(topConfig->muonPtcut(),
new top::StandardIsolation(topConfig->muonIsolation(),
topConfig->muonIsolationLoose()),
topConfig->muond0Sigcut(),
topConfig->muondeltaz0cut(),
topConfig->applyTTVACut()));
}
......
......@@ -60,6 +60,8 @@ namespace top {
registerParameter("ElectronIDLoose",
"Type of electron for background. Likelihood LooseAndBLayerLH, MediumLH, TightLH", "MediumLH");
registerParameter("ElectronPt", "Electron pT cut for object selection (in MeV). Default 25 GeV.", "25000.");
registerParameter("Electrond0Sig", "Electron d0 significance cut for object selection. Default 5", "5.");
registerParameter("Electrondeltaz0", "Electron delta z0 cut for object selection. Default 0.5 mm", "0.5");
registerParameter("EgammaSystematicModel", "Egamma Calibration Systematic model : FULL_v1 , 1NP_v1 (default)",
"1NP_v1");
registerParameter("ElectronEfficiencySystematicModel",
......@@ -109,6 +111,8 @@ namespace top {
registerParameter("MuonPt", "Muon pT cut for object selection (in MeV). Default 25 GeV.", "25000");
registerParameter("MuonEta", "Absolute Muon eta cut for object selection. Default 2.5.", "2.5");
registerParameter("Muond0Sig", "Muon d0 significance cut for object selection. Default 3", "3.");
registerParameter("Muondeltaz0", "Muon delta z0 cut for object selection. Default 0.5 mm", "0.5");
registerParameter("MuonQuality",
"Muon quality cut for object selection. Options are VeryLoose, Loose, Medium (default) and Tight",
"Medium");
......
......@@ -197,6 +197,8 @@ namespace top {
m_electronIsolationLoose("SetMe"),
m_electronIsolationSF("SetMe"),
m_electronIsolationSFLoose("SetMe"),
m_electron_d0SigCut(5.0),
m_electron_delta_z0(0.5),
m_electronIDDecoration("SetMe"),
m_electronIDLooseDecoration("SetMe"),
m_useElectronChargeIDSelection(false),
......@@ -1093,6 +1095,8 @@ namespace top {
this->useElectronChargeIDSelection(settings->value("UseElectronChargeIDSelection"));
this->useEgammaLeakageCorrection(settings->value("UseEgammaLeakageCorrection"));
this->electronPtcut(std::stof(settings->value("ElectronPt")));
this->electrond0Sigcut(std::stof(settings->value("Electrond0Sig")));
this->electrondeltaz0cut(std::stof(settings->value("Electrondeltaz0")));
this->enablePromptLeptonImprovedVetoStudies(settings->value("EnablePromptLeptonImprovedVetoStudies"));
......@@ -1174,6 +1178,8 @@ namespace top {
// Muon configuration
this->muonPtcut(std::stof(settings->value("MuonPt")));
this->muonEtacut(std::stof(settings->value("MuonEta")));
this->muond0Sigcut(std::stof(settings->value("Muond0Sig")));
this->muondeltaz0cut(std::stof(settings->value("Muondeltaz0")));
this->muonQuality(settings->value("MuonQuality"));
this->muonQualityLoose(settings->value("MuonQualityLoose"));
{
......
......@@ -739,6 +739,18 @@ namespace top {
}
}
inline virtual void electrond0Sigcut(const float d0sig) {
if (!m_configFixed) {
m_electron_d0SigCut = d0sig;
}
}
inline virtual void electrondeltaz0cut(const float delta_z0) {
if (!m_configFixed) {
m_electron_delta_z0 = delta_z0;
}
}
inline virtual void electronIsolation(const std::string& iso) {
if (!m_configFixed) {
m_electronIsolation = iso;
......@@ -793,6 +805,8 @@ namespace top {
inline virtual const std::string& electronIDLoose() const {return m_electronIDLoose;}
inline virtual bool electronVetoLArCrack() const {return m_electronVetoLArCrack;}
inline virtual float electronPtcut() const {return m_electronPtcut;}
inline virtual float electrond0Sigcut() const {return m_electron_d0SigCut;}
inline virtual float electrondeltaz0cut() const {return m_electron_delta_z0;}
inline virtual const std::string& electronIsolation() const {return m_electronIsolation;}
inline virtual const std::string& electronIsolationLoose() const {return m_electronIsolationLoose;}
inline virtual const std::vector<std::string>& electronIsolationWPs() const {return m_electronIsolationWPs;}
......@@ -899,6 +913,18 @@ namespace top {
}
}
inline virtual void muond0Sigcut(const float d0sig) {
if (!m_configFixed) {
m_muon_d0SigCut = d0sig;
}
}
inline virtual void muondeltaz0cut(const float delta_z0) {
if (!m_configFixed) {
m_muon_delta_z0 = delta_z0;
}
}
inline virtual void muonEtacut(const float eta) {
if (!m_configFixed) {
m_muonEtacut = eta;
......@@ -979,6 +1005,8 @@ namespace top {
inline virtual float muonPtcut() const {return m_muonPtcut;}
inline virtual float muonEtacut() const {return m_muonEtacut;}
inline virtual float muond0Sigcut() const {return m_muon_d0SigCut;}
inline virtual float muondeltaz0cut() const {return m_muon_delta_z0;}
inline virtual const std::string& muonQuality() const {return m_muonQuality;}
inline virtual const std::string& muonQualityLoose() const {return m_muonQualityLoose;}
inline virtual bool muonUseMVALowPt() const {return m_muonUseMVALowPt;}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "TopObjectSelectionTools/ElectronCutBasedMC15.h"
namespace top {
ElectronCutBasedMC15::ElectronCutBasedMC15(double ptcut, bool vetoCrack, const std::string& quality,
const std::string& qualityLoose, IsolationBase* isolation) :
m_ptcut(ptcut),
m_vetoCrack(vetoCrack),
m_quality(quality),
m_qualityLoose(qualityLoose),
m_isolation(isolation) {
}
bool ElectronCutBasedMC15::passSelection(const xAOD::Electron& el) const {
if (!passSelectionNoIsolation(el, m_quality)) return false;
if (m_isolation && !m_isolation->passSelection(el)) return false;
return true;
}
bool ElectronCutBasedMC15::passSelectionLoose(const xAOD::Electron& el) const {
if (!passSelectionNoIsolation(el, m_qualityLoose)) return false;
if (m_isolation && !m_isolation->passSelectionLoose(el)) return false;
return true;
}
bool ElectronCutBasedMC15::passSelectionNoIsolation(const xAOD::Electron& el, const std::string& quality) const {
// if (el.author() != xAOD::EgammaParameters::AuthorElectron && el.author() != xAOD::EgammaParameters::AuthorSofte)
// return false;
if (el.pt() < m_ptcut) return false;
// This will be replaced with the proper AsgElectronIsEMSelector
// Once the calib files are on afs (cvmfs?) - not there yet.....
if (!el.passSelection(quality)) return false;
//WARNING: Not all electrons keep clusters in the derivation
//i.e. bad electrons (which is why we moved the check on the quality
//before the check on the calo cluster)
//Good electrons should always have a cluster, if not then crash to warn us
//Better than checking and silently doing nothing...
//This stops a crash
if (std::fabs(el.caloCluster()->etaBE(2)) > 2.47) return false;
if (m_vetoCrack && std::fabs(el.caloCluster()->etaBE(2)) > 1.37 &&
std::fabs(el.caloCluster()->etaBE(2)) < 1.52) return false;
return true;
}
void ElectronCutBasedMC15::print(std::ostream& os) const {
os << "ElectronCutBasedMC15\n";
os << " * pT > " << m_ptcut << "\n";
os << " * Currently disabled --- |cluster_eta| < 2.47 \n";
os << " * Veto 1.37 < |cluster_eta| < 1.52? " << std::boolalpha << m_vetoCrack << "\n";
os << " * Quality " << m_quality << "\n";
if (!m_isolation) os << " * No isolation requirement\n";
else m_isolation->print(os);
}
}
......@@ -15,9 +15,12 @@ namespace top {
ElectronLikelihoodMC15::ElectronLikelihoodMC15(const double ptcut, const bool vetoCrack,
const std::string& operatingPoint,
const std::string& operatingPointLoose, StandardIsolation* isolation,
const bool applyTTVACut, const bool applyChargeIDCut) :
const double d0SigCut, const double delta_z0, const bool applyTTVACut,
const bool applyChargeIDCut) :
m_ptcut(ptcut),
m_vetoCrack(vetoCrack),
m_d0SigCut(d0SigCut),
m_delta_z0(delta_z0),
m_operatingPoint("SetMe"),
m_operatingPointLoose("SetMe"),
m_operatingPoint_DF("SetMe"),
......@@ -74,6 +77,25 @@ namespace top {
top::check(m_deadHVTool.retrieve(), "Failed to setup Egamma DeadHVCellRemovalTool");
}
ElectronLikelihoodMC15::ElectronLikelihoodMC15(const double ptcut, const bool vetoCrack,
const std::string& operatingPoint,
const std::string& operatingPointLoose,
StandardIsolation* isolation,
const bool applyChargeIDCut)
: ElectronLikelihoodMC15::ElectronLikelihoodMC15(ptcut, vetoCrack, operatingPoint,
operatingPointLoose, isolation, 5.0, 0.5, true,
applyChargeIDCut) {}
ElectronLikelihoodMC15::ElectronLikelihoodMC15(const double ptcut, const bool vetoCrack,
const std::string& operatingPoint,
const std::string& operatingPointLoose,
StandardIsolation* isolation,
const bool applyTTVACut,
const bool applyChargeIDCut)
: ElectronLikelihoodMC15::ElectronLikelihoodMC15(ptcut, vetoCrack, operatingPoint,
operatingPointLoose, isolation, 5.0, 0.5, applyTTVACut,
applyChargeIDCut) {}
bool ElectronLikelihoodMC15::passSelection(const xAOD::Electron& el) const {
if (!passSelectionNoIsolation(el, m_operatingPoint_DF, m_operatingPoint)) return false;
......@@ -143,7 +165,7 @@ namespace top {
//Veto electrons suffering from the 2015+2016/mc16a crack+topocluster association bug
//See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/HowToCleanJets2017#EGamma_Crack_Electron_topocluste for details
if (el.isAvailable<char>("DFCommonCrackVetoCleaning"))
if (!el.auxdataConst<char>("DFCommonCrackVetoCleaning")) return false;
if (!el.auxdataConst<char>("DFCommonCrackVetoCleaning")) return false;
if (m_vetoCrack && std::fabs(el.caloCluster()->etaBE(2)) > 1.37 &&
std::fabs(el.caloCluster()->etaBE(2)) < 1.52) return false;
......
......@@ -10,8 +10,12 @@
using namespace TopObjectSelectionTools;
namespace top {
MuonMC15::MuonMC15(const double ptcut, IsolationBase* isolation, const bool applyTTVACut) :
MuonMC15::MuonMC15(const double ptcut, IsolationBase* isolation,
const double d0SigCut, const double delta_z0_sintheta,
const bool applyTTVACut) :
m_ptcut(ptcut),
m_d0SigCut(d0SigCut),
m_delta_z0(delta_z0_sintheta),
m_muonSelectionTool("MuonSelectionTool"),
m_muonSelectionToolLoose("MuonSelectionToolLoose"),
m_isolation(isolation),
......@@ -20,6 +24,12 @@ namespace top {
top::check(m_muonSelectionToolLoose.retrieve(), "Failed to retrieve muonSelectionToolLoose");
}
MuonMC15::MuonMC15(const double ptcut, IsolationBase* isolation, const bool applyTTVACut)
: MuonMC15::MuonMC15(ptcut, isolation, 3.0, 0.5, applyTTVACut) {}
MuonMC15::MuonMC15(const double ptcut, IsolationBase* isolation)
: MuonMC15::MuonMC15(ptcut, isolation, 3.0, 0.5, true) {}
bool MuonMC15::passSelection(const xAOD::Muon& mu) const {
if (mu.pt() < m_ptcut) return false;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ELECTRONCUTBASEDMC15_H_
#define ELECTRONCUTBASEDMC15_H_
#include "TopObjectSelectionTools/ElectronSelectionBase.h"
#include "TopObjectSelectionTools/IsolationTools.h"
#include <memory>
namespace top {
/**
* @brief Electron selection based on the cut-based thingy.
*/
class ElectronCutBasedMC15: public top::ElectronSelectionBase {
public:
/**
* @brief Class to help select cut-based good electrons.
*
* @param ptcut The minimum pT cut to apply to the electrons.
* @param vetoCrack Do you want to veto 1.37 < |cluster_eta| < 1.52?
* @param quality The definition for good electrons, e.g. "Tight"
* @param qualityLoose The loose defeinition, for fake-lepton estimates with
* the matrix method?
* @param isolation nullptr for un-isolated, or a new "isolation object" to
* apply isolation cuts
*/
ElectronCutBasedMC15(double ptcut, bool vetoCrack, const std::string& quality, const std::string& qualityLoose,
IsolationBase* isolation);
virtual ~ElectronCutBasedMC15() {}
/**
* @brief The cuts to select good electrons for your analysis should be
* implemented in here.
*
* @param el The electron to cut on (all electrons in the event are passed
* to the tool)
* @return True if this is a good electron, false otherwise.
*/
virtual bool passSelection(const xAOD::Electron& el) const override;
/**
* @brief The loose selection needed by some background estimates.
*
* @param el
* @return
*/
virtual bool passSelectionLoose(const xAOD::Electron& el) const override;
/**
* @brief Print some useful information about the electron selection.
*
* Usually this goes to the log file, so you know what you ran with.
*
* @param Where the print-out should go, e.g. msg stream
*/
virtual void print(std::ostream&) const override;
protected:
/**
* @brief Since both selections are fairly similar, we can perform
* the un-isolated part in one function.
*
* Do all the cuts except for the isolation.
*
* @param el The electron in question
* @param quality The string "Tight" or whatever to say which quality cuts
* should be applied.
* @return True if the electron passes
*/
bool passSelectionNoIsolation(const xAOD::Electron& el, const std::string& quality) const;
///minimum pT cut to apply
double m_ptcut;
///Should we veto the LAr crack region?
bool m_vetoCrack;
///Quality requirement for the tight (analysis) definition
std::string m_quality;
///Quality requirement for the loose (background estimate?) definition
std::string m_qualityLoose;
///The isolation tool, or nullptr if we don't want isolation
std::unique_ptr<top::IsolationBase> m_isolation;
};
}
#endif
......@@ -26,13 +26,25 @@ namespace top {
* definition
* @param operatingPointLoose Likelihood operating point for the loose
* objects (fakes estimates?)
* @param isolation The isolation tool the user wants to use. If you don't
* @param isolation The isolation tool the user wants to use. If you don't
* want any isolation cuts to be applied then leave this as a nullptr.
* @param d0SigCut The maximum d0 significance cut
* @param delta_z0 The maximum |delta z0 sin(theta)| cut
* @param applyTTVACut Whether to apply cuts on d0 and z0
* @param applyChargeIDCut Whether to apply charge identification selector tool
*/
ElectronLikelihoodMC15(const double ptcut, const bool vetoCrack, const std::string& operatingPoint,
const std::string& operatingPointLoose, StandardIsolation* isolation,
const bool applyTTVACut = true, const bool applyChargeIDCut = false);
// this constructor is kept for backward compatibility - isPrimaryxAOD is not needed anymore
const bool applyChargeIDCut);
ElectronLikelihoodMC15(const double ptcut, const bool vetoCrack, const std::string& operatingPoint,
const std::string& operatingPointLoose, StandardIsolation* isolation,
const bool applyTTVACut, const bool applyChargeIDCut);
ElectronLikelihoodMC15(const double ptcut, const bool vetoCrack, const std::string& operatingPoint,
const std::string& operatingPointLoose, StandardIsolation* isolation,
const double d0SigCut, const double delta_z0, const bool applyTTVACut,
const bool applyChargeIDCut);
virtual ~ElectronLikelihoodMC15() {}
/**
......@@ -101,6 +113,10 @@ namespace top {
///Veto the crack region?
bool m_vetoCrack;
/// TTVA cuts
double m_d0SigCut;
double m_delta_z0;
std::string m_operatingPoint;
std::string m_operatingPointLoose;
std::string m_operatingPoint_DF;
......
......@@ -22,10 +22,22 @@ namespace top {
*
* @param ptcut The minimum pT cut for good muons.
* @param isolation The isolation the user wants to apply. Don't want any
* isolation to be applied? Then leave this as a nullptr.
* isolation to be applied? Then leave this as a nullptr.
* @param d0SigCut The maximum d0 significance cut
* @param delta_z0 The maximum |delta z0 sin(theta)| cut
* @param applyTTVACut Whether to apply cuts on d0 and z0
*/
MuonMC15(const double ptcut,
IsolationBase* isolation);
MuonMC15(const double ptcut,
IsolationBase* isolation,
const bool applyTTVACut);
MuonMC15(const double ptcut,
IsolationBase* isolation,
const double d0SigCut,
const double delta_z0,
const bool applyTTVACut = true);
// Does nothing.
......@@ -61,6 +73,10 @@ namespace top {
// Lower pT threshold to apply to object selection.
double m_ptcut;
// TTVA cuts
double m_d0SigCut;
double m_delta_z0;
// Proper tool to select muons.
ToolHandle<CP::IMuonSelectionTool> m_muonSelectionTool;
ToolHandle<CP::IMuonSelectionTool> m_muonSelectionToolLoose;
......
Markdown is supported
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