From 968fd1e8088d61ec4c4427cf77d4b44104b00b8b Mon Sep 17 00:00:00 2001
From: Daniela Kuechler <daniela.kuechler@cern.ch>
Date: Mon, 29 Mar 2021 15:34:57 +0200
Subject: [PATCH] add photon ID tool and fill corresponding plots in the same
 way as for isolation

---
 .../egamma/egammaValidation/CMakeLists.txt    |  2 +-
 .../egammaValidation/src/EgammaMonitoring.cxx | 40 +++++++++++++++++++
 .../egammaValidation/src/EgammaMonitoring.h   |  7 ++++
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/Reconstruction/egamma/egammaValidation/CMakeLists.txt b/Reconstruction/egamma/egammaValidation/CMakeLists.txt
index 6f704d797d16..4e3005d8c983 100644
--- a/Reconstruction/egamma/egammaValidation/CMakeLists.txt
+++ b/Reconstruction/egamma/egammaValidation/CMakeLists.txt
@@ -8,7 +8,7 @@ atlas_add_component ( egammmaValidation
 	src/*.cxx 
 	src/components/*.cxx 
 	LINK_LIBRARIES AsgTools AthenaBaseComps EgammaAnalysisInterfacesLib GaudiKernel IsolationSelectionLib 
-	MCTruthClassifierLib PATCoreAcceptLib xAODBase xAODEgamma xAODEventInfo 
+	MCTruthClassifierLib PATCoreAcceptLib xAODBase xAODEgamma xAODEventInfo ElectronPhotonSelectorToolsLib
 	xAODTracking xAODTruth )
 
 atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
diff --git a/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.cxx b/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.cxx
index e448427b46f6..69c561fc18ce 100644
--- a/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.cxx
+++ b/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.cxx
@@ -17,6 +17,8 @@ EgammaMonitoring::EgammaMonitoring(const std::string &name, ISvcLocator *pSvcLoc
   m_LooseLH("AsgElectronLikelihoodTool/LooseLH"),
   m_MediumLH("AsgElectronLikelihoodTool/MediumLH"),
   m_TightLH("AsgElectronLikelihoodTool/TightLH"),
+  m_LooseLH_Photon("AsgPhotonIsEMSelector/photonLooseIsEMSelector"),
+  m_TightLH_Photon("AsgPhotonIsEMSelector/photonTightIsEMSelector"),
   m_IsoFixedCutTight("CP::IsolationSelectionTool/IsoFixedCutTight"),
   m_IsoFixedCutTightTrackOnly("CP::IsolationSelectionTool/IsoFixedCutTightTrackOnly"),
   m_IsoFixedCutTightCaloOnly("CP::IsolationSelectionTool/IsoFixedCutTightCaloOnly"),
@@ -201,6 +203,18 @@ StatusCode EgammaMonitoring::initialize() {
     truthPhotonUnconvRecoUnconv = std::unique_ptr<egammaMonitoring::IHistograms>(new egammaMonitoring::TruthPhotonHistograms(
         "truthUnconvRecoUnconv","truthUnconvRecoUnconv", "/MONITORING/truthUnconvRecoUnconv/", rootHistSvc));
 
+    recoPhotonUnconvLooseLH = std::unique_ptr<egammaMonitoring::IHistograms>(new egammaMonitoring::TruthPhotonHistograms(
+      "recoPhotonUnconvLooseLH","LLH Photons Reco Photon", "/MONITORING/recoPhotonUnconvLooseLH/", rootHistSvc));
+
+    recoPhotonUnconvTightLH = std::unique_ptr<egammaMonitoring::IHistograms>(new egammaMonitoring::TruthPhotonHistograms(
+      "recoPhotonUnconvTightLH","TLH Photons Reco Photon", "/MONITORING/recoPhotonUnconvTightLH/", rootHistSvc));
+
+    recoPhotonConvLooseLH = std::unique_ptr<egammaMonitoring::IHistograms>(new egammaMonitoring::TruthPhotonHistograms(
+      "recoPhotonConvLooseLH","LLH Photons Reco Photon", "/MONITORING/recoPhotonConvLooseLH/", rootHistSvc));
+
+    recoPhotonConvTightLH = std::unique_ptr<egammaMonitoring::IHistograms>(new egammaMonitoring::TruthPhotonHistograms(
+      "recoPhotonConvTightLH","LLH Photons Reco Photon", "/MONITORING/recoPhotonConvTightLH/", rootHistSvc));
+
     recoPhotonUnconvIsoFixedCutTight = std::unique_ptr<egammaMonitoring::IHistograms>(new egammaMonitoring::TruthPhotonHistograms(
     "recoPhotonUnconvIsoFixedCutTight","Isolation Fixed Cut Tight Photons Reco Photon", "/MONITORING/recoPhotonUnconvIsoFixedCutTight/", rootHistSvc));
 
@@ -302,6 +316,10 @@ StatusCode EgammaMonitoring::initialize() {
     ATH_CHECK(truthPhotonUnconvRecoConv2TRT->initializePlots());
     ATH_CHECK(truthPhotonUnconvRecoConv2SiTRT->initializePlots());
     ATH_CHECK(truthPhotonUnconvRecoUnconv->initializePlots());
+    ATH_CHECK(recoPhotonUnconvLooseLH->initializePlots());
+    ATH_CHECK(recoPhotonUnconvTightLH->initializePlots());
+    ATH_CHECK(recoPhotonConvLooseLH->initializePlots());
+    ATH_CHECK(recoPhotonConvTightLH->initializePlots());
     ATH_CHECK(recoPhotonUnconvIsoFixedCutTight->initializePlots());
     ATH_CHECK(recoPhotonUnconvIsoFixedCutTightCaloOnly->initializePlots());
     ATH_CHECK(recoPhotonUnconvIsoFixedCutLoose->initializePlots());
@@ -353,6 +371,14 @@ StatusCode EgammaMonitoring::initialize() {
   ATH_CHECK(m_TightLH.setProperty("WorkingPoint", "TightLHElectron"));
   ATH_CHECK(m_TightLH.initialize());
 
+  //*****************LLH Requirement********************
+  ANA_CHECK(m_LooseLH_Photon.setProperty("WorkingPoint", "LoosePhoton"));
+  ANA_CHECK(m_LooseLH_Photon.initialize());
+  //*****************TLH Requirement********************
+  ANA_CHECK(m_TightLH_Photon.setProperty("WorkingPoint", "TightPhoton"));
+  ANA_CHECK(m_TightLH_Photon.initialize());
+
+
   //*****************Iso Requirements********************
   ATH_CHECK(m_IsoFixedCutTight.setProperty("PhotonWP", "FixedCutTight"));
   ATH_CHECK(m_IsoFixedCutTight.initialize());
@@ -755,6 +781,8 @@ StatusCode EgammaMonitoring::execute() {
           if (m_IsoFixedCutTight->accept(*photon)) recoPhotonConvIsoFixedCutTight->fill(*egtruth, mu);
           if (m_IsoFixedCutTightCaloOnly->accept(*photon)) recoPhotonConvIsoFixedCutTightCaloOnly->fill(*egtruth, mu);
           if (m_IsoFixedCutLoose->accept(*photon)) recoPhotonConvIsoFixedCutLoose->fill(*egtruth, mu);
+          if (m_LooseLH_Photon->accept(photon)) recoPhotonConvLooseLH->fill(*egtruth, mu);
+          if (m_TightLH_Photon->accept(photon)) recoPhotonConvTightLH->fill(*egtruth, mu);
         } // isRecoConv
         else {
           truthPhotonConvRecoUnconv->fill(*egtruth, mu);
@@ -791,6 +819,8 @@ StatusCode EgammaMonitoring::execute() {
         if (m_IsoFixedCutTight->accept(*photon)) recoPhotonUnconvIsoFixedCutTight->fill(*egtruth, mu);
         if (m_IsoFixedCutTightCaloOnly->accept(*photon)) recoPhotonUnconvIsoFixedCutTightCaloOnly->fill(*egtruth, mu);
         if (m_IsoFixedCutLoose->accept(*photon)) recoPhotonUnconvIsoFixedCutLoose->fill(*egtruth, mu);
+        if (m_LooseLH_Photon->accept(photon)) recoPhotonUnconvLooseLH->fill(*egtruth, mu);
+        if (m_TightLH_Photon->accept(photon)) recoPhotonUnconvTightLH->fill(*egtruth, mu);
       } // !isTrueLateConv
     } //egtruth Loop
 
@@ -919,6 +949,16 @@ StatusCode EgammaMonitoring::finalize() {
     egammaMonitoring::EfficiencyPlot recoPhotonConvIsoFixedCutLooseEfficiency("recoPhotonConvIsoFixedCutLooseEfficiency", "/MONITORING/recoPhotonConvIsoFixedCutLooseEfficiency/", rootHistSvc );
     ATH_CHECK(recoPhotonConvIsoFixedCutLooseEfficiency.divide( recoPhotonConvIsoFixedCutLoose.get(), truthPhotonConvRecoConv.get()));
   
+    egammaMonitoring::EfficiencyPlot recoPhotonConvLooseLHEfficiency("recoPhotonConvLooseLHEfficiency", "/MONITORING/recoPhotonConvLooseLHEfficiency/", rootHistSvc );
+    ATH_CHECK(recoPhotonConvLooseLHEfficiency.divide( recoPhotonConvLooseLH.get(), truthPhotonConvRecoConv.get()));
+    egammaMonitoring::EfficiencyPlot recoPhotonConvTightLHEfficiency("recoPhotonConvTightLHEfficiency", "/MONITORING/recoPhotonConvTightLHEfficiency/", rootHistSvc );
+    ATH_CHECK(recoPhotonConvTightLHEfficiency.divide( recoPhotonConvTightLH.get(), truthPhotonConvRecoConv.get()));
+    egammaMonitoring::EfficiencyPlot recoPhotonUnconvLooseLHEfficiency("recoPhotonUnconvLooseLHEfficiency", "/MONITORING/recoPhotonUnconvLooseLHEfficiency/", rootHistSvc );
+    ATH_CHECK(recoPhotonUnconvLooseLHEfficiency.divide( recoPhotonUnconvLooseLH.get(), truthPhotonUnconvRecoUnconv.get()));
+    egammaMonitoring::EfficiencyPlot recoPhotonUnconvTightLHEfficiency("recoPhotonUnconvTightLHEfficiency", "/MONITORING/recoPhotonUnconvTightLHEfficiency/", rootHistSvc );
+    ATH_CHECK(recoPhotonUnconvTightLHEfficiency.divide( recoPhotonUnconvTightLH.get(), truthPhotonUnconvRecoUnconv.get()));
+
+
     egammaMonitoring::WidthPlot truthPhotonRecoPhotonWidth("truthPhotonRecoPhotonWidth", "/MONITORING/truthPhotonRecoPhotonWidth/", rootHistSvc);
     ATH_CHECK(truthPhotonRecoPhotonWidth.fill(truthPhotonRecoPhoton.get()));
     egammaMonitoring::WidthPlot truthPhotonConvPhotonWidth("truthPhotonConvPhotonWidth", "/MONITORING/truthPhotonConvPhotonWidth/", rootHistSvc);
diff --git a/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.h b/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.h
index 16256c4e6bcb..095fb3b1dc32 100644
--- a/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.h
+++ b/Reconstruction/egamma/egammaValidation/src/EgammaMonitoring.h
@@ -31,6 +31,7 @@
 #include "AthenaBaseComps/AthAlgorithm.h"
 #include "AsgTools/AnaToolHandle.h"
 #include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
+#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
 #include "PATCore/AcceptData.h"
 
 
@@ -119,6 +120,10 @@ class EgammaMonitoring : public AthAlgorithm
   std::unique_ptr<egammaMonitoring::IHistograms> truthPhotonUnconvRecoConv2TRT  ;
   std::unique_ptr<egammaMonitoring::IHistograms> truthPhotonUnconvRecoConv2SiTRT;
   std::unique_ptr<egammaMonitoring::IHistograms> truthPhotonUnconvRecoUnconv    ;
+  std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonUnconvLooseLH;
+  std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonUnconvTightLH;
+  std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonConvLooseLH;
+  std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonConvTightLH;
   std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonUnconvIsoFixedCutTight;
   std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonUnconvIsoFixedCutTightCaloOnly;
   std::unique_ptr<egammaMonitoring::IHistograms> recoPhotonUnconvIsoFixedCutLoose;
@@ -173,6 +178,8 @@ private:
   asg::AnaToolHandle<IAsgElectronLikelihoodTool> m_LooseLH ; //!
   asg::AnaToolHandle<IAsgElectronLikelihoodTool> m_MediumLH; //!
   asg::AnaToolHandle<IAsgElectronLikelihoodTool> m_TightLH ; //!
+  asg::AnaToolHandle<IAsgPhotonIsEMSelector> m_LooseLH_Photon; //!
+  asg::AnaToolHandle<IAsgPhotonIsEMSelector> m_TightLH_Photon; //!
   asg::AnaToolHandle<CP::IIsolationSelectionTool> m_IsoFixedCutTight; //!
   asg::AnaToolHandle<CP::IIsolationSelectionTool> m_IsoFixedCutTightTrackOnly; //!
   asg::AnaToolHandle<CP::IIsolationSelectionTool> m_IsoFixedCutTightCaloOnly; //!
-- 
GitLab