26 m_globalTriggerSF(
"TrigGlobalEfficiencyCorrectionTool::TrigGlobal"),
27 m_globalTriggerSFLoose(
"TrigGlobalEfficiencyCorrectionTool::TrigGlobalLoose"),
29 m_decor_triggerSF(
"AnalysisTop_Trigger_SF") {
34 ATH_MSG_INFO(
" top::GlobalLeptonTriggerCalculator initialize");
37 "Failed to retrieve global trigger SF tool");
42 for (
auto&
s :
m_config->getGlobalTriggerElectronSystematics())
ATH_MSG_DEBUG(
" - Electron systematics : " <<
s);
47 std::vector<ToolHandle<IAsgElectronEfficiencyCorrectionTool> >
tools;
48 tools.reserve(
m_config->getGlobalTriggerElectronTools().size());
49 for (
auto const&
s :
m_config->getGlobalTriggerElectronTools()) {
52 top::check(
tools.back().retrieve(),
"Failed to retrieve electron tool");
57 std::vector<ToolHandle<CP::IMuonTriggerScaleFactors> >
tools;
59 for (
auto const&
s :
m_config->getGlobalTriggerMuonTools()) {
67 std::vector<ToolHandle<IAsgPhotonEfficiencyCorrectionTool> >
tools;
68 tools.reserve(
m_config->getGlobalTriggerPhotonTools().size());
69 for (
auto const&
s :
m_config->getGlobalTriggerPhotonTools()) {
78 return StatusCode::SUCCESS;
82 ATH_MSG_DEBUG(
"Entered GlobalLeptonTriggerCalculator::execute");
84 auto const& nominalHash =
m_config->nominalHashValue();
88 m_config->sgKeyTopSystematicEvents()),
89 "Failed to get xAOD::SystematicEventContainer");
91 bool withScaleFactorVariations = (systEvent->hashValue() == nominalHash);
98 m_config->sgKeyTopSystematicEventsLoose()),
99 "Failed to get xAOD::SystematicEventContainer");
101 bool withScaleFactorVariations = (systEvent->hashValue() == nominalHash);
106 ATH_MSG_DEBUG(
"Leaving GlobalLeptonTriggerCalculator::execute");
107 return StatusCode::SUCCESS;
114 std::string
const& systname =
m_config->systematicName(
hash);
115 ATH_MSG_DEBUG(
"Calculating trigger SF for variation " << systname <<
" (" <<
hash <<
") with isLoose=" << isLoose);
121 std::vector<const xAOD::Muon*> selectedMuons;
122 std::vector<const xAOD::Electron*> selectedElectrons;
123 std::vector<const xAOD::Photon*> selectedPhotons;
129 selectedMuons.push_back(muons->
at(
index));
141 selectedPhotons.push_back(photons->
at(
index));
146 auto setCurrentElectronVariation = [
this, &electronSystSet](std::string
const& parameterName,
int value) {
147 electronSystSet.
clear();
149 parameterName,
value));
152 electronSystSet),
"Failed to apply systematic");
158 auto setCurrentMuonVariation = [
this, &muonSystSet](std::string
const& parameterName,
int value) {
161 parameterName,
value));
164 muonSystSet),
"Failed to apply systematic");
170 auto setCurrentPhotonVariation = [
this, &photonSystSet](std::string
const& parameterName,
int value) {
171 photonSystSet.
clear();
173 parameterName,
value));
176 photonSystSet),
"Failed to apply systematic");
182 auto decorateEventForCurrentVariation = [&]() {
185 if (selectedElectrons.empty() && selectedMuons.empty() && selectedPhotons.empty()) {
189 globalTriggerTool->getEfficiencyScaleFactor(
197 if (!(electronSystSet.
empty() && muonSystSet.
empty() && photonSystSet.
empty())) {
199 systSet.
insert(electronSystSet);
200 systSet.
insert(muonSystSet);
201 systSet.
insert(photonSystSet);
202 auxname += systSet.
name();
209 setCurrentElectronVariation(
"", 0);
210 setCurrentMuonVariation(
"", 0);
211 setCurrentPhotonVariation(
"", 0);
212 decorateEventForCurrentVariation();
215 if (withScaleFactorVariations) {
219 for (
auto&
s :
m_config->getGlobalTriggerElectronSystematics()) {
220 for (
int val : {1, -1}) {
221 setCurrentElectronVariation(
s,
val);
222 decorateEventForCurrentVariation();
226 setCurrentElectronVariation(
"", 0);
227 for (
auto&
s :
m_config->getGlobalTriggerMuonSystematics()) {
228 for (
int val : {1, -1}) {
229 setCurrentMuonVariation(
s,
val);
230 decorateEventForCurrentVariation();
233 setCurrentMuonVariation(
"", 0);
235 for (
auto&
s :
m_config->getGlobalTriggerPhotonSystematics()) {
236 for (
int val : {1, -1}) {
237 setCurrentPhotonVariation(
s,
val);
238 decorateEventForCurrentVariation();
241 setCurrentPhotonVariation(
"", 0);