Commit b2449d3a authored by Marco Vanadia's avatar Marco Vanadia
Browse files

AnalysisTop: adding possiblity to use loose objects in MET building

parent 949ad7bf
......@@ -9,6 +9,7 @@
#include "TopConfiguration/TopConfig.h"
#include "TopEventSelectionTools/TreeManager.h"
#include "TopParticleLevel/TruthTools.h"
#include "xAODMissingET/MissingETContainer.h"
#include "AthContainers/AuxTypeRegistry.h"
......@@ -158,7 +159,9 @@ namespace top {
m_useVarRCAdditionalJSS(false),
m_useElectronChargeIDSelection(false),
m_met_met(0.),
m_met_phi(0.) {
m_met_phi(0.),
m_met_met_withLooseObjects(0.),
m_met_phi_withLooseObjects(0.) {
m_weight_leptonSF_EL_SF_CorrModel_Reco_UP = std::vector<float>();
m_weight_leptonSF_EL_SF_CorrModel_Reco_DOWN = std::vector<float>();
m_weight_leptonSF_EL_SF_CorrModel_ID_UP = std::vector<float>();
......@@ -1263,6 +1266,12 @@ namespace top {
//met
systematicTree->makeOutputVariable(m_met_met, "met_met");
systematicTree->makeOutputVariable(m_met_phi, "met_phi");
//these are for specific studies on the met, turned off by default, and turned on with the WriteMETBuiltWithLooseObjects option
if(m_config->writeMETBuiltWithLooseObjects())
{
systematicTree->makeOutputVariable(m_met_met_withLooseObjects, "met_met_withLooseObjects");
systematicTree->makeOutputVariable(m_met_phi_withLooseObjects, "met_phi_withLooseObjects");
}
if (m_config->doKLFitter()) {
/// Global result
......@@ -3733,6 +3742,16 @@ namespace top {
//met
m_met_met = event.m_met->met();
m_met_phi = event.m_met->phi();
if(m_config->writeMETBuiltWithLooseObjects())
{
const xAOD::MissingETContainer* mets(nullptr);
if(event.m_isLoose) top::check(evtStore()->retrieve(mets, m_config->sgKeyMissingEtLoose(event.m_hashValue)+"WithLooseObjects"), "Failed to retrieve MET");
else top::check(evtStore()->retrieve(mets, m_config->sgKeyMissingEt(event.m_hashValue)+"WithLooseObjects"), "Failed to retrieve MET");
m_met_met_withLooseObjects=(*mets)["FinalTrk"]->met();
m_met_phi_withLooseObjects=(*mets)["FinalTrk"]->phi();
}
//KLFitter
if (m_config->doKLFitter()) {
......
......@@ -822,6 +822,9 @@ namespace top {
//met
float m_met_met;
float m_met_phi;
//these are for specific studies on the met, turned off by default, and turned on with the WriteMETBuiltWithLooseObjects option
float m_met_met_withLooseObjects;
float m_met_phi_withLooseObjects;
//KLFitter
short m_klfitter_selected;
......
......@@ -393,6 +393,11 @@ namespace top {
registerParameter("DoLoose", "Run Loose selection and dumps the Loose trees : Data (default), MC, Both, False",
"Data");
registerParameter("DoSysts", "Run systematics on given selection: Both (default), Tight, Loose", "Both");
registerParameter("UseLooseObjectsInMETInLooseTree","Experimental: use loose objects when rebuilding the MET for the loose tree : True or False (default = False)","False");
registerParameter("UseLooseObjectsInMETInNominalTree","Experimental: use loose objects when rebuilding the MET for the nominal tree : True or False (default = False)","False");
registerParameter("WriteMETBuiltWithLooseObjects","Write a separate branch with the met built with loose objects in the output for tests: True or False (default = False)","False");
registerParameter("OverlapRemovalLeptonDef",
"Special: run overlap removal on : Tight (top default) or Loose (not top default) lepton definitions",
......
......@@ -85,6 +85,11 @@ namespace top {
m_FakesMMConfigIFF("$ROOTCOREBIN/data/TopFakes/efficiencies.xml:1T:1F[T]"),
// Debug level for MM fake estimate using FakeBkgTools from IFF
m_doFakesMMIFFDebug(false),
//options to select if you want to use loose objects for MET rebuilding instead of the tight ones
m_useLooseObjectsInMETInLooseTree(false),
m_useLooseObjectsInMETInNominalTree(false),
//this will write a separate branch with the met built using loose objects
m_writeMETBuiltWithLooseObjects(false),
// Apply overlap removal on loose lepton definitons - not the top recommendation, for studies only
m_doOverlapRemovalOnLooseLeptonDef(false),
// do overlap removal also with large-R jets
......@@ -890,6 +895,10 @@ namespace top {
bool topParticleLevel=true;
settings->retrieve("TopParticleLevel",topParticleLevel);
this->setTopParticleLevel(topParticleLevel);
settings->retrieve("UseLooseObjectsInMETInLooseTree", m_useLooseObjectsInMETInLooseTree);
settings->retrieve("UseLooseObjectsInMETInNominalTree", m_useLooseObjectsInMETInNominalTree);
settings->retrieve("WriteMETBuiltWithLooseObjects", m_writeMETBuiltWithLooseObjects);
// Particle-level OR
if (settings->value("DoParticleLevelOverlapRemoval") == "True") {
......
......@@ -247,6 +247,15 @@ namespace top {
{m_FakesMMConfigIFF = configIFF;}
inline void setFakesMMIFFDebug()
{m_doFakesMMIFFDebug = true;}
//by default AT uses always tight objects in MET re-building; these options allow for using loose objects instead in the loose analysis and/or in the nominal analysis
inline void setUseLooseObjectsInMETInLooseTree() {if (!m_configFixed) m_useLooseObjectsInMETInLooseTree = true;}
inline bool useLooseObjectsInMETInLooseTree() const {return m_useLooseObjectsInMETInLooseTree;}
inline void setUseLooseObjectsInMETInNominalTree() {if (!m_configFixed) m_useLooseObjectsInMETInNominalTree = true;}
inline bool useLooseObjectsInMETInNominalTree() const {return m_useLooseObjectsInMETInNominalTree;}
//this will write a separate branch with the met built using loose objects
inline void setWriteMETBuiltWithLooseObjects() {if (!m_configFixed) m_writeMETBuiltWithLooseObjects=true;}
inline bool writeMETBuiltWithLooseObjects() {return m_writeMETBuiltWithLooseObjects;}
// By default the top group does overlap removal on the tight lepton definitions
// If you use this you are going off piste and need to report
......@@ -2051,6 +2060,12 @@ namespace top {
std::string m_FakesMMConfigIFF;
// Debug mode?
bool m_doFakesMMIFFDebug;
//options to select if you want to use loose objects for MET rebuilding instead of the tight ones
bool m_useLooseObjectsInMETInLooseTree;
bool m_useLooseObjectsInMETInNominalTree;
//this will write a separate branch with the met built using loose objects
bool m_writeMETBuiltWithLooseObjects;
// By default the top group does overlap removal on
// the tight lepton definitions.
......
......@@ -84,6 +84,8 @@ namespace top {
if (m_config->doOverlapRemovalOnLooseLeptonDef()) m_doLooseCuts = true;
if (m_config->doLooseEvents()) m_doLooseCuts = true;
if(m_config->useLooseObjectsInMETInLooseTree() || m_config->useLooseObjectsInMETInNominalTree() || m_config->writeMETBuiltWithLooseObjects()) m_doLooseCuts = true;
if (m_config->applyElectronInJetSubtraction()) {
m_electronInJetSubtractor = std::unique_ptr<top::ElectronInJetSubtractionCollectionMaker>
......
......@@ -100,6 +100,7 @@ namespace top {
if (!executeNominal && m_config->isSystNominal(m_config->systematicName(x->hashValue()))) continue;
if (executeNominal && !m_config->isSystNominal(m_config->systematicName(x->hashValue()))) continue;
top::check(recalculateEventMET(x, xaod_met_core, xaod_met_map), "Failed to recalculate MET for event");
if(m_config->writeMETBuiltWithLooseObjects()) top::check(recalculateEventMET(x, xaod_met_core, xaod_met_map, true, "WithLooseObjects"), "Failed to recalculate MET using loose leptons for event");
}
} // tight events
if (m_config->doLooseEvents()) {
......@@ -120,6 +121,7 @@ namespace top {
if (!executeNominal && m_config->isSystNominal(m_config->systematicName(x->hashValue()))) continue;
if (executeNominal && !m_config->isSystNominal(m_config->systematicName(x->hashValue()))) continue;
top::check(recalculateEventMET(x, xaod_met_core, xaod_met_map), "Failed to recalculate MET for loose event");
if(m_config->writeMETBuiltWithLooseObjects()) top::check(recalculateEventMET(x, xaod_met_core, xaod_met_map, true, "WithLooseObjects"), "Failed to recalculate MET using loose leptons for event");
}
} // Loose events
......@@ -128,7 +130,9 @@ namespace top {
StatusCode MissingETObjectCollectionMaker::recalculateEventMET(xAOD::SystematicEvent* event,
const xAOD::MissingETContainer* xaod_met_core,
const xAOD::MissingETAssociationMap* xaod_met_map) {
const xAOD::MissingETAssociationMap* xaod_met_map,
bool forceUseLooseObjects,
std::string outputContainerSuffix) {
// decoration for objects that pass pre OR selection
std::string passPreORSelection = "passPreORSelection";
......@@ -136,7 +140,7 @@ namespace top {
// default behaviour for top analysis - use the "Tight" definitions
bool looseLeptonOR(is_loose_event);
if (m_config->doOverlapRemovalOnLooseLeptonDef()) {
if (m_config->doOverlapRemovalOnLooseLeptonDef() || (is_loose_event && m_config->useLooseObjectsInMETInLooseTree()) || (!is_loose_event && m_config->useLooseObjectsInMETInNominalTree()) || forceUseLooseObjects) {
looseLeptonOR = true;
// change decoration we check
passPreORSelection = "passPreORSelectionLoose";
......@@ -301,6 +305,8 @@ namespace top {
// Save corrected xAOD Container to StoreGate / TStore
std::string outputSGKey = m_config->sgKeyMissingEt(hash);
if (is_loose_event) outputSGKey = m_config->sgKeyMissingEtLoose(hash);
outputSGKey+=outputContainerSuffix;
std::string outputSGKeyAux = outputSGKey + "Aux.";
xAOD::TReturnCode save = evtStore()->tds()->record(new_met_container, outputSGKey);
......
......@@ -63,7 +63,9 @@ namespace top {
private:
StatusCode recalculateEventMET(xAOD::SystematicEvent* event,
const xAOD::MissingETContainer* met_core,
const xAOD::MissingETAssociationMap* met_map);
const xAOD::MissingETAssociationMap* met_map,
bool forceUseLooseObjects=false,
std::string outputContainerSuffix="");
std::shared_ptr<top::TopConfig> m_config;
......
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