From 42a82ef1f43f3efa4a2e578a91b74e11f1fcaca4 Mon Sep 17 00:00:00 2001
From: Johannes Josef Junggeburth <johannes.josef.junggeburth@cern.ch>
Date: Tue, 26 Mar 2019 15:30:12 +0000
Subject: [PATCH] Add method to the MuonTriggerScaleFactor telling the user
 whether the trigger is supported or not.

---
 .../IMuonTriggerScaleFactors.h                   | 15 +++------------
 .../MuonTriggerScaleFactors.h                    | 16 ++++------------
 .../Root/MuonTriggerScaleFactors.cxx             | 12 +++++++-----
 3 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/PhysicsAnalysis/Interfaces/MuonAnalysisInterfaces/MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h b/PhysicsAnalysis/Interfaces/MuonAnalysisInterfaces/MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h
index caf4b44050b..0b4c4f6621f 100644
--- a/PhysicsAnalysis/Interfaces/MuonAnalysisInterfaces/MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h
+++ b/PhysicsAnalysis/Interfaces/MuonAnalysisInterfaces/MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h
@@ -1,18 +1,7 @@
 /*
- Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
  */
 
-/*
- *  IMuonTriggerScaleFactors.h
- *
- *  Created on: Oct. 22, 2014
- *      Author: Kota Kasahara <kota.kasahara@cern.ch>
- *
- *  Updates for 2016: Jun 20, 2016
- *      Author: Lidia Dell'Asta <dellasta@cern.ch> 
- */
-
-
 #ifndef IMUONTRIGGERSCALEFACTORS_H_
 #define IMUONTRIGGERSCALEFACTORS_H_
 
@@ -71,6 +60,8 @@ namespace CP {
                             Bool_t dataType) const = 0;
       
             virtual int getBinNumber(const xAOD::Muon& muon, const std::string& trigger) const = 0;
+            /// Returns whether the trigger is supported in the current data-period
+            virtual bool isTriggerSupported(const std::string& trigger) const = 0;
 
           
     };
diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonTriggerScaleFactors.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonTriggerScaleFactors.h
index 3b634f34d6e..939c08dd453 100644
--- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonTriggerScaleFactors.h
+++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonTriggerScaleFactors.h
@@ -1,17 +1,6 @@
 /*
- Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
  */
-
-/*
- *  MuonTriggerScaleFactors.h
- *
- *  Created on: Oct 22, 2014
- *      Author: Kota Kasahara <kota.kasahara@cern.ch>
- *
- *  Updates for 2016: Jun 20, 2016
- *      Author: Lidia Dell'Asta <dellasta@cern.ch> 
- */
-
 #ifndef MUONTRIGGERSCALEFACTORS_H_
 #define MUONTRIGGERSCALEFACTORS_H_
 
@@ -77,6 +66,9 @@ namespace CP {
             virtual double dR(const double eta1, const double phi1, const double eta2, const double phi2) const;
 
             virtual int getReplica_index(std::string sysBaseName, const std::string trigStr) const;
+      
+            /// Returns whether the trigger is supported by the tool or not. The decision depends on the present (random)RunNumber 
+            virtual bool isTriggerSupported(const std::string& trigger) const;
         private:
 
             virtual CorrectionCode getMuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::Muon& muon, const std::string& trigger, const std::string& systematic) const;
diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonTriggerScaleFactors.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonTriggerScaleFactors.cxx
index bb35760787f..7f43c694e53 100644
--- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonTriggerScaleFactors.cxx
+++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonTriggerScaleFactors.cxx
@@ -29,9 +29,7 @@ namespace CP {
     }
     MuonTriggerScaleFactors::MuonTriggerScaleFactors(const std::string& name) :
       asg::AsgTool(name),
-
       m_systFilter(),
-
       m_appliedSystematics(nullptr),
       m_fileName(),
       m_efficiencyMap(),
@@ -201,7 +199,6 @@ namespace CP {
         origDir->cd();
         return StatusCode::SUCCESS;
     }
-
     // ==================================================================================
     // == MuonTriggerScaleFactors::initialize()
     // ==================================================================================
@@ -212,8 +209,8 @@ namespace CP {
         ATH_MSG_INFO("CalibrationRelease = '" << m_calibration_version << "'");
         ATH_MSG_INFO("CustomInputFolder = '" << m_custom_dir << "'");
         ATH_MSG_INFO("AllowZeroSF = " << m_allowZeroSF);
-	ATH_MSG_INFO("experimental = " << m_experimental);
-	ATH_MSG_INFO("useRel27 = " << m_useRel207);
+	    ATH_MSG_INFO("experimental = " << m_experimental);
+    	ATH_MSG_INFO("useRel27 = " << m_useRel207);
 
         if (registerSystematics() != CP::SystematicCode::Ok) {
             return StatusCode::FAILURE;
@@ -371,6 +368,11 @@ namespace CP {
         return replica_v;
     }
 
+   bool MuonTriggerScaleFactors::isTriggerSupported(const std::string& trigger) const{
+       TH1_Ptr H1 = getEfficiencyHistogram(trigger, true, "nominal");
+       return H1.get() != nullptr;
+    }
+    
   int MuonTriggerScaleFactors::getBinNumber(const xAOD::Muon& muon, const std::string& trigger) const{
     if(!m_experimental){
       ATH_MSG_ERROR("MuonTriggerScaleFactors::getTriggerScaleFactor This is an experimental function. If you really know what you are doing set UseExperimental property.");
-- 
GitLab