Commit 71116ecb authored by Tomas Dado's avatar Tomas Dado Committed by Nils Erik Krumnack
Browse files

AnalysisTop: Implementing photon trigger SFs

parent de13b6b1
......@@ -681,6 +681,10 @@ namespace top {
"weight_photonSF_effIso_UP");
systematicTree->makeOutputVariable(m_weight_photonSF_effIso_DOWN,
"weight_photonSF_effIso_DOWN");
systematicTree->makeOutputVariable(m_weight_photonSF_Trigger_UNCERT_UP,
"weight_photonSF_Trigger_UNCERT_UP");
systematicTree->makeOutputVariable(m_weight_photonSF_Trigger_UNCERT_DOWN,
"weight_photonSF_Trigger_UNCERT_DOWN");
}
systematicTree->makeOutputVariable(m_weight_jvt_up, "weight_jvt_UP");
......@@ -1972,6 +1976,8 @@ namespace top {
m_weight_photonSF_ID_DOWN = m_sfRetriever->photonSF(event, top::topSFSyst::PHOTON_IDSF_DOWN);
m_weight_photonSF_effIso_UP = m_sfRetriever->photonSF(event, top::topSFSyst::PHOTON_EFF_ISO_UP);
m_weight_photonSF_effIso_DOWN = m_sfRetriever->photonSF(event, top::topSFSyst::PHOTON_EFF_ISO_DOWN);
m_weight_photonSF_Trigger_UNCERT_UP = m_sfRetriever->photonSF(event, top::topSFSyst::PHOTON_EFF_TRIGGER_UNCERTAINTY_UP);
m_weight_photonSF_Trigger_UNCERT_DOWN = m_sfRetriever->photonSF(event, top::topSFSyst::PHOTON_EFF_TRIGGER_UNCERTAINTY_DOWN);
}
......
......@@ -403,6 +403,8 @@ namespace top {
float m_weight_photonSF_ID_DOWN = 0.;
float m_weight_photonSF_effIso_UP = 0.;
float m_weight_photonSF_effIso_DOWN = 0.;
float m_weight_photonSF_Trigger_UNCERT_UP = 0.;
float m_weight_photonSF_Trigger_UNCERT_DOWN = 0.;
// nominal b-tagging SF [WP]
std::unordered_map<std::string, float> m_weight_bTagSF;
......
......@@ -27,7 +27,6 @@
#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
#include "MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h"
#include "MuonEfficiencyCorrections/MuonTriggerScaleFactors.h"
#include <EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h>
#include "PATCore/PATCoreEnums.h"
#include "xAODBase/ObjectType.h"
#include <boost/algorithm/string.hpp>
......@@ -189,7 +188,7 @@ namespace top {
// Get trigger strings from configuration
std::map<std::string, std::string> triggerCombination, triggerCombinationLoose;
std::vector<std::string> electronSystematics, muonSystematics, electronToolNames, muonToolNames;
std::vector<std::string> electronSystematics, muonSystematics, photonSystematics, electronToolNames, muonToolNames, photonToolNames;
std::unordered_map<std::string, std::vector<std::pair<std::string, int> > > const emptymap;
std::unordered_map<std::string, std::vector<std::pair<std::string, int> > > const&
triggersByPeriod = (m_config->doTightEvents() ? m_config->getGlobalTriggers() : emptymap),
......@@ -350,7 +349,8 @@ namespace top {
// Setup photon tools
ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonEffTools;
ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonSFTools;
std::vector<asg::AnaToolHandle<IAsgPhotonEfficiencyCorrectionTool> > factory;
ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonEffToolsLoose;
ToolHandleArray<IAsgPhotonEfficiencyCorrectionTool> photonSFToolsLoose;
const std::string photonKey = PhotonKeys(triggersByPeriod);
const std::string photonKeyLoose = PhotonKeys(triggersByPeriodLoose);
......@@ -358,44 +358,62 @@ namespace top {
static const std::string mapPath = "PhotonEfficiencyCorrection/2015_2018/rel21.2/Summer2020_Rec_v1/map2.txt";
if (photonKey != "" || photonKeyLoose != "") {
if (m_config->doTightEvents()) {
nTools = 0;
top::check(CheckPhotonIsolation(photonIso), "Unsupported photon isolation for photon triggers provided: " + photonIso);
for(int j=0;j<2;++j) { /// two instances: 0 -> MC efficiencies, 1 -> SFs
const std::string name = "AsgPhotonEfficiencyCorrectionTool/" + std::string(j? "PhTrigEff" : "PhTrigSF");
auto t = factory.emplace(factory.end(), name);
top::check(t->setProperty("MapFilePath", mapPath.c_str()), "Cannot set MapFilePath");
top::check(t->setProperty("TriggerKey", std::string(j ? "" : "Eff_") + photonKey), "Cannot set TriggerKey");
top::check(t->setProperty("IsoKey", photonIso), "Cannot set IsoKey");
top::check(t->setProperty("ForceDataType", (int)PATCore::ParticleDataType::Full), "Cannot set ForceDataType");
top::check(t->initialize(), "Cannot initialise the photon tools");
auto& photonHandles = (j? photonSFTools : photonEffTools);
photonHandles.push_back(t->getHandle());
for (auto& y_t : photonLegsByPeriod) {
const std::string year = y_t.first;
for (auto& trigKey : y_t.second) {
for (auto& y_t : photonLegsByPeriod) {
const std::string year = y_t.first;
for (auto& trigKey : y_t.second) {
nTools++;
for(int j=0;j<2;++j) { /// two instances: 0 -> MC efficiencies, 1 -> SFs
const std::string nameTool = "AsgPhotonEfficiencyCorrectionTool/" + std::string(j? "PhTrigEff" : "PhTrigSF") + "_" + std::to_string(nTools);
auto t = m_photonToolsFactory.emplace(m_photonToolsFactory.end(), nameTool);
top::check(t->setProperty("MapFilePath", mapPath.c_str()), "Cannot set MapFilePath");
top::check(t->setProperty("TriggerKey", std::string(j ? "" : "Eff_") + photonKey), "Cannot set TriggerKey");
top::check(t->setProperty("IsoKey", photonIso), "Cannot set IsoKey");
top::check(t->setProperty("ForceDataType", (int)PATCore::ParticleDataType::Full), "Cannot set ForceDataType");
top::check(t->setProperty("OutputLevel", MSG::ERROR), "Cannot set OutputLevel");
top::check(t->initialize(), "Cannot initialise the photon tools");
auto& photonHandles = (j? photonSFTools : photonEffTools);
photonHandles.push_back(t->getHandle());
const std::string name = photonHandles.back().name();
legsPerTool[name] = trigKey + " [" + year + "]";
photonToolNames.push_back(name);
if (photonSystematics.size() == 0 && j == 1) {
for (const auto& s : photonHandles.back()->recommendedSystematics().getBaseNames()) {
photonSystematics.push_back(s);
}
}
}
}
}
}
if (m_config->doLooseEvents()) {
nTools = 0;
top::check(CheckPhotonIsolation(photonIsoLoose), "Unsupported photon isolation for photon triggers provided: " + photonIsoLoose);
for(int j=0;j<2;++j) { /// two instances: 0 -> MC efficiencies, 1 -> SFs
const std::string name = "AsgPhotonEfficiencyCorrectionTool/" + std::string(j? "PhTrigEff" : "PhTrigSF");
auto t = factory.emplace(factory.end(), name);
top::check(t->setProperty("MapFilePath", mapPath.c_str()), "Cannot set MapFilePath");
top::check(t->setProperty("TriggerKey", std::string(j ? "" : "Eff_") + photonKeyLoose), "Cannot set TriggerKey");
top::check(t->setProperty("IsoKey", photonIsoLoose), "Cannot set IsoKey");
top::check(t->setProperty("ForceDataType", (int)PATCore::ParticleDataType::Full), "Cannot set ForceDataType");
top::check(t->initialize(), "Cannot initialise the photon tools");
auto& photonHandles = (j? photonSFTools : photonEffTools);
photonHandles.push_back(t->getHandle());
for (auto& y_t : photonLegsByPeriodLoose) {
const std::string year = y_t.first;
for (auto& trigKey : y_t.second) {
const std::string name =photonHandles.back().name();
legsPerTool[name] = trigKey + " [" + year + "]";
for (auto& y_t : photonLegsByPeriodLoose) {
const std::string year = y_t.first;
for (auto& trigKey : y_t.second) {
nTools++;
for(int j=0;j<2;++j) { /// two instances: 0 -> MC efficiencies, 1 -> SFs
const std::string nameTool = "AsgPhotonEfficiencyCorrectionTool/" + std::string(j? "PhTrigEff" : "PhTrigSF") + "_" + std::to_string(nTools);
auto tLoose = m_photonToolsFactoryLoose.emplace(m_photonToolsFactoryLoose.end(), nameTool);
top::check(tLoose->setProperty("MapFilePath", mapPath.c_str()), "Cannot set MapFilePath");
top::check(tLoose->setProperty("TriggerKey", std::string(j ? "" : "Eff_") + photonKeyLoose), "Cannot set TriggerKey");
top::check(tLoose->setProperty("IsoKey", photonIsoLoose), "Cannot set IsoKey");
top::check(tLoose->setProperty("ForceDataType", (int)PATCore::ParticleDataType::Full), "Cannot set ForceDataType");
top::check(tLoose->setProperty("OutputLevel", MSG::ERROR), "Cannot set OutputLevel");
top::check(tLoose->initialize(), "Cannot initialise the photon tools");
auto& photonHandlesLoose = (j? photonSFToolsLoose : photonEffToolsLoose);
photonHandlesLoose.push_back(tLoose->getHandle());
const std::string name = photonHandlesLoose.back().name();
legsPerToolLoose[name] = trigKey + " [" + year + "]";
photonToolNames.push_back(name);
if (photonSystematics.size() == 0 && j == 1) {
for (const auto& s : photonHandlesLoose.back()->recommendedSystematics().getBaseNames()) {
photonSystematics.push_back(s);
}
}
}
}
}
......@@ -452,8 +470,8 @@ namespace top {
top::check(globalTriggerEffToolLoose->setProperty("ElectronEfficiencyTools", electronEffToolsLoose), "Failed to attach electron efficiency tools");
top::check(globalTriggerEffToolLoose->setProperty("ElectronScaleFactorTools", electronSFToolsLoose), "Failed to attach electron scale factor tools");
top::check(globalTriggerEffToolLoose->setProperty("MuonTools", muonToolsLoose), "Failed to attach muon tools");
top::check(globalTriggerEffToolLoose->setProperty("PhotonEfficiencyTools", photonEffTools), "Failed to attach photon eff tools");
top::check(globalTriggerEffToolLoose->setProperty("PhotonScaleFactorTools", photonSFTools), "Failed to attach photon SF tools");
top::check(globalTriggerEffToolLoose->setProperty("PhotonEfficiencyTools", photonEffToolsLoose), "Failed to attach photon eff tools");
top::check(globalTriggerEffToolLoose->setProperty("PhotonScaleFactorTools", photonSFToolsLoose), "Failed to attach photon SF tools");
top::check(globalTriggerEffToolLoose->setProperty("ListOfLegsPerTool", legsPerToolLoose), "Failed to define list of legs per tool");
top::check(globalTriggerEffToolLoose->setProperty("TriggerCombination", triggerCombinationLoose), "Failed to define trigger combination");
top::check(globalTriggerEffToolLoose->setProperty("TriggerMatchingTool", m_trigMatchTool), "Failed to set TriggerMatchingTool");
......@@ -464,7 +482,7 @@ namespace top {
}
// Set information about systematics inside TopConfig
m_config->setGlobalTriggerConfiguration(electronSystematics, muonSystematics, electronToolNames, muonToolNames);
m_config->setGlobalTriggerConfiguration(electronSystematics, muonSystematics, photonSystematics, electronToolNames, muonToolNames, photonToolNames);
return statusCode;
}
......
......@@ -24,6 +24,7 @@
#include "TriggerAnalysisInterfaces/ITrigGlobalEfficiencyCorrectionTool.h"
// Need to have these tools held in the class
#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
#include "MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h"
namespace top {
......@@ -56,6 +57,8 @@ namespace top {
asg::AnaToolHandle<CP::IMuonTriggerScaleFactors> m_muonToolLoose;
std::vector<asg::AnaToolHandle<IAsgElectronEfficiencyCorrectionTool> > m_electronToolsFactory;
std::vector<asg::AnaToolHandle<IAsgElectronEfficiencyCorrectionTool> > m_electronToolsFactoryLoose;
std::vector<asg::AnaToolHandle<IAsgPhotonEfficiencyCorrectionTool> > m_photonToolsFactory;
std::vector<asg::AnaToolHandle<IAsgPhotonEfficiencyCorrectionTool> > m_photonToolsFactoryLoose;
};
} // namespace top
......
......@@ -3980,12 +3980,17 @@ namespace top {
void TopConfig::setGlobalTriggerConfiguration(std::vector<std::string> electron_trigger_systematics,
std::vector<std::string> muon_trigger_systematics,
std::vector<std::string> photon_trigger_systematics,
std::vector<std::string> electron_tool_names,
std::vector<std::string> muon_tool_names) {
std::vector<std::string> muon_tool_names,
std::vector<std::string> photon_tool_names
) {
m_trigGlobalConfiguration.electron_trigger_systematics = electron_trigger_systematics;
m_trigGlobalConfiguration.muon_trigger_systematics = muon_trigger_systematics;
m_trigGlobalConfiguration.photon_trigger_systematics = photon_trigger_systematics;
m_trigGlobalConfiguration.electron_trigger_tool_names = electron_tool_names;
m_trigGlobalConfiguration.muon_trigger_tool_names = muon_tool_names;
m_trigGlobalConfiguration.photon_trigger_tool_names = photon_tool_names;
m_trigGlobalConfiguration.isConfigured = true;
return;
}
......
......@@ -2053,7 +2053,8 @@ namespace top {
inline bool isNominalAvailable() const {return m_isNominalAvailable;}
// Function to set the options for global trigger tool
void setGlobalTriggerConfiguration(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
void setGlobalTriggerConfiguration(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>,
std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
inline bool useGlobalTrigger() const {return m_trigGlobalConfiguration.isActivated;} // Was this requested by the
// user
inline auto const& getGlobalTriggers() const {return m_trigGlobalConfiguration.trigger;}
......@@ -2063,8 +2064,10 @@ namespace top {
// configured
inline std::vector<std::string> getGlobalTriggerElectronSystematics() const {return m_trigGlobalConfiguration.electron_trigger_systematics;}
inline std::vector<std::string> getGlobalTriggerMuonSystematics() const {return m_trigGlobalConfiguration.muon_trigger_systematics;}
inline std::vector<std::string> getGlobalTriggerPhotonSystematics() const {return m_trigGlobalConfiguration.photon_trigger_systematics;}
inline std::vector<std::string> getGlobalTriggerElectronTools() const {return m_trigGlobalConfiguration.electron_trigger_tool_names;}
inline std::vector<std::string> getGlobalTriggerMuonTools() const {return m_trigGlobalConfiguration.muon_trigger_tool_names;}
inline std::vector<std::string> getGlobalTriggerPhotonTools() const {return m_trigGlobalConfiguration.photon_trigger_tool_names;}
inline const TreeFilter* getTreeFilter() const { return m_treeFilter.get();}
......@@ -2666,10 +2669,14 @@ namespace top {
std::vector<std::string> electron_trigger_systematics;
// Names of CP::SystematicSet from muon trigger tools
std::vector<std::string> muon_trigger_systematics;
// Names of CP::SystematicSet from photon trigger tools
std::vector<std::string> photon_trigger_systematics;
// Name of the underlying electron tools, to be accessed and passes CP::SystematicSet
std::vector<std::string> electron_trigger_tool_names;
// Name of the underlying muon tools, to be accessed and passes CP::SystematicSet
std::vector<std::string> muon_trigger_tool_names;
// Name of the underlying photon tools, to be accessed and passes CP::SystematicSet
std::vector<std::string> photon_trigger_tool_names;
} m_trigGlobalConfiguration;
// Muon Trigger SF configuration
......
......@@ -41,6 +41,7 @@ namespace top {
// Retrieve the systematic names we stored
for (auto& s : m_config->getGlobalTriggerElectronSystematics()) ATH_MSG_DEBUG(" - Electron systematics : " << s);
for (auto& s : m_config->getGlobalTriggerMuonSystematics()) ATH_MSG_DEBUG(" - Muon systematics : " << s);
for (auto& s : m_config->getGlobalTriggerPhotonSystematics()) ATH_MSG_DEBUG(" - Photon systematics : " << s);
{
std::vector<ToolHandle<IAsgElectronEfficiencyCorrectionTool> > tools;
......@@ -62,6 +63,17 @@ namespace top {
}
m_muonTools.swap(tools);
}
{
std::vector<ToolHandle<IAsgPhotonEfficiencyCorrectionTool> > tools;
tools.reserve(m_config->getGlobalTriggerPhotonTools().size());
for (auto const& s : m_config->getGlobalTriggerPhotonTools()) {
ATH_MSG_DEBUG(" - Photon tools : " << s);
tools.emplace_back(s);
top::check(tools.back().retrieve(), "Failed to retrieve photon tool");
}
m_photonTools.swap(tools);
}
return StatusCode::SUCCESS;
}
......@@ -105,8 +117,10 @@ namespace top {
// Retrieve nominal muons, retrieve nominal electrons
const xAOD::MuonContainer* muons(nullptr);
const xAOD::ElectronContainer* electrons(nullptr);
const xAOD::PhotonContainer* photons(nullptr);
std::vector<const xAOD::Muon*> selectedMuons;
std::vector<const xAOD::Electron*> selectedElectrons;
std::vector<const xAOD::Photon*> selectedPhotons;
if (m_config->useMuons()) top::check(evtStore()->retrieve(muons, m_config->sgKeyMuons(hash)), "Failed to retrieve muons");
......@@ -121,6 +135,12 @@ namespace top {
selectedElectrons.push_back(electrons->at(index));
}
if (m_config->usePhotons()) top::check(evtStore()->retrieve(photons, m_config->sgKeyPhotons(hash)), "Failed to retrieve photons");
// Put into a vector
for (size_t index : systEvent->goodPhotons()) {
selectedPhotons.push_back(photons->at(index));
}
// manage current electron trigger SF variation
CP::SystematicSet electronSystSet;
auto setCurrentElectronVariation = [this, &electronSystSet](std::string const& parameterName, int value) {
......@@ -145,26 +165,40 @@ namespace top {
}
};
// manage current photon trigger SF variation
CP::SystematicSet photonSystSet;
auto setCurrentPhotonVariation = [this, &photonSystSet](std::string const& parameterName, int value) {
photonSystSet.clear();
if (!parameterName.empty()) photonSystSet.insert(CP::SystematicVariation(
parameterName, value));
for (auto&& tool : m_photonTools) {
top::check(tool->applySystematicVariation(
photonSystSet), "Failed to apply systematic");
}
};
// compute and store trigger SF for current variation
auto&& globalTriggerTool = (isLoose ? m_globalTriggerSFLoose : m_globalTriggerSF);
auto decorateEventForCurrentVariation = [&]() {
double sf;
if (selectedElectrons.empty() && selectedMuons.empty()) {
if (selectedElectrons.empty() && selectedMuons.empty() && selectedPhotons.empty()) {
sf = 1.;
} else {
sf = NAN;
top::check(globalTriggerTool->getEfficiencyScaleFactor(
selectedElectrons,
selectedMuons,
selectedPhotons,
sf), "Failed to get global trigger SF");
}
std::string auxname(m_decor_triggerSF);
auxname += "_";
if (!(electronSystSet.empty() && muonSystSet.empty())) {
if (!(electronSystSet.empty() && muonSystSet.empty() && photonSystSet.empty())) {
CP::SystematicSet systSet;
systSet.insert(electronSystSet);
systSet.insert(muonSystSet);
systSet.insert(photonSystSet);
auxname += systSet.name();
}
ATH_MSG_DEBUG("Adding decoration " << auxname << " = " << sf);
......@@ -174,6 +208,7 @@ namespace top {
///-- Set the nominal --///
setCurrentElectronVariation("", 0);
setCurrentMuonVariation("", 0);
setCurrentPhotonVariation("", 0);
decorateEventForCurrentVariation();
///-- Apply and calculate variations on nominal --///
......@@ -196,6 +231,14 @@ namespace top {
}
}
setCurrentMuonVariation("", 0);
for (auto& s : m_config->getGlobalTriggerPhotonSystematics()) {
for (int val : {1, -1}) {
setCurrentPhotonVariation(s, val);
decorateEventForCurrentVariation();
}
}
setCurrentPhotonVariation("", 0);
}
}
}
......@@ -33,8 +33,10 @@ namespace top {
for (std::string selPtr : *selectors) {
std::vector<std::pair<std::string, int> > muonTrig_Tight = m_config->muonTriggers_Tight(selPtr);
std::vector<std::pair<std::string, int> > electronTrig_Tight = m_config->electronTriggers_Tight(selPtr);
std::vector<std::pair<std::string, int> > photonTrig_Tight = m_config->photonTriggers_Tight(selPtr);
std::vector<std::pair<std::string, int> > muonTrig_Loose = m_config->muonTriggers_Loose(selPtr);
std::vector<std::pair<std::string, int> > electronTrig_Loose = m_config->electronTriggers_Loose(selPtr);
std::vector<std::pair<std::string, int> > photonTrig_Loose = m_config->photonTriggers_Loose(selPtr);
for (auto trig : muonTrig_Tight)
m_muonTriggers_Tight.push_back(trig);
......@@ -45,6 +47,11 @@ namespace top {
m_electronTriggers_Tight.push_back(trig);
for (auto trig : electronTrig_Loose)
m_electronTriggers_Loose.push_back(trig);
for (auto trig : photonTrig_Tight)
m_photonTriggers_Tight.push_back(trig);
for (auto trig : photonTrig_Loose)
m_photonTriggers_Loose.push_back(trig);
}
return StatusCode::SUCCESS;
......@@ -89,6 +96,7 @@ namespace top {
top::check(eventInfo, "Failed to retrieve SystematicEvent");
const bool electronTriggerIsEmpty = event.m_isLoose ? m_electronTriggers_Loose.empty() : m_electronTriggers_Tight.empty();
const bool muonTriggerIsEmpty = event.m_isLoose ? m_muonTriggers_Loose.empty() : m_muonTriggers_Tight.empty();
const bool photonTriggerIsEmpty = event.m_isLoose ? m_photonTriggers_Loose.empty() : m_photonTriggers_Tight.empty();
// Create a hard-coded map linking top::topSFSyst <-> EventInfo decoration
switch (SFSyst) {
......@@ -140,6 +148,22 @@ namespace top {
}
break;
case top::topSFSyst::PHOTON_EFF_TRIGGER_UNCERTAINTY_UP:
if (photonTriggerIsEmpty) {
sf = 1;
} else {
sf = eventInfo->auxdataConst<float>(prefix + "PH_EFF_TRIGGER_Uncertainty__1up");
}
break;
case top::topSFSyst::PHOTON_EFF_TRIGGER_UNCERTAINTY_DOWN:
if (photonTriggerIsEmpty) {
sf = 1;
} else {
sf = eventInfo->auxdataConst<float>(prefix + "PH_EFF_TRIGGER_Uncertainty__1down");
}
break;
default:
// Nominal weight
sf = eventInfo->auxdataConst<float>(prefix);
......@@ -150,10 +174,29 @@ namespace top {
float ScaleFactorRetriever::triggerSF(const top::Event& event,
const top::topSFSyst SFSyst) const {
// if it has photon triggers return 1;
if (event.m_isLoose) {
if (!m_photonTriggers_Loose.empty()) return 1.;
} else {
if (!m_photonTriggers_Tight.empty()) return 1.;
}
return(m_preferGlobalTriggerSF &&
m_config->useGlobalTrigger() ? globalTriggerSF(event, SFSyst) : oldTriggerSF(event, SFSyst));
}
float ScaleFactorRetriever::triggerSFPhoton(const top::Event& event,
const top::topSFSyst SFSyst) const {
if (!m_config->useGlobalTrigger()) {
ATH_MSG_WARNING("Photon trigger SFs are currently supported only for the global triggers");
return 1.;
}
return globalTriggerSF(event, SFSyst);
}
float ScaleFactorRetriever::oldTriggerSF(const top::Event& event,
const top::topSFSyst SFSyst) const {
bool retrieveLoose = (event.m_isLoose && !m_config->applyTightSFsInLooseTree());
......@@ -748,7 +791,7 @@ namespace top {
return sf;
}
float ScaleFactorRetriever::muonEff_Trigger(const xAOD::Muon& x,
const top::topSFSyst SFSyst,
bool useLooseDef) const {
......@@ -1101,13 +1144,15 @@ namespace top {
float sf(1.);
float reco(1.);
float isol(1.);
float trigger(1.);
for (auto photon : event.m_photons) {
reco *= photonSF_Reco(*photon, SFSyst);
isol *= photonSF_Isol(*photon, SFSyst, event.m_isLoose);
}
trigger = triggerSFPhoton(event, SFSyst);
sf = reco * isol;
sf = reco * isol * trigger;
return sf;
}
......
......@@ -27,6 +27,7 @@
// CP Tool include(s):
#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
#include "MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h"
#include "TriggerAnalysisInterfaces/ITrigGlobalEfficiencyCorrectionTool.h"
......@@ -61,6 +62,7 @@ namespace top {
std::vector<ToolHandle<IAsgElectronEfficiencyCorrectionTool> > m_electronTools;
std::vector<ToolHandle<CP::IMuonTriggerScaleFactors> > m_muonTools;
std::vector<ToolHandle<IAsgPhotonEfficiencyCorrectionTool> > m_photonTools;
std::string m_decor_triggerSF;
};
......
......@@ -88,6 +88,8 @@ namespace top {
// Photon SFs
PHOTON_IDSF_UP, PHOTON_IDSF_DOWN,
PHOTON_EFF_ISO_UP, PHOTON_EFF_ISO_DOWN,
PHOTON_EFF_TRIGGER_UNCERTAINTY_UP,
PHOTON_EFF_TRIGGER_UNCERTAINTY_DOWN,
// B-tagging SFs
BTAG_SF_EIGEN_B, BTAG_SF_EIGEN_C,
BTAG_SF_EIGEN_LIGHT,
......@@ -233,6 +235,7 @@ namespace top {
// Obtain the trigger SF
float triggerSF(const top::Event& event, const top::topSFSyst SFSyst) const;
float triggerSFPhoton(const top::Event& event, const top::topSFSyst SFSyst) const;
// Obtain trigger SF via global tool
float globalTriggerSF(const top::Event& event, const top::topSFSyst SFSyst) const;
......@@ -467,8 +470,10 @@ namespace top {
// If any one passes, the event passes
std::vector<std::pair<std::string, int> > m_electronTriggers_Tight;
std::vector<std::pair<std::string, int> > m_muonTriggers_Tight;
std::vector<std::pair<std::string, int> > m_photonTriggers_Tight;
std::vector<std::pair<std::string, int> > m_electronTriggers_Loose;
std::vector<std::pair<std::string, int> > m_muonTriggers_Loose;
std::vector<std::pair<std::string, int> > m_photonTriggers_Loose;
// Do we need to add tau triggers?
// Configuration
......
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