diff --git a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/CMakeLists.txt b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/CMakeLists.txt
index 1ff87d1c910f88e2fdbf07f469e6240a6a36c20b..e6ff59386096aa8c55f357d3c638b91397d09a16 100644
--- a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/CMakeLists.txt
+++ b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/CMakeLists.txt
@@ -21,6 +21,7 @@ atlas_depends_on_subdirs(
    PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces
    Trigger/TrigEvent/TrigDecisionInterface
    PhysicsAnalysis/AnalysisCommon/PATInterfaces
+   DataQuality/GoodRunsLists
    PRIVATE
    Event/xAOD/xAODEventInfo
    Tools/PathResolver
@@ -44,7 +45,7 @@ atlas_add_library( PileupReweightingLib
    PUBLIC_HEADERS PileupReweighting
    PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
    LINK_LIBRARIES AsgTools PATInterfaces AsgAnalysisInterfaces
-   TrigDecisionInterface
+   TrigDecisionInterface GoodRunsListsLib
    PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} PathResolver ${extra_libs} )
 
 if( NOT XAOD_STANDALONE )
diff --git a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/TPileupReweighting.cxx b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/TPileupReweighting.cxx
index abc0560a3f76840cbdbcd2c3d57c44d5d42c48ce..a4254a50ccba1460f134cc1fd8a5caf7f90d9e6c 100644
--- a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/TPileupReweighting.cxx
+++ b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/TPileupReweighting.cxx
@@ -1646,6 +1646,13 @@ Double_t CP::TPileupReweighting::GetPrescaleWeight(Int_t runNumber, const TStrin
   if(out<=0) return 0; //happens when triggers disabled/unavailable for a given mu ... therefore the prescale weight is 0
   return 1./out;
 
+
+Double_t CP::TPileupReweighting::GetPrescaleWeight(Int_t runNumber, const TString& trigger) {
+   //special mu-independent version of GetPrescaleWeight. Will just use the global luminosity
+   m_doGlobalDataWeight=true;
+   double out = GetPrescaleWeight(runNumber, trigger, 0);
+   m_doGlobalDataWeight=false;
+   return out;
 }
 
 
diff --git a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/debugExample.C b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/debugExample.C
new file mode 100644
index 0000000000000000000000000000000000000000..d2357d0013874b2477ed2458b13f3a933f615dc6
--- /dev/null
+++ b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/debugExample.C
@@ -0,0 +1,37 @@
+//This is an example ROOT macro for running PRW
+//If you want me to help you debug a problem, please 
+//copy this macro and modify it so that it reproduces your issue
+//please locate all the input files on public (afs) space
+
+//execute with: root debugExample.C
+
+#define GAUDI_V20_COMPAT
+#include "GaudiKernel/ToolHandle.h"
+
+void debugExample() {
+  
+  POOL::TEvent evt(POOL::TEvent::kClassAccess);
+
+  evt.readFrom("$ASG_TEST_FILE_MC"); //replace with your input file
+
+  ToolHandle<CP::IPileupReweightingTool> prw("CP::PileupReweightingTool/tool");
+
+  //update the following two lines to point to your config and lumicalc files
+  //(if they are not in the calib area)
+  AAH::setProperty( prw, "ConfigFiles" , "['dev/PileupReweighting/mc15c_v2_defaults.NotRecommended.prw.root']");
+  AAH::setProperty( prw, "LumiCalcFiles" , "['GoodRunsLists/data15_13TeV/20160720/physics_25ns_20.7.lumicalc.OflLumi-13TeV-005.root','GoodRunsLists/data16_13TeV/20170215/physics_25ns_20.7.lumicalc.OflLumi-13TeV-008.root']");
+
+  prw.retrieve(); //initializes the tool
+
+
+  evt.getEntry(0); //update to go to the problematic event;
+
+  const xAOD::EventInfo_v1* ei = 0;
+  evt.retrieve( ei );
+
+  prw->getCombinedWeight( *ei ); //change this to reproduce your problem
+		   
+  
+
+
+}
diff --git a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/generatePRW_jobOptions.py b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/generatePRW_jobOptions.py
index a2be966d96a1e9ef9d8f9cb83ede3c2bc4c38ae5..0d36542a935fb6c9e3e233ac2f7a3d0e7c1185b1 100644
--- a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/generatePRW_jobOptions.py
+++ b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/share/generatePRW_jobOptions.py
@@ -5,9 +5,7 @@ theApp.EvtMax=-1                                         #says how many events t
 import AthenaRootComps.ReadAthenaxAODHybrid
 svcMgr.EventSelector.AccessMode=1 #use class access mode ... I know it's wrong, but it should be ok just for the EventInfo information
 from glob import glob
-defFile = os.environ.get ('ASG_TEST_FILE_MC',
-                          '/afs/cern.ch/user/a/asgbase/patspace/xAODs/r7725/mc15_13TeV.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.AOD.e3698_s2608_s2183_r7725_r7676/AOD.07915862._000100.pool.root.1')
-svcMgr.EventSelector.InputCollections=glob( vars().get("FILES",defFile).strip() )
+svcMgr.EventSelector.InputCollections=glob( vars().get("FILES",os.environ['ASG_TEST_FILE_MC']).strip() )
 
 if len(svcMgr.EventSelector.InputCollections)==0:
    print("WARNING  >>>>>>>>>>  generatePRW_jobOptions.py:   NO INPUT FILES PROVIDED/FOUND FROM: %s ... this will produce a failure unless you are sending this job to the grid <<<<<<<<<<<<" % vars().get("FILES","/afs/cern.ch/atlas/project/PAT/xAODs/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5591/AOD.01494882._111853.pool.root.1").strip())
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt
index 683b8814079bf713522c0adb4bf96944bbe9ea3b..d4d91d67803920e2b45f8e0df6259854d87a48b3 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt
@@ -11,8 +11,7 @@ atlas_depends_on_subdirs( PUBLIC
                           Control/AthenaBaseComps
                           PhysicsAnalysis/AnalysisCommon/PATCore
                           PhysicsAnalysis/DerivationFramework/DerivationFrameworkInterfaces
-                          PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools
-                          PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool
+                          PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces
                           PRIVATE
                           Event/xAOD/xAODBase
                           Event/xAOD/xAODCaloEvent
@@ -32,13 +31,14 @@ atlas_add_library( DerivationFrameworkEGammaLib
                    src/*.cxx
                    PUBLIC_HEADERS DerivationFrameworkEGamma
                    PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                   LINK_LIBRARIES AsgTools AthenaBaseComps PATCoreLib ElectronPhotonSelectorToolsLib ElectronPhotonShowerShapeFudgeToolLib ExpressionEvaluationLib MCTruthClassifierLib
-                   PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} xAODBase xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth GaudiKernel )
+                   LINK_LIBRARIES AsgTools AthenaBaseComps PATCoreLib EgammaAnalysisInterfacesLib ExpressionEvaluationLib MCTruthClassifierLib CaloCalibHitRecLib
+                   PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} xAODBase xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth )
 
 atlas_add_component( DerivationFrameworkEGamma
                      src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools AthenaBaseComps PATCoreLib ElectronPhotonSelectorToolsLib ElectronPhotonShowerShapeFudgeToolLib xAODBase xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth GaudiKernel ExpressionEvaluationLib MCTruthClassifierLib DerivationFrameworkEGammaLib )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES}  AsgTools AthenaBaseComps PATCoreLib  EgammaAnalysisInterfacesLib xAODBase 
+		     xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth GaudiKernel ExpressionEvaluationLib MCTruthClassifierLib CaloCalibHitRecLib DerivationFrameworkEGammaLib )
 
 # Install files from the package:
 atlas_install_python_modules( python/*.py )
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h
index 7a977df7beac677ce5cce5c42996092a3a5ae72b..51dc98099843f3e15ca95df5038adcfc76f6cea7 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h
@@ -13,10 +13,8 @@
 
 #include "AthenaBaseComps/AthAlgTool.h"
 #include "DerivationFrameworkInterfaces/IAugmentationTool.h"
-#include "ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h"
-//#include "ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h"
-//#include "ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h"
-#include "ElectronPhotonShowerShapeFudgeTool/IElectronPhotonShowerShapeFudgeTool.h"
+#include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h"
 #include "PATCore/IAsgSelectionTool.h"
 #include "AsgTools/IAsgTool.h"
 #include "GaudiKernel/ToolHandle.h"
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py
index d94fb9e2f7fad401cab252950b6acab176113417..d8c24f416f9c114992d83944796603490e7e7b87 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py
@@ -2,7 +2,7 @@
 
 ElectronsCPContent = [
 "Electrons",
-"ElectronsAux.trackParticleLinks.pt.eta.phi.m.truthParticleLink.truthOrigin.truthType.caloClusterLinks.author.OQ.ethad1.ethad.f1.f3.f3core.e233.e237.e277.weta1.weta2.e2tsts1.fracs1.wtots1.emins1.emaxs1.etcone20.ptcone30.deltaEta1.deltaPhi1.deltaPhi2.deltaPhiRescaled2.deltaPhiFromLastMeasurement.Loose.Medium.Tight.DFCommonElectronsLHLoose.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsML.ptcone20.ptcone30.ptcone40.ptvarcone20.ptvarcone30.ptvarcone40.topoetcone20.topoetcone30.topoetcone40.charge.Reta.Rphi.Eratio.Rhad.Rhad1.DeltaE.DFCommonElectronsIsEMLoose.DFCommonElectronsIsEMMedium.DFCommonElectronsIsEMTight.topoetcone20ptCorrection.topoetcone30ptCorrection.topoetcone40ptCorrection.etcone20ptCorrection.etcone30ptCorrection.etcone40ptCorrection.LHLoose",
+"ElectronsAux.trackParticleLinks.pt.eta.phi.m.caloClusterLinks.author.OQ.ethad1.ethad.f1.f3.f3core.e233.e237.e277.weta1.weta2.e2tsts1.fracs1.wtots1.emins1.emaxs1.etcone20.ptcone30.deltaEta1.deltaPhi1.deltaPhi2.deltaPhiRescaled2.deltaPhiFromLastMeasurement.Loose.Medium.Tight.LHLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsML.ptcone20.ptcone30.ptcone40.ptvarcone20.ptvarcone30.ptvarcone40.topoetcone20.topoetcone30.topoetcone40.charge.Reta.Rphi.Eratio.Rhad.Rhad1.DeltaE.DFCommonElectronsIsEMLoose.DFCommonElectronsIsEMMedium.DFCommonElectronsIsEMTight.topoetcone20ptCorrection.topoetcone30ptCorrection.topoetcone40ptCorrection.etcone20ptCorrection.etcone30ptCorrection.etcone40ptCorrection.ambiguityLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.lastEgMotherTruthType.lastEgMotherTruthOrigin.lastEgMotherTruthParticleLink.lastEgMotherPdgId.ambiguityType",
 "GSFTrackParticles",
 "GSFTrackParticlesAux.chiSquared.phi.d0.theta.qOverP.definingParametersCovMatrix.parameterX.parameterPX.parameterPY.parameterPZ.parameterPosition.numberOfBLayerHits.numberOfBLayerOutliers.expectBLayerHit.numberOfPixelHits.numberOfPixelOutliers.numberOfPixelDeadSensors.numberOfSCTHits.numberOfSCTOutliers.numberOfSCTDeadSensors.numberOfTRTHits.numberOfTRTOutliers.numberOfTRTHighThresholdHits.numberOfTRTHighThresholdOutliers.numberOfTRTXenonHits.z0.vz.charge.vertexLink.numberOfInnermostPixelLayerHits.numberOfInnermostPixelLayerOutliers.numberOfNextToInnermostPixelLayerOutliers.expectInnermostPixelLayerHit.eProbabilityComb.truthParticleLink.originalTrackParticle.eProbabilityHT.numberOfNextToInnermostPixelLayerHits.expectNextToInnermostPixelLayerHit",
 "GSFConversionVertices",
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx
index d8f4c0dbeb5a455011a94023f7f532318017bd37..60c0f4b7040606d309446a1586302c41085d82bd 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx
@@ -91,13 +91,13 @@ namespace DerivationFramework {
 	// apply the shower shape corrections
 	CP::CorrectionCode correctionCode = CP::CorrectionCode::Ok;
 	if (type==xAOD::Type::Electron) {
-	    const xAOD::Electron* eg = dynamic_cast<const xAOD::Electron*>(*pItr);
+	    const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(*pItr);
 	    xAOD::Electron* el = 0;
 	    correctionCode = m_fudgeMCTool->correctedCopy(*eg, el);
 	    pCopy = el;
 	}
 	else {
-	    const xAOD::Photon* eg = dynamic_cast<const xAOD::Photon*>(*pItr);
+	    const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(*pItr);
 	    xAOD::Photon* ph = 0;
 	    correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph);
 	    pCopy = ph;
diff --git a/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..d09e31f90dcac9fd0964eb1df8e46ef64877bc09
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/CMakeLists.txt
@@ -0,0 +1,33 @@
+################################################################################
+# Package: EgammaAnalysisHelpers
+################################################################################
+
+# Declare the package name:
+atlas_subdir(EgammaAnalysisHelpers )
+
+# Declare the package's dependencies:
+atlas_depends_on_subdirs(
+  PUBLIC
+  Event/xAOD/xAODEgamma
+  PRIVATE
+  Control/AthToolSupport/AsgTools
+  Event/xAOD/xAODCaloEvent
+  ${extra_dep} )
+
+# External dependencies:
+find_package( ROOT COMPONENTS Core MathCore Hist MathMore )
+
+# Component(s) in the package:
+atlas_add_library( EgammaAnalysisHelpersLib
+  EgammaAnalysisHelpers/*.h Root/*.cxx
+  PUBLIC_HEADERS EgammaAnalysisHelpers
+  PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+  LINK_LIBRARIES xAODEgamma 
+  PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODCaloEvent)
+
+atlas_add_dictionary( EgammaAnalysisHelpersDict
+  EgammaAnalysisHelpers/EgammaAnalysisHelpersDict.h
+  EgammaAnalysisHelpers/selection.xml
+  LINK_LIBRARIES EgammaAnalysisHelpersLib )
+
+
diff --git a/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/EgammaAnalysisHelpersDict.h b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/EgammaAnalysisHelpersDict.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf7eaf83d4996fbcf63dd044e4023d816e659044
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/EgammaAnalysisHelpersDict.h
@@ -0,0 +1,10 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef __EGAMMAANALYSISHELPERSDICT__
+#define __EGAMMAANALYSISHELPERSDICT__
+
+#include "EgammaAnalysisHelpers/PhotonHelpers.h"
+
+#endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/PhotonHelpers.h b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/PhotonHelpers.h
new file mode 100644
index 0000000000000000000000000000000000000000..3b05feaa04a4906fd43847e36ee59f7a94e9b3c2
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/PhotonHelpers.h
@@ -0,0 +1,21 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// Dear emacs, this is -*-c++-*-
+
+#ifndef __PHOTONHELPERS__
+#define __PHOTONHELPERS__
+
+// Atlas includes
+#include "xAODEgamma/PhotonFwd.h"
+#include <cstddef>
+
+namespace PhotonHelpers{
+  ///@brief Helper to ease the implemmantation of the pass Quality requirements
+  bool passOQquality(const xAOD::Photon *ph);
+  ///@brief Helpers to ease the implementation of the pass Quality requirements
+  bool passOQqualityDelayed(const xAOD::Photon *ph);
+}
+
+#endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/selection.xml b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/selection.xml
new file mode 100644
index 0000000000000000000000000000000000000000..979ffbfb2b66cd9de846cd042cb761a0f8db3e09
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/EgammaAnalysisHelpers/selection.xml
@@ -0,0 +1,4 @@
+<lcgdict>
+<!--Add Helper Functions -->
+<function pattern="PhotonHelpers::*"/>
+</lcgdict>
diff --git a/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/Root/PhotonHelpers.cxx b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/Root/PhotonHelpers.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..b2dc23c91721b918fd9ff42a407638946aee4b9e
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers/Root/PhotonHelpers.cxx
@@ -0,0 +1,47 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "EgammaAnalysisHelpers/PhotonHelpers.h"
+#include "xAODEgamma/Photon.h"
+#include "xAODCaloEvent/CaloCluster.h"
+#include "xAODEgamma/EgammaxAODHelpers.h"
+#include "AsgTools/AsgMessaging.h"
+
+// ==================================================================
+bool PhotonHelpers::passOQquality(const xAOD::Photon *ph){
+
+  static const asg::AsgMessaging msg("PhotonHelpers");
+  if(!ph){
+    msg.msg(MSG::WARNING) << "No photon found!" << endmsg;
+    return 0;
+  }
+  
+  if( !( ( ph->OQ() & 1073741824 )!=0 ||
+	 ( ( ph->OQ() & 134217728 )!=0 &&
+	   ( ph->showerShapeValue(xAOD::EgammaParameters::Reta) > 0.98
+	    || ph->showerShapeValue(xAOD::EgammaParameters::f1) > 0.4
+	    || (ph->OQ() & 67108864) !=0)
+	   ) ) ){
+    return true;
+  } 
+  return false;
+}
+// ==================================================================
+bool PhotonHelpers::passOQqualityDelayed(const xAOD::Photon *ph){
+
+  static const asg::AsgMessaging msg("PhotonHelpers");
+  if(!ph){
+    msg.msg(MSG::WARNING) << "No photon found!" << endmsg;
+    return 0;
+  }
+  
+  if( !( ( ph->OQ() & 1073741824)!=0 ||
+	 ( ( ph->OQ() & 134217728)!=0 &&
+	   ( ph->showerShapeValue(xAOD::EgammaParameters::Reta) > 0.98
+	     || ph->showerShapeValue(xAOD::EgammaParameters::f1) > 0.4
+	     ) ) ) ) {
+    return true;
+  }
+  return false;
+}
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/CMakeLists.txt
index d8e77b2d8f18fbcfd80e1bef0f3b3b6bea6f848b..3de07c50ea664a0ae0d2d2c98074c38d2123080a 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/CMakeLists.txt
@@ -23,6 +23,7 @@ atlas_depends_on_subdirs(
    PhysicsAnalysis/AnalysisCommon/PATCore
    PhysicsAnalysis/AnalysisCommon/PATInterfaces
    PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces
+   PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces	
    PRIVATE
    Control/AthAnalysisBaseComps
    Tools/PathResolver
@@ -45,7 +46,7 @@ atlas_add_library( ElectronEfficiencyCorrectionLib
    PUBLIC_HEADERS ElectronEfficiencyCorrection
    INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
    LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthContainers AsgTools
-   xAODEgamma PATInterfaces PATCoreLib AsgAnalysisInterfaces
+   xAODEgamma PATInterfaces PATCoreLib AsgAnalysisInterfaces EgammaAnalysisInterfacesLib
    PRIVATE_LINK_LIBRARIES xAODCaloEvent xAODCore xAODEventInfo xAODTracking
    xAODMetaData PathResolver )
 
@@ -95,7 +96,6 @@ if( XAOD_STANDALONE )
       LINK_LIBRARIES ${ROOT_LIBRARIES} xAODRootAccess xAODEventInfo xAODEgamma
       xAODCore ElectronPhotonSelectorToolsLib ElectronEfficiencyCorrectionLib )
 
-
 endif()
 
 # Install files from the package:
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
index 262346abf40341fb684d5b5442371f698a427560..f1894cafa48fb5de0a322bc971c156ad07d583ff 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h
@@ -28,12 +28,12 @@
 //xAOD includes
 #include "AsgTools/AsgTool.h"
 #include "AsgTools/AsgMetadataTool.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
 
 #include "PATInterfaces/ISystematicsTool.h"
 #include "PATInterfaces/SystematicRegistry.h"
 #include "PATInterfaces/CorrectionCode.h"
 #include "ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h"
-#include "ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h"
 #include "xAODEgamma/ElectronFwd.h"
 
 class AsgElectronEfficiencyCorrectionTool
@@ -100,6 +100,8 @@ public:
 
   CP::SystematicCode registerSystematics();
 
+  int systUncorrVariationIndex( const xAOD::Electron &inputObject) const;
+
   // Private member variables
 private:
   // To check if the metadat can be retrieved 
@@ -108,9 +110,12 @@ private:
   // Get the simulation type from metadata
   StatusCode get_simType_from_metadata(PATCore::ParticleDataType::DataType& result) const;
 
+  int currentSimplifiedUncorrSystRegion(const double cluster_eta, const double et) const ;
+  int currentUncorrSystRegion(const double cluster_eta, const double et) const ;
+
 
   /// The main calculate method: the actual correction factors are determined here
-  const Root::TResult& calculate( const xAOD::Electron& egam, const unsigned int runnumber, int &currentElectronSimplifiedUncorrSystRegion, int& currentElectronUncorrSystRegion ) const ;
+  const Root::TResult& calculate( const double cluster_eta, const double et, const unsigned int runnumber ) const ;
   CP::SystematicCode InitSystematics();
 
   // struct for toys
@@ -213,6 +218,8 @@ private:
   TH2F * m_UncorrRegions;
   int m_nSimpleUncorrSyst;
 
+
+
 }; // End: class definition
 
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h
index a2f6c5edd2a8ca7007b5232d4411dddf6e2c19d8..23c97e45c8e8d9488dcea6ebcd6dafe426682353 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h
@@ -153,7 +153,7 @@ namespace CP {
     CP::SystematicSet m_affectingSys;
 
     /// Currently applied systematics
-   CP::SystematicSet* m_appliedSystematics;
+    CP::SystematicSet* m_appliedSystematics;
  
     /// Decorator
     std::string m_sf_decoration_name;
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronEfficiencyCorrectionDict.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronEfficiencyCorrectionDict.h
index 09c777eef0723a20a5f8acc4c1633f2c9f60d98b..e04e4a69af7dfcd2f5cda6ea5512cafec9002ebe 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronEfficiencyCorrectionDict.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/ElectronEfficiencyCorrectionDict.h
@@ -7,6 +7,5 @@
 #ifndef __ELECTRONEFFICIENCYCORRECTIONDICT__
 #define __ELECTRONEFFICIENCYCORRECTIONDICT__
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
-#include "ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h"
 #include "ElectronEfficiencyCorrection/ElectronChargeEfficiencyCorrectionTool.h"
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h
index 4e2a255dd07c667bf35a79e43c208ddd41b04b3a..ea8aeb75e81543ebe1d7c4f5a3a8da1861687e7b 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h
@@ -6,32 +6,7 @@
 #ifndef __IASGELECTRONEFFICIENCYCORRECTION__
 #define __IASGELECTRONEFFICIENCYCORRECTION__
 
-#include "AsgTools/IAsgTool.h"
-#include "xAODEgamma/ElectronFwd.h"
-#include "PATInterfaces/CorrectionCode.h"
-#include "PATInterfaces/ISystematicsTool.h"
-namespace xAOD{
-  class IParticle;
-}
-
-
-class IAsgElectronEfficiencyCorrectionTool : virtual public CP::ISystematicsTool
-{
-  ASG_TOOL_INTERFACE(IAsgElectronEfficiencyCorrectionTool)
-
-  public:
-  ///The interface for Scale Factors
-  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Electron& inputObject, double& efficiencyScaleFactor) const = 0;
-  virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::Electron& inputObject) const = 0;
-  virtual ~IAsgElectronEfficiencyCorrectionTool() {}
-
-};
-
-
-
-
-
-
-
+#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h
index a67dce1cf35074ec5e06616700452c6159c2db19..6385e65d44623c37208891a8d6b8474a23a5a4b9 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h
@@ -86,15 +86,15 @@ namespace Root {
       }
   
       /// helper functions to retrieve the position of the first/last toy MC scale factors and correlated systematics in the result
-      int getFirstToyMCPosition();
-      int getLastToyMCPosition();
-      int getFirstCorrSysPosition();
-      int getLastCorrSysPosition();
-      int getGlobalBinNumberPosition();
-      int getNbins(std::map<float, std::vector<float> >&); 
-      int getNSyst() {return m_nSysMax;};
+      int getFirstToyMCPosition() const ;
+      int getLastToyMCPosition() const ;
+      int getFirstCorrSysPosition() const ;
+      int getLastCorrSysPosition() const ;
+      int getGlobalBinNumberPosition() const ;
+      int getNbins(std::map<float, std::vector<float> >&) const; 
+      int getNSyst() const {return m_nSysMax;}  ;
 
-      void printResultMap();
+      void printResultMap() const;
 
       enum detailLevel{simple,medium,detailed};
 
@@ -108,11 +108,11 @@ namespace Root {
 
       // Private methods
     private:
+
       /// Load all histograms from the input file(s)
       int getHistograms();
       int getHistogramInDirectory( TKey *key );
       int setupHistogramsInFolder( const TObjArray& dirNameArray, int lastIdx );
-
       void calcDetailLevels(TH1D *eig) ;
 
       std::vector<TObjArray> buildToyMCTable (const TObjArray &sf, const TObjArray &eig, 
@@ -131,17 +131,20 @@ namespace Root {
       int setupSys( std::vector<TObjArray> & hist,
 		    std::vector< std::vector< TObjArray>> & histList);
 
-      void printDefaultReturnMessage(TString reason, int line);
+      void printDefaultReturnMessage(const TString& reason, int line) const;
 
       TRandom3 m_Rndm;
       int m_randomCounter;
+      ///
       bool m_isInitialized;
       /// The detail level
       int m_detailLevel;
+      ///
       int m_toyMCSF;
       //
       /// The seed
       int m_seed;
+      ///
       bool m_doToyMC;
       bool m_doCombToyMC;
       int m_nToyMC;
@@ -175,13 +178,13 @@ namespace Root {
       /// total number of bins in the efficiency tables
       int m_nbins; 
 
+      /// Number of uncorelated systematucs
       int m_nSimpleUncorrSyst;
 
       /// The position of the efficiency scale factor uncorrelated systematic uncertainty in the result
       int m_position_globalBinNumber; 
 
-
-      //description here ?
+      ///Uncorrelated toy systematics
       std::vector< std::vector<TObjArray>> m_uncorrToyMCSystFull;
       std::vector< std::vector<TObjArray>> m_uncorrToyMCSystFast;
       /// The list of file name(s)
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/selection.xml b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/selection.xml
index adac54aace8765f4e307c89b028e7242f720ddf9..42ea137ec7cbce54e7094956c02ece2869683584 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/selection.xml
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/ElectronEfficiencyCorrection/selection.xml
@@ -1,5 +1,4 @@
 <lcgdict>
     <class name="AsgElectronEfficiencyCorrectionTool" /> 
-    <class name="IAsgElectronEfficiencyCorrectionTool" /> 
     <class name="CP::ElectronChargeEfficiencyCorrectionTool" /> 
 </lcgdict>
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx
index a426dc0d489565e29428ccec8426b9dbad15a196..be21204eddfa44d00632d084646af235331bfe60 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/AsgElectronEfficiencyCorrectionTool.cxx
@@ -5,16 +5,12 @@
 /**
    @class AthElectronEfficiencyCorrectionTool
    @brief Calculate the egamma scale factors in Athena
-
-   @author Rob Roy Fletcher <rob.fletcher@cern.ch>, Karsten Koeneke
-   @date   May 2014
 */
 
 // Include this class's header
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
 #include "PathResolver/PathResolver.h"
 
-
 // STL includes
 #include <string>
 #include <cfloat>
@@ -32,10 +28,13 @@
 // xAOD includes
 #include "xAODEgamma/Electron.h"
 #include "xAODEventInfo/EventInfo.h"
-#ifndef ROOTCORE
+
 #include <boost/algorithm/string.hpp>
+
+#ifndef ROOTCORE
 #include "AthAnalysisBaseComps/AthAnalysisHelper.h"
 #endif
+
 #include "xAODMetaData/FileMetaData.h"
 #include "PathResolver/PathResolver.h"
 #include "ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h"
@@ -46,11 +45,11 @@
 
 namespace correlationModel{
   enum model { COMBMCTOYS =0,
-         MCTOYS=1,
-         FULL=2,
-         SIMPLIFIED=3,
-         TOTAL=4,
-         SYST=5
+	       MCTOYS=1,
+	       FULL=2,
+	       SIMPLIFIED=3,
+	       TOTAL=4,
+	       SYST=5
   };
 }
 
@@ -86,7 +85,7 @@ AsgElectronEfficiencyCorrectionTool::AsgElectronEfficiencyCorrectionTool(std::st
                   "Key associated with trigger working point");
 
   declareProperty("ForceDataType", m_dataTypeOverwrite = -1,
-                  "Force the DataType of the electron to specified value (to circumvent problem of incorrect DataType for forward electrons in some old releases)");
+		  "Force the DataType of the electron to specified value (to circumvent problem of incorrect DataType for forward electrons in some old releases)");
 
   declareProperty("ResultPrefix", m_resultPrefix = "", "The prefix string for the result");
   declareProperty("ResultName", m_resultName = "", "The string for the result");
@@ -134,7 +133,7 @@ AsgElectronEfficiencyCorrectionTool::initialize() {
   // and if overwrite is not set we will set the m_dataType based on metadata
   if (m_dataTypeOverwrite != -1) {
     if (m_dataTypeOverwrite != static_cast<int> (PATCore::ParticleDataType::Full)
-        && m_dataTypeOverwrite != static_cast<int> (PATCore::ParticleDataType::Fast)) {
+	&& m_dataTypeOverwrite != static_cast<int> (PATCore::ParticleDataType::Fast)) {
       ATH_MSG_ERROR("Unsupported Particle Data Type Overwrite" << m_dataTypeOverwrite);
       return StatusCode::FAILURE;
     }
@@ -277,12 +276,12 @@ AsgElectronEfficiencyCorrectionTool::initialize() {
   //
   //Initialize the systematics
   if (InitSystematics() != CP::SystematicCode::Ok) {
-      ATH_MSG_ERROR("(InitSystematics() != CP::SystematicCode::Ok)");
+    ATH_MSG_ERROR("(InitSystematics() != CP::SystematicCode::Ok)");
     return StatusCode::FAILURE;
   }
   // Add the recommended systematics to the registry
   if (registerSystematics() != CP::SystematicCode::Ok) {
-      ATH_MSG_ERROR("(registerSystematics() != CP::SystematicCode::Ok)");
+    ATH_MSG_ERROR("(registerSystematics() != CP::SystematicCode::Ok)");
     return StatusCode::FAILURE;
   }
   // Configure for nominal systematics
@@ -307,10 +306,7 @@ AsgElectronEfficiencyCorrectionTool::finalize() {
 
 CP::CorrectionCode
 AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(const xAOD::Electron &inputObject,
-                                                              double &efficiencyScaleFactor) const {
-
-  int currentUncorrSystRegion = 0;
-  int currentSimplifiedUncorrSystRegion = 0;
+							      double &efficiencyScaleFactor) const {
 
   //Retrieve the proper random Run Number
   unsigned int runnumber = m_defaultRandomRunNumber;
@@ -331,9 +327,18 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(const xAOD::Electr
     runnumber = randomrunnumber(*(eventInfo));
   }
   //
-  //Get the result
-  const Root::TResult& result = calculate(inputObject, runnumber, currentSimplifiedUncorrSystRegion,
-           currentUncorrSystRegion);
+  //Get the result 
+  double cluster_eta(-9999.9);
+  double et(0.0);
+
+
+  et = inputObject.pt();
+  const xAOD::CaloCluster *cluster = inputObject.caloCluster();
+  if (cluster) {
+    cluster_eta = cluster->etaBE(2);
+  }
+
+  const Root::TResult& result = calculate(cluster_eta,et, runnumber);
   efficiencyScaleFactor = result.getScaleFactor();
   //
   // The default of the underlying tool is -999 , if we are in a valid range
@@ -394,17 +399,30 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(const xAOD::Electr
     }
   }
   //If there are not correlated systematic
-  else if (m_nCorrSyst == 0) {
+  if (m_nCorrSyst == 0) {
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + "CorrUncertainty",1))) {
-      
+
       sys = sqrt(result.getTotalUncertainty() * result.getTotalUncertainty()
-       - result.getResult(4) * result.getResult(4)); // total -stat
+		 - result.getResult(4) * result.getResult(4)); // total -stat
       func(efficiencyScaleFactor, sys);
     }
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + "CorrUncertainty" ,-1))) {
 
       sys = -1* sqrt(result.getTotalUncertainty() * result.getTotalUncertainty()
-         - result.getResult(4) * result.getResult(4)); // total -stat
+		     - result.getResult(4) * result.getResult(4)); // total -stat
+      func(efficiencyScaleFactor, sys);
+    }
+  }else if (m_correlation_model == correlationModel::TOTAL) { // one "TOTAL" uncertainty
+    if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
+                                                                     m_correlation_model_name + "_" +
+                                                                     "1NPCOR_PLUS_UNCOR" ,1))) {
+      sys = result.getTotalUncertainty();
+      func(efficiencyScaleFactor, sys);
+    }
+    if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
+                                                                     m_correlation_model_name + "_" +
+                                                                     "1NPCOR_PLUS_UNCOR" ,-1))) {
+      sys =  -1*result.getTotalUncertainty();
       func(efficiencyScaleFactor, sys);
     }
   }
@@ -413,34 +431,40 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(const xAOD::Electr
   // =======================================================================
   // Then the uncorrelated, we just need to see if the applied matches the current electron pt and eta
   if (m_correlation_model == correlationModel::FULL) {// The Full Model
+
+    int currentUncorrSystReg = currentUncorrSystRegion( cluster_eta, et);
+
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
-                                                                     m_correlation_model_name + "_" +
-                                                                     Form("UncorrUncertaintyNP%d",
-                                                                          currentUncorrSystRegion),1))) {
+								     m_correlation_model_name + "_" +
+								     Form("UncorrUncertaintyNP%d",
+									  currentUncorrSystReg),1))) {
       sys = result.getResult(4);//
       func(efficiencyScaleFactor, sys);
     }
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
-                                                                     m_correlation_model_name + "_" +
-                                                                     Form("UncorrUncertaintyNP%d",
-                                                                          currentUncorrSystRegion),-1))) {
+								     m_correlation_model_name + "_" +
+								     Form("UncorrUncertaintyNP%d",
+									  currentUncorrSystReg),-1))) {
       sys = -1*result.getResult(4);//
       func(efficiencyScaleFactor, sys);
     }
   }
   else if (m_correlation_model == correlationModel::SIMPLIFIED) {
+
+    int currentSimplifiedUncorrSystReg = currentSimplifiedUncorrSystRegion( cluster_eta, et);
+
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
-                                                                     m_correlation_model_name + "_" +
-                                                                     Form("UncorrUncertaintyNP%d",
-                                                                          currentSimplifiedUncorrSystRegion),1))) {
+								     m_correlation_model_name + "_" +
+								     Form("UncorrUncertaintyNP%d",
+									  currentSimplifiedUncorrSystReg),1))) {
       sys = result.getResult(4);//
       func(efficiencyScaleFactor, sys);
     }
 
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
-                                                                     m_correlation_model_name + "_" +
-                                                                     Form("UncorrUncertaintyNP%d",
-                                                                          currentSimplifiedUncorrSystRegion),-1))) {
+								     m_correlation_model_name + "_" +
+								     Form("UncorrUncertaintyNP%d",
+									  currentSimplifiedUncorrSystReg),-1))) {
       sys = -1*result.getResult(4);//
       func(efficiencyScaleFactor, sys);
     }
@@ -449,12 +473,12 @@ AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(const xAOD::Electr
   //If it has not returned so far , it means we wants to do the correlated for the full models
   for (int i = 0; i < m_nCorrSyst; ++i) {/// number of correlated sources
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
-                     Form("CorrUncertaintyNP%d", i),1))) {
+								     Form("CorrUncertaintyNP%d", i),1))) {
       sys = result.getResult(5 + i);
       func(efficiencyScaleFactor, sys);
     }
     if (appliedSystematics().matchSystematic(CP::SystematicVariation("EL_EFF_" + m_sysSubstring +
-                     Form("CorrUncertaintyNP%d", i),-1))) {
+								     Form("CorrUncertaintyNP%d", i),-1))) {
       sys = -1* result.getResult(5 + i);
       func(efficiencyScaleFactor, sys);
     }
@@ -546,7 +570,7 @@ AsgElectronEfficiencyCorrectionTool::applySystematicVariation(const CP::Systemat
     if (filteredSys.size() == 0 && systConfig.size() > 0) {
       ATH_MSG_DEBUG("systematics : ");
       for (auto &syst : systConfig) {
-        ATH_MSG_DEBUG(syst.name());
+	ATH_MSG_DEBUG(syst.name());
       }
       ATH_MSG_DEBUG(" Not supported ");
     }
@@ -565,75 +589,14 @@ AsgElectronEfficiencyCorrectionTool::applySystematicVariation(const CP::Systemat
 // The main Result  method:
 // TRANSFER RESULT OF UNDERLYING TOOL TO xAOD TOOL
 // =============================================================================
-const Root::TResult& AsgElectronEfficiencyCorrectionTool::calculate(const xAOD::Electron &egam, const unsigned int runnumber,
-                   int &currentSimplifiedUncorrSystRegion, int &currentUncorrSystRegion
-                   ) const {
-  double cluster_eta(-9999.9);
-  double et(0.0);
-
-  et = egam.pt();
-  const xAOD::CaloCluster *cluster = egam.caloCluster();
-  if (cluster) {
-    cluster_eta = cluster->etaBE(2);
-  }
-
-  //  std::cout<< cluster_eta << std::endl;
-  /* For now the dataType must be set by the user. May be added to the IParticle class later.  */
-  if (m_correlation_model == correlationModel::SIMPLIFIED) {
-    int ptbin = m_UncorrRegions->GetXaxis()->FindBin(et) - 1;
-    int etabin = m_UncorrRegions->GetYaxis()->FindBin(fabs(cluster_eta)) - 1;
-    int reg = ((etabin) * m_UncorrRegions->GetNbinsX() + ptbin);
-    currentSimplifiedUncorrSystRegion = reg;
-  }
-
-  if (m_correlation_model == correlationModel::FULL) {
-    int etabin = -1;
-    int reg = 0;
-    bool found = false;
-    float cluster_eta_electron = 0;
-    std::map<float, std::vector<float> >::const_iterator itr_ptBEGIN = m_pteta_bins.begin();
-    std::map<float, std::vector<float> >::const_iterator itr_ptEND = m_pteta_bins.end();
-
-    // Consider using std::map::lower_bound, returns the iterator to the first element that is greater-or-equal to a pt
-    for (; itr_ptBEGIN != itr_ptEND; itr_ptBEGIN++) {
-      std::map<float, std::vector<float> >::const_iterator itr_ptBEGINplusOne = itr_ptBEGIN;
-      itr_ptBEGINplusOne++;
-
-      if ((et > itr_ptBEGIN->first && itr_ptBEGINplusOne == itr_ptEND) ||
-          (et > itr_ptBEGIN->first && et <= itr_ptBEGINplusOne->first)) {// find the pt bin
-        etabin=0;
-        // if it is ordered in eta from smaller to larger ascending order
-        // consider using std::lower_bound(begin,end) to find the position?
-        if ((itr_ptBEGIN->second).at(0) >= 0) {
-          cluster_eta_electron = fabs(cluster_eta);
-        }else {
-          cluster_eta_electron = (cluster_eta);
-        };
-
-        for (unsigned int etab = 0; etab < ((itr_ptBEGIN->second).size() - 1); ++etab) {// find the eta bin
-	etabin++;	
-          if ((cluster_eta_electron) > (itr_ptBEGIN->second).at(etab) &&
-              (cluster_eta_electron) <= (itr_ptBEGIN->second).at(etab + 1)) {
-            found = true;
-            break;
-          } // if ( (cluster_eta_electron)
-        } // for (unsigned int etab=0;etab<((itr_ptBEGIN->second).size()-1) ; ++etab)
-      }
-      if (found) {
-        break;
-      }
-      reg = reg + (itr_ptBEGIN->second).size();
-    }
-    reg = reg + etabin;
-    currentUncorrSystRegion = reg;
-  }
+const Root::TResult& AsgElectronEfficiencyCorrectionTool::calculate(const double cluster_eta, const double et, const unsigned int runnumber) const {
 
   // Call the ROOT tool to get an answer
   return m_rootTool->calculate(m_dataType,
-                               runnumber,
-                               cluster_eta,
-                               et /* in MeV */
-                               );
+			       runnumber,
+			       cluster_eta,
+			       et /* in MeV */
+			       );
 }
 /// returns: initialized the list for a specific model
 
@@ -646,6 +609,10 @@ AsgElectronEfficiencyCorrectionTool::InitSystematics() {
   }else if (m_correlation_model == correlationModel::MCTOYS) {
     m_affectedSys.insert((CP::SystematicVariation::makeToyEnsemble("EL_EFF_" + m_sysSubstring + "MCTOY")));
 
+  }else if (m_nCorrSyst == 0) {
+    m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + "CorrUncertainty", 1));
+    m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + "CorrUncertainty", -1));
+
   }else if (m_correlation_model != correlationModel::TOTAL) {
     if ( m_nCorrSyst == 0 ) {
       m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + "CorrUncertainty", 1));
@@ -658,22 +625,22 @@ AsgElectronEfficiencyCorrectionTool::InitSystematics() {
   // Different tratement for the uncorrelated
   if (m_correlation_model == correlationModel::TOTAL) {
     m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + m_correlation_model_name + "_" +
-                                                 "1NPCOR_PLUS_UNCOR", 1));
+						 "1NPCOR_PLUS_UNCOR", 1));
     m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + m_correlation_model_name + "_" +
                                                  "1NPCOR_PLUS_UNCOR", -1));
   }else if (m_correlation_model == correlationModel::FULL) {
     for (int i = 0; i < m_nUncorrSyst; ++i) {
       m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + m_correlation_model_name + "_" +
-                                                   Form("UncorrUncertaintyNP%d", i), 1));
+						   Form("UncorrUncertaintyNP%d", i), 1));
       m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + m_correlation_model_name + "_" +
-                                                   Form("UncorrUncertaintyNP%d", i), -1));
+						   Form("UncorrUncertaintyNP%d", i), -1));
     }
   }else if (m_correlation_model == correlationModel::SIMPLIFIED) {
     for (int i = 0; i < m_nSimpleUncorrSyst; ++i) {
       m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + m_correlation_model_name + "_" +
-                                                   Form("UncorrUncertaintyNP%d", i), 1));
+						   Form("UncorrUncertaintyNP%d", i), 1));
       m_affectedSys.insert(CP::SystematicVariation("EL_EFF_" + m_sysSubstring + m_correlation_model_name + "_" +
-                                                   Form("UncorrUncertaintyNP%d", i), -1));
+						   Form("UncorrUncertaintyNP%d", i), -1));
     }
   }
   return CP::SystematicCode::Ok;
@@ -684,30 +651,30 @@ AsgElectronEfficiencyCorrectionTool::InitSystematics() {
 //===============================================================================
 StatusCode AsgElectronEfficiencyCorrectionTool::beginInputFile(){
 
- // User preference of dataType, already done in initialize
+  // User preference of dataType, already done in initialize
   if (m_dataTypeOverwrite != -1) return StatusCode::SUCCESS;
 
- PATCore::ParticleDataType::DataType dataType_metadata;
- const StatusCode status = get_simType_from_metadata(dataType_metadata);
+  PATCore::ParticleDataType::DataType dataType_metadata;
+  const StatusCode status = get_simType_from_metadata(dataType_metadata);
 
- if (status == StatusCode::SUCCESS) {
+  if (status == StatusCode::SUCCESS) {
     //m_metadata_retrieved isn't useful (might remove it later)
     m_metadata_retrieved = true;
     ATH_MSG_DEBUG("metadata from new file: " << (dataType_metadata == PATCore::ParticleDataType::Data ? "data" : (dataType_metadata == PATCore::ParticleDataType::Full ? "full simulation" : "fast simulation")));
 
     if (dataType_metadata != PATCore::ParticleDataType::Data) {
 
-       if (m_dataTypeOverwrite == -1) { m_dataType = dataType_metadata; }
-       else {ATH_MSG_DEBUG("Use should set the dataType, otherwise it will take FullSim Type");}
+      if (m_dataTypeOverwrite == -1) { m_dataType = dataType_metadata; }
+      else {ATH_MSG_DEBUG("Use should set the dataType, otherwise it will take FullSim Type");}
     }
- }
+  }
 
   else { // not able to retrieve metadata
     m_metadata_retrieved = false;
     ATH_MSG_DEBUG("not able to retrieve metadata, please set the dataType");
   }
 
-return StatusCode::SUCCESS;
+  return StatusCode::SUCCESS;
 }
 //===============================================================================
 // end input file
@@ -722,7 +689,7 @@ StatusCode AsgElectronEfficiencyCorrectionTool::endInputFile(){
 //===============================================================================
 StatusCode AsgElectronEfficiencyCorrectionTool::beginEvent(){
 
-return StatusCode::SUCCESS;
+  return StatusCode::SUCCESS;
 }
 
 //===============================================================================
@@ -732,6 +699,7 @@ StatusCode
 AsgElectronEfficiencyCorrectionTool::get_simType_from_metadata(PATCore::ParticleDataType::DataType& result) const
 {
   // adapted from https://svnweb.cern.ch/trac/atlasoff/browser/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/trunk/Root/MetadataToolExample.cxx
+
 #ifndef ROOTCORE
   //Determine MC/Data
   std::string dataType("");
@@ -754,14 +722,13 @@ AsgElectronEfficiencyCorrectionTool::get_simType_from_metadata(PATCore::Particle
   }
 #endif
 
-  //here's how things will work dual use, when file metadata is available in files
+  //Here's how things will work dual use, when file metadata is available in files
   if (inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) {
     const xAOD::FileMetaData* fmd = 0;
     ATH_CHECK(inputMetaStore()->retrieve(fmd, "FileMetaData"));
 
     std::string simType("");
     const bool s = fmd->value(xAOD::FileMetaData::simFlavour, simType);
-
     if (!s) {
       ATH_MSG_DEBUG("no sim flavour from metadata: must be data");
       result = PATCore::ParticleDataType::Data;
@@ -769,7 +736,8 @@ AsgElectronEfficiencyCorrectionTool::get_simType_from_metadata(PATCore::Particle
     }
     else {
       ATH_MSG_DEBUG("sim type = " + simType);
-      result = simType == "FullSim" ? PATCore::ParticleDataType::Full : PATCore::ParticleDataType::Fast;
+      boost::to_upper(simType);
+      result = (simType.find("ATLFASTII")==std::string::npos) ?  PATCore::ParticleDataType::Full : PATCore::ParticleDataType::Fast;
       return StatusCode::SUCCESS;
     }
   }
@@ -827,11 +795,11 @@ AsgElectronEfficiencyCorrectionTool::convertToOneKey(const std::string& recokey,
 
     // Trigger SF file with isolation
     if (isokey != "") {
-          key = std::string (trigkey + "_" + idkey + "_" + isokey);
-      } else {
-          // Trigger SF file without isolation
-  key = std::string(trigkey + "_" + idkey);
-      }
+      key = std::string (trigkey + "_" + idkey + "_" + isokey);
+    } else {
+      // Trigger SF file without isolation
+      key = std::string(trigkey + "_" + idkey);
+    }
   }
   ATH_MSG_DEBUG("Full Key is " + key);
   return key;
@@ -844,15 +812,15 @@ AsgElectronEfficiencyCorrectionTool::getValueByKey(const std::string& mapFile, c
 
   std::string value;
   if (read(mapFile).isFailure()) {
-      ATH_MSG_ERROR("Couldn't read Map File" + mapFile);
-      return "" ;
+    ATH_MSG_ERROR("Couldn't read Map File" + mapFile);
+    return "" ;
   }
   if (getValue(key, value) == "") {
-      ATH_MSG_DEBUG("Error(" + key + ") not found ");
-      return "";
+    ATH_MSG_DEBUG("Error(" + key + ") not found ");
+    return "";
   } else {
-      ATH_MSG_DEBUG("Full Path of the correction file is " + value);
-      return value;
+    ATH_MSG_DEBUG("Full Path of the correction file is " + value);
+    return value;
   }
 }
 // Reads the provided map file
@@ -862,19 +830,19 @@ AsgElectronEfficiencyCorrectionTool::read(const std::string& strFile) {
 
   std::ifstream is(strFile.c_str());
   if (!is.is_open()){
-      ATH_MSG_ERROR("Couldn't read Map File" + strFile);
-      return StatusCode::FAILURE;
+    ATH_MSG_ERROR("Couldn't read Map File" + strFile);
+    return StatusCode::FAILURE;
   }
   while (!is.eof()) {
-      std::string strLine;
-      getline(is,strLine);
+    std::string strLine;
+    getline(is,strLine);
 
-      int nPos = strLine.find('=');
+    int nPos = strLine.find('=');
 
-      if ((signed int)std::string::npos == nPos) continue; // no '=', invalid line;
-      std::string strKey = strLine.substr(0,nPos);
-      std::string strVal = strLine.substr(nPos + 1, strLine.length() - nPos + 1);
-      m_map.insert(std::map<std::string,std::string>::value_type(strKey,strVal));
+    if ((signed int)std::string::npos == nPos) continue; // no '=', invalid line;
+    std::string strKey = strLine.substr(0,nPos);
+    std::string strVal = strLine.substr(nPos + 1, strLine.length() - nPos + 1);
+    m_map.insert(std::map<std::string,std::string>::value_type(strKey,strVal));
   }
   return StatusCode::SUCCESS;
 }
@@ -889,8 +857,82 @@ AsgElectronEfficiencyCorrectionTool::getValue(const std::string& strKey, std::st
   i = m_map.find(strKey);
 
   if (i != m_map.end()) {
-      strValue = i->second;
-      return strValue;
+    strValue = i->second;
+    return strValue;
   }
   return "";
 }
+
+int AsgElectronEfficiencyCorrectionTool::currentSimplifiedUncorrSystRegion(const double cluster_eta, const double et) const {
+  int ptbin = m_UncorrRegions->GetXaxis()->FindBin(et) - 1;
+  int etabin = m_UncorrRegions->GetYaxis()->FindBin(fabs(cluster_eta)) - 1;
+  int reg = ((etabin) * m_UncorrRegions->GetNbinsX() + ptbin);
+  return reg;
+}
+
+
+
+int AsgElectronEfficiencyCorrectionTool::currentUncorrSystRegion(const double cluster_eta, const double et) const {
+  int etabin = -1;
+  int reg = 0; 
+  bool found = false;
+  float cluster_eta_electron = 0;
+  std::map<float, std::vector<float> >::const_iterator itr_ptBEGIN = m_pteta_bins.begin();
+  std::map<float, std::vector<float> >::const_iterator itr_ptEND = m_pteta_bins.end();
+  // Consider using std::map::lower_bound, returns the iterator to the first element that is greater-or-equal to a pt
+  for (; itr_ptBEGIN != itr_ptEND; itr_ptBEGIN++) {
+    std::map<float, std::vector<float> >::const_iterator itr_ptBEGINplusOne = itr_ptBEGIN;
+    itr_ptBEGINplusOne++;
+
+    if ((et > itr_ptBEGIN->first && itr_ptBEGINplusOne == itr_ptEND) ||
+	(et > itr_ptBEGIN->first && et <= itr_ptBEGINplusOne->first)) {// find the pt bin
+      etabin=0;
+      // if it is ordered in eta from smaller to larger ascending order
+      // consider using std::lower_bound(begin,end) to find the position?
+      if ((itr_ptBEGIN->second).at(0) >= 0) {
+	cluster_eta_electron = fabs(cluster_eta);
+      }else {
+	cluster_eta_electron = (cluster_eta);
+      };
+      for (unsigned int etab = 0; etab < ((itr_ptBEGIN->second).size() - 1); ++etab) {// find the eta bin
+	etabin++;       
+	if ((cluster_eta_electron) > (itr_ptBEGIN->second).at(etab) &&
+	    (cluster_eta_electron) <= (itr_ptBEGIN->second).at(etab + 1)) {
+	  found = true;
+	  break;
+	} // if ( (cluster_eta_electron)
+      } // for (unsigned int etab=0;etab<((itr_ptBEGIN->second).size()-1) ; ++etab)
+    } 
+    if (found) {
+      break;
+    } 
+    reg = reg + (itr_ptBEGIN->second).size();
+  } 
+  reg = reg + etabin;
+  return reg;
+}
+
+int AsgElectronEfficiencyCorrectionTool::systUncorrVariationIndex( const xAOD::Electron &inputObject) const{
+  int currentSystRegion=-999;
+  double cluster_eta(-9999.9);
+  double et(0.0);
+ 
+  et = inputObject.pt();
+  const xAOD::CaloCluster *cluster = inputObject.caloCluster();
+  if (cluster) {
+    cluster_eta = cluster->etaBE(2);
+  }
+
+
+
+  if (m_correlation_model == correlationModel::SIMPLIFIED) {
+    currentSystRegion = currentSimplifiedUncorrSystRegion( cluster_eta, et);
+  }
+
+  if (m_correlation_model == correlationModel::FULL) {
+    currentSystRegion = currentUncorrSystRegion( cluster_eta, et);
+  }
+
+  return currentSystRegion;
+}
+
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/TElectronEfficiencyCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/TElectronEfficiencyCorrectionTool.cxx
index d36060770e73e2d858ba2c18853343000c6ec3a2..65379eea4052e48c1afabcf12b898ca5059e7428 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/TElectronEfficiencyCorrectionTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/Root/TElectronEfficiencyCorrectionTool.cxx
@@ -753,9 +753,8 @@ Root::TElectronEfficiencyCorrectionTool::buildToyMCTable(const TObjArray& sf, co
 // Helper function to retrieve number of uncorrelated bins
 // =============================================================================
 int
-Root::TElectronEfficiencyCorrectionTool::getNbins(std::map<float, std::vector<float> > &pt_eta1) {
-  std::vector<TObjArray > tmpVec;
-  tmpVec = m_histList[mapkey::sf];
+Root::TElectronEfficiencyCorrectionTool::getNbins(std::map<float, std::vector<float> > &pt_eta1) const {
+  const std::vector<TObjArray >& tmpVec = m_histList.at(mapkey::sf);
   int nbinsTotal = 0;
   pt_eta1.clear();
   std::vector<float>eta1;
@@ -792,7 +791,7 @@ Root::TElectronEfficiencyCorrectionTool::getNbins(std::map<float, std::vector<fl
 // =============================================================================
 // Helper function to retrieve the position of the first toy MC scale factor
 // =============================================================================
-int Root::TElectronEfficiencyCorrectionTool::getFirstToyMCPosition() {
+int Root::TElectronEfficiencyCorrectionTool::getFirstToyMCPosition() const {
   if (!m_isInitialized) {
     ATH_MSG_ERROR(" (file: " << __FILE__ << ", line: " << __LINE__ << ") " << "Tool not initialized.");
     return -1;
@@ -806,7 +805,7 @@ int Root::TElectronEfficiencyCorrectionTool::getFirstToyMCPosition() {
   }
 }
 
-int Root::TElectronEfficiencyCorrectionTool::getLastToyMCPosition() {
+int Root::TElectronEfficiencyCorrectionTool::getLastToyMCPosition() const {
   if (!m_isInitialized) {
     ATH_MSG_ERROR(" (file: " << __FILE__ << ", line: " << __LINE__ << ") " << "Tool not initialized.");
     return -1;
@@ -821,7 +820,7 @@ int Root::TElectronEfficiencyCorrectionTool::getLastToyMCPosition() {
 }
 //================================================================================
 /// Helpers
-int Root::TElectronEfficiencyCorrectionTool::getFirstCorrSysPosition() {
+int Root::TElectronEfficiencyCorrectionTool::getFirstCorrSysPosition() const {
   if (!m_isInitialized) {
     ATH_MSG_ERROR(" (file: " << __FILE__ << ", line: " << __LINE__ << ") " << "Tool not initialized.");
     return -1;
@@ -835,7 +834,7 @@ int Root::TElectronEfficiencyCorrectionTool::getFirstCorrSysPosition() {
   }
 }
 
-int Root::TElectronEfficiencyCorrectionTool::getLastCorrSysPosition() {
+int Root::TElectronEfficiencyCorrectionTool::getLastCorrSysPosition() const {
   if (!m_isInitialized) {
     ATH_MSG_ERROR(" (file: " << __FILE__ << ", line: " << __LINE__ << ") " << "Tool not initialized.");
     return -1;
@@ -853,7 +852,7 @@ int Root::TElectronEfficiencyCorrectionTool::getLastCorrSysPosition() {
     return 0;
   }
 }
-int Root::TElectronEfficiencyCorrectionTool::getGlobalBinNumberPosition() {
+int Root::TElectronEfficiencyCorrectionTool::getGlobalBinNumberPosition() const {
   if (!m_isInitialized) {
     ATH_MSG_ERROR(" (file: " << __FILE__ << ", line: " << __LINE__ << ") " << "Tool not initialized.");
     return -1;
@@ -861,7 +860,7 @@ int Root::TElectronEfficiencyCorrectionTool::getGlobalBinNumberPosition() {
   return m_position_globalBinNumber;
 }
 
-void Root::TElectronEfficiencyCorrectionTool::printResultMap() {
+void Root::TElectronEfficiencyCorrectionTool::printResultMap() const {
   if (!m_isInitialized) {
     ATH_MSG_ERROR(" (file: " << __FILE__ << ", line: " << __LINE__ << ") " << "Tool not initialized.");
     return;
@@ -1248,7 +1247,7 @@ Root::TElectronEfficiencyCorrectionTool::setup(const TObjArray& hists,
 // print a message that the default scale factor is returned
 // =============================================================================
 void
-Root::TElectronEfficiencyCorrectionTool::printDefaultReturnMessage(TString reason, int line) {
+Root::TElectronEfficiencyCorrectionTool::printDefaultReturnMessage(const TString& reason, int line) const{
   ATH_MSG_DEBUG(
 		this->getName() << " (file: " << __FILE__ << ", line: " << line << ")  " << reason << "\n" <<
 		"Returning scale factor -999 ");
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/src/testAthenaElectronAlg.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/src/testAthenaElectronAlg.cxx
index 83892aa7fb80881dad84c0b4f8876744660f6899..2aac6b8a2f02b10180e193341a03e1f3e64af790 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/src/testAthenaElectronAlg.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/src/testAthenaElectronAlg.cxx
@@ -10,7 +10,7 @@
 #include "xAODEgamma/ElectronAuxContainer.h"
 #include "xAODCore/ShallowCopy.h"
 #include "PATInterfaces/SystematicsTool.h"
-#include "ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
 
 testAthenaElectronAlg::testAthenaElectronAlg( const std::string& name, ISvcLocator* pSvcLocator ) : 
   AthAlgorithm( name, pSvcLocator ),  
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/EgEfficiencyCorr_mem_check.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/EgEfficiencyCorr_mem_check.cxx
index 0c2360bfd5538996fbf70d671d29be9747c94e1e..6b80812b410fa51e89ef1c03f2c7f0073c1d6de8 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/EgEfficiencyCorr_mem_check.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/EgEfficiencyCorr_mem_check.cxx
@@ -14,7 +14,7 @@ http://valgrind.org/docs/manual/faq.html#faq.deflost
 #include <iostream>
 #include <vector>
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
-#include "ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
 #include "AsgAnalysisInterfaces/IEfficiencyScaleFactorTool.h"
 #include "AsgTools/AsgMessaging.h"
 #include "AsgTools/AnaToolHandle.h"
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/Messaging.h b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/Messaging.h
index bf47a78bfee8b5bb5180daeaab7d81b9a9068d40..90a91c47ce15094809072d958c1ba47d90c9554e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/Messaging.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/Messaging.h
@@ -6,19 +6,24 @@
 #define __ELECTRONEFFICIENCYCORRECTIONMESSAGING__
 #include "AsgTools/AsgMessaging.h"
 
-static  asg::AsgMessaging dummymsg("");
+namespace MSGHELPERS{
+  const asg::AsgMessaging& getMsgStream();
+}
+const asg::AsgMessaging& MSGHELPERS::getMsgStream(){
+  static const asg::AsgMessaging dummymsg("");
+  return dummymsg;
+}
 
-#define DUMMY_MSG( lvl, ARG ) {dummymsg.msg(lvl)<<ARG<<endmsg ;}
+#define DUMMY_MSG(lvl, ARG ) {						\
+    const asg::AsgMessaging& dummymsg=MSGHELPERS::getMsgStream();	\
+    dummymsg.msg(lvl)<<ARG<<endmsg ;					\
+}
 #define MSG_DEBUG( ARG ) {DUMMY_MSG(MSG::DEBUG, ARG);}
 #define MSG_INFO( ARG ) {DUMMY_MSG(MSG::INFO, ARG);}
-#define MSG_WARNING( ARG ) {DUMMY_MSG(MSG::WARNING, ARG);}
-#define MSG_ERROR( ARG ) {DUMMY_MSG(MSG::ERROR, ARG);}
-#define MSG_FATAL( ARG ) {DUMMY_MSG(MSG::FATAL, ARG);}
-#define MSG_ABORT( ARG ) {DUMMY_MSG(MSG::FATAL, ARG); std::abort();} 
+#define MSG_WARNING( ARG ) { DUMMY_MSG(MSG::WARNING, ARG);}
+#define MSG_ERROR( ARG ) { DUMMY_MSG(MSG::ERROR, ARG);}
+#define MSG_FATAL( ARG ) { DUMMY_MSG(MSG::FATAL, ARG);}
+#define MSG_ABORT( ARG ) { DUMMY_MSG(MSG::FATAL, ARG); std::abort();} 
 
-namespace MSGHELPERS{
-  const asg::AsgMessaging& getMsgStream();
-}
-const asg::AsgMessaging& MSGHELPERS::getMsgStream(){return dummymsg;}
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx
index 0273f4c1af79f0e33aa19ceb275035847a56b3d9..16fc1ce16c04fddbd70cd3226f13eab02d711d3e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorr.cxx
@@ -5,6 +5,7 @@
 // System include(s):
 #include <memory>
 #include <cstdlib>
+#include "Messaging.h"
 
 // ROOT include(s):
 #include <TFile.h>
@@ -24,6 +25,7 @@
 #include "xAODEgamma/Egamma.h"
 #include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
 #include "xAODCore/ShallowCopy.h"
+#include "AsgTools/AsgMessaging.h"
 
 
 #include <string>
@@ -46,6 +48,11 @@ int main( int argc, char* argv[] ) {
    // The application's name:
    const char* APP_NAME = argv[ 0 ];
 
+  MSG::Level mylevel=MSG::DEBUG;
+
+  MSGHELPERS::getMsgStream().msg().setLevel(mylevel);
+  MSGHELPERS::getMsgStream().msg().setName(APP_NAME);
+
    // Check if we received a file name:
    if( argc < 2 ) {
      Error( APP_NAME, "No file name received!" );
@@ -84,12 +91,14 @@ int main( int argc, char* argv[] ) {
    //Likelihood
    AsgElectronEfficiencyCorrectionTool myEgCorrections ("myEgCorrections");
    //std::vector<std::string> inputFiles{"ElectronEfficiencyCorrection/efficiencySF.offline.Loose.2012.8TeV.rel17p2.v07.root"} ;
-   std::vector<std::string> inputFiles{"ElectronEfficiencyCorrection/efficiencySF.offline.MediumLLH_d0z0_v11.root"} ;
+   std::vector<std::string> inputFiles{"efficiencySF.offline.MediumLLH_d0z0_v11.root"} ;
    CHECK( myEgCorrections.setProperty("CorrectionFileNameList",inputFiles) );
+    myEgCorrections.msg().setLevel(mylevel);
 
    CHECK( myEgCorrections.setProperty("ForceDataType",3) );
    CHECK( myEgCorrections.setProperty("CorrelationModel", "SIMPLIFIED" ));
    CHECK( myEgCorrections.setProperty("UseRandomRunNumber", false ));
+   CHECK( myEgCorrections.setProperty("DefaultRandomRunNumber", 299999));
 
    CHECK( myEgCorrections.initialize() );
 
@@ -99,14 +108,15 @@ int main( int argc, char* argv[] ) {
    std::vector<CP::SystematicSet> sysList = CP::make_systematics_vector(recSysts);
   std::cout << "=="<<std::endl;
    // Loop over the events:
-   entries = 1;
-   for( Long64_t entry = 0; entry < entries; ++entry ) {
+   Long64_t entry = 10;
+   entries = entry+1;
+   for(  ; entry < entries; ++entry ) {
      
      // Tell the object which entry to look at:
      event.getEntry( entry );
      
      std::cout << "=================NEXT EVENT==========================" << std::endl;
-     Info (APP_NAME,"Electron 6" );
+   //  Info (APP_NAME,"Electron 6" );
 
  
      const xAOD::EventInfo* event_info = 0;  
@@ -148,6 +158,10 @@ int main( int argc, char* argv[] ) {
 
          Info (APP_NAME,"Electron #%d", i); 
 
+int sysreg = myEgCorrections.systUncorrVariationIndex(*el);
+         Info (APP_NAME,"sysregion %d ", sysreg);
+
+
          if(myEgCorrections.getEfficiencyScaleFactor(*el,SF) != CP::CorrectionCode::Ok){
            Error( APP_NAME, "Problem in getEfficiencyScaleFactor");
            return EXIT_FAILURE;
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx
index 79edb7d6778a527ac44234077c6acb6146e6d4cb..8bcc2fd01c5115b4c8e547c9869a6a40e659ea2e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection/util/testEgEfficiencyCorrWithoutFile.cxx
@@ -130,6 +130,8 @@ void dumbProperties(const AsgElectronEfficiencyCorrectionTool& tool){
 }
 
 
+int main( int argc, char* argv[] ) {
+  xAOD::TReturnCode::enableFailure();
 
 int main( int argc, char* argv[] ) {
   xAOD::TReturnCode::enableFailure();
@@ -354,10 +356,8 @@ int main( int argc, char* argv[] ) {
   if ( isokey!="")   CHECK( myEgCorrections.setProperty("IsoKey", isokey));
   if ( triggerkey!="")   CHECK( myEgCorrections.setProperty("TriggerKey", triggerkey));
   CHECK( myEgCorrections.setProperty("ForceDataType",(int)SimType) );
- // CHECK( myEgCorrections.setProperty("CorrelationModel", "TOTAL" ));
-CHECK( myEgCorrections.setProperty("CorrelationModel", "FULL" ));
-   
- myEgCorrections.msg().setLevel(mylevel);
+  CHECK( myEgCorrections.setProperty("CorrelationModel", "TOTAL" ));
+  myEgCorrections.msg().setLevel(mylevel);
   CHECK( myEgCorrections.initialize() );  
   dumbProperties(myEgCorrections);
   double SF = 0; 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/CMakeLists.txt
index 77bb3238aa81ff0ad0732765b83ec05333d08b19..9f36c61202a95a8dd51ab440d96df0179f560ea7 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/CMakeLists.txt
@@ -25,11 +25,12 @@ atlas_depends_on_subdirs(
    Event/xAOD/xAODEventInfo
    PhysicsAnalysis/AnalysisCommon/PATCore
    PhysicsAnalysis/AnalysisCommon/PATInterfaces
+   PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces	
    PRIVATE
    Event/xAOD/xAODBase
    Event/xAOD/xAODCore
    Event/xAOD/xAODTracking
-	 Event/xAOD/xAODMetaData
+   Event/xAOD/xAODMetaData
    Reconstruction/egamma/egammaLayerRecalibTool
    Reconstruction/egamma/egammaMVACalib
    Event/xAOD/xAODTruth
@@ -38,6 +39,7 @@ atlas_depends_on_subdirs(
 
 # External dependencies:
 find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
+find_package( Boost )
 
 # Component(s) in the package:
 atlas_add_library( ElectronPhotonFourMomentumCorrectionLib
@@ -45,7 +47,7 @@ atlas_add_library( ElectronPhotonFourMomentumCorrectionLib
    PUBLIC_HEADERS ElectronPhotonFourMomentumCorrection
    INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
    LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODCaloEvent xAODEgamma
-   xAODEventInfo PATInterfaces PATCoreLib egammaMVACalibLib xAODTruth
+   xAODEventInfo PATInterfaces EgammaAnalysisInterfacesLib PATCoreLib egammaMVACalibLib xAODTruth
    PRIVATE_LINK_LIBRARIES xAODTracking xAODMetaData egammaLayerRecalibTool
    PathResolver )
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h
index db5dee0c33f583d0049a8115ece1f3c531c76393..b7a149e12141ad469769534c33209128a2bbba46 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h
@@ -13,10 +13,10 @@
 #include <array>
 #include <memory>
 
+#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
 #include "AsgTools/AsgTool.h"
 #include "AsgTools/AsgMetadataTool.h"
 #include "AsgTools/AsgMessaging.h"
-#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h"
 #include "PATInterfaces/ISystematicsTool.h"
 #include "PATInterfaces/SystematicSet.h"
 #include "xAODEgamma/Electron.h"
@@ -144,6 +144,7 @@ private:
   egEnergyCorr::Resolution::resolutionType m_TResolutionType;
   int m_use_AFII;
   PATCore::ParticleDataType::DataType m_simulation = PATCore::ParticleDataType::Full;
+  int m_RandomRunNumber;
   //flags duplicated from the underlying ROOT tool
   int m_useLayerCorrection;
   int m_usePSCorrection;
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrectionDict.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrectionDict.h
index 2dc6735cf73653abaa00acb09082c6711cd2d7f0..ad0735fed5d7a1e763b8026d2ce2bbe465e019fb 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrectionDict.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrectionDict.h
@@ -11,8 +11,8 @@
 #ifndef ELECTRONPHOTONFOURMOMENTUMCORRECTION_ELECTRONPHOTONFOURMOMENTUMCORRECTIONDICT_H
 #define ELECTRONPHOTONFOURMOMENTUMCORRECTION_ELECTRONPHOTONFOURMOMENTUMCORRECTIONDICT_H
 
+
 #include "ElectronPhotonFourMomentumCorrection/egammaEnergyCorrectionTool.h"
-#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h"
 #include "ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h"
 #include "ElectronPhotonFourMomentumCorrection/eg_resolution.h"
 #include "ElectronPhotonFourMomentumCorrection/EgammaFactory.h"
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/GainUncertainty.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/GainUncertainty.h
index f354111d591ea363c8ca26fe3e771b972ee19107..ae355993f4e129dbc4cbf09a8775d5b1217a7267 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/GainUncertainty.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/GainUncertainty.h
@@ -18,11 +18,11 @@ class TH1D;
 namespace egGain{
 
 class GainUncertainty : public asg::AsgMessaging {
-
 public:
 
-  GainUncertainty();
-  ~GainUncertainty();
+    GainUncertainty(std::string filename);
+    void Init(std::string filename);
+    ~GainUncertainty();
 
  // return relative uncertainty on energy from gain uncertainty
  // input etaCalo_input = eta in Calo frame
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h
index 086a76553b4bfd3e9bb188a1142892ad2ccf36d1..d3867d0c305511a38ef1c211f4a8b922f1954612 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h
@@ -8,49 +8,7 @@
 #ifndef IEGAMMA_CALIB_TOOL_H_
 #define IEGAMMA_CALIB_TOOL_H_
 
-#include "AsgTools/IAsgTool.h"
-//xAOD
-#include "xAODEgamma/ElectronFwd.h"
-#include "xAODEgamma/PhotonFwd.h"
-#include "xAODEgamma/EgammaFwd.h"
-#include "PATInterfaces/CorrectionCode.h"
-#include "PATInterfaces/ISystematicsTool.h"
-// PAT includes
-#include "PATCore/PATCoreEnums.h"
+#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
-
-namespace EgammaCalibPeriodRunNumbersExample {
-  const int run_2016 = 297730;
-  const int run_2015 = 252604;
-  struct ROOT6_NamespaceAutoloadHook{};
-}
-
-
-namespace CP {
-
-  class IEgammaCalibrationAndSmearingTool : public CP::ISystematicsTool{
-    /// Declare the interface that the class provides
-    ASG_TOOL_INTERFACE( IEgammaCalibrationAndSmearingTool )
-    public:
-    
-    virtual ~IEgammaCalibrationAndSmearingTool() {};
-    
-    virtual StatusCode initialize() = 0;
-    
-    //Apply the correction on a modifyable egamma object (xAOD::Electron or xAOD::Photon)
-    virtual CP::CorrectionCode applyCorrection(xAOD::Egamma &) = 0;
-    
-    //Create a corrected copy from a constant egamma object
-    virtual CP::CorrectionCode correctedCopy(const xAOD::Electron&, xAOD::Electron*&) = 0;
-    virtual CP::CorrectionCode correctedCopy(const xAOD::Photon&, xAOD::Photon*&) = 0;
-    
-    //functions to be used per-event
-    virtual void setRandomSeed(unsigned seed) = 0;
-    
-    virtual double resolution( double energy, double cl_eta, double cl_etaCalo,
-			       PATCore::ParticleType::Type ptype = PATCore::ParticleType::Electron, bool withCT=false) const = 0;
-    virtual double getResolution(const xAOD::Egamma& particle, bool withCT=true) const = 0;
-  };
-  
-}
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/egammaEnergyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/egammaEnergyCorrectionTool.h
index b189578ae7fb1996a655e7a80a999b8c0d7bfaf3..106768d30dd2ca4b8f70ffee4c51941bcdfad0c6 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/egammaEnergyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/egammaEnergyCorrectionTool.h
@@ -209,7 +209,10 @@ namespace egEnergyCorr {
     es2015c_summer,         // data-driven for mc15c (to be used in summer 2016)
     es2016PRE,              // as es2015c_summer + temperature extrapolation
     es2017,                 // Moriond 2017
-
+    es2017_summer,          // Summer 2017
+    es2017_summer_improved, // Recommendations for Higgs mass paper
+    es2017_R21_PRE,         // Pre-recommendations for release 21
+    
     UNDEFINED
 
   };
@@ -501,7 +504,7 @@ namespace AtlasRoot {
 
     TH1F*         m_pedestals_es2017;
 
-    TH2D*         m_convRadius;
+    TH1D*         m_convRadius;
     TH1D*         m_convFakeRate;
     TH1D*         m_convRecoEfficiency;
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/selection.xml b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/selection.xml
index ca64235d33b2a28136235b66c4abc485426bd787..f781a587b098966c91986504b21c985b273516d8 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/selection.xml
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/selection.xml
@@ -5,9 +5,6 @@
 
    <class name="AtlasRoot::egammaEnergyCorrectionTool" />
 
-   <variable pattern="EgammaCalibPeriodRunNumbersExample::*"/>
-   <class name="EgammaCalibPeriodRunNumbersExample::ROOT6_NamespaceAutoloadHook" /> 
-
    <namespace name="egEnergyCorr" />
    <enum pattern="egEnergyCorr::*"/>
    <class name="egEnergyCorr::ROOT6_OpenNamespaceWorkaround" />
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/EgammaCalibrationAndSmearingTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/EgammaCalibrationAndSmearingTool.cxx
index b014502c3c72b2fc5f20df4348ec512759900527..d2baf7a71d653bbb82897503a79e05cfdb246238 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/EgammaCalibrationAndSmearingTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/EgammaCalibrationAndSmearingTool.cxx
@@ -19,8 +19,9 @@
 #include "PathResolver/PathResolver.h"
 #include "CxxUtils/make_unique.h"
 #include "xAODMetaData/FileMetaData.h"
-#ifndef ROOTCORE
 #include <boost/algorithm/string.hpp>
+
+#ifndef ROOTCORE
 #include "AthAnalysisBaseComps/AthAnalysisHelper.h"
 #endif
 
@@ -60,10 +61,13 @@ std::unique_ptr<egGain::GainTool> gainToolFactory(egEnergyCorr::ESModel model)
       return CxxUtils::make_unique<egGain::GainTool>(gain_filename1, gain_filename2);
     }
     case egEnergyCorr::es2017:
-      return nullptr;
+    case egEnergyCorr::es2017_summer: 
+    case egEnergyCorr::es2017_summer_improved:
+    case egEnergyCorr::es2017_R21_PRE:
+      return nullptr;  
     default:
       return nullptr;
-    }
+  }
 }
 
 std::unique_ptr<egammaMVATool> egammaMVAToolFactory(egEnergyCorr::ESModel model)
@@ -92,8 +96,13 @@ std::unique_ptr<egammaMVATool> egammaMVAToolFactory(egEnergyCorr::ESModel model)
         case egEnergyCorr::es2015c_summer:
         case egEnergyCorr::es2016PRE:
         case egEnergyCorr::es2017:
+        case egEnergyCorr::es2017_summer:
+        case egEnergyCorr::es2017_summer_improved:
           folder = "egammaMVACalib/offline/v4.0";
           break;
+        case egEnergyCorr::es2017_R21_PRE:
+	  folder = "egammaMVACalib/offline/v7";
+          break;
         default: folder = "";
     }
 
@@ -106,7 +115,6 @@ std::unique_ptr<egammaMVATool> egammaMVAToolFactory(egEnergyCorr::ESModel model)
     else { return nullptr; }
 }
 
-
 std::unique_ptr<egammaLayerRecalibTool> egammaLayerRecalibToolFactory(egEnergyCorr::ESModel model)
 {
   std::string tune = "";
@@ -127,8 +135,13 @@ std::unique_ptr<egammaLayerRecalibTool> egammaLayerRecalibToolFactory(egEnergyCo
     case egEnergyCorr::es2015c_summer:
     case egEnergyCorr::es2016PRE:
     case egEnergyCorr::es2017:
+    case egEnergyCorr::es2017_R21_PRE:  
       tune = "2012_alt_with_layer2";
       break;
+    case egEnergyCorr::es2017_summer:
+    case egEnergyCorr::es2017_summer_improved:
+      tune = "es2017_20.7_improved";
+      break;
     default:
       return nullptr;
   }
@@ -158,6 +171,9 @@ bool use_intermodule_correction(egEnergyCorr::ESModel model)
     case egEnergyCorr::es2015c_summer:
     case egEnergyCorr::es2016PRE:
     case egEnergyCorr::es2017:
+    case egEnergyCorr::es2017_summer:  
+    case egEnergyCorr::es2017_summer_improved:
+    case egEnergyCorr::es2017_R21_PRE:
       return true;
     case egEnergyCorr::UNDEFINED:  // TODO: find better logic
       return false;
@@ -193,6 +209,9 @@ bool is_run2(egEnergyCorr::ESModel model)
     case egEnergyCorr::es2015c_summer:
     case egEnergyCorr::es2016PRE:
     case egEnergyCorr::es2017:
+    case egEnergyCorr::es2017_summer:
+    case egEnergyCorr::es2017_summer_improved:    
+    case egEnergyCorr::es2017_R21_PRE:  
       return true;
     case egEnergyCorr::UNDEFINED:  // TODO: find better logic
       return false;
@@ -270,6 +289,9 @@ StatusCode EgammaCalibrationAndSmearingTool::initialize() {
   else if (m_ESModel == "es2015c_summer") { m_TESModel = egEnergyCorr::es2015c_summer; }
   else if (m_ESModel == "es2016PRE") { m_TESModel = egEnergyCorr::es2016PRE; }
   else if (m_ESModel == "es2016data_mc15c") { m_TESModel = egEnergyCorr::es2017; }
+  else if (m_ESModel == "es2016data_mc15c_summer") { m_TESModel = egEnergyCorr::es2017_summer; }
+  else if (m_ESModel == "es2016data_mc15c_summer_improved") { m_TESModel = egEnergyCorr::es2017_summer_improved; } 
+  else if (m_ESModel == "es2017_R21_PRE") { m_TESModel = egEnergyCorr::es2017_R21_PRE; }
   else if (m_ESModel.empty()) {
     ATH_MSG_ERROR("you must set ESModel property");
     return StatusCode::FAILURE;
@@ -402,16 +424,23 @@ StatusCode EgammaCalibrationAndSmearingTool::initialize() {
   }
 
   // configure layer recalibration tool
-  ATH_MSG_DEBUG("initializing layer recalibration tool (if needed)");
-  if (m_layer_recalibration_tune == "") { // automatically configure layer recalibration tool
-    m_layer_recalibration_tool = egammaLayerRecalibToolFactory(m_TESModel).release();
-    if (!m_layer_recalibration_tool) { ATH_MSG_INFO("not using layer recalibration"); }
+  //For now: layer recalibration only needed before release 21
+  if (m_ESModel == "es2017_R21_PRE"){
+    ATH_MSG_INFO("Layer recalibration already applied at cell level");
+    m_useLayerCorrection = false;
   }
-  else {
-    m_layer_recalibration_tool = new egammaLayerRecalibTool(m_layer_recalibration_tune);
+  else{
+    ATH_MSG_DEBUG("initializing layer recalibration tool (if needed)");
+    if (m_layer_recalibration_tune == "") { // automatically configure layer recalibration tool
+      m_layer_recalibration_tool = egammaLayerRecalibToolFactory(m_TESModel).release();
+      if (!m_layer_recalibration_tool) { ATH_MSG_INFO("not using layer recalibration"); }
+    }
+    else {
+      m_layer_recalibration_tool = new egammaLayerRecalibTool(m_layer_recalibration_tune);
+    }
+    if (m_layer_recalibration_tool) { m_layer_recalibration_tool->msg().setLevel(this->msg().level()); }
   }
-  if (m_layer_recalibration_tool) { m_layer_recalibration_tool->msg().setLevel(this->msg().level()); }
-
+  
   if (m_use_temp_correction201215 != AUTO) m_rootTool->use_temp_correction201215(m_use_temp_correction201215);
   if (m_use_uA2MeV_2015_first2weeks_correction != AUTO) m_rootTool->use_uA2MeV_2015_first2weeks_correction(m_use_uA2MeV_2015_first2weeks_correction);
   if (not m_use_full_statistical_error and m_decorrelation_model_scale == ScaleDecorrelation::FULL) { m_rootTool->useStatErrorScaling(true); }
@@ -420,7 +449,7 @@ StatusCode EgammaCalibrationAndSmearingTool::initialize() {
     ATH_MSG_ERROR("ep combination not supported yet");
     throw std::runtime_error("ep combination not supported yet");
   }
-
+  
   if (m_useIntermoduleCorrection == AUTO) { m_useIntermoduleCorrection = use_intermodule_correction(m_TESModel); }
   if (m_usePhiUniformCorrection == AUTO) { m_usePhiUniformCorrection = use_phi_uniform_correction(m_TESModel); }
   m_use_mapping_correction = not is_run2(m_TESModel);
@@ -434,6 +463,11 @@ StatusCode EgammaCalibrationAndSmearingTool::initialize() {
     ATH_MSG_ERROR("cannot instantiate gain tool for this model (you can only disable the gain tool, but not enable it)");
   }
 
+  //No scale correction for release 21 ==> obsolete
+  /*if (m_ESModel == "es2017_R21_PRE"){
+    m_doScaleCorrection = 0;
+  }
+  */
 
   ATH_MSG_INFO("ESModel: " << m_ESModel);
   ATH_MSG_INFO("ResolutionType: " << m_ResolutionType);
@@ -473,7 +507,6 @@ StatusCode EgammaCalibrationAndSmearingTool::get_simflavour_from_metadata(PATCor
     result = PATCore::ParticleDataType::Data;
     return StatusCode::SUCCESS;
   }
-
   // Determine Fast/FullSim
   std::string simType("");
   ATH_CHECK(AthAnalysisHelper::retrieveMetadata("/Simulation/Parameters", "SimulationFlavour", simType, inputMetaStore()));
@@ -495,7 +528,8 @@ StatusCode EgammaCalibrationAndSmearingTool::get_simflavour_from_metadata(PATCor
     }
     else {
       ATH_MSG_DEBUG("sim type = " + simType);
-      result = simType == "FullSim" ? PATCore::ParticleDataType::Full : PATCore::ParticleDataType::Fast;
+      boost::to_upper(simType);
+      result = (simType.find("ATLFASTII")==std::string::npos) ?  PATCore::ParticleDataType::Full : PATCore::ParticleDataType::Fast;
       return StatusCode::SUCCESS;
     }
   }
@@ -863,7 +897,8 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
     // additional systematics for S12 run2
     if (m_TESModel == egEnergyCorr::es2015PRE_res_improved or m_TESModel == egEnergyCorr::es2015PRE or
         m_TESModel == egEnergyCorr::es2015cPRE or m_TESModel == egEnergyCorr::es2015c_summer or
-        m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017) {
+        m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017 or 
+	m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_LARCALIB_EXTRA2015PRE", +1)] = SysInfo{always, egEnergyCorr::Scale::LArCalibExtra2015PreUp};
       m_syst_description[CP::SystematicVariation("EG_SCALE_LARCALIB_EXTRA2015PRE", -1)] = SysInfo{always, egEnergyCorr::Scale::LArCalibExtra2015PreDown};
     }
@@ -877,25 +912,26 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
     }
 
     // additional systematic for S12 last eta bin run2
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_S12EXTRALASTETABINRUN2", +1)] = SysInfo{always, egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_S12EXTRALASTETABINRUN2", -1)] = SysInfo{always, egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Down};
     }
 
     // additional systematic for PP0 region
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_MATPP0", +1)] = SysInfo{always, egEnergyCorr::Scale::MatPP0Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_MATPP0", -1)] = SysInfo{always, egEnergyCorr::Scale::MatPP0Down};
     }
 
     // systematic related to wtots1
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_WTOTS1", +1)] = SysInfo{always, egEnergyCorr::Scale::Wtots1Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_WTOTS1", -1)] = SysInfo{always, egEnergyCorr::Scale::Wtots1Down};
     }
 
     // systematic for the scintillators
-    if (m_TESModel == egEnergyCorr::es2015cPRE or m_TESModel == egEnergyCorr::es2015c_summer or m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2015cPRE or m_TESModel == egEnergyCorr::es2015c_summer or m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017
+	or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       // scintillator systematics
       m_syst_description[CP::SystematicVariation("EG_SCALE_E4SCINTILLATOR", +1)] = SysInfo{always, egEnergyCorr::Scale::E4ScintillatorUp};
       m_syst_description[CP::SystematicVariation("EG_SCALE_E4SCINTILLATOR", -1)] = SysInfo{always, egEnergyCorr::Scale::E4ScintillatorDown};
@@ -916,6 +952,13 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
         m_syst_description[CP::SystematicVariation(#name, -1)] = SysInfo{always, flagdown};
       #include "ElectronPhotonFourMomentumCorrection/systematics_1NPCOR_PLUS_UNCOR.def"
       #undef SYSMACRO
+
+    // additional systematic for S12 last eta bin run2
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
+      m_syst_description[CP::SystematicVariation("EG_SCALE_S12EXTRALASTETABINRUN2", +1)] = SysInfo{always, egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Up};
+      m_syst_description[CP::SystematicVariation("EG_SCALE_S12EXTRALASTETABINRUN2", -1)] = SysInfo{always, egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Down};
+    }
+
   }
   else if (m_decorrelation_model_scale == ScaleDecorrelation::FULL) {
     typedef std::vector<std::pair<double, double>> pairvector;
@@ -963,7 +1006,8 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
     // additional systematics for S12 run2
     if (m_TESModel == egEnergyCorr::es2015PRE_res_improved or m_TESModel == egEnergyCorr::es2015PRE or
         m_TESModel == egEnergyCorr::es2015cPRE or m_TESModel == egEnergyCorr::es2015c_summer or
-        m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017) {
+        m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017
+	or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN0", +1)] = SysInfo{AbsEtaCaloPredicateFactory({0, 1.45}), egEnergyCorr::Scale::LArCalibExtra2015PreUp};
       m_syst_description[CP::SystematicVariation("EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN0", -1)] = SysInfo{AbsEtaCaloPredicateFactory({0, 1.45}), egEnergyCorr::Scale::LArCalibExtra2015PreDown};
       m_syst_description[CP::SystematicVariation("EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN1", +1)] = SysInfo{AbsEtaCaloPredicateFactory({1.45, 2.47}), egEnergyCorr::Scale::LArCalibExtra2015PreUp};
@@ -983,13 +1027,13 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
     }
 
     // additional systematic for S12 last eta bin run2
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_S12EXTRALASTETABINRUN2", +1)] = SysInfo{always, egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_S12EXTRALASTETABINRUN2", -1)] = SysInfo{always, egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Down};
     }
 
     // additional systematic for PP0 region
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_MATPP0__ETABIN0", +1)] = SysInfo{AbsEtaCaloPredicateFactory(0, 1.5), egEnergyCorr::Scale::MatPP0Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_MATPP0__ETABIN1", +1)] = SysInfo{AbsEtaCaloPredicateFactory(1.5, 2.5), egEnergyCorr::Scale::MatPP0Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_MATPP0__ETABIN0", -1)] = SysInfo{AbsEtaCaloPredicateFactory(0, 1.5), egEnergyCorr::Scale::MatPP0Down};
@@ -997,13 +1041,14 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
     }
 
     // systematic related to wtots1
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_WTOTS1", +1)] = SysInfo{always, egEnergyCorr::Scale::Wtots1Up};
       m_syst_description[CP::SystematicVariation("EG_SCALE_WTOTS1", -1)] = SysInfo{always, egEnergyCorr::Scale::Wtots1Down};
     }
 
     // systematic for the scintillators
-    if (m_TESModel == egEnergyCorr::es2015cPRE or m_TESModel == egEnergyCorr::es2015c_summer or m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2015cPRE or m_TESModel == egEnergyCorr::es2015c_summer or m_TESModel == egEnergyCorr::es2016PRE or m_TESModel == egEnergyCorr::es2017
+	or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description[CP::SystematicVariation("EG_SCALE_E4SCINTILLATOR__ETABIN0", +1)] = SysInfo{AbsEtaCaloPredicateFactory(1.4, 1.46), egEnergyCorr::Scale::E4ScintillatorUp};
       m_syst_description[CP::SystematicVariation("EG_SCALE_E4SCINTILLATOR__ETABIN1", +1)] = SysInfo{AbsEtaCaloPredicateFactory(1.46, 1.52), egEnergyCorr::Scale::E4ScintillatorUp};
       m_syst_description[CP::SystematicVariation("EG_SCALE_E4SCINTILLATOR__ETABIN2", +1)] = SysInfo{AbsEtaCaloPredicateFactory(1.52, 1.6), egEnergyCorr::Scale::E4ScintillatorUp};
@@ -1046,7 +1091,7 @@ void EgammaCalibrationAndSmearingTool::setupSystematics() {
     m_syst_description_resolution[CP::SystematicVariation("EG_RESOLUTION_MATERIALCRYO", -1)] = egEnergyCorr::Resolution::MaterialCryoDown;
     m_syst_description_resolution[CP::SystematicVariation("EG_RESOLUTION_PILEUP", +1)] = egEnergyCorr::Resolution::PileUpUp;
     m_syst_description_resolution[CP::SystematicVariation("EG_RESOLUTION_PILEUP", -1)] = egEnergyCorr::Resolution::PileUpDown;
-    if (m_TESModel == egEnergyCorr::es2017) {
+    if (m_TESModel == egEnergyCorr::es2017 or m_TESModel == egEnergyCorr::es2017_summer or m_TESModel == egEnergyCorr::es2017_summer_improved or m_TESModel == egEnergyCorr::es2017_R21_PRE) {
       m_syst_description_resolution[CP::SystematicVariation("EG_RESOLUTION_MATERIALIBL", +1)] = egEnergyCorr::Resolution::MaterialIBLUp;
       m_syst_description_resolution[CP::SystematicVariation("EG_RESOLUTION_MATERIALIBL", -1)] = egEnergyCorr::Resolution::MaterialIBLDown;
       m_syst_description_resolution[CP::SystematicVariation("EG_RESOLUTION_MATERIALPP0", +1)] = egEnergyCorr::Resolution::MaterialPP0Up;
@@ -1111,52 +1156,110 @@ CP::SystematicCode EgammaCalibrationAndSmearingTool::applySystematicVariation(co
 
 double EgammaCalibrationAndSmearingTool::intermodule_correction(double Ecl,  double phi, double eta) const
 {
+    
+  //Intermodule Widening Correction: E_corr = E / (a' - b' * ((1 / (1 + exp((phi_mod - 2 * pi / 32) * c))) * (1 / (1 + exp((phi_mod - 2 * pi / 32) * (d))))))
+  //(phi_min, phi_max) : [a' = a / a, b' = b / a, c, d]
+  
   double Ecl_corr = 0.;
   int DivInt = 0;
   double pi = 3.1415926535897932384626433832795 ;
 
-  //  Definitions of module folding into four quarters (top, left, bottom and right)
-
-  DivInt =  (int) (phi / ((2 * pi) / 16.));
-  double phi_mod = phi - DivInt * (2 * pi / 16.);
-
-
-  //  Centring on the intermodule --> phi_mod will now be in [0,0.4]
-  if (phi_mod < 0) phi_mod += pi / 8.;
-
-  //  The correction concerns only the barrel
-  if(fabs(eta) <= 1.4){
-
-    //  Top quarter
-    if(phi < (3 * pi) / 4. && phi >= pi / 4.){
-Ecl_corr = Ecl / (1-0.131 * ((1 / (1 + exp((phi_mod-0.2) * 199.08))) * (1 / (1 + exp((phi_mod-0.2) * (-130.36))))));
+  if ( m_TESModel == egEnergyCorr::es2017_summer_improved ) {
+    
+    double phi_mod = 0;
+    if (phi < 0)
+      phi_mod = fmod(phi, 2 * pi / 16.) + pi / 8.;
+    else
+      phi_mod = fmod(phi, 2 * pi / 16.);
+    
+    //  The correction concerns only the barrel
+    if(fabs(eta) <= 1.37){
+      
+      if(phi< (-7 * pi / 8) && phi> (-1 * pi))
+	Ecl_corr = Ecl / (1-0.1086 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 175.2759))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-189.3612))))));
+      if(phi< (-6 * pi / 8) && phi> (-7 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0596 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 170.8305))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-233.3782))))));
+      if(phi< (-5 * pi / 8) && phi> (-6 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0596 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 147.1451))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-139.3386))))));
+      if(phi< (-4 * pi / 8) && phi> (-5 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0583 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 168.4644))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-246.2897))))));
+      if(phi< (-3 * pi / 8) && phi> (-4 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0530 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 177.6703))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-198.3227))))));
+      if(phi< (-2 * pi / 8) && phi> (-3 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0672 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 145.0693))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-242.1771))))));
+      if(phi< (-1 * pi / 8) && phi> (-2 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0871 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 132.3303))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-166.1833))))));
+      if(phi< (0 * pi / 8) && phi> (-1 * pi / 8))
+	Ecl_corr = Ecl / (1-0.0948 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 127.6780))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-150.0700))))));
+      if(phi< (1 * pi / 8) && phi> (0 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1166 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 172.0679))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-235.3293))))));
+      if(phi< (2 * pi / 8) && phi> (1 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1172 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 190.3524))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-198.9400))))));
+      if(phi< (3 * pi / 8) && phi> (2 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1292 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 158.0540))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-165.3893))))));
+      if(phi< (4 * pi / 8) && phi> (3 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1557 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 162.2793))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-133.5131))))));
+      if(phi< (5 * pi / 8) && phi> (4 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1659 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 180.5270))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-168.5074))))));
+      if(phi< (6 * pi / 8) && phi> (5 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1123 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 128.2277))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-154.4455))))));
+      if(phi< (7 * pi / 8) && phi> (6 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1394 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 192.1216))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-198.0727))))));
+      if(phi< (8 * pi / 8) && phi> (7 * pi / 8))
+	Ecl_corr = Ecl / (1-0.1001 * ((1 / (1 + exp((phi_mod- 2*pi/32.) * 199.1735))) * (1 / (1 + exp((phi_mod- 2*pi/32.) * (-176.4056))))));
     }
-
-    //  Right quarter
-    if(phi < pi / 4. && phi >= -pi / 4.){
-Ecl_corr = Ecl / (1-0.0879 * ((1 / (1 + exp((phi_mod-0.2) * 221.01))) * (1 / (1 + exp((phi_mod-0.2) * (-149.51))))));
+    
+    
+    //  No correction for the EC
+    else{
+      Ecl_corr = Ecl;
     }
-    //  Bottom quarter
-    if(phi < -pi / 4. && phi >= (-3 * pi) / 4.){
-Ecl_corr = Ecl / (1-0.0605 * ((1 / (1 + exp((phi_mod-0.2) * 281.37))) * (1 / (1 + exp((phi_mod-0.2) * (-170.29))))));
+    
+  }
+  
+  else {
+    
+    //  Definitions of module folding into four quarters (top, left, bottom and right)
+    
+    DivInt =  (int) (phi / ((2 * pi) / 16.));
+    double phi_mod = phi - DivInt * (2 * pi / 16.);
+    
+    
+    //  Centring on the intermodule --> phi_mod will now be in [0,0.4]
+    if (phi_mod < 0) phi_mod += pi / 8.;
+    
+    //  The correction concerns only the barrel
+    if(fabs(eta) <= 1.4){
+      
+      //  Top quarter
+      if(phi < (3 * pi) / 4. && phi >= pi / 4.){
+	Ecl_corr = Ecl / (1-0.131 * ((1 / (1 + exp((phi_mod-0.2) * 199.08))) * (1 / (1 + exp((phi_mod-0.2) * (-130.36))))));
+      }
+      
+      //  Right quarter
+      if(phi < pi / 4. && phi >= -pi / 4.){
+	Ecl_corr = Ecl / (1-0.0879 * ((1 / (1 + exp((phi_mod-0.2) * 221.01))) * (1 / (1 + exp((phi_mod-0.2) * (-149.51))))));
+      }
+      //  Bottom quarter
+      if(phi < -pi / 4. && phi >= (-3 * pi) / 4.){
+	Ecl_corr = Ecl / (1-0.0605 * ((1 / (1 + exp((phi_mod-0.2) * 281.37))) * (1 / (1 + exp((phi_mod-0.2) * (-170.29))))));
+      }
+      //  Left quarter
+      if((phi < (-3 * pi) / 4.) || (phi >= (3 * pi) / 4.)){
+	Ecl_corr = Ecl / (1-0.102 * ((1 / (1 + exp((phi_mod-0.2) * 235.37))) * (1 / (1 + exp((phi_mod-0.2) * (-219.04))))));
+      }
     }
-    //  Left quarter
-    if((phi < (-3 * pi) / 4.) || (phi >= (3 * pi) / 4.)){
-Ecl_corr = Ecl / (1-0.102 * ((1 / (1 + exp((phi_mod-0.2) * 235.37))) * (1 / (1 + exp((phi_mod-0.2) * (-219.04))))));
+    
+    //  No correction for the EC
+    else{
+      Ecl_corr = Ecl;
     }
   }
-
-  //  No correction for the EC
-  else{
-    Ecl_corr = Ecl;
-  }
-
+  
   return Ecl_corr;
-
+  
 }
 
-
-
 double EgammaCalibrationAndSmearingTool::correction_phi_unif(double eta, double phi) const
 {
   const double PI = 3.141592653589793;  // TODO: move to M_PI from cmath with #define _USE_MATH_DEFINES
@@ -1169,44 +1272,95 @@ double EgammaCalibrationAndSmearingTool::correction_phi_unif(double eta, double
       else if (phi < (13 * PI / 32.) && phi > (12 * PI / 32.)) { Fcorr -= 0.035; }
     }
   }
+  
+  if ( m_TESModel == egEnergyCorr::es2017_summer_improved ) {
+
+    if(eta < 0.2 && eta > 0.) {
+      if (phi < (-7 * 2 * PI / 32.) && phi > (-8 * 2 * PI / 32.)) { Fcorr = 1.016314; }
+    } 
+    
+    else if (eta < 0.6 && eta > 0.4) {
+      if (phi < 0 && phi > (-2 * PI / 32.)) { Fcorr = 1.041591; }
+      else if (phi < (-4 * 2 * PI / 32.) && phi > (-5 * 2 * PI / 32.)) { Fcorr = 1.067346; }
+    }
+    
+    else if (eta < 0.8 && eta > 0.6) {
+      if (phi < (7 * 2 * PI / 32.) && phi > (6 * 2 * PI / 32.)) { Fcorr = 1.027980; }
+    }
+    
+    else if (eta < 1.4 && eta > 1.2) {
+      if (phi < (-9 * 2 * PI / 32.) && phi > (-10 * 2 * PI / 32.)) { Fcorr = 1.020299; }
+      else if (phi < (-11 * 2 * PI / 32.) && phi > (-12 * 2 * PI / 32.)) { Fcorr = 1.051426; }
+    }
+    
+    else if (eta < 2.3 && eta > 2.1) {
+      if (phi < (-12 * 2 * PI / 32.) && phi > (-13 * 2 * PI / 32.)) { Fcorr = 1.071695; }
+    }
+    
+    else if(eta < 0. && eta > -0.2) {
+      if (phi < (-12 * 2 * PI / 32.) && phi > (-13 * 2 * PI / 32.)) { Fcorr = 1.008227; }
+      else if (phi < (-8 * 2 * PI / 32.) && phi > (-9 * 2 * PI / 32.)) { Fcorr = 1.013929; }
+    }
+    
+    else if(eta < -0.2 && eta > -0.4) {
+      if (phi < (-9 * 2 * PI / 32.) && phi > (-10 * 2 * PI / 32.)) { Fcorr = 1.015749; }
+    }
+    
+    else if(eta < -1.2 && eta > -1.4) {
+      if (phi < (-6 * 2 * PI / 32.) && phi > (-7 * 2 * PI / 32.)) { Fcorr = 1.064954; }
+    }
+    
+    else if (eta < -1.6 && eta > -1.8 ) {
+      if (phi < (9 * 2 * PI / 32.) && phi > (8 * 2 * PI / 32.)) { Fcorr = 1.027448; }
+    }
+    
+    else if(eta < -2.3 && eta > -2.5) {
+      if (phi < (-8 * 2 * PI / 32.) && phi > (-9 * 2 * PI / 32.)) { Fcorr = 1.025882; }
+      else if (phi < (5 * 2 * PI / 32.) && phi > (4 * 2 * PI / 32.)) { Fcorr = 1.036616; }
+      else if (phi < (9 * 2 * PI / 32.) && phi > (8 * 2 * PI / 32.)) { Fcorr = 1.053838; }
+      else if (phi < (10 * 2 * PI / 32.) && phi > (9 * 2 * PI / 32.)) { Fcorr = 1.026856; }
+      else if (phi < (11 * 2 * PI / 32.) && phi > (10 * 2 * PI / 32.)) { Fcorr = 0.994382; }
+    }
+    
+  } // es2017_summer_improved end
+  
+  else{
+    if (eta < 0.6 && eta > 0.4) {
+      if (phi < 0 && phi > (-2 * PI / 32.)) { Fcorr = 1.028; }
+      else if (phi < (-4 * 2 * PI / 32.) && phi > (-5 * 2 * PI / 32.)) { Fcorr = 1.044; }
+    }
 
-  if (eta < 0.6 && eta > 0.4) {
-    if (phi < 0 && phi > (-2 * PI / 32.)) { Fcorr = 1.028; }
-    else if (phi < (-4 * 2 * PI / 32.) && phi > (-5 * 2 * PI / 32.)) { Fcorr = 1.044; }
-  }
-
-  else if (eta < 0.8 && eta > 0.6) {
-    if (phi < (7 * 2 * PI / 32.) && phi > (6 * 2 * PI / 32.)) { Fcorr = 1.022; }
-  }
+    else if (eta < 0.8 && eta > 0.6) {
+      if (phi < (7 * 2 * PI / 32.) && phi > (6 * 2 * PI / 32.)) { Fcorr = 1.022; }
+    }
 
-  else if (eta < 1.4 && eta > 1.2) {
-    if (phi < (-11 * 2 * PI / 32.) && phi > (-12 * 2 * PI / 32.)) { Fcorr = 1.038; }
-  }
+    else if (eta < 1.4 && eta > 1.2) {
+      if (phi < (-11 * 2 * PI / 32.) && phi > (-12 * 2 * PI / 32.)) { Fcorr = 1.038; }
+    }
 
-  else if (eta < 2.0 && eta > 1.9 ) {
-    if (phi < (10 * 2 * PI / 32.) && phi > (9 * 2 * PI / 32.)) { Fcorr = 1.029; }
-  }
+    else if (eta < 2.0 && eta > 1.9 ) {
+      if (phi < (10 * 2 * PI / 32.) && phi > (9 * 2 * PI / 32.)) { Fcorr = 1.029; }
+    }
 
-  else if(eta < -1.2 && eta > -1.4) {
-    if (phi < (-4 * 2 * PI / 32.) && phi > (-5 * 2 * PI / 32.)) { Fcorr = 1.048; }
-    else if (phi < (-6 * 2 * PI / 32.) && phi > (-7 * 2 * PI / 32.)) { Fcorr = 1.048; }
-  }
+    else if(eta < -1.2 && eta > -1.4) {
+      if (phi < (-4 * 2 * PI / 32.) && phi > (-5 * 2 * PI / 32.)) { Fcorr = 1.048; }
+      else if (phi < (-6 * 2 * PI / 32.) && phi > (-7 * 2 * PI / 32.)) { Fcorr = 1.048; }
+    }
 
-  else if (eta < -1.6 && eta > -1.8 ) {
-    if (phi < (9 * 2 * PI / 32.) && phi > (8 * 2 * PI / 32.)) { Fcorr = 1.024; }
-  }
+    else if (eta < -1.6 && eta > -1.8 ) {
+      if (phi < (9 * 2 * PI / 32.) && phi > (8 * 2 * PI / 32.)) { Fcorr = 1.024; }
+    }
 
-  else if(eta < -2.3 && eta > -2.5) {
-    if (phi < (-8 * 2 * PI / 32.) && phi > (-9 * 2 * PI / 32.)) { Fcorr = 1.037; }
-    else if (phi < (5 * 2 * PI / 32.) && phi > (4 * 2 * PI / 32.)) { Fcorr = 1.031; }
-    else if (phi < (9 * 2 * PI / 32.) && phi > (8 * 2 * PI / 32.)) { Fcorr = 1.040; }
-    else if (phi < (10 * 2 * PI / 32.) && phi > (9 * 2 * PI / 32.)) { Fcorr = 1.030; }
-    else if (phi < (11 * 2 * PI / 32.) && phi > (10 * 2 * PI / 32.)) { Fcorr = 1.020; }
+    else if(eta < -2.3 && eta > -2.5) {
+      if (phi < (-8 * 2 * PI / 32.) && phi > (-9 * 2 * PI / 32.)) { Fcorr = 1.037; }
+      else if (phi < (5 * 2 * PI / 32.) && phi > (4 * 2 * PI / 32.)) { Fcorr = 1.031; }
+      else if (phi < (9 * 2 * PI / 32.) && phi > (8 * 2 * PI / 32.)) { Fcorr = 1.040; }
+      else if (phi < (10 * 2 * PI / 32.) && phi > (9 * 2 * PI / 32.)) { Fcorr = 1.030; }
+      else if (phi < (11 * 2 * PI / 32.) && phi > (10 * 2 * PI / 32.)) { Fcorr = 1.020; }
+    }
   }
-
+  
   return Fcorr;
 }
 
-
-
 } // namespace CP
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/GainUncertainty.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/GainUncertainty.cxx
index 22f58ee3b46adab852d3a2c2401776318d4c8576..e5cf54659ae047a8baef6fb266c8a4f129cc62dd 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/GainUncertainty.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/GainUncertainty.cxx
@@ -16,10 +16,8 @@ namespace egGain {
 
 //--------------------------------------
 
-  GainUncertainty::GainUncertainty() : asg::AsgMessaging("GainUncertainty") {
-
-    const std::string filename = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v8/gain_uncertainty_specialRun.root");
-
+  GainUncertainty::GainUncertainty(std::string filename) : asg::AsgMessaging("GainUncertainty") {
+    
     ATH_MSG_INFO("opening file " << filename);
     m_gainFile = CxxUtils::make_unique<TFile>(filename.c_str());
 
@@ -34,7 +32,7 @@ namespace egGain {
      sprintf(name,"gain_Impact_unco_%d",i);
      if (not (m_gain_Impact_unco[i]= (TH1D*)(m_gainFile->Get(name)))) ATH_MSG_FATAL("cannot open histogram5");
     }
-
+    
   }
 
 //----------------------------------------------
@@ -62,7 +60,10 @@ namespace egGain {
        else if (aeta<1.80) ibin=3;
        else if (aeta<2.50) ibin=4;
        if (ibin<0) return 0.;
-
+       
+       //Protection needed as the histograms stops at 1 TeV
+       if(et_input>999999.) et_input = 999999.;
+       
 //       std::cout << " --- in  GainUncertainty::getUncertainty " << etaCalo_input << " " << et_input << " " << ptype << " ibin " << ibin << std::endl;
 
        double impact=0.;
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/e1hg_systematics.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/e1hg_systematics.cxx
index 6ec5509f6b0f8b29eaabe2b74c7c646f4c9f8185..6864be8740e34ae5c1d0782c885272e524609428 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/e1hg_systematics.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/e1hg_systematics.cxx
@@ -81,10 +81,17 @@ double e1hg_systematics::getAlpha(int particle_type, double energy, double eta,
 //   cout << " energy, et , ibinEt " << energyGeV << " " << et << " " << ibinEt << endl;
 
    Double_t scale=0.;
-   if (aeta<1.80) scale=0.;
-   else if (aeta<2.3) scale = 0.050*(aeta-1.8)/0.4 /0.05;
-   else scale=0.025/0.05;
+   //HACK: some ES model dependency needs to be introduced
+   /*Default up to es2017_summer
+     if (aeta<1.80) scale=0.;
+     else if (aeta<2.3) scale = 0.050*(aeta-1.8)/0.4 /0.05;
+     else scale=0.025/0.05;
+   */
 
+   if (aeta<1.80) scale=0.;
+   else if (aeta<2.3) scale = (0.050*(aeta-1.8)/0.4+0.025)/0.05;
+   else scale = 0.05/0.05;
+   
    if( !interpolate ) {
      if (particle_type==0) return scale*m_helec[ieta]->GetBinContent(ibinEt+1);
      else if (particle_type==1) return scale*m_hphot[ieta]->GetBinContent(ibinEt+1);
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/egammaEnergyCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/egammaEnergyCorrectionTool.cxx
index b535a46ee883af49fa51bf5e71d7981d9e73a277..d20d4ee23ae39f1f872c59106963d50558a9ce38 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/egammaEnergyCorrectionTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/Root/egammaEnergyCorrectionTool.cxx
@@ -72,13 +72,13 @@ namespace AtlasRoot {
 
     m_rootFile = nullptr;
 
-    m_rootFileName = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v8/egammaEnergyCorrectionData.root");
-
+    m_rootFileName = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v13/egammaEnergyCorrectionData.root");
+    
     if (m_rootFileName.empty()) {
       ATH_MSG_FATAL("cannot find configuration file");
       throw std::runtime_error("cannot find file");
     }
-
+    
     m_begRunNumber = 0;
     m_endRunNumber = 0;
 
@@ -766,7 +766,7 @@ namespace AtlasRoot {
       m_use_temp_correction201516 = true;
     }
 
-    else if (m_esmodel == egEnergyCorr::es2017) {
+    else if (m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) {//add release 21 here for now
       m_use_etaCalo_scales = true;
       m_use_new_resolution_model = true;
       m_resolution_tool = new eg_resolution("run2_pre");
@@ -777,15 +777,50 @@ namespace AtlasRoot {
       m_daS12Cor     = (TH1D*) m_rootFile->Get("Scales/es2012c/dalphaS12_cor");                 m_daS12Cor->SetDirectory(0);
 
       m_trkSyst      = (TH1D*) m_rootFile->Get("Scales/es2012c/momentum_errSyst");              m_trkSyst->SetDirectory(0);
-
+      
+      if(m_esmodel == egEnergyCorr::es2017){
       m_zeeNom       = (TH1D*) m_rootFile->Get("Scales/es2017/alphaZee_errStat_period_2016");         m_zeeNom->SetDirectory(0);
       m_zeeNom_data2015 = (TH1D*) m_rootFile->Get("Scales/es2017/alphaZee_errStat_period_2015");      m_zeeNom_data2015->SetDirectory(0);
-      m_zeeSyst      = (TH1D*) m_rootFile->Get("Scales/es2017/alphaZee_errSyst");         m_zeeSyst->SetDirectory(0);
+      }
+      else if(m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved){
+	m_zeeNom       = (TH1D*) m_rootFile->Get("Scales/es2017_summer/alphaZee_errStat_period_2016");         m_zeeNom->SetDirectory(0); 
+	m_zeeNom_data2015 = (TH1D*) m_rootFile->Get("Scales/es2017_summer/alphaZee_errStat_period_2015");      m_zeeNom_data2015->SetDirectory(0);
+      }
+      else{
+	m_zeeNom       = (TH1D*) m_rootFile->Get("Scales/es2017_R21_PRE/alphaZee_errStat_period_2016");         m_zeeNom->SetDirectory(0);  
+        //SAME HISTO FOR 2015 FOR NOW
+	m_zeeNom_data2015 = (TH1D*) m_rootFile->Get("Scales/es2017_R21_PRE/alphaZee_errStat_period_2016");      m_zeeNom_data2015->SetDirectory(0);
+      }
+      if(m_esmodel == egEnergyCorr::es2017){
+	m_zeeSyst      = (TH1D*) m_rootFile->Get("Scales/es2017/alphaZee_errSyst");         m_zeeSyst->SetDirectory(0);
+      }
+      //else if(m_esmodel == egEnergyCorr::es2017_summer_improved){
+      //m_zeeSyst      = (TH1D*) m_rootFile->Get("Scales/es2017_summer_improved/alphaZee_errSyst");         m_zeeSyst->SetDirectory(0);
+      //}
+      else{
+	m_zeeSyst      = (TH1D*) m_rootFile->Get("Scales/es2017_summer/alphaZee_errSyst");         m_zeeSyst->SetDirectory(0);
+      }
+      
       m_uA2MeV_2015_first2weeks_correction = nullptr;
-
-      m_resNom       = (TH1D*) m_rootFile->Get("Resolution/es2017/ctZee_errStat");        m_resNom->SetDirectory(0);
-      m_resSyst      = (TH1D*) m_rootFile->Get("Resolution/es2017/ctZee_errSyst");        m_resSyst->SetDirectory(0);
-
+      if(m_esmodel == egEnergyCorr::es2017){
+	m_resNom       = (TH1D*) m_rootFile->Get("Resolution/es2017/ctZee_errStat");        m_resNom->SetDirectory(0);
+      }
+      else if(m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved){
+	m_resNom       = (TH1D*) m_rootFile->Get("Resolution/es2017_summer/ctZee_errStat");        m_resNom->SetDirectory(0);
+      }
+      else{
+	m_resNom       = (TH1D*) m_rootFile->Get("Resolution/es2017_R21_PRE/ctZee_errStat");        m_resNom->SetDirectory(0); 
+      }
+      if(m_esmodel == egEnergyCorr::es2017){
+	m_resSyst      = (TH1D*) m_rootFile->Get("Resolution/es2017/ctZee_errSyst");        m_resSyst->SetDirectory(0);
+      }
+      else{ 
+	m_resSyst      = (TH1D*) m_rootFile->Get("Resolution/es2017_summer/ctZee_errSyst");        m_resSyst->SetDirectory(0);
+      }
+      //else{
+      //m_resSyst      = (TH1D*) m_rootFile->Get("Resolution/es2017_summer_improved/ctZee_errSyst");        m_resSyst->SetDirectory(0);
+      //}
+      
       m_pedestals_es2017 = get_object<TH1F>(*m_rootFile, "Pedestals/es2017/pedestals");          m_pedestals_es2017->SetDirectory(0);
 
       m_dX_ID_Nom    = (TH1D*) m_rootFile->Get("Material/DX0_ConfigA");                         m_dX_ID_Nom->SetDirectory(0);
@@ -802,10 +837,16 @@ namespace AtlasRoot {
       m_dX_PSAcc_LAr = (TH1D*) m_rootFile->Get("Material/Measured/DXerr_PSAcc_NewG_errLAr");    m_dX_PSAcc_LAr->SetDirectory(0);
       m_dX_PSAcc_G4  = (TH1D*) m_rootFile->Get("Material/Measured/DXerr_PSAcc_NewG_errG4");     m_dX_PSAcc_G4->SetDirectory(0);
 
-      m_convRadius            = (TH2D*) m_rootFile->Get("Conversions/es2012c/convRadiusMigrations");  m_convRadius->SetDirectory(0);
-      m_convFakeRate          = (TH1D*) m_rootFile->Get("Conversions/es2012c/convFakeRate");          m_convFakeRate->SetDirectory(0);
-      m_convRecoEfficiency    = (TH1D*) m_rootFile->Get("Conversions/es2012c/convRecoEfficiency");    m_convRecoEfficiency->SetDirectory(0);
-
+      m_convRadius            = (TH1D*) m_rootFile->Get("Conversions/es2012c/convRadiusMigrations");  m_convRadius->SetDirectory(0);
+      if(m_esmodel == egEnergyCorr::es2017){
+	m_convFakeRate          = (TH1D*) m_rootFile->Get("Conversions/es2012c/convFakeRate");          m_convFakeRate->SetDirectory(0);
+	m_convRecoEfficiency    = (TH1D*) m_rootFile->Get("Conversions/es2012c/convRecoEfficiency");    m_convRecoEfficiency->SetDirectory(0);
+      }
+      else{
+	m_convFakeRate          = (TH1D*) m_rootFile->Get("Conversions/es2017_summer/convFakeRate");          m_convFakeRate->SetDirectory(0); 
+        m_convRecoEfficiency    = (TH1D*) m_rootFile->Get("Conversions/es2017_summer/convRecoEfficiency");    m_convRecoEfficiency->SetDirectory(0);
+      }
+      
       // TODO: change path when moving to calibarea
       // TODO: better package this somewhere
 
@@ -860,8 +901,16 @@ namespace AtlasRoot {
       const std::string gain_filename1 = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v8/FunctionsTO.root");
       const std::string gain_filename2 = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v8/FunctionsG_all.root");
       m_gain_tool = nullptr;
-      m_gain_tool_run2 = new egGain::GainUncertainty();
 
+      std::string gain_tool_run_2_filename;
+      if(m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_R21_PRE){
+	gain_tool_run_2_filename = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v11/gain_uncertainty_specialRun.root"); 
+      }
+      else{
+	gain_tool_run_2_filename = PathResolverFindCalibFile("ElectronPhotonFourMomentumCorrection/v12/gain_uncertainty_specialRun.root");
+      }
+      m_gain_tool_run2 = new egGain::GainUncertainty(gain_tool_run_2_filename);
+      
       m_e1hg_tool = new e1hg_systematics();
       m_use_temp_correction201215 = false;
       m_use_temp_correction201516 = false;
@@ -929,7 +978,8 @@ namespace AtlasRoot {
     }
 
     if (m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or
-        m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017)
+        m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017
+	or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE)
     {
       // E4 systematics
       m_E4ElectronEtaBins = get_object<TAxis>(*m_rootFile, "E4Recalibration/v4/electron_eta_axis");
@@ -944,7 +994,8 @@ namespace AtlasRoot {
     // ... PS and S12 recalibration curves
     if (m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or
         m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or
-        m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017) {
+        m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017
+	or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) {
 
       m_psElectronEtaBins =          get_object<TAxis>(*m_rootFile, "PSRecalibration/es2015PRE/ElectronAxis");
       m_psElectronGraphs =           get_object<TList>(*m_rootFile, "PSRecalibration/es2015PRE/ElectronBiasPS");
@@ -1022,7 +1073,7 @@ namespace AtlasRoot {
       m_G4OverAFII_unconverted = (TH1D*) m_rootFile->Get("FastSim/es2015/ph_unconv_scale_full_fast_peak_gaussian"); m_G4OverAFII_unconverted->SetDirectory(0);
       m_G4OverAFII_converted = (TH1D*) m_rootFile->Get("FastSim/es2015/ph_conv_scale_full_fast_peak_gaussian"); m_G4OverAFII_converted->SetDirectory(0);
     }
-    else if (m_esmodel == egEnergyCorr::es2017) {
+    else if (m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) {
       m_G4OverAFII_electron = (TH1D*) m_rootFile->Get("FastSim/es2017/el_scale_full_fast_peak_gaussian"); m_G4OverAFII_electron->SetDirectory(0);
       m_G4OverAFII_unconverted = (TH1D*) m_rootFile->Get("FastSim/es2017/ph_unconv_scale_full_fast_peak_gaussian"); m_G4OverAFII_unconverted->SetDirectory(0);
       m_G4OverAFII_converted = (TH1D*) m_rootFile->Get("FastSim/es2017/ph_conv_scale_full_fast_peak_gaussian"); m_G4OverAFII_converted->SetDirectory(0);
@@ -1033,10 +1084,16 @@ namespace AtlasRoot {
     m_G4OverFrSh            = (TH1D*) m_rootFile->Get("FastSim/hG4OverFS");                 m_G4OverFrSh->SetDirectory(0);
 
     // ... Leakage systematics
-
-    m_leakageConverted      = (TH1D*) m_rootFile->Get("Leakage/LeakageDiffConverted");      m_leakageConverted->SetDirectory(0);
-    m_leakageUnconverted    = (TH1D*) m_rootFile->Get("Leakage/LeakageDiffUnconverted");    m_leakageUnconverted->SetDirectory(0);
-
+    
+    if(m_esmodel != egEnergyCorr::es2017_summer and m_esmodel != egEnergyCorr::es2017_summer_improved and m_esmodel != egEnergyCorr::es2017_R21_PRE){
+      m_leakageConverted      = (TH1D*) m_rootFile->Get("Leakage/LeakageDiffConverted");      m_leakageConverted->SetDirectory(0);
+      m_leakageUnconverted    = (TH1D*) m_rootFile->Get("Leakage/LeakageDiffUnconverted");    m_leakageUnconverted->SetDirectory(0);
+    }
+    else{
+      m_leakageConverted      = (TH1D*) m_rootFile->Get("Leakage/es2017_summer/LeakageDiffConverted");      m_leakageConverted->SetDirectory(0);
+      m_leakageUnconverted    = (TH1D*) m_rootFile->Get("Leakage/es2017_summer/LeakageDiffUnconverted");    m_leakageUnconverted->SetDirectory(0);
+    }
+      
     // ... Zee S2 profile (needed for gain switch syst).
 
     m_zeeES2Profile         = (TH1D*) m_rootFile->Get("ZeeEnergyProfiles/p2MC");    m_zeeES2Profile->SetDirectory(0);
@@ -1171,7 +1228,7 @@ namespace AtlasRoot {
 
     double daE4 = 0., linE4 = 0.;
     // E4 contribution
-    if ((m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017) and
+    if ((m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) and
         (var == egEnergyCorr::Scale::E4ScintillatorUp or var == egEnergyCorr::Scale::E4ScintillatorDown))
     {
       daE4 = getE4Uncertainty(cl_eta);
@@ -1181,7 +1238,7 @@ namespace AtlasRoot {
 
     //wtots1 contribution
     double daWtots1 = 0.;
-    if ((m_esmodel==egEnergyCorr::es2017) and (var == egEnergyCorr::Scale::Wtots1Up or var == egEnergyCorr::Scale::Wtots1Down)){
+    if ((m_esmodel==egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) and (var == egEnergyCorr::Scale::Wtots1Up or var == egEnergyCorr::Scale::Wtots1Down)){
       daWtots1 = getWtots1Uncertainty(cl_eta, energy, ptype);
       if(var == egEnergyCorr::Scale::Wtots1Down)
 	daWtots1 = -daWtots1;
@@ -1731,8 +1788,7 @@ namespace AtlasRoot {
     }
 
     if (fast and std::abs(cl_eta) < 2.5) {
-      if (m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or
-      m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE) {
+      if (m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE or m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE) {
 
         double ratio_IQR_full_fast = 1.;
         const double ptGeV = energy / cosh(cl_eta) / 1E3;
@@ -1868,7 +1924,8 @@ namespace AtlasRoot {
 
     if (m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or
         m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or
-        m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017) {
+        m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017
+	or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) {
       if (ptype == PATCore::ParticleType::Electron) { return getValueHistoAt(*m_G4OverAFII_electron, eta); }
       else if (ptype == PATCore::ParticleType::ConvertedPhoton) { return getValueHistoAt(*m_G4OverAFII_converted, eta); }
       else if (ptype == PATCore::ParticleType::UnconvertedPhoton) { return getValueHistoAt(*m_G4OverAFII_unconverted, eta); }
@@ -1905,7 +1962,7 @@ namespace AtlasRoot {
     int ieta = m_zeeNom->GetXaxis()->FindBin(eta);
     double value = m_zeeNom->GetBinContent(ieta);
 
-    if (m_esmodel==egEnergyCorr::es2017 && runnumber < 297000) {
+    if ((m_esmodel==egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved) && runnumber < 297000) {
       // 2 sets of scales for this configuration
       // change histogram if 2015 data
       int ieta = m_zeeNom_data2015->GetXaxis()->FindBin(eta);
@@ -1969,7 +2026,7 @@ namespace AtlasRoot {
       const double sign = (var == egEnergyCorr::Scale::ZeeStatUp) ? 1 : -1;
 
       const TH1* h = m_zeeNom;
-      if (m_esmodel == egEnergyCorr::es2017 && runnumber < 297000) h = m_zeeNom_data2015; // special for 2015 with es2017
+      if ((m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved) && runnumber < 297000) h = m_zeeNom_data2015; // special for 2015 with es2017
       double stat_error = h->GetBinError(h->FindFixBin(eta));
 	    if (m_use_stat_error_scaling) {
         stat_error = stat_error / sqrt(h->GetNbinsX());
@@ -2174,26 +2231,47 @@ namespace AtlasRoot {
       else if (var == egEnergyCorr::Scale::S12Down && m_aS12Nom) { value = -m_aS12Nom->GetBinError(m_aS12Nom->FindBin(cl_eta)); }
       else if (var == egEnergyCorr::Scale::LArCalibUp && m_daS12Cor) { value = m_daS12Cor->GetBinContent(m_daS12Cor->FindBin(cl_eta)); }
       else if (var == egEnergyCorr::Scale::LArCalibDown && m_daS12Cor) { value = -m_daS12Cor->GetBinContent( m_daS12Cor->FindBin(cl_eta)); }
-      else if (var == egEnergyCorr::Scale::LArCalibExtra2015PreUp and
-               (m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or
-                m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or
-                m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017)) {
-	      // special case for es2015PRE and also for es2015c_summer and also for es2017
-	      // numbers from Lydia and Christophe,
-	      // https://indico.cern.ch/event/395345/contribution/2/material/slides/0.pdf
-	      // assuming constant uncertainty
-	      value = 1.5E-2;
+      else if (var == egEnergyCorr::Scale::LArCalibExtra2015PreUp and 
+	       (m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or
+		m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or
+		m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017
+		or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE)) { 
+	// special case for es2015PRE and also for es2015c_summer and also for es2017
+	// numbers from Lydia and Christophe,
+	// https://indico.cern.ch/event/395345/contribution/2/material/slides/0.pdf
+	// assuming constant uncertainty
+	// es2017_summer: increased to 5% in the endcap
+	const double aeta = std::abs(cl_eta); 
+	//endcap
+	if ( aeta >= 1.37 and aeta < 2.5){
+	  if ( m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) value = 5.0E-2;
+	  else value = 1.5E-2;
+	}
+	else{//barrel
+	  if (m_esmodel == egEnergyCorr::es2017_summer_improved) value = 2.5E-2;
+	  else value = 1.5E-2;
+	}
       }
       else if (var == egEnergyCorr::Scale::LArCalibExtra2015PreDown and
                (m_esmodel == egEnergyCorr::es2015PRE or m_esmodel == egEnergyCorr::es2015PRE_res_improved or
                 m_esmodel == egEnergyCorr::es2015cPRE or m_esmodel == egEnergyCorr::es2015cPRE_res_improved or
-                m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017)) {
-	      value = -1.5E-2;
+                m_esmodel == egEnergyCorr::es2015c_summer or m_esmodel == egEnergyCorr::es2016PRE or m_esmodel == egEnergyCorr::es2017
+		or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE)) {
+	const double aeta = std::abs(cl_eta);  
+        //endcap 
+        if ( aeta >= 1.37 and aeta < 2.5){ 
+          if ( m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) value = -5.0E-2; 
+          else value = -1.5E-2; 
+        } 
+        else{//barrel 
+          if (m_esmodel == egEnergyCorr::es2017_summer_improved) value = -2.5E-2; 
+          else value = -1.5E-2; 
+        } 
       }
-
+      
       else if (var == egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Up or var == egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Down) {
         // special large sys for run2 in the last eta-bin in es2017, see ATLASEG-42
-        if (m_esmodel == egEnergyCorr::es2017) {
+        if (m_esmodel == egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE) {
 	  const double aeta = std::abs(cl_eta);
 	  if (aeta >= 2.4 and aeta < 2.5) {
 	    if (var == egEnergyCorr::Scale::S12ExtraLastEtaBinRun2Up) value = 25E-2;
@@ -2655,6 +2733,11 @@ namespace AtlasRoot {
 	alpha = delta / (energy / cosh(cl_eta));
 	if (var == egEnergyCorr::Scale::PedestalDown) alpha *= -1;
       }
+      else if(m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved or m_esmodel == egEnergyCorr::es2017_R21_PRE){
+	//Et uncertainty band: 10 MeV for the corrected cluster
+	alpha = 10. / (energy / cosh(cl_eta));
+	if (var == egEnergyCorr::Scale::PedestalDown) alpha *= -1;
+      }
       else {
 	// observed pedestal corrected as a systematic on MC for now.
 	// TODO : correct for it in the data
@@ -2868,7 +2951,7 @@ namespace AtlasRoot {
 	}
 
 	// systematics from material in IBL+PP0 for barrel
-	if (isys==7 && fabs(eta)<1.5  && m_esmodel==egEnergyCorr::es2017) {
+	if (isys==7 && fabs(eta)<1.5  && (m_esmodel==egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved)) {
 	  double  sigmaE = m_getMaterialDelta->getDelta(particle_type,energy,eta,1,5);
 	  sigma2 = sigmaE*sigmaE;
 	  sigma2up = sigma2;
@@ -2877,7 +2960,7 @@ namespace AtlasRoot {
 	}
 
 	// systematics from material in IBL+PP0 for end-cap
-	if (isys==8 && fabs(eta)>1.5 && m_esmodel==egEnergyCorr::es2017) {
+	if (isys==8 && fabs(eta)>1.5 && (m_esmodel==egEnergyCorr::es2017 or m_esmodel == egEnergyCorr::es2017_summer or m_esmodel == egEnergyCorr::es2017_summer_improved)) {
 	  double sigmaE =  m_getMaterialDelta->getDelta(particle_type,energy,eta,1,5);
 	  // scale factor 2.3 in X0 => sqrt(2) in resolution or 2 in resolution**2
 	  sigma2 = 2.3*sigmaE*sigmaE;
@@ -2901,8 +2984,9 @@ namespace AtlasRoot {
 
 // use average of up and down for symmetric uncertainty for All
 
-        double rr1 = sqrt(resolution2+sigma2up);   // nominal (data) + up error
-        double rr2=0.;
+	double rr1=0.;
+	if((resolution2+sigma2up)>0.) rr1 = sqrt(resolution2+sigma2up);   // nominal (data) + up error
+	double rr2=0.;
         if((resolution2+sigma2down) > 0.) rr2 = sqrt(resolution2+sigma2down);  // max(0, nominal (data) + down error
         double deltaSigma_sys;
         deltaSigma_sys = 0.5*(rr1-rr2);        // average of up and down uncertainties
@@ -2918,8 +3002,8 @@ namespace AtlasRoot {
 	if ((resolution2+sigma2down)>0.) rr2=sqrt(resolution2+sigma2down);
 	else rr2=0.;
 	double deltaSigmaDown = (rr2-resolution)/resolution;
-
 	//std::cout << " relative resolution change Down " << deltaSigmaDown << std::endl;
+	
 	sum_deltaUp += deltaSigmaUp;
 	sum_deltaDown += deltaSigmaDown;
 
@@ -2933,9 +3017,9 @@ namespace AtlasRoot {
     resolution_error_up = sum_deltaUp*resolution;
     resolution_error_down = sum_deltaDown*resolution;
 
-
+    
     //std::cout << " Resolution (MeV): " << resolution << "   Resolution Error (MeV): " << resolution_error
-    //  << " Z smearing " << smearingZ << " +- " << esmearingZ << std::endl;
+    //	      << " Z smearing " << smearingZ << " +- " << esmearingZ << std::endl;
 
   }
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/share/dumpAllSystematics.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/share/dumpAllSystematics.py
index 8fdc6bf8d47a64f8954609ec250f1a1ca26d3de6..ad156e32a95760c9c1e23a8209a72dd8a2667a54 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/share/dumpAllSystematics.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/share/dumpAllSystematics.py
@@ -5,7 +5,7 @@ from AthenaCommon import CfgMgr
 
 import cppyy
 try :
-    cppyy.loadDictionary("ElectronPhotonFourMomentumCorrectionDict")
+    cppyy.loadDictionary("EgammaAnalysisInterfacesDict")
 except :
     pass
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/CalibratedEgammaProvider.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/CalibratedEgammaProvider.h
index 16490c5aca9ca17af4c2cb9207f84887f058ba6c..8876bad77329f13f27c3d375d1e2272f457b2058 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/CalibratedEgammaProvider.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/CalibratedEgammaProvider.h
@@ -15,8 +15,7 @@
 #include "AsgTools/ToolHandle.h"
 
 // Local include(s):
-#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h"
-
+#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
 #include "xAODCore/ShallowCopy.h"
 
 #include "xAODEgamma/ElectronContainer.h" 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/dumpAllSystematics.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/dumpAllSystematics.h
index c3afb17b5120fc4b53fa2e3055b787c02adff9e4..c99ef08367ad8b6f22dea9213a03443250d24455 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/dumpAllSystematics.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/dumpAllSystematics.h
@@ -17,7 +17,7 @@
 #include "TTree.h"
 
 // Local include(s):
-#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h"
+#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
 
 class DumpAllSystematics : public AthAlgorithm {
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/testAthenaEgammaCalibTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/testAthenaEgammaCalibTool.h
index 221d3c9d254a63ccb5253cf07bcb6b8650ae9fc4..a4b217e79fb17098a50066d6e1d0d6a3982b897f 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/testAthenaEgammaCalibTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/src/testAthenaEgammaCalibTool.h
@@ -12,7 +12,7 @@
 #include "AsgTools/ToolHandle.h"
 
 // Local include(s):
-#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h"
+#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
 
 class testAthenaEgammaCalibTool : public AthAlgorithm {
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/test/ut_test_resolution.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/test/ut_test_resolution.py
index e3145c8705dd5b9bc596a5e8812668a3eaa801c4..453bc56dd33c2d84b88c14db5cf61e323515f6ce 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/test/ut_test_resolution.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/test/ut_test_resolution.py
@@ -92,7 +92,9 @@ class TestEgammaResolution(unittest.TestCase):
                                                   msg="resolution should be different for particle=%d, eta=%f, e=%d, rtype=%d" % (ptype, eta, e, t))
 
     def test_nonregression_run1(self):
-        f = ROOT.TFile("$ROOTCOREBIN/data/ElectronPhotonFourMomentumCorrection/test_resolution_nonregression_run1_data.root")
+        from PathResolver import PathResolver
+        rootfile = PathResolver.FindCalibFile("ElectronPhotonFourMomentumCorrection/v8/test_resolution_nonregression_run1_data.root")
+        f = ROOT.TFile(rootfile)
         tree = f.Get("test_resolution_nonregression_data_run1")
 
         for ievent in xrange(tree.GetEntries()):
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/util/testEgammaCalibTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/util/testEgammaCalibTool.cxx
index 56c41166796038528384250a868d641b8b8a9093..95f7e6ea9cb64ab96e62837616cd72f58321387e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/util/testEgammaCalibTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/util/testEgammaCalibTool.cxx
@@ -96,7 +96,7 @@ int main( int argc, char* argv[] ) {
 
    // Create the tool
    std::unique_ptr<CP::IEgammaCalibrationAndSmearingTool> tool(new CP::EgammaCalibrationAndSmearingTool("EgammaCalibrationAndSmearingTool"));
-   asg::setProperty(tool.get(), "ESModel", "es2016data_mc15c");
+   asg::setProperty(tool.get(), "ESModel", "es2017_R21_PRE");
    asg::setProperty(tool.get(), "randomRunNumber", 123456);
    RETURN_CHECK(APP_NAME, tool->initialize());
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/CMakeLists.txt
index 23162eb99899b03dda04b4bd0ee8eb21b56d087e..553a3411410edabcb7cc58d4065e46935d59ac66 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 790746 2016-12-21 14:00:25Z ludovica $
 ################################################################################
 # Package: ElectronPhotonSelectorTools
 ################################################################################
@@ -22,12 +21,14 @@ atlas_depends_on_subdirs(
   Event/xAOD/xAODTracking
   Reconstruction/MVAUtils
   PhysicsAnalysis/AnalysisCommon/PATCore
+  PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces
   PRIVATE
   Control/CxxUtils
   Event/FourMomUtils
   Event/xAOD/xAODHIEvent
   Event/xAOD/xAODCaloEvent
   Event/xAOD/xAODCore
+  Event/xAOD/xAODEventInfo
   Tools/PathResolver
   ${extra_dep} )
 
@@ -39,9 +40,9 @@ atlas_add_library( ElectronPhotonSelectorToolsLib
   ElectronPhotonSelectorTools/*.h Root/*.cxx
   PUBLIC_HEADERS ElectronPhotonSelectorTools
   PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-  LINK_LIBRARIES AsgTools xAODEgamma xAODTracking xAODHIEvent PATCoreLib
+  LINK_LIBRARIES EgammaAnalysisInterfacesLib AsgTools xAODEgamma  xAODTracking xAODHIEvent PATCoreLib
   PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} CxxUtils FourMomUtils
-  xAODCaloEvent xAODCore PathResolver MVAUtils )
+  xAODCaloEvent xAODCore xAODEventInfo PathResolver MVAUtils )
 
 if( NOT XAOD_STANDALONE )
    atlas_add_component( ElectronPhotonSelectorTools
@@ -71,10 +72,10 @@ if( XAOD_STANDALONE )
       LINK_LIBRARIES ${ROOT_LIBRARIES} xAODCore xAODEgamma CxxUtils AsgTools
       xAODRootAccess ElectronPhotonSelectorToolsLib )
 
-   atlas_add_executable( EGIdentification_testEMAmbiguityResolver
-      util/testEMAmbiguityResolver.cxx
+   atlas_add_executable( EGIdentification_testEGChargeIDSelector
+      util/testEGChargeIDSelector.cxx
       INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-      LINK_LIBRARIES ${ROOT_LIBRARIES} xAODEgamma AsgTools xAODRootAccess
+      LINK_LIBRARIES ${ROOT_LIBRARIES} xAODEgamma AsgTools xAODRootAccess 
       ElectronPhotonSelectorToolsLib )
 
    atlas_add_executable( EGIdentification_testEGChargeIDSelector
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgDeadHVCellRemovalTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgDeadHVCellRemovalTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..95f0c1460be995a851546ab514369b8f14024c83
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgDeadHVCellRemovalTool.h
@@ -0,0 +1,43 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// Dear emacs, this is -*-c++-*-
+#ifndef __ASGDEADHVCELLREMOVALTOOL__
+#define __ASGDEADHVCELLREMOVALTOOL__
+
+#include "EgammaAnalysisInterfaces/IAsgDeadHVCellRemovalTool.h"
+#include "AsgTools/AsgTool.h"
+#include "xAODEgamma/EgammaFwd.h"
+
+class AsgDeadHVCellRemovalTool : public asg::AsgTool,
+				 virtual public IAsgDeadHVCellRemovalTool
+{
+  ASG_TOOL_CLASS2(AsgDeadHVCellRemovalTool, 
+		  IAsgDeadHVCellRemovalTool,
+		  asg::IAsgTool)
+
+public: 
+  /** Standard constructor */
+  AsgDeadHVCellRemovalTool(std::string myname);
+
+  /** Standard destructor */
+  virtual ~AsgDeadHVCellRemovalTool();
+
+  /** Gaudi Service Interface method implementations */
+  virtual StatusCode initialize();
+
+  /** Gaudi Service Interface method implementations */
+  virtual StatusCode finalize();
+
+  virtual bool accept( const xAOD::Egamma* eg ) const final;
+
+  /** Accept using reference **/
+  virtual bool accept( const xAOD::Egamma& part ) const final ;
+
+private:
+
+}; // End: class definition
+
+#endif
+
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h
index c403ee84ec76cc97ce3f5bb13852dcf3daa1d5ce..01923da93d62c034b66a0eb8319705bc67642cf0 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h
@@ -4,12 +4,12 @@
 
 // Dear emacs, this is -*-c++-*-
 
-#ifndef __ASGELECTRONCHARGEIDSELECTORTOOL__
-#define __ASGELECTRONCHARGEIDSELECTORTOOL__
+#ifndef ELECTRONPHOTONSELECTORTOOLS_ASGELECTRONCHARGEIDSELECTORTOOL_H
+#define ELECTRONPHOTONSELECTORTOOLS_ASGELECTRONCHARGEIDSELECTORTOOL_H
 // Atlas includes
 #include "AsgTools/AsgTool.h"
 #include "MVAUtils/BDT.h"
-#include "ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
 #include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
 #include <unordered_map>
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h
index 447751b6083bb6110ce0ab17a7ade05c72c8abc2..e019cf137afcb192e7b1bc222fc01803d8cdac59 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h
@@ -24,9 +24,10 @@
 #include "AsgTools/AsgTool.h"
 
 // Include the interfaces
-#include "ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h"
-// Include the return object and the underlying ROOT tool
+#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
+
 #include "PATCore/TAccept.h"
+
 #include <string>
 
 namespace Root{
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h
index 4ed3639f6c3fb80850d57e76412f5aba8d48f79c..217b35fdd9e7b7d71cb4b70b0aa3f4417f515c5a 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h
@@ -10,7 +10,7 @@
 
 // Atlas includes
 #include "AsgTools/AsgTool.h"
-#include "ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
 #include "xAODEgamma/ElectronFwd.h"
 #include "PATCore/TAccept.h"            // for TAccept
 #include "PATCore/TResult.h"            // for TResult
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronMultiLeptonSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronMultiLeptonSelector.h
index 145c74a3188a942a0bb84525e0df173707efc84c..f7aa2b9b2944418ef0545abff8c14f132dd06ad9 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronMultiLeptonSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgElectronMultiLeptonSelector.h
@@ -20,7 +20,7 @@
 
 // Atlas includes
 #include "AsgTools/AsgTool.h"
-#include "ElectronPhotonSelectorTools/IAsgElectronMultiLeptonSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronMultiLeptonSelector.h"
 
 // Include the return object and ROOT tool
 #include "PATCore/TAccept.h"
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h
index 026f90b670c4607cea884bd8797327957ec397fa..8bde35a92c0ba336c28fc14b29fccd1543fb7573 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h
@@ -24,9 +24,10 @@
 #include "AsgTools/AsgTool.h"
 
 // Include the interfaces
-#include "ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h"
-// Include the return object and the underlying ROOT tool
+#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
+
 #include "PATCore/TAccept.h"
+
 #include <string>
 
 namespace Root{
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h
index 1274a539a9d85f528d2263a452318f7d040bb605..9f7db442eff7626c51a548620e1e2e96ae239a06 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h
@@ -23,7 +23,7 @@
 #include "AsgTools/AsgTool.h"
 
 // Include the interfaces
-#include "ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
 #include "xAODEgamma/PhotonFwd.h"
 #include "xAODEgamma/EgammaFwd.h"
 #include "xAODEgamma/ElectronFwd.h"
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/EGammaAmbiguityTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/EGammaAmbiguityTool.h
index 26e93ee33561abf551a6f62488c070d8b473d9b1..fca0500523649e1bc784af95c68375cdd61997db 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/EGammaAmbiguityTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/EGammaAmbiguityTool.h
@@ -17,7 +17,7 @@
 
 // Atlas includes
 #include "AsgTools/AsgTool.h"
-#include "ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h"
+#include "EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h"
 #include "xAODEgamma/EgammaContainerFwd.h"
 
 class EGammaAmbiguityTool : public asg::AsgTool,
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsCoreDict.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsCoreDict.h
index 346c538d8ef6a1513942783f29d25c7eb0d6bd4c..43757494d432d5af4058cbbbff56f28396b56d56 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsCoreDict.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsCoreDict.h
@@ -8,6 +8,6 @@
 #define __ELECTRONPHOTONSELECTORTOOLSCOREDICT__
 
 #include "ElectronPhotonSelectorTools/egammaPIDdefs.h" 
-#include "ElectronPhotonSelectorTools/LikelihoodEnums.h" //For the LikelihoodEnums
+#include "ElectronPhotonSelectorTools/LikelihoodEnums.h" 
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsDict.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsDict.h
deleted file mode 100644
index fe9afcada0f6bc4b9c94fd0c3271af9996b7970e..0000000000000000000000000000000000000000
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsDict.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// Dear emacs, this is -*-c++-*-
-
-#ifndef __ELECTRONPHOTONSELECTORTOOLSDICT__
-#define __ELECTRONPHOTONSELECTORTOOLSDICT__
-
-/**
-   @brief For dictionary generation.
-
-   @author Tulay Cuhadar Donszelmann, Jovan Mitrevski
-   @date   September 2011
-
-*/
-
-#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
-#include "ElectronPhotonSelectorTools/LikelihoodEnums.h" //For the LikelihoodEnums
-// for python
-#include "ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgElectronMultiLeptonSelector.h"
-#include "ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
-#include "ElectronPhotonSelectorTools/EGammaAmbiguityTool.h"
-#include "ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h"
-
-#endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsPythonDict.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsPythonDict.h
index 0a1858028f0a141ebf7509ccab73f4e747edec37..809b4c30819790de7964f8083b12140996000177 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsPythonDict.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronPhotonSelectorToolsPythonDict.h
@@ -2,8 +2,8 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-#ifndef __ELECTRONPHOTONSELECTORTOOLSPYTHONDICT__
-#define __ELECTRONPHOTONSELECTORTOOLSPYTHONDICT__
+#ifndef ELECTRONPHOTONSELECTORTOOLS_ELECTRONPHOTONSELECTORTOOLPYTHONDICT_H
+#define ELECTRONPHOTONSELECTORTOOLS_ELECTRONPHOTONSELECTORTOOLPYTHONDICT_H
 
 // for python
 #include "ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h"
@@ -13,4 +13,5 @@
 #include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
 #include "ElectronPhotonSelectorTools/EGammaAmbiguityTool.h"
 #include "ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h"
+#include "ElectronPhotonSelectorTools/AsgDeadHVCellRemovalTool.h"
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronSelectorHelpers.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronSelectorHelpers.h
index d211622407ed08e212525516969c5bb62089df0d..868f695bb935483ed347c51efb2ce4961620bb8f 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronSelectorHelpers.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/ElectronSelectorHelpers.h
@@ -12,6 +12,8 @@
 #include "xAODTracking/TrackParticleFwd.h"
 #include <cstddef>
 
+#include "EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h"
+
 namespace ElectronSelectorHelpers{
   ///@brief return the number of Pixel hits plus dead sensors in the track particle
   std::size_t numberOfPixelHitsAndDeadSensors(const xAOD::TrackParticle *tp);
@@ -27,6 +29,10 @@ namespace ElectronSelectorHelpers{
   //        to innermost layer. If both are off, then return true)
   bool passBLayerRequirement(const xAOD::TrackParticle *tp);
 
+  ///@brief return true if the ambiguity type is one of several that are stored in a bitmask
+  bool passAmbiguity(xAOD::AmbiguityTool::AmbiguityType type, const uint8_t criterion);
+
+  struct ROOT6_NamespaceAutoloadHook{};
 }
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgDeadHVCellRemovalTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgDeadHVCellRemovalTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..636692d2dcfe6e94fab0f4e7f37ea7c36706a26a
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgDeadHVCellRemovalTool.h
@@ -0,0 +1,13 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// Dear emacs, this is -*-c++-*-
+#ifndef __IASGDEADHVCELLREMOVALTOOL__
+#define __IASGDEADHVCELLREMOVALTOOL__
+
+#include "EgammaAnalysisInterfaces/IAsgDeadHVCellRemovalTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
+
+#endif
+
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h
index 22f289f95041341e98633b360eb1144cd4d0a384..757e3e627b504086b4459568ff6b8179a25439e2 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h
@@ -7,59 +7,8 @@
 #ifndef __IASGEGAMMAISEMSELECTOR__
 #define __IASGEGAMMAISEMSELECTOR__
 
-/**
-   @class IAsgEGammaIsEMSelector
-   @brief Interface to tool to select photons
-
-   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
-   @date   Dec 2011 - Fab 2012
-
-   11-MAR-2014, convert to ASGTool
-*/
-
-// Include the interfaces
-#include "PATCore/IAsgSelectionTool.h"
-#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
-
-// Forward declarations
-namespace Root{
-  class TAccept;
-}
-#include "xAODEgamma/EgammaFwd.h"
-#include "xAODEgamma/PhotonFwd.h"
-#include "xAODEgamma/ElectronFwd.h"
-
-class IAsgEGammaIsEMSelector : virtual public IAsgSelectionTool
-{
-
-  ASG_TOOL_INTERFACE(IAsgEGammaIsEMSelector)
-
-public:
-
-  /**Virtual Destructor*/
-  virtual ~IAsgEGammaIsEMSelector() {};
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
-
-  /////Egammma IsEM specific methods
-
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
-
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
-
-  virtual unsigned int IsemValue() const =0;
-
-  /** Method to get the operating point */
-  virtual std::string getOperatingPointName( ) const =0;
- 
-}; // End: class definition
-
+#include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h
index 4681916939452e9d5b397461653cab17fb06e1f4..79d4556e8453cee72672a61cf02f83f9868cc1b4 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h
@@ -7,79 +7,8 @@
 #ifndef __IASGELECTRONISEMSELECTOR__
 #define __IASGELECTRONISEMSELECTOR__
 
-/**
-   @class IAsgElectronIsEMSelector
-   @brief Interface to tool to select electrons
-
-   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
-   @date   Dec 2011 - Fab 2012
-
-   11-MAR-2014, convert to ASGTool
-*/
-
-// Include the interfaces
-#include "PATCore/IAsgSelectionTool.h"
-#include "ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
-// Forward declarations
-namespace Root{
-  class TAccept;
-}
-#include "xAODEgamma/ElectronFwd.h"
-#include "xAODEgamma/PhotonFwd.h"
-#include "xAODEgamma/EgammaFwd.h"
-
-class IAsgElectronIsEMSelector : virtual public IAsgEGammaIsEMSelector
-{
-
-  ASG_TOOL_INTERFACE(IAsgElectronIsEMSelector)
-  
-  public:
-
-  /**Virtual Destructor*/
-  virtual ~IAsgElectronIsEMSelector() {};
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
-  
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
-
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
-
-  /** Accept with Photon objects */
-  virtual const Root::TAccept& accept( const xAOD::Photon* part ) const = 0;
-
-  /** Accept with Photon objects */
-  virtual const Root::TAccept& accept( const xAOD::Photon& part ) const = 0;
-
-  /** Accept with Electron objects */
-  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
-
-  /** Accept with Electron objects */
-  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
-
-
-  ///////////////Expert methods //////////////////////////////////////
-
-  
-  //The main execute method
-  virtual StatusCode execute(const xAOD::Egamma* eg) const =0;
-
-  //////////////////////////////////////////////////////////////
-  virtual unsigned int IsemValue() const = 0;
-  
-  /** Method to get the operating point */
-  virtual std::string getOperatingPointName( ) const =0;
-
-
-
-}; // End: class definition
-
+#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h
index 261caf3a2d76c4488b813a0bbc92c9eb8e846e14..5955935ff6a68772297b795ff9123129445ae4ae 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h
@@ -2,101 +2,11 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-// Dear emacs, this is -*-c++-*-
-
 #ifndef __IASGELECTRONLIKELIHOODSELECTOR__
 #define __IASGELECTRONLIKELIHOODSELECTOR__
 
-/**
-   @class IAsgElectronLikelihoodTool
-   @brief Interface to tool to select electrons
-
-   12-MAR-2014, convert to ASG tool
-
-*/
-
-// CONSIDER MERGING THIS WITH IASGELECTRONMULTILEPTONSELECTOR, SINCE THE INTERFACE
-// IS EXACTLY THE SAME. LEAVING THEM SEPERATE FOR NOW IN CASE THEY DIVERGE
-
-// Include the interfaces
-#include "PATCore/IAsgSelectionTool.h"
-// Forward declarations
-namespace Root{
-  class TAccept;
-  class TResult;
-}
-#include "xAODEgamma/ElectronFwd.h"
-#include "xAODEgamma/EgammaFwd.h"
-
-class IAsgElectronLikelihoodTool : virtual public IAsgSelectionTool
-{
-
-  ASG_TOOL_INTERFACE(IAsgElectronLikelihoodTool)
-
-  public:
-
-  /**Virtual Destructor*/
-  virtual ~IAsgElectronLikelihoodTool() {};
-
-
-  /** The main accept method: using the generic interface , with pointers*/
-  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Egamma* part ) const = 0;
-
-  /** The main accept method: in case mu not in EventInfo online */
-  virtual const Root::TAccept& accept( const xAOD::Electron* part, double mu ) const = 0;
-
-  /** The main accept method: in case mu not in EventInfo online */
-  virtual const Root::TAccept& accept( const xAOD::Egamma* part, double mu ) const = 0;
-
-
-  /** The main accept method: using the generic interface, with reference */
-  virtual const Root::TAccept& accept( const xAOD::IParticle& part) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Egamma& part ) const = 0;
-
-  /** The main accept method: in case mu not in EventInfo online */
-  virtual const Root::TAccept& accept( const xAOD::Electron& part, double mu ) const = 0;
-
-  /** The main accept method: in case mu not in EventInfo online */
-  virtual const Root::TAccept& accept( const xAOD::Egamma& part, double mu ) const = 0;
-
-
-  /** The main result method: the actual likelihood is calculated here */
-  virtual const Root::TResult& calculate( const xAOD::IParticle* part ) const = 0;
-
-  /** The main result method: the actual likelihood is calculated here */
-  virtual const Root::TResult& calculate( const xAOD::Electron* eg ) const = 0;
-
-  /** The main result method: the actual likelihood is calculated here */
-  virtual const Root::TResult& calculate( const xAOD::Egamma* eg ) const = 0;
-
-  /** The main result method: in case mu not in EventInfo online */
-  virtual const Root::TResult& calculate( const xAOD::Electron* eg, double mu ) const = 0;
-
-  /** The main result method: in case mu not in EventInfo online */
-  virtual const Root::TResult& calculate( const xAOD::Egamma* eg, double mu ) const = 0;
-
-
-  /** Method to get the plain TResult */
-  virtual const Root::TResult& getTResult( ) const=0;
-
-  /** Method to get the operating point */
-  virtual std::string getOperatingPointName( ) const =0;
-
-  //virtual const Root::TAccept& getTAccept( ) const =0; // in base
-
-}; // End: class definition
-
+#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronMultiLeptonSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronMultiLeptonSelector.h
index 88ec591fecbdd5428c2e52470f89bb4e4329770e..8d0b4c4495e23ac4703bb95212cc2c982ead8300 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronMultiLeptonSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgElectronMultiLeptonSelector.h
@@ -7,46 +7,8 @@
 #ifndef __IASGELECTRONMULTILEPTONSELECTOR__
 #define __IASGELECTRONMULTILEPTONSELECTOR__
 
-/**
-   @class IAsgElectronMultiLeptonSelector
-   @brief Interface to tool to select electrons
-
-   12-MAR-2014, convert to ASG tool
-
-*/
-// Include the interfaces
-#include "PATCore/IAsgSelectionTool.h"
-// Forward declarations
-namespace Root{
-  class TAccept;
-}
-#include "xAODEgamma/ElectronFwd.h"
-
-class IAsgElectronMultiLeptonSelector : virtual public IAsgSelectionTool
-{
-
-  ASG_TOOL_INTERFACE(IAsgElectronMultiLeptonSelector)
-
-public:
-
-  /**Virtual Destructor*/
-  virtual ~IAsgElectronMultiLeptonSelector() {};
-
-  /** The main accept method: using the generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
-  /** The main accept method: using the generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
-
-  /** Method to get the operating point */
-  virtual std::string getOperatingPointName( ) const=0;
-
-}; // End: class definition
+#include "EgammaAnalysisInterfaces/IAsgElectronMultiLeptonSelector.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h
index 9529b301f1b40452789a1fe954a965b3f1231ccd..f07a46f8a3c3492241bd4e592706822a7a5399f1 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h
@@ -7,81 +7,8 @@
 #ifndef __IASGFORWARDELECTRONISEMSELECTOR__
 #define __IASGFORWARDELECTRONISEMSELECTOR__
 
-/**
-   @class IAsgForwardElectronIsEMSelector
-   @brief Interface to tool to select electrons
-
-   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
-   @date   Dec 2011 - Fab 2012
-
-   11-MAR-2014, convert to ASGTool
-*/
-
-// Include the interfaces
-#include "PATCore/IAsgSelectionTool.h"
-#include "ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h"
-// Include the return object and the underlying ROOT tool
-#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
-
-// Forward declarations
-namespace Root{
-  class TAccept;
-}
-#include "xAODEgamma/ElectronFwd.h"
-#include "xAODEgamma/PhotonFwd.h"
-#include "xAODEgamma/EgammaFwd.h"
-
-class IAsgForwardElectronIsEMSelector : virtual public IAsgEGammaIsEMSelector
-{
-
-  ASG_TOOL_INTERFACE(IAsgForwardElectronIsEMSelector)
-  
-  public:
-
-  /**Virtual Destructor*/
-  virtual ~IAsgForwardElectronIsEMSelector() {};
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
-  
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
-
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
-
-  /** Accept with Photon objects */
-  virtual const Root::TAccept& accept( const xAOD::Photon* part ) const = 0;
-
-  /** Accept with Photon objects */
-  virtual const Root::TAccept& accept( const xAOD::Photon& part ) const = 0;
-
-  /** Accept with Electron objects */
-  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
-
-  /** Accept with Electron objects */
-  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
-
-
-  ///////////////Expert methods //////////////////////////////////////
-
-  
-  //The main execute method
-  virtual StatusCode execute(const xAOD::Egamma* eg) const =0;
-
-  //////////////////////////////////////////////////////////////
-  virtual unsigned int IsemValue() const = 0;
-  
-  /** Method to get the operating point */
-  virtual std::string getOperatingPointName( ) const =0;
-
-
-
-}; // End: class definition
-
+#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h
index 016a29d67250290db7ba47aee23abe3e12fe0edc..b46ec975a4d22221611784a4c9256e6b72ca81a4 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h
@@ -7,74 +7,8 @@
 #ifndef __IASGPHOTONISEMSELECTOR__
 #define __IASGPHOTONISEMSELECTOR__
 
-/**
-   @class IAsgPhotonIsEMSelector
-   @brief Interface to tool to select photons
-
-   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
-   @date   Dec 2011 - Fab 2012
-
-   11-MAR-2014, convert to ASGTool
-*/
-
-// Include the interfaces
-#include "PATCore/IAsgSelectionTool.h"
-#include "ElectronPhotonSelectorTools/IAsgEGammaIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
-
-// Forward declarations
-namespace Root{
-  class TAccept;
-}
-#include "xAODEgamma/EgammaFwd.h"
-#include "xAODEgamma/PhotonFwd.h"
-#include "xAODEgamma/ElectronFwd.h"
-
-class IAsgPhotonIsEMSelector : virtual public IAsgEGammaIsEMSelector
-{
-
-  ASG_TOOL_INTERFACE(IAsgPhotonIsEMSelector)
-
-public:
-
-  /**Virtual Destructor*/
-  virtual ~IAsgPhotonIsEMSelector() {};
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
-
-  /** Accept with generic interface */
-  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
-  
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
-
-  /** Accept with Egamma objects */
-  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Photon* part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Photon& part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
-
-  /** The main accept method: the actual cuts are applied here */
-  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
-
-
-  ////Expert methods /////////////////////////////////////
-  /** The isem potentially for the trigger */
-  virtual StatusCode execute(const xAOD::Egamma* eg) const =0;
-
-  virtual unsigned int IsemValue() const =0;
-
-  /** Method to get the operating point */
-  virtual std::string getOperatingPointName( ) const =0;
- 
-}; // End: class definition
+#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h
index ed7a2044ddc4dd9d7244952c33393b75acfd2cb1..8008a8dbb843854456ba9f6fc763ea9516bbdf8e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h
@@ -2,86 +2,11 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-// Dear emacs, this is -*-c++-*-
-
 #ifndef __IEGammaAmbiguityTool__
 #define __IEGammaAmbiguityTool__
 
-/**
-   @class EGammaAmbiguityTool
-   @brief Electron / photon ambiguity resolution. Dual-use version, interface
-
-   @author Bruno Lenzi
-   @date   May 2015
-*/
-
-// Include the interfaces
-#include "AsgTools/IAsgTool.h"
-
-// Include the return object
-// #include "PATCore/TAccept.h"
-
-// Forward declarations
-#include "xAODCaloEvent/CaloClusterFwd.h"
-#include "xAODTracking/VertexFwd.h"
-#include "xAODTracking/TrackParticleFwd.h"
-#include "xAODEgamma/EgammaFwd.h"
-#include "xAODEgamma/EgammaContainerFwd.h"
-
-//This will need to be copied over to EgammaEnums.h
-//under xAODEgamma
-//Plus Set/Get true Accessor methods when we have 
-//finalise the design.
-namespace xAOD {
-  namespace AmbiguityTool {
-    /// @name Ambiguity types
-    enum AmbiguityType {
-      electron = 0,
-      ambiguousTrackEoverPBetterThanVertexEoverP=1,
-      ambiguousTrackLowPt=2,
-      ambiguousTrackLowEoverP=3,
-      ambiguousTrackNoPixel =4,
-      ambiguousVertexEoverPBetterThanTrackEoverP=5,
-      photon=6,
-      unknown=7
-    };
-  }
-}
-
-
-
-class IEGammaAmbiguityTool : virtual public asg::IAsgTool
-{
-  ASG_TOOL_INTERFACE(IEGammaAmbiguityTool)
-
-public:
-
-  /**Virtual Destructor*/
-  virtual ~IEGammaAmbiguityTool() {};
-
-  /** Return value: AuthorElectron, AuthorPhoton, AuthorAmbiguous, AuthorUnknown */
-  virtual unsigned int ambiguityResolve(const xAOD::CaloCluster* cluster,
-                                        const xAOD::Vertex* vx,
-                                        const xAOD::TrackParticle* tp, xAOD::AmbiguityTool::AmbiguityType& type) const = 0;
-
-  /** Return value: AuthorElectron, AuthorPhoton, AuthorAmbiguous, AuthorUnknown 
-      Needed because of cliets
-      implementation calls method above
-   */
-  virtual unsigned int ambiguityResolve(const xAOD::CaloCluster* cluster,
-                                        const xAOD::Vertex* vx,
-                                        const xAOD::TrackParticle* tp) const = 0;
-
-  /** Redo the ambiguity resolution of central electrons and photons and return
-    * AuthorElectron, AuthorPhoton, AuthorAmbiguous, AuthorUnknown 
-    * or the author of the object if no overlapping object is found **/
-  virtual unsigned int ambiguityResolve(const xAOD::Egamma& egamma) const = 0;
-
-  /** Accept or reject egamma object based on ambiguity resolution */
-  virtual bool accept( const xAOD::Egamma& egamma, bool acceptAmbiguous = true) const = 0;
-  
-}; // End: class definition
-
+#include "EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/LikelihoodEnums.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/LikelihoodEnums.h
index f78b682c931da2d46884d513780326e04f318e4a..6efd7309f243a156283942a8d7ce46acd28f1f63 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/LikelihoodEnums.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/LikelihoodEnums.h
@@ -2,8 +2,8 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-#ifndef ELECTRON_LIKELIHOODENUMS_H
-#define ELECTRON_LIKELIHOODENUMS_H
+#ifndef _LIKELIHOODENUMS_H
+#define _LIKELIHOODENUMS_H
 
 
 namespace LikeEnum {
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/egammaPIDdefs.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/egammaPIDdefs.h
index 946e42877158a2db213a53a554decdeeb7de8a78..90358faf132ce06e62427a55f1df89d52cfb453b 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/egammaPIDdefs.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/egammaPIDdefs.h
@@ -2,8 +2,8 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-#ifndef ELECTRONPHOTONSELECTORTOOLS_EGAMMAPIDDEFS_H
-#define ELECTRONPHOTONSELECTORTOOLS_EGAMMAPIDDEFS_H
+#ifndef _EGAMMAPIDDEFS_H
+#define _EGAMMAPIDDEFS_H
 /**
   @class egammaPIDdefs
      This file defines the bit-occupation of the PID and OQ flags of egamma 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selection.xml b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selection.xml
deleted file mode 100644
index 0268f6d7bd614b8c2155bd7e028465469ec60bf5..0000000000000000000000000000000000000000
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selection.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<lcgdict>
-  <enum pattern="egammaPID::*"/>
-  <variable pattern="egammaPID::*"/>
-  <class name="egammaPID::ROOT6_NamespaceAutoloadHook" /> 
-  <enum name="LikeEnum::Menu" />
-  <class name="LikeEnum::ROOT6_NamespaceAutoloadHook" /> 
-  <class name="IAsgElectronIsEMSelector" /> 
-  <class name="IAsgForwardElectronIsEMSelector" /> 
-  <class name="IAsgPhotonIsEMSelector" />
-  <class name="IAsgElectronMultiLeptonSelector" /> 
-  <class name="IAsgElectronLikelihoodTool" /> 
-  <class name="IEGammaAmbiguityTool" />
-  <class name="AsgElectronIsEMSelector" /> 
-  <class name="AsgForwardElectronIsEMSelector" /> 
-  <class name="AsgPhotonIsEMSelector" />
-  <class name="AsgElectronMultiLeptonSelector" /> 
-  <class name="AsgElectronLikelihoodTool" /> 
-  <class name="EGammaAmbiguityTool" /> 
-  <class name="AsgElectronChargeIDSelectorTool"/>
-</lcgdict>
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selectionPython.xml b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selectionPython.xml
index 6154069a15791f1d925812786d4e7cf6738d9c6c..3f816ee712fd6461e97da31d2c8004106a49e2c2 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selectionPython.xml
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/ElectronPhotonSelectorTools/selectionPython.xml
@@ -1,15 +1,10 @@
 <lcgdict>
-  <class name="IAsgElectronIsEMSelector" /> 
-  <class name="IAsgForwardElectronIsEMSelector" /> 
-  <class name="IAsgPhotonIsEMSelector" />
-  <class name="IAsgElectronMultiLeptonSelector" /> 
-  <class name="IAsgElectronLikelihoodTool" /> 
-  <class name="IEGammaAmbiguityTool" />
   <class name="AsgElectronIsEMSelector" /> 
   <class name="AsgForwardElectronIsEMSelector" /> 
   <class name="AsgPhotonIsEMSelector" />
   <class name="AsgElectronMultiLeptonSelector" /> 
   <class name="AsgElectronLikelihoodTool" /> 
   <class name="EGammaAmbiguityTool" /> 
+  <class name="AsgDeadHVCellRemovalTool" /> 
   <class name="AsgElectronChargeIDSelectorTool"/>
 </lcgdict>
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgDeadHVCellRemovalTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgDeadHVCellRemovalTool.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..e9089d33605d9a443b723064945189284d4bfc16
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgDeadHVCellRemovalTool.cxx
@@ -0,0 +1,99 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "ElectronPhotonSelectorTools/AsgDeadHVCellRemovalTool.h"
+#include "xAODEgamma/Egamma.h"
+#include "xAODCaloEvent/CaloCluster.h"
+#include "xAODEventInfo/EventInfo.h"
+
+AsgDeadHVCellRemovalTool::AsgDeadHVCellRemovalTool(std::string myname) :
+  asg::AsgTool(myname){
+}
+
+AsgDeadHVCellRemovalTool::~AsgDeadHVCellRemovalTool(){
+}
+
+StatusCode AsgDeadHVCellRemovalTool::initialize(){
+  return StatusCode::SUCCESS ;
+}
+
+StatusCode AsgDeadHVCellRemovalTool::finalize(){
+  return StatusCode::SUCCESS;
+}
+
+bool AsgDeadHVCellRemovalTool::accept( const xAOD::Egamma* eg ) const{
+  
+  if ( !eg ){
+    ATH_MSG_ERROR ("Failed, no egamma object.");
+    return false;
+  }
+  
+  const xAOD::CaloCluster* cluster = eg->caloCluster();  
+  if ( !cluster ){
+    ATH_MSG_ERROR ("Failed, cluster.");
+    return false;
+  }  
+
+  const xAOD::EventInfo *eventInfo = evtStore()->retrieve< const xAOD::EventInfo> ("EventInfo");
+  bool isSimul= eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION);
+  
+  unsigned int runnumber (0);
+  static const SG::AuxElement::ConstAccessor<unsigned int> randomrunnumber("RandomRunNumber");
+  static const SG::AuxElement::ConstAccessor<unsigned int> datarunnumber("runNumber");
+  
+  if(!isSimul&& datarunnumber.isAvailable(*eventInfo) ){
+    runnumber = datarunnumber(*eventInfo);
+  }
+  else if(isSimul && randomrunnumber.isAvailable(*eventInfo) ){
+    runnumber = randomrunnumber(*eventInfo);
+  }
+  else {
+    ATH_MSG_ERROR ("Failed, to retrieve the proper run number from event info");
+    return false;
+  }
+  
+  double eta_calo;
+  double phi_calo;
+  if (! cluster->retrieveMoment(xAOD::CaloCluster::ETACALOFRAME,eta_calo) || 
+      ! cluster->retrieveMoment(xAOD::CaloCluster::PHICALOFRAME,phi_calo)){
+    ATH_MSG_ERROR ("Could not get Eta/Phi in calo frame");
+    return false;
+  }
+  
+  if ((runnumber>=296939 && runnumber<298967) || 
+      (runnumber>=299144 && runnumber<300279)){
+    
+    if (   eta_calo > - 1.825 
+	   && eta_calo < -1.5  
+	   && phi_calo > -1.104921 
+	   && phi_calo < -0.956748){
+      return false;
+    }
+  } 
+  
+  if ((runnumber>=298967 && runnumber<299144 ) || 
+      (runnumber>=300279 && runnumber< 305291)){
+    
+    if (eta_calo > - 1.825 
+	&& eta_calo < -1.5  
+	&& phi_calo > -1.104921 
+	&& phi_calo < -0.956748){
+      return false;
+    }
+    
+    if (eta_calo> - 1.825 
+	&& eta_calo < -1.5  
+	&& phi_calo > 1.054922 
+	&& phi_calo < 1.203097){
+      return false;
+    }
+  }
+  
+  return true ;
+}
+
+bool AsgDeadHVCellRemovalTool::accept( const xAOD::Egamma& part ) const{
+  return accept (&part);
+}
+
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronChargeIDSelectorTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronChargeIDSelectorTool.cxx
index d78e948d37ddebe844eda12266c57a7584ce6da4..b4194147ed8a6079a3a1b6cc90cf7741ed08736c 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronChargeIDSelectorTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronChargeIDSelectorTool.cxx
@@ -415,7 +415,7 @@ const Root::TResult& AsgElectronChargeIDSelectorTool::calculate( const xAOD::Ele
   if (!allFound) ATH_MSG_FATAL("Missing input variable for ECIDS BDT calculation");
 
   //long unsigned event_number=0;
-  //unsigned m_bdt_index=event_number%2;
+  //unsigned bdt_index=event_number%2;
 
   ////KM: dumping variables
   for (auto input: m_map_inputs)
@@ -423,7 +423,7 @@ const Root::TResult& AsgElectronChargeIDSelectorTool::calculate( const xAOD::Ele
 
   ////KM: dumping variables, only variables used by BDT
   // unsigned i=0;
-  // for (auto pointer: m_v_bdts.at(m_bdt_index)->GetPointers()) {
+  // for (auto pointer: m_v_bdts.at(bdt_index)->GetPointers()) {
   //   std::cout<<"\t kmdebug: "<<m_inputVars.at(i)<<"\t("<<pointer<<")\t = "<<*pointer<<std::endl; i++;
   // }
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx
index 79fedf95d2b8768399e8100d595d4c52179a2af8..f797fe8dc3ce72fa7720d887a33405a5ba807e9f 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/AsgElectronLikelihoodTool.cxx
@@ -77,6 +77,8 @@ AsgElectronLikelihoodTool::AsgElectronLikelihoodTool(std::string myname) :
   declareProperty("CutLikelihoodPileupCorrection4GeV",m_rootTool->CutLikelihoodPileupCorrection4GeV,"Pileup correction for LH discriminant, 4 GeV special bin");
   // do the conversion cut
   declareProperty("doCutConversion",m_rootTool->doCutConversion,"Apply the conversion bit cut");
+  // do the ambiguity cut
+  declareProperty("CutAmbiguity" ,m_rootTool->CutAmbiguity ,"Apply a cut on the ambiguity bit");
   // cut on b-layer
   declareProperty("CutBL",m_rootTool->CutBL,"Cut on b-layer");
   // cut on pixel hits
@@ -202,6 +204,8 @@ StatusCode AsgElectronLikelihoodTool::initialize()
     m_rootTool->CutLikelihoodPileupCorrection4GeV = AsgConfigHelper::HelperDouble("CutLikelihoodPileupCorrection4GeV", env);
     // do the conversion cut
     m_rootTool->doCutConversion = env.GetValue("doCutConversion", false);
+    // do the ambiguity cut
+    m_rootTool->CutAmbiguity  = AsgConfigHelper::HelperInt("CutAmbiguity", env);
     // cut on b-layer
     m_rootTool->CutBL = AsgConfigHelper::HelperInt("CutBL",env);
     // cut on pixel hits
@@ -292,27 +296,30 @@ StatusCode AsgElectronLikelihoodTool::finalize()
 //=============================================================================
 const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Electron* eg, double mu ) const
 {
-  if ( !eg )
-    {
-      ATH_MSG_ERROR ("Failed, no egamma object.");
-      return m_acceptDummy;
-    }
+  if ( !eg ){
+    ATH_MSG_ERROR ("Failed, no egamma object.");
+    return m_acceptDummy;
+  }
+
+  if( eg->author() == xAOD::EgammaParameters::AuthorFwdElectron ){
+    ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!");
+    return m_acceptDummy;
+  }
   
   const xAOD::CaloCluster* cluster = eg->caloCluster();
-  if ( !cluster )
-    {
-      ATH_MSG_ERROR("exiting because cluster is NULL " << cluster);
-      return m_acceptDummy;
-    }  
+  if ( !cluster ){
+    ATH_MSG_ERROR("exiting because cluster is NULL " << cluster);
+    return m_acceptDummy;
+  }  
+
+  if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){
+    ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2");
+    return m_acceptDummy;
+  }
 
   const double energy =  cluster->e();
   const float eta = (cluster->etaBE(2)); 
-  if ( fabs(eta) > 2.5 )
-    {
-      ATH_MSG_WARNING("Failed, cluster->etaBE(2) range." << eta );
-      return m_acceptDummy;
-    }
-  
+
   // transverse energy of the electron (using the track eta) 
   //  const double et = eg->pt(); 
   double et = 0.;
@@ -329,13 +336,29 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Electron* eg
   float deltaEta=0, deltaPhiRescaled2=0;
   float wstot=0, EoverP=0;
   int convBit(0); // this no longer works
+  uint8_t ambiguityBit(0); 
   double ip(0);
 
   bool allFound = true;
+  std::string notFoundList = "";
 
   // Wstot for use when CutWstotAtHighET vector is filled
-  allFound = allFound && eg->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1);
+  if( !eg->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1) ){
+    allFound = false;
+    notFoundList += "wtots1 ";
+  }
 
+  // get the ambiguity type from the decoration
+  if ( m_rootTool->CutAmbiguity.size() ) {
+    if ( eg->isAvailable<uint8_t>("ambiguityType") ) {
+      static const SG::AuxElement::Accessor<uint8_t> acc("ambiguityType");    
+      ambiguityBit = acc(*eg);
+    } else {
+      allFound = false;
+      notFoundList += "ambiguityType ";
+    }
+  }
+  
   if(!m_caloOnly) {
       // retrieve associated track
       const xAOD::TrackParticle* t  = eg->trackParticle();    
@@ -347,11 +370,18 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Electron* eg
         EoverP = fabs(t->qOverP()) * energy;
       }
       else {
-        ATH_MSG_WARNING ( "Failed, no track particle: et= " << et << "eta= " << eta );
+        ATH_MSG_ERROR( "Failed, no track particle. et= " << et << "eta= " << eta );
+        return m_acceptDummy;
       }
 
-      allFound = allFound && eg->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1);
-      allFound = allFound && eg->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2);
+      if( !eg->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1) ){
+        allFound = false;
+        notFoundList += "deltaEta1 ";
+      }
+      if( !eg->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2) ){
+        allFound = false;
+        notFoundList += "deltaPhiRescaled2 ";
+      }
 
   } //if not calo ONly
 
@@ -368,18 +398,18 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Electron* eg
   // for now don't cache. 
   double likelihood = calculate(eg, ip); 
 
-  ATH_MSG_VERBOSE ( Form("PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, nHitsPlusPixDeadSensors=%i, passBLayerRequirement=%i, convBit=%i, d0=%8.5f, deltaEta=%8.5f, deltaphires=%5.8f, wstot=%8.5f, EoverP=%8.5f, ip=%8.5f",
-                         likelihood, eta, et,
-                         nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors, 
-                         passBLayerRequirement,
-                         convBit, d0, deltaEta, deltaPhiRescaled2, 
-                         wstot, EoverP, ip ) );
-
-
+  ATH_MSG_VERBOSE( Form("PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, nHitsPlusPixDeadSensors=%i, passBLayerRequirement=%i, convBit=%i, ambiguityBit=%i, d0=%8.5f, deltaEta=%8.5f, deltaphires=%5.8f, wstot=%8.5f, EoverP=%8.5f, ip=%8.5f",
+			likelihood, eta, et,
+			nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors,
+			passBLayerRequirement,
+			convBit, ambiguityBit, d0, deltaEta, deltaPhiRescaled2,
+			wstot, EoverP, ip ));
+  
   if (!allFound) {
-    ATH_MSG_WARNING("Have some variables missing.");
+    ATH_MSG_ERROR("Skipping LH rectangular cuts! The following variables are missing: " << notFoundList);
+    return m_acceptDummy;
   }
-
+  
   // Get the answer from the underlying ROOT tool
   return m_rootTool->accept( likelihood,
                              eta,
@@ -388,6 +418,7 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Electron* eg
                              nPixHitsPlusDeadSensors,
                              passBLayerRequirement,
                              convBit,
+                             ambiguityBit,
                              d0,
                              deltaEta,
                              deltaPhiRescaled2,
@@ -402,32 +433,35 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Electron* eg
 //=============================================================================
 const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Egamma* eg, double mu) const
 {
+  if ( !eg ){
+    ATH_MSG_ERROR ("Failed, no egamma object.");
+    return m_acceptDummy;
+  }
+
   // Call the main accept if this is not a calo-only LH
-  if( !m_caloOnly )
-    {
-      const xAOD::Electron* el = dynamic_cast<const xAOD::Electron*>(eg);
-      return accept(el, mu); 
-    }
-  if ( !eg )
-    {
-      ATH_MSG_ERROR ("Failed, no egamma object.");
-      return m_acceptDummy;
-    }
+  if( !m_caloOnly ){
+    const xAOD::Electron* el = dynamic_cast<const xAOD::Electron*>(eg);
+    return accept(el, mu); 
+  }
+
+  if( eg->author() == xAOD::EgammaParameters::AuthorFwdElectron ){
+    ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!");
+    return m_acceptDummy;
+  }
   
   const xAOD::CaloCluster* cluster = eg->caloCluster();
-  if ( !cluster )
-    {
-      ATH_MSG_ERROR ("Failed, no cluster.");
-      return m_acceptDummy;
-    }  
+  if ( !cluster ){
+    ATH_MSG_ERROR ("Failed, no cluster.");
+    return m_acceptDummy;
+  }  
+
+  if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){
+    ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2");
+    return m_acceptDummy;
+  }
   
   const double energy =  cluster->e();
   const float eta = (cluster->etaBE(2)); 
-  if ( fabs(eta) > 300.0 )
-    {
-      ATH_MSG_ERROR ("Failed, eta range.");
-      return m_acceptDummy;
-    }
   
   const double et  = ( cosh(eta) != 0.) ? energy/cosh(eta) : 0.;
   
@@ -436,6 +470,7 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Egamma* eg,
   uint8_t nPixHitsPlusDeadSensors(0);
   bool passBLayerRequirement(false); 
   int convBit(0); // this no longer works
+  uint8_t ambiguityBit(0);
 
   // Get the pileup or centrality information
   double ip(0);
@@ -452,22 +487,28 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Egamma* eg,
   // for now don't cache. 
   double likelihood = calculate(eg, ip); 
 
-  ATH_MSG_VERBOSE ( Form("PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, nPixHitsPlusDeadSensors=%i, passBLayerRequirement=%i, convBit=%i, ip=%8.5f",
-                         likelihood, eta, et,
-                         nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors, 
-                         passBLayerRequirement,
-                         convBit, ip ) );
-
   double deltaEta=0,deltaPhiRescaled2=0,d0=0;
   float wstot=0, EoverP=0;
 
   bool allFound = true;
+  std::string notFoundList = "";
 
   // Wstot for use when CutWstotAtHighET vector is filled
-  allFound = allFound && eg->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1);
+  if( !eg->showerShapeValue(wstot, xAOD::EgammaParameters::wtots1) ){
+    allFound = false; 
+    notFoundList += "wtots1 ";
+  }
+
+  ATH_MSG_VERBOSE( Form("PassVars: LH=%8.5f, eta=%8.5f, et=%8.5f, nSiHitsPlusDeadSensors=%i, nPixHitsPlusDeadSensors=%i, passBLayerRequirement=%i, convBit=%i, ambiguityBit=%i, ip=%8.5f, wstot=%8.5f",
+			likelihood, eta, et,
+			nSiHitsPlusDeadSensors, nPixHitsPlusDeadSensors, 
+			passBLayerRequirement,
+			convBit, ambiguityBit, ip, wstot));
+  
 
   if (!allFound) {
-    ATH_MSG_WARNING("Have some variables missing.");
+    ATH_MSG_ERROR("Skipping LH rectangular cuts! The following variables are missing: " << notFoundList);
+    return m_acceptDummy;
   }
 
   // Get the answer from the underlying ROOT tool
@@ -478,6 +519,7 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Egamma* eg,
                              nPixHitsPlusDeadSensors,
                              passBLayerRequirement,
                              convBit,
+                             ambiguityBit,
                              d0,
                              deltaEta,
                              deltaPhiRescaled2,
@@ -496,26 +538,29 @@ const Root::TAccept& AsgElectronLikelihoodTool::accept( const xAOD::Egamma* eg,
 //=============================================================================
 const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Electron* eg, double mu ) const
 {
-  if ( !eg )
-    {
-      ATH_MSG_ERROR ("Failed, no egamma object.");
-      return m_resultDummy;
-    }
+  if ( !eg ){
+    ATH_MSG_ERROR ("Failed, no egamma object.");
+    return m_resultDummy;
+  }
+
+  if( eg->author() == xAOD::EgammaParameters::AuthorFwdElectron ){
+    ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!");
+    return m_resultDummy;
+  }
   
   const xAOD::CaloCluster* cluster = eg->caloCluster();
-  if ( !cluster )
-    {
-      ATH_MSG_ERROR ("Failed, no cluster.");
-      return m_resultDummy;
-    }  
+  if ( !cluster ){
+    ATH_MSG_ERROR ("Failed, no cluster.");
+    return m_resultDummy;
+  }  
+
+  if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){
+    ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2");
+    return m_resultDummy;
+  }
 
   const double energy =  cluster->e();
   const float eta = cluster->etaBE(2); 
-  if ( fabs(eta) > 300.0 )
-    {
-      ATH_MSG_ERROR ("Failed, eta range.");
-      return m_resultDummy;
-    }
   
   //double et = cluster->e()/cosh(eta); 
   // transverse energy of the electron (using the track eta) 
@@ -537,6 +582,8 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Electron*
   float deltaEta=0, deltaPhiRescaled2=0;
 
   bool allFound = true;
+  std::string notFoundList = "";
+
   if (!m_caloOnly){
   // retrieve associated TrackParticle
     const xAOD::TrackParticle* t = eg->trackParticle();    
@@ -549,7 +596,10 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Electron*
 	  d0sigma=sqrtf(vard0);
         }
 
-        allFound = allFound && t->summaryValue(TRT_PID, xAOD::eProbabilityHT);
+        if( !t->summaryValue(TRT_PID, xAOD::eProbabilityHT) ){
+          allFound = false; 
+          notFoundList += "eProbabilityHT ";
+        }
 
         //Transform the TRT PID output for use in the LH tool.
         double tau = 15.0; 
@@ -569,40 +619,73 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Electron*
 	
 	  dpOverp = 1 - trackqoverp/(refittedTrack_LMqoverp);
         }
+        else{
+          allFound = false; 
+          notFoundList += "deltaPoverP ";
+        }
       
       }
     else
       {
-        ATH_MSG_WARNING ( "Failed, no track particle: et= " << et << "eta= " << eta );
+        ATH_MSG_ERROR( "Failed, no track particle. et= " << et << "eta= " << eta );
+        return m_resultDummy;
       }
   }  // if not calo Only
 
-  float Reta(0), Rphi(0),  Rhad1(0), Rhad(0), ws3(0), w2(0), f1(0), Eratio(0), f3(0);
+  float Reta(0), Rphi(0),  Rhad1(0), Rhad(0), w2(0), f1(0), Eratio(0), f3(0);
 
   // reta = e237/e277
-  allFound = allFound && eg->showerShapeValue(Reta, xAOD::EgammaParameters::Reta);
+  if( !eg->showerShapeValue(Reta, xAOD::EgammaParameters::Reta) ){
+    allFound = false; 
+    notFoundList += "Reta ";
+  }
   // rphi e233/e237
-  allFound = allFound && eg->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi);
+  if( !eg->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi) ){
+    allFound = false;
+    notFoundList += "Rphi ";
+  }
   // rhad1 = ethad1/et
-  allFound = allFound && eg->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1);
+  if( !eg->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1) ){
+    allFound = false;
+    notFoundList += "Rhad1 ";
+  }
   // rhad = ethad/et
-  allFound = allFound && eg->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad);
-  // shower width in 3 strips in 1st sampling
-  allFound = allFound && eg->showerShapeValue(ws3, xAOD::EgammaParameters::weta1);
+  if( !eg->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad) ){
+    allFound = false;
+    notFoundList += "Rhad ";
+  }
   // shower width in 2nd sampling
-  allFound = allFound && eg->showerShapeValue(w2, xAOD::EgammaParameters::weta2);
+  if( !eg->showerShapeValue(w2, xAOD::EgammaParameters::weta2) ){
+    allFound = false;
+    notFoundList += "weta2 ";
+  }
   // fraction of energy reconstructed in the 1st sampling
-  allFound = allFound && eg->showerShapeValue(f1, xAOD::EgammaParameters::f1);
+  if( !eg->showerShapeValue(f1, xAOD::EgammaParameters::f1) ){
+    allFound = false;
+    notFoundList += "f1 ";
+  }
   // E of 2nd max between max and min in strips
-  allFound = allFound && eg->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio);
+  if( !eg->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio) ){
+    allFound = false;
+    notFoundList += "Eratio ";
+  }
   // fraction of energy reconstructed in the 3rd sampling
-  allFound = allFound && eg->showerShapeValue(f3, xAOD::EgammaParameters::f3);
+  if( !eg->showerShapeValue(f3, xAOD::EgammaParameters::f3) ){
+    allFound = false;
+    notFoundList += "f3 ";
+  }
 
   if( !m_caloOnly){
-    allFound = allFound && eg->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1);
-
+    // deltaEta1
+    if( !eg->trackCaloMatchValue(deltaEta, xAOD::EgammaParameters::deltaEta1) ){
+      allFound = false;
+      notFoundList += "deltaEta1 ";
+    }
     // difference between the cluster phi (sampling 2) and the eta of the track extrapolated from the last measurement point.
-    allFound = allFound && eg->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2);
+    if( !eg->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2) ){
+      allFound = false;
+      notFoundList += "deltaPhiRescaled2 ";
+    }
 
   }
 
@@ -618,18 +701,18 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Electron*
     ip = mu;
   }
 
-  ATH_MSG_VERBOSE ( Form("Vars: eta=5%8.5f, et=%8.5f, f3=%8.5f, rHad==%8.5f, rHad1=%8.5f, Reta=%8.5f, w2=%8.5f, f1=%8.5f, Emaxs1=%8.5f, deltaEta=%8.5f, d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, ws3=%8.5f, dpOverp=%8.5f, deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, trans_TRT_PID=%8.5f, ip=%8.5f",
-                         eta, et, f3, Rhad, Rhad1, Reta,
-                         w2, f1, Eratio,
-                         deltaEta, d0,
-                         d0sigma, 
-                         Rphi, ws3, dpOverp, deltaPhiRescaled2,
-                         TRT_PID, trans_TRT_PID,
-                         ip ) );
-
+  ATH_MSG_VERBOSE( Form("Vars: eta=5%8.5f, et=%8.5f, f3=%8.5f, rHad==%8.5f, rHad1=%8.5f, Reta=%8.5f, w2=%8.5f, f1=%8.5f, Emaxs1=%8.5f, deltaEta=%8.5f, d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, dpOverp=%8.5f, deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, trans_TRT_PID=%8.5f, ip=%8.5f",
+      eta, et, f3, Rhad, Rhad1, Reta,
+      w2, f1, Eratio,
+      deltaEta, d0,
+      d0sigma, 
+      Rphi, dpOverp, deltaPhiRescaled2,
+      TRT_PID, trans_TRT_PID,
+      ip ) );
 
   if (!allFound) {
-    ATH_MSG_WARNING("Have some variables missing.");
+    ATH_MSG_ERROR("Skipping LH calculation! The following variables are missing: " << notFoundList);
+    return m_resultDummy;
   }
 
   // Get the answer from the underlying ROOT tool
@@ -658,31 +741,34 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Electron*
 //=============================================================================
 const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Egamma* eg, double mu ) const
 {
-  if( !m_caloOnly )
-    {
-      const xAOD::Electron* el = dynamic_cast<const xAOD::Electron*>(eg);
-      return calculate(el, mu);
-    }
-  if ( !eg )
-    {
-      ATH_MSG_ERROR ("Failed, no egamma object.");
-      return m_resultDummy;
-    }
+  if ( !eg ){
+    ATH_MSG_ERROR ("Failed, no egamma object.");
+    return m_resultDummy;
+  }
+
+  if( !m_caloOnly ){
+    const xAOD::Electron* el = dynamic_cast<const xAOD::Electron*>(eg);
+    return calculate(el, mu);
+  }
+
+  if( eg->author() == xAOD::EgammaParameters::AuthorFwdElectron ){
+    ATH_MSG_WARNING("Failed, this is a forward electron! The AsgElectronLikelihoodTool is only suitable for central electrons!");
+    return m_resultDummy;
+  }
   
   const xAOD::CaloCluster* cluster = eg->caloCluster();
-  if ( !cluster )
-    {
-      ATH_MSG_ERROR ("Failed, no cluster.");
-      return m_resultDummy;
-    }  
+  if ( !cluster ){
+    ATH_MSG_ERROR ("Failed, no cluster.");
+    return m_resultDummy;
+  }  
+
+  if( !cluster->hasSampling(CaloSampling::CaloSample::EMB2) && !cluster->hasSampling(CaloSampling::CaloSample::EME2) ){
+    ATH_MSG_ERROR("Failed, cluster is missing samplings EMB2 and EME2");
+    return m_resultDummy;
+  }
   
   const double energy =  cluster->e();
   const float eta = cluster->etaBE(2); 
-  if ( fabs(eta) > 300.0 )
-    {
-      ATH_MSG_ERROR ("Failed, eta range.");
-      return m_resultDummy;
-    }
   
   const double et  = ( cosh(eta) != 0.) ? energy/cosh(eta) : 0.;
 
@@ -695,28 +781,51 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Egamma* e
   float TRT_PID(0.0);
 
   // Calo Variables
-  float Reta(0), Rphi(0),  Rhad1(0), Rhad(0), ws3(0), w2(0), f1(0), Eratio(0), f3(0);
+  float Reta(0), Rphi(0),  Rhad1(0), Rhad(0), w2(0), f1(0), Eratio(0), f3(0);
 
   bool allFound = true;
+  std::string notFoundList = "";
 
   // reta = e237/e277
-  allFound = allFound && eg->showerShapeValue(Reta, xAOD::EgammaParameters::Reta);
+  if( !eg->showerShapeValue(Reta, xAOD::EgammaParameters::Reta) ){
+    allFound = false; 
+    notFoundList += "Reta ";
+  }
   // rphi e233/e237
-  allFound = allFound && eg->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi);
+  if( !eg->showerShapeValue(Rphi, xAOD::EgammaParameters::Rphi) ){
+    allFound = false; 
+    notFoundList += "Rphi ";
+  }
   // rhad1 = ethad1/et
-  allFound = allFound && eg->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1);
+  if( !eg->showerShapeValue(Rhad1, xAOD::EgammaParameters::Rhad1) ){
+    allFound = false; 
+    notFoundList += "Rhad1 ";
+  }
   // rhad = ethad/et
-  allFound = allFound && eg->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad);
-  // shower width in 3 strips in 1st sampling
-  allFound = allFound && eg->showerShapeValue(ws3, xAOD::EgammaParameters::weta1);
+  if( !eg->showerShapeValue(Rhad, xAOD::EgammaParameters::Rhad) ){
+    allFound = false; 
+    notFoundList += "Rhad ";
+  }
   // shower width in 2nd sampling
-  allFound = allFound && eg->showerShapeValue(w2, xAOD::EgammaParameters::weta2);
+  if( !eg->showerShapeValue(w2, xAOD::EgammaParameters::weta2) ){
+    allFound = false; 
+    notFoundList += "weta2 ";
+  }
   // fraction of energy reconstructed in the 1st sampling
-  allFound = allFound && eg->showerShapeValue(f1, xAOD::EgammaParameters::f1);
+  if( !eg->showerShapeValue(f1, xAOD::EgammaParameters::f1) ){
+    allFound = false; 
+    notFoundList += "f1 ";
+  }
   // E of 2nd max between max and min in strips
-  allFound = allFound && eg->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio);
+  if( !eg->showerShapeValue(Eratio, xAOD::EgammaParameters::Eratio) ){
+    allFound = false; 
+    notFoundList += "Eratio ";
+  }
   // fraction of energy reconstructed in the 3rd sampling
-  allFound = allFound && eg->showerShapeValue(f3, xAOD::EgammaParameters::f3);
+  if( !eg->showerShapeValue(f3, xAOD::EgammaParameters::f3) ){
+    allFound = false; 
+    notFoundList += "f3 ";
+  }
 
   // Get the pileup or centrality information
   double ip(0);
@@ -729,18 +838,19 @@ const Root::TResult& AsgElectronLikelihoodTool::calculate( const xAOD::Egamma* e
   else {
     ip = mu;
   }
-  ATH_MSG_VERBOSE ( Form("Vars: eta=%8.5f, et=%8.5f, f3=%8.5f, rHad==%8.5f, rHad1=%8.5f, Reta=%8.5f, w2=%8.5f, f1=%8.5f, Emaxs1=%8.5f, deltaEta=%8.5f, d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, ws3=%8.5f, dpOverp=%8.5f, deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, ip=%8.5f",
-                         eta, et, f3, Rhad, Rhad1, Reta,
-                         w2, f1, Eratio,
-                         deltaEta, d0,
-                         d0sigma, 
-                         Rphi, ws3, dpOverp, deltaPhiRescaled2,
-			 TRT_PID,
-                         ip ) );
 
+  ATH_MSG_VERBOSE(Form("Vars: eta=%8.5f, et=%8.5f, f3=%8.5f, rHad==%8.5f, rHad1=%8.5f, Reta=%8.5f, w2=%8.5f, f1=%8.5f, Emaxs1=%8.5f, deltaEta=%8.5f, d0=%8.5f, d0sigma=%8.5f, Rphi=%8.5f, dpOverp=%8.5f, deltaPhiRescaled2=%8.5f, TRT_PID=%8.5f, ip=%8.5f",
+				 eta, et, f3, Rhad, Rhad1, Reta,
+				 w2, f1, Eratio,
+				 deltaEta, d0,
+				 d0sigma, 
+				 Rphi, dpOverp, deltaPhiRescaled2,
+				 TRT_PID,
+                                 ip ));
 
   if (!allFound) {
-    ATH_MSG_WARNING("Have some variables missing.");
+    ATH_MSG_ERROR("Skipping LH calculation! The following variables are missing: " << notFoundList);
+    return m_resultDummy;
   }
 
   // Get the answer from the underlying ROOT tool
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h
index 79aa6743c9444f4b74269dc15a872a0a3a13fece..20ce54c4d637f48faa620c2d6a97ffac2b7217fe 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/EGSelectorConfigurationMapping.h
@@ -13,16 +13,22 @@ namespace EgammaSelectors {
   //----------------------------------------------------------
   //This is the internal part , We need to  map string to latest reccomendations
   const std::map<std::string,std::string> LHPointToConfFile={
-    {"VeryLooseLHElectron","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth.conf"},
-    {"VeryLooseLHNod0Electron", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth_NoD0.conf"},
-    {"LooseLHElectron","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_Smooth.conf"},
-    {"LooseLHNod0Electron", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_Smooth_NoD0.conf"},
-    {"LooseBLLHElectron","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth.conf"},
-    {"LooseBLLHNod0Electron", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth_NoD0.conf"},
-    {"MediumLHElectron","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth.conf"},
-    {"MediumLHNod0Electron", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth_NoD0.conf"},
-    {"TightLHElectron","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodTightOfflineConfig2016_Smooth.conf"},
-    {"TightLHNod0Electron", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodTightOfflineConfig2016_Smooth_NoD0.conf"}
+    // default tunes, recommended for rel 21
+    {"VeryLooseLHElectron","ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodVeryLooseOfflineConfig2017_Smooth.conf"},
+    {"LooseLHElectron"    ,"ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodLooseOfflineConfig2017_Smooth.conf"},
+    {"LooseBLLHElectron"  ,"ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodLooseOfflineConfig2017_CutBL_Smooth.conf"},
+    {"MediumLHElectron"   ,"ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodMediumOfflineConfig2017_Smooth.conf"},
+    {"TightLHElectron"    ,"ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodTightOfflineConfig2017_Smooth.conf"},
+    // legacy rel 20p7 tunes, to allow usage in rel 20p7 derivations
+    {"VeryLooseLHElectron_Rel20p7","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth.conf"},
+    {"VeryLooseLHNod0Electron_Rel20p7", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth_NoD0.conf"},
+    {"LooseLHElectron_Rel20p7","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_Smooth.conf"},
+    {"LooseLHNod0Electron_Rel20p7", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_Smooth_NoD0.conf"},
+    {"LooseBLLHElectron_Rel20p7","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth.conf"},
+    {"LooseBLLHNod0Electron_Rel20p7", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth_NoD0.conf"},
+    {"MediumLHElectron_Rel20p7","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth.conf"},
+    {"MediumLHNod0Electron_Rel20p7", "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth_NoD0.conf"},
+    {"TightLHElectron_Rel20p7","ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodTightOfflineConfig2016_Smooth.conf"},
   };
   const std::map<std::string,std::string> PhotonCutPointToConfFile={
     {"LoosePhoton","ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf"},
@@ -42,8 +48,8 @@ namespace EgammaSelectors {
   //----------------------------------------------------------
   //Map enums to masks , needed for photons
   const std::map<std::string,unsigned int> PhotonCutPointToMask={{"LoosePhoton",egammaPID::PhotonLoose},
-								   {"MediumPhoton",egammaPID::PhotonMedium},
-								   {"TightPhoton",egammaPID::PhotonTight},
+                                                                 {"MediumPhoton",egammaPID::PhotonMedium},
+                                                                 {"TightPhoton",egammaPID::PhotonTight},
   };
 }
 ////////////////////////////////////////////
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx
index 2c3a2652379861363c6623fb701e45a7e00cd358..9c216cf713fbadd2eb10e63d8bdf0a8edeebafc6 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx
@@ -98,3 +98,12 @@ bool ElectronSelectorHelpers::passBLayerRequirement(const xAOD::TrackParticle *t
 
   return passBLReq;
 }
+
+
+// ==================================================================
+bool ElectronSelectorHelpers::passAmbiguity(xAOD::AmbiguityTool::AmbiguityType type, const uint8_t criterion){
+
+  // helper to check if ambiguity type is one of several that are stored in a bitmask
+  return criterion & 0x1<<type;
+
+}
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx
index b0d212978cf8b0da54b4d6e53ebc0d8ee0f714a5..0aa02b8d5c8a05c109c4bd29cb3470095a8f0604 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.cxx
@@ -14,6 +14,9 @@
 #include "TFile.h"                      // for TFile
 #include "TH1.h"                        // for TH1F
 #include "TString.h"                    // for TString
+
+#include "ElectronPhotonSelectorTools/ElectronSelectorHelpers.h"
+
 /** 
     Author : Kurt Brendlinger <kurb@sas.upenn.edu>
     Please see TElectronLikelihoodTool.h for usage.
@@ -51,6 +54,7 @@ Root::TElectronLikelihoodTool::TElectronLikelihoodTool(const char* name) :
   m_cutPosition_NPixel(-9),
   m_cutPosition_NBlayer(-9),
   m_cutPosition_conversion(-9),
+  m_cutPosition_ambiguity(-9),
   m_cutPosition_LH(-9),
   m_cutPositionTrackA0(-9),
   m_cutPositionTrackMatchEta(-9),
@@ -141,6 +145,11 @@ int Root::TElectronLikelihoodTool::initialize()
   m_cutPosition_conversion = m_accept.addCut( "conversion", "pass conversion" );
   if ( m_cutPosition_conversion < 0 ) sc = 0;
 
+ // Ambiguity
+  m_cutPosition_ambiguity = m_accept.addCut( "ambiguity", "pass ambiguity" );
+  if ( m_cutPosition_ambiguity < 0 ) {sc = 0;}
+
+
   // Cut position for the likelihood selection - DO NOT CHANGE ORDER!
   m_cutPosition_LH = m_accept.addCut( "passLH", "pass Likelihood" );
   if ( m_cutPosition_LH < 0 ) sc = 0;
@@ -223,26 +232,27 @@ int Root::TElectronLikelihoodTool::initialize()
 		  << "\n - Variable bitmask                             : " << m_variableBitMask);
 
   ATH_MSG_DEBUG("\n - VariableNames                                : " << VariableNames
-                << "\n - (bool)CutBL (yes/no)                         : " << (CutBL.size() ? "yes" : "no")
-                << "\n - (bool)CutPi (yes/no)                         : " << (CutPi.size() ? "yes" : "no")
-                << "\n - (bool)CutSi (yes/no)                         : " << (CutSi.size() ? "yes" : "no")
-                << "\n - (bool)doCutConversion (yes/no)               : " << (doCutConversion ? "yes" : "no")
-                << "\n - (bool)doRemoveF3AtHighEt (yes/no)            : " << (doRemoveF3AtHighEt ? "yes" : "no")
-                << "\n - (bool)doRemoveTRTPIDAtHighEt (yes/no)        : " << (doRemoveTRTPIDAtHighEt ? "yes" : "no")
-                << "\n - (bool)doSmoothBinInterpolation (yes/no)      : " << (doSmoothBinInterpolation ? "yes" : "no")
-                << "\n - (bool)useHighETLHBinning (yes/no)            : " << (useHighETLHBinning ? "yes" : "no")
-                << "\n - (bool)useOneExtraHighETLHBin(yes/no)         : " << (useOneExtraHighETLHBin ? "yes" : "no")
-                << "\n - (double)HighETBinThreshold                   : " << HighETBinThreshold
-                << "\n - (bool)doPileupTransform (yes/no)             : " << (doPileupTransform ? "yes" : "no")
-                << "\n - (bool)doCentralityTransform (yes/no)         : " << (doCentralityTransform ? "yes" : "no")
-                << "\n - (bool)CutLikelihood (yes/no)                 : " << (CutLikelihood.size() ? "yes" : "no")
-                << "\n - (bool)CutLikelihoodPileupCorrection (yes/no) : " << (CutLikelihoodPileupCorrection.size() ? "yes" : "no")
-                << "\n - (bool)CutA0 (yes/no)                         : " << (CutA0.size() ? "yes" : "no")
-                << "\n - (bool)CutDeltaEta (yes/no)                   : " << (CutDeltaEta.size() ? "yes" : "no")
-                << "\n - (bool)CutDeltaPhiRes (yes/no)                : " << (CutDeltaPhiRes.size() ? "yes" : "no")
-                << "\n - (bool)CutWstotAtHighET (yes/no)              : " << (CutWstotAtHighET.size() ? "yes" : "no")
-                << "\n - (bool)CutEoverPAtHighET (yes/no)             : " << (CutEoverPAtHighET.size() ? "yes" : "no")
-                );
+		<< "\n - (bool)CutBL (yes/no)                         : " << (CutBL.size() ? "yes" : "no")
+		<< "\n - (bool)CutPi (yes/no)                         : " << (CutPi.size() ? "yes" : "no")
+		<< "\n - (bool)CutSi (yes/no)                         : " << (CutSi.size() ? "yes" : "no")
+		<< "\n - (bool)doCutConversion (yes/no)               : " << (doCutConversion ? "yes" : "no")
+		<< "\n - (bool)CutAmbiguity (yes/no)                  : " << (CutAmbiguity.size() ? "yes" : "no")
+		<< "\n - (bool)doRemoveF3AtHighEt (yes/no)            : " << (doRemoveF3AtHighEt ? "yes" : "no")
+		<< "\n - (bool)doRemoveTRTPIDAtHighEt (yes/no)        : " << (doRemoveTRTPIDAtHighEt ? "yes" : "no")
+		<< "\n - (bool)doSmoothBinInterpolation (yes/no)      : " << (doSmoothBinInterpolation ? "yes" : "no")
+		<< "\n - (bool)useHighETLHBinning (yes/no)            : " << (useHighETLHBinning ? "yes" : "no")
+		<< "\n - (bool)useOneExtraHighETLHBin(yes/no)         : " << (useOneExtraHighETLHBin ? "yes" : "no")
+		<< "\n - (double)HighETBinThreshold                   : " << HighETBinThreshold
+		<< "\n - (bool)doPileupTransform (yes/no)             : " << (doPileupTransform ? "yes" : "no")
+		<< "\n - (bool)doCentralityTransform (yes/no)         : " << (doCentralityTransform ? "yes" : "no")
+		<< "\n - (bool)CutLikelihood (yes/no)                 : " << (CutLikelihood.size() ? "yes" : "no")
+		<< "\n - (bool)CutLikelihoodPileupCorrection (yes/no) : " << (CutLikelihoodPileupCorrection.size() ? "yes" : "no")
+		<< "\n - (bool)CutA0 (yes/no)                         : " << (CutA0.size() ? "yes" : "no")
+		<< "\n - (bool)CutDeltaEta (yes/no)                   : " << (CutDeltaEta.size() ? "yes" : "no")
+		<< "\n - (bool)CutDeltaPhiRes (yes/no)                : " << (CutDeltaPhiRes.size() ? "yes" : "no")
+		<< "\n - (bool)CutWstotAtHighET (yes/no)              : " << (CutWstotAtHighET.size() ? "yes" : "no")
+		<< "\n - (bool)CutEoverPAtHighET (yes/no)             : " << (CutEoverPAtHighET.size() ? "yes" : "no")
+		);
   return sc;
 }
 
@@ -323,7 +333,7 @@ const Root::TAccept& Root::TElectronLikelihoodTool::accept( double likelihood,
                                                             double eta, double eT,
                                                             int nSiHitsPlusDeadSensors, int nPixHitsPlusDeadSensors,
                                                             bool passBLayerRequirement,
-                                                            int convBit, double d0, double deltaEta, double deltaphires, 
+                                                            int convBit, uint8_t ambiguityBit, double d0, double deltaEta, double deltaphires, 
                                                             double wstot, double EoverP, double ip
                                                             ) const
 {
@@ -336,6 +346,7 @@ const Root::TAccept& Root::TElectronLikelihoodTool::accept( double likelihood,
   vars.nPixHitsPlusDeadSensors = nPixHitsPlusDeadSensors;
   vars.passBLayerRequirement   = passBLayerRequirement;
   vars.convBit                 = convBit;
+  vars.ambiguityBit            = ambiguityBit;
   vars.d0                      = d0;
   vars.deltaEta                = deltaEta;
   vars.deltaphires             = deltaphires;
@@ -358,6 +369,7 @@ const Root::TAccept& Root::TElectronLikelihoodTool::accept( LikeEnum::LHAcceptVa
   bool passNPixel(true);
   bool passNBlayer(true);
   bool passConversion(true);
+  bool passAmbiguity(true);
   bool passLH(true);
   bool passTrackA0(true);
   bool passDeltaEta(true);
@@ -389,7 +401,17 @@ const Root::TAccept& Root::TElectronLikelihoodTool::accept( LikeEnum::LHAcceptVa
       ATH_MSG_DEBUG("Likelihood macro: Conversion Bit Failed." );
       passConversion = false;
   }
-
+  
+  // ambiguity bit
+  if (CutAmbiguity.size()) {
+    if ( !ElectronSelectorHelpers::passAmbiguity((xAOD::AmbiguityTool::AmbiguityType)vars_struct.ambiguityBit,
+						CutAmbiguity[etabin])
+	 ) {
+      ATH_MSG_DEBUG("Likelihood macro: ambiguity Bit Failed." );
+      passAmbiguity = false;
+    }
+  }
+  
   // blayer cut
   if (CutBL.size() ) {
     if(CutBL[etabin] == 1 && !vars_struct.passBLayerRequirement) {
@@ -499,6 +521,7 @@ const Root::TAccept& Root::TElectronLikelihoodTool::accept( LikeEnum::LHAcceptVa
   m_accept.setCutResult( m_cutPosition_NPixel, passNPixel );
   m_accept.setCutResult( m_cutPosition_NBlayer, passNBlayer );
   m_accept.setCutResult( m_cutPosition_conversion, passConversion );
+  m_accept.setCutResult( m_cutPosition_ambiguity, passAmbiguity );
   m_accept.setCutResult( m_cutPosition_LH, passLH );  
   m_accept.setCutResult( m_cutPositionTrackA0, passTrackA0 );  
   m_accept.setCutResult( m_cutPositionTrackMatchEta, passDeltaEta );  
@@ -947,6 +970,8 @@ double Root::TElectronLikelihoodTool::InterpolatePdfs(unsigned int s_or_b,unsign
   int etabin = getLikelihoodEtaBin(eta);
   double integral = double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->Integral());
   double prob = double(fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetBinContent(bin)) / integral;
+
+  int Nbins      = fPDFbins[s_or_b][ipbin][etbin][etabin][var]->GetNbinsX();
   if (et > 42500.) return prob; // interpolation stops here.
   if (et < 6000.) return prob; // interpolation stops here.
   if (22500. < et && et < 27500.) return prob; // region of non-interpolation for pdfs
@@ -962,16 +987,35 @@ double Root::TElectronLikelihoodTool::InterpolatePdfs(unsigned int s_or_b,unsign
   if (et > bin_center){
     double prob_next = prob;
     if (etbin+1<=6) {
+      // account for potential histogram bin inequalities
+      int NbinsPlus  = fPDFbins[s_or_b][ipbin][etbin+1][etabin][var]->GetNbinsX();
+      int binplus = bin;
+      if (Nbins < NbinsPlus){
+	binplus = int(round(bin*(Nbins/NbinsPlus)));
+      }
+      else if (Nbins > NbinsPlus){
+	binplus = int(round(bin*(NbinsPlus/Nbins)));
+      }
+      // do interpolation
       double integral_next = double(fPDFbins[s_or_b][ipbin][etbin+1][etabin][var]->Integral());
-      prob_next = double(fPDFbins[s_or_b][ipbin][etbin+1][etabin][var]->GetBinContent(bin)) / integral_next;
+      prob_next = double(fPDFbins[s_or_b][ipbin][etbin+1][etabin][var]->GetBinContent(binplus)) / integral_next;
       return prob+(prob_next-prob)*(et-bin_center)/(bin_width);
     }
   }
   // or else if et < bin_center :
   double prob_before = prob;
   if (etbin-1>=0) {
+    // account for potential histogram bin inequalities
+    int NbinsMinus = fPDFbins[s_or_b][ipbin][etbin-1][etabin][var]->GetNbinsX();
+    int binminus = bin;
+    if (Nbins < NbinsMinus){
+      binminus = int(round(bin*(Nbins/NbinsMinus)));
+    }
+    else if (Nbins > NbinsMinus){
+      binminus = int(round(bin*(NbinsMinus/Nbins)));
+    }
     double integral_before = double(fPDFbins[s_or_b][ipbin][etbin-1][etabin][var]->Integral());
-    prob_before = double(fPDFbins[s_or_b][ipbin][etbin-1][etabin][var]->GetBinContent(bin)) / integral_before;
+    prob_before = double(fPDFbins[s_or_b][ipbin][etbin-1][etabin][var]->GetBinContent(binminus)) / integral_before;
   }
   return prob-(prob-prob_before)*(bin_center-et)/(bin_width);
 }
@@ -1042,7 +1086,11 @@ int Root::TElectronLikelihoodTool::SafeTH1::FindBin(double value){
 }
 
 double Root::TElectronLikelihoodTool::SafeTH1::GetBinContent(int bin){
-  return m_binContent[bin];
+  int nbins = this->GetNbinsX();
+  // since we store the bin content in a vector we need a protection 
+  // for cases where we try to access a non-existing bin. In these 
+  // cases just go to the last bin
+  return (bin>nbins) ? m_binContent[nbins-1] : m_binContent[bin];
 }
 
 double Root::TElectronLikelihoodTool::SafeTH1::GetBinLowEdge(int bin){
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h
index 85f2361ca4c49f974b9874d964144404d5f00041..202ca449f8b85e0b409515337ea29e89f4c2d202 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/TElectronLikelihoodTool.h
@@ -73,6 +73,7 @@
    nNextToInnerMostLayerOutliers 	: next to the inner most 
    expectNextToInnerMostLayer 	: next to the inner most 
    convBit 		: el_isEM & (0x1 << egammaPID::ConversionMatch_Electron)
+   ambiguityBit 	: cut on the ambiguity type
    ip 		: Count number of vertices in vxp_n with >= 2 tracks in vxp_trk_n
 
    Created:
@@ -111,6 +112,7 @@ namespace LikeEnum {
     int nPixHitsPlusDeadSensors;
     bool passBLayerRequirement;
     int convBit;
+    uint8_t ambiguityBit;
     double d0;
     double deltaEta;
     double deltaphires;
@@ -185,7 +187,7 @@ namespace Root {
                                  double eta, double eT,
                                  int nSiHitsPlusDeadSensors, int nPixHitsPlusDeadSensors,
                                  bool passBLayerRequirement,
-                                 int convBit, double d0, double deltaEta, double deltaphires, 
+                                 int convBit, uint8_t ambiguityBit, double d0, double deltaEta, double deltaphires, 
                                  double wstot, double EoverP, double ip ) const;
     const Root::TResult& calculate(LikeEnum::LHCalcVars_t& vars_struct) const ;
     const Root::TResult& calculate( double eta, double eT,double f3, double rHad, double rHad1,
@@ -256,6 +258,8 @@ namespace Root {
     std::vector<double> CutDeltaPhiRes;
     /** @brief do cut on conversion bit*/
     bool doCutConversion;
+    /** @brief do cut on ambiguity bit*/
+    std::vector<int> CutAmbiguity;
     /** @brief do remove f3 variable from likelihood at high Et (>80 GeV)*/
     bool doRemoveF3AtHighEt;
     /** @brief do remove TRTPID variable from likelihood at high Et (>80 GeV)*/
@@ -322,7 +326,7 @@ namespace Root {
     unsigned int getLikelihoodEtHistBin(double eT)const ;
     
     /// Fine Et binning. Used for the likelihood discriminant cuts.
-    unsigned int getLikelihoodEtDiscBin(double eT) const;
+    unsigned int getLikelihoodEtDiscBin(double eT , const bool isLHbinning) const;
 
 
     // Private member variables
@@ -358,6 +362,9 @@ namespace Root {
     /// The position of the conversion cut bit in the TAccept return object
     int m_cutPosition_conversion;
 
+    /// The position of the ambiguity cut bit in the TAccept return object
+    int m_cutPosition_ambiguity;
+
     /// The position of the likelihood cut bit in the TAccept return object
     int m_cutPosition_LH;
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgElectronLikelihoodTools.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgElectronLikelihoodTools.py
index f3eb1b25712020d87b8d25214c21653812b2e16f..480d090c3aedb012d9dae4b91cc2baed6a30cca0 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgElectronLikelihoodTools.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgElectronLikelihoodTools.py
@@ -20,7 +20,7 @@ import sys
 from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronLikelihoodTool
 from ElectronPhotonSelectorTools.ElectronLikelihoodToolMapping import ElectronLikelihoodMap, electronLHmenu
 
-def ConfiguredAsgElectronLikelihoodTool( name, quality, menu=electronLHmenu.offline2015, **kw ):
+def ConfiguredAsgElectronLikelihoodTool( name, quality, menu=electronLHmenu.offlineMC16, **kw ):
     """
     Configure the AsgElectronIsEMSelector with the quality cuts
     and allow for (re-)setting of all provided cuts.
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodMenuDefs.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodMenuDefs.py
index 6a933e66a72cff2dc5a6dc9ea300eb6d696fc8df..00900caa12fa28e62a2b17bb3ff0b2981c99132b 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodMenuDefs.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodMenuDefs.py
@@ -201,3 +201,43 @@ def ElectronLikelihoodTightOfflineConfig2015(theTool) :
     '''
     theTool = GetTool(theTool)
     theTool.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodTightOfflineConfig2016_Smooth.conf"
+
+
+
+def ElectronLikelihoodVeryLooseOfflineConfig2016(theTool) :
+    '''
+    This is for the custom implementation of the VeryLoose offline likelihood for MC16 / Run 2 / Release 21.
+    This uses Offline PDFs, but does not yet have the pileup dependent discriminant cut.
+    '''
+    theTool = GetTool(theTool)
+    theTool.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodVeryLooseOfflineConfig2017_Smooth.conf"
+    
+    
+def ElectronLikelihoodLooseOfflineConfig2016(theTool) :
+    '''
+    This is for the custom implementation of the Loose offline likelihood for MC16 / Run 2 / Release 21.
+    This uses Offline PDFs, but does not yet have the pileup dependent discriminant cut.
+    (NOTE: same signal eff as offline Loosepp + 1%)
+    '''
+    theTool = GetTool(theTool)
+    theTool.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodLooseOfflineConfig2017_Smooth.conf"
+
+    
+def ElectronLikelihoodMediumOfflineConfig2016(theTool) :
+    '''
+    This is for the custom implementation of the Medium offline likelihood for MC16 / Run 2 / Release 21.
+    This uses Offline PDFs, but does not yet have the pileup dependent discriminant cut.
+    (NOTE: same signal eff as offline Mediumpp + 1%)
+    '''    
+    theTool = GetTool(theTool)
+    theTool.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodMediumOfflineConfig2017_Smooth.conf"
+
+    
+def ElectronLikelihoodTightOfflineConfig2016(theTool) :
+    '''
+    This is for the custom implementation of the Tight offline likelihood for MC16 / Run 2 / Release 21.
+    This uses Offline PDFs, but does not yet have the pileup dependent discriminant cut.
+    (NOTE: same signal eff as offline Tightpp + 1%)
+    '''
+    theTool = GetTool(theTool)
+    theTool.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodTightOfflineConfig2017_Smooth.conf"
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodToolMapping.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodToolMapping.py
index e2567154a6bfe3d9c4f359d4aefec79286822fd8..f436a1038ed12b3b3cd4dbf9ec38b95bfcea9c8d 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodToolMapping.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ElectronLikelihoodToolMapping.py
@@ -22,6 +22,7 @@ class electronLHmenu:
     trigger2012 = 1
     trigger2015 = 2
     offline2015 = 3
+    offlineMC16 = 4
 
 import ElectronPhotonSelectorTools.ElectronLikelihoodMenuDefs as ElectronLikelihoodMenuDefs
 
@@ -47,6 +48,13 @@ ElectronLHMapOffline2015 = {
     LikeEnum.Tight: ( LikeEnum.CustomOperatingPoint, ElectronLikelihoodMenuDefs.ElectronLikelihoodTightOfflineConfig2015 ),
     }
 
+ElectronLHMapOffline2016 = {
+    LikeEnum.VeryLoose: ( LikeEnum.CustomOperatingPoint, ElectronLikelihoodMenuDefs.ElectronLikelihoodVeryLooseOfflineConfig2016 ),
+    LikeEnum.Loose: ( LikeEnum.CustomOperatingPoint, ElectronLikelihoodMenuDefs.ElectronLikelihoodLooseOfflineConfig2016 ),
+    LikeEnum.Medium: ( LikeEnum.CustomOperatingPoint, ElectronLikelihoodMenuDefs.ElectronLikelihoodMediumOfflineConfig2016 ),
+    LikeEnum.Tight: ( LikeEnum.CustomOperatingPoint, ElectronLikelihoodMenuDefs.ElectronLikelihoodTightOfflineConfig2016 ),
+    }
+
 def ElectronLikelihoodMap(quality, menu):
     if menu == electronLHmenu.customMenu:
         return ElectronLHMapCustom[quality]
@@ -56,5 +64,7 @@ def ElectronLikelihoodMap(quality, menu):
         return ElectronLHMapTrigger2015[quality]
     elif menu == electronLHmenu.offline2015:
         return ElectronLHMapOffline2015[quality]
+    elif menu == electronLHmenu.offlineMC16:
+        return ElectronLHMapOffline2016[quality]
     else:
         raise ValueError("Requested menu is undefined: %d" % menu)
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/src/components/ElectronPhotonSelectorTools_entries.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/src/components/ElectronPhotonSelectorTools_entries.cxx
index b4460d449a74b10149b6ba481f6f6785761fc197..8b2545996bae176fa03f66bd5120d1c9e37ae22f 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/src/components/ElectronPhotonSelectorTools_entries.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/src/components/ElectronPhotonSelectorTools_entries.cxx
@@ -5,6 +5,7 @@
 #include "ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h"
 #include "ElectronPhotonSelectorTools/EGammaAmbiguityTool.h"
 #include "ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h"
+#include "ElectronPhotonSelectorTools/AsgDeadHVCellRemovalTool.h"
 
 DECLARE_COMPONENT( AsgElectronIsEMSelector )
 DECLARE_COMPONENT( AsgElectronMultiLeptonSelector )
@@ -13,4 +14,5 @@ DECLARE_COMPONENT( AsgPhotonIsEMSelector )
 DECLARE_COMPONENT( AsgForwardElectronIsEMSelector )
 DECLARE_COMPONENT( EGammaAmbiguityTool )
 DECLARE_COMPONENT( AsgElectronChargeIDSelectorTool )
+DECLARE_COMPONENT( AsgDeadHVCellRemovalTool )
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/EGIdentification_mem_check.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/EGIdentification_mem_check.cxx
index 577f2f4d55e72f5eca478df3191324d41a664dc7..44cd4cd017577e52bdfb48f10c049dcacb7d52c6 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/EGIdentification_mem_check.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/EGIdentification_mem_check.cxx
@@ -11,28 +11,20 @@ http://valgrind.org/docs/manual/faq.html#faq.deflost
 
 */
 
-#include "ElectronPhotonSelectorTools/IAsgPhotonIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/IAsgElectronLikelihoodTool.h"
-
-#include "ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
-#include "CxxUtils/make_unique.h"
-
+#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
+#include "AsgTools/AnaToolHandle.h"
+#include "AsgTools/MessageCheck.h"
 
 int main(){
+  using namespace asg::msgUserCode;
+  ANA_CHECK_SET_TYPE (int);
 
-  /*std::unique_ptr<AsgElectronIsEMSelector> electronMediumIsEMSelector = CxxUtils::make_unique<AsgElectronIsEMSelector> ("electronMediumIsEMSelector");
-    electronMediumIsEMSelector->setProperty("WorkingPoint", "MediumElectron");
-    electronMediumIsEMSelector->initialize();
-  */
-
-  std::unique_ptr<AsgElectronLikelihoodTool> MediumLH = CxxUtils::make_unique<AsgElectronLikelihoodTool> ("MediumLH");
-  MediumLH->setProperty("WorkingPoint", "MediumLHElectron");
-  MediumLH->initialize();
+  asg::AnaToolHandle<IAsgElectronLikelihoodTool> MediumLH("AsgElectronLikelihoodTool/MediumLH");
+  ANA_CHECK(MediumLH.setProperty("WorkingPoint", "MediumLHElectron"));
+  ANA_CHECK(MediumLH.initialize());
 
   return 0;
 }
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEGIdentificationPoints.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEGIdentificationPoints.cxx
index 7dac45252bac8e8901f7fbb106e32de9e7035119..e6d1981496f8971aada21a4610507bc3c92d6827 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEGIdentificationPoints.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEGIdentificationPoints.cxx
@@ -16,20 +16,20 @@
 #include "xAODEgamma/PhotonContainer.h" 
 #include "xAODEgamma/Electron.h" 
 #include "xAODEgamma/Photon.h" 
-
-#include "ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h"
-#include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
-#include "CxxUtils/make_unique.h"
-#include "AsgTools/AsgMessaging.h"
-
+#include "AsgTools/AnaToolHandle.h"
+
+#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
+#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
+//
+#include "AsgTools/MessageCheck.h"
+#include "AsgTools/MsgStream.h"
 // Derivation include
 #include "xAODCore/tools/IOStats.h"
 #include "xAODCore/tools/ReadStats.h"
 
-
-
 // Infrastructure include(s):
 #ifdef ROOTCORE
 #   include "xAODRootAccess/Init.h"
@@ -37,75 +37,59 @@
 #   include "xAODRootAccess/TStore.h"
 #endif // ROOTCORE
 
-//Define msg functionality using AsgMessaging
-//---------------------------------------------------
-namespace{  
-  asg::AsgMessaging dummymsg("");
+namespace asg{
+  ANA_MSG_HEADER (msgSelectorCheck)
+  ANA_MSG_SOURCE (msgSelectorCheck, "EgammaSelectorCheck") 
 }
-#define DUMMY_MSG( lvl, ARG ) {dummymsg.msg(lvl)<<ARG<<endmsg ;}
-#define MSG_DEBUG( ARG ) {DUMMY_MSG(MSG::DEBUG, ARG);}
-#define MSG_INFO( ARG ) {DUMMY_MSG(MSG::INFO, ARG);}
-#define MSG_WARNING( ARG ) {DUMMY_MSG(MSG::WARNING, ARG);}
-#define MSG_ERROR( ARG ) {DUMMY_MSG(MSG::ERROR, ARG);}
-#define MSG_FATAL( ARG ) {DUMMY_MSG(MSG::FATAL, ARG);}
-#define MSG_ABORT( ARG ) {DUMMY_MSG(MSG::FATAL, ARG); std::abort();} 
-#define CHECK( ARG )                                                    \
-  do {                                                                  \
-    const bool result = ARG;                                            \
-    if( ! result ) {                                                    \
-      MSG_ERROR("FAILED  to execute" <<#ARG);                           \
-      return EXIT_FAILURE;                                              \
-    }                                                                   \
-  } while( false )
-//---------------------------------------------------
 
 //main test code
 int main( int argc, char* argv[] ) {
 
-   // The application's name:
-   const char* APP_NAME = argv[ 0 ];
+  //
+  using namespace asg::msgSelectorCheck;
+  ANA_CHECK_SET_TYPE (int);
+  MSG::Level mylevel=MSG::INFO;
+  setMsgLevel(mylevel);
+  //
+
+  // The application's name:
+  const char* APP_NAME = argv[ 0 ];
 
-   MSG::Level mylevel=MSG::DEBUG;
-   dummymsg.msg().setLevel(mylevel);
-   dummymsg.msg().setName(APP_NAME);
    // Check if we received a file name:
    if( argc < 2 ) {
-     MSG_ERROR("No file name received!" );
-     MSG_ERROR( "  Usage: %s [xAOD file name]");
+     ANA_MSG_ERROR("No file name received!" );
+     ANA_MSG_ERROR( "  Usage: %s [xAOD file name]");
      return EXIT_FAILURE;
    }
    
    // Initialise the application:
-   CHECK( xAOD::Init( APP_NAME ) );
+   ANA_CHECK( xAOD::Init( APP_NAME ) );
 
    // Open the input file:
    const TString fileName = argv[ 1 ];
    Info( APP_NAME, "Opening file: %s", fileName.Data() );
    std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
-   CHECK( ifile.get() );
+   ANA_CHECK( ifile.get() );
  
   // Check if we want to process Electron or Photon
    bool isElectron = true;   
    if( argc < 4 ) {
-     Info (APP_NAME, "By default lookign to Electron" );
+     Info (APP_NAME, "By default looking to Electron" );
    } else {  
     int  argv1 = atoi(argv[ 3 ]);
     if(argv1 == 0)   isElectron = false; 
-    if(isElectron)  Info( APP_NAME, "We are lookign to Electron-ID: %i", isElectron );
-    else  Info( APP_NAME, "We are lookign to Photon-ID" );
+    if(isElectron)  Info( APP_NAME, "We are looking to Electron-ID: %i", isElectron );
+    else  Info( APP_NAME, "We are looking to Photon-ID" );
    }
    // Create a TEvent object (persistent store)
 
-   //For 2.4.5 testing
-   xAOD::TEvent pers( xAOD::TEvent::kAthenaAccess );
-   //For 2.3
-   //xAOD::TEvent pers( xAOD::TEvent::kBranchAccess );
+   xAOD::TEvent pers( xAOD::TEvent::kClassAccess );
 
    // Create a TStore object (transient store)
    xAOD::TStore trans;
-   CHECK( pers.readFrom( ifile.get() ) );
+   ANA_CHECK( pers.readFrom( ifile.get() ) );
    //
-   MSG_INFO("Number of events in the file: "<< pers.getEntries());
+   ANA_MSG_INFO("Number of events in the file: "<< pers.getEntries());
 
    // Decide how many events to run over:
    Long64_t entries = pers.getEntries();
@@ -119,71 +103,100 @@ int main( int argc, char* argv[] ) {
 
    if (isElectron) {
    //Medium cut based Electrons
-   std::unique_ptr<AsgElectronIsEMSelector> m_electronMediumIsEMSelector = CxxUtils::make_unique<AsgElectronIsEMSelector> ("electronMediumIsEMSelector");
-   CHECK(m_electronMediumIsEMSelector->setProperty("WorkingPoint", "MediumElectron"));
-   m_electronMediumIsEMSelector->msg().setLevel(mylevel);
-   CHECK(m_electronMediumIsEMSelector->initialize());
-   
-   //Medium Likelihood electron
-   std::unique_ptr<AsgElectronLikelihoodTool> m_MediumLH = CxxUtils::make_unique<AsgElectronLikelihoodTool> ("MediumLH");
-   CHECK(m_MediumLH->setProperty("WorkingPoint", "MediumLHElectron"));
-   m_MediumLH->msg().setLevel(mylevel);
-   CHECK(m_MediumLH->initialize());
-   
-   // Loop over the events:
-   for( Long64_t entry = 0; entry < entries; ++entry ) {
+
+     asg::AnaToolHandle<IAsgElectronIsEMSelector> electronMediumIsEMSelector ("AsgElectronIsEMSelector/electronMediumIsEMSelector");
+     ANA_CHECK(electronMediumIsEMSelector.setProperty("WorkingPoint", "MediumElectron"));
+     ANA_CHECK(electronMediumIsEMSelector.setProperty("OutputLevel", mylevel));
+     ANA_CHECK(electronMediumIsEMSelector.initialize());
+
+     asg::AnaToolHandle<IAsgElectronLikelihoodTool> electronMediumLHSelector ("AsgElectronLikelihoodTool/electronMediumLHSelector");
+     ANA_CHECK(electronMediumLHSelector.setProperty("WorkingPoint", "MediumLHElectron"));
+     ANA_CHECK(electronMediumLHSelector.setProperty("OutputLevel", mylevel));
+     ANA_CHECK(electronMediumLHSelector.initialize());
      
+     
+   // Loop over the events:
+     for( Long64_t entry = 0; entry < entries; ++entry ) {
+       
      // Tell the object which entry to look at:
-     pers.getEntry( entry );
-     MSG_INFO("============================");
-     MSG_INFO("Event: " <<entry);
-
-     const xAOD::ElectronContainer* electrons;
-     CHECK(pers.retrieve(electrons, "Electrons"));
-
-     unsigned int counter=0;
-     for (const xAOD::Electron* el : *electrons) {
-       MSG_INFO("---------------------------");
-       MSG_INFO("Electron: " << counter);
-       MSG_INFO("Electron LH Medium accept result: " <<m_MediumLH->accept(*el));
-       MSG_INFO("Electron stored LH Medium: "  << el->passSelection("LHMedium") );
-       MSG_INFO("Electron Cut Medium accept result: " <<m_electronMediumIsEMSelector->accept(*el));
-       MSG_INFO("Electron stored Medium: "  << el->passSelection("Medium") );
-       ++counter;
-     }
-   } // loop entries
+       pers.getEntry( entry );
+       ANA_MSG_INFO("============================");
+       ANA_MSG_INFO("Event: " <<entry);
+
+       const xAOD::ElectronContainer* electrons;
+       ANA_CHECK(pers.retrieve(electrons, "Electrons"));
+       
+       unsigned int counter=0;
+       for (const xAOD::Electron* el : *electrons) {
+       ANA_MSG_INFO("---------------------------");
+       ANA_MSG_INFO("Electron: " << counter);
+       ANA_MSG_INFO("Electron LH Medium accept result: " <<electronMediumLHSelector->accept(*el));
+       ANA_MSG_INFO("Electron Cut based");
+       ANA_MSG_INFO("Electron Cut Medium accept result: " <<electronMediumIsEMSelector->accept(*el));
    
-   } // is electron
+       //Bitset manipulation 
+       ANA_MSG_INFO("Decision as a bitset: ");
+       std::bitset<32> decision = electronMediumIsEMSelector->accept(*el).getCutResultBitSet();
+       ANA_MSG_INFO("Result bitset: " <<decision);
+       std::bitset<32> isEMdecision = electronMediumIsEMSelector->accept(*el).getCutResultInvertedBitSet() ;
+       ANA_MSG_INFO("isEM Result bitset: " << isEMdecision);
+       //
+       ANA_MSG_INFO("Masks: " );
+       std::bitset<32> MediumMask(egammaPID::ElectronMediumPP);
+       ANA_MSG_INFO("Medium mask: " << MediumMask);
+
+       std::bitset<32> HadLeakageOnlyMask( 0x1 << egammaPID::ClusterHadronicLeakage_Electron);
+       ANA_MSG_INFO("HadLeakageOnly mask: " << HadLeakageOnlyMask);
+       //
+       std::bitset<32> MediumWithouHadLeakageMask( egammaPID::ElectronMediumPP ^ (0x1 << egammaPID::ClusterHadronicLeakage_Electron));
+       ANA_MSG_INFO("Medium Without Had Leakage  mask: " << MediumWithouHadLeakageMask);
+       //
+
+       bool passALLDecisionisem= (isEMdecision&MediumMask)==0;
+       std::bitset<32> passALLDecisionisemBitSet(isEMdecision&MediumMask);
+       ANA_MSG_INFO("Electron check all cuts via  isem: "<< passALLDecisionisem << " ,bitset " << passALLDecisionisemBitSet);
+
+       bool checkOnlyHadLeakageisem= (isEMdecision&HadLeakageOnlyMask)==0;
+       std::bitset<32> checkOnlyHadLeakageisemBitSet(isEMdecision&HadLeakageOnlyMask);
+       ANA_MSG_INFO("Electron check Only Had Leakage via isem:: "<< checkOnlyHadLeakageisem << " ,bitset " << checkOnlyHadLeakageisemBitSet);
+
+       bool ignoreHadLeakageisem= (isEMdecision&MediumWithouHadLeakageMask)==0;
+       std::bitset<32> ignoreHadLeakageisemBitSet(isEMdecision&MediumWithouHadLeakageMask);
+       ANA_MSG_INFO("Electron ignore Had Leakage check all else via isem:: "<< ignoreHadLeakageisem << " ,bitset " << ignoreHadLeakageisemBitSet);
+
+       ++counter;
+
+
+       }
+     } // loop entries
+   }// is electron
    else {
      //Tight cut based photon
-     std::unique_ptr<AsgPhotonIsEMSelector> m_photonTightIsEMSelector = CxxUtils::make_unique<AsgPhotonIsEMSelector> ("photonTightIsEMSelector");
-     CHECK(m_photonTightIsEMSelector->setProperty("WorkingPoint", "TightPhoton"));
-     m_photonTightIsEMSelector->msg().setLevel(mylevel);
-     CHECK(m_photonTightIsEMSelector->initialize());
      
+     asg::AnaToolHandle<IAsgPhotonIsEMSelector> photonTightIsEMSelector ("AsgPhotonIsEMSelector/photonTightIsEMSelector");
+     ANA_CHECK(photonTightIsEMSelector.setProperty("WorkingPoint", "TightPhoton"));
+     ANA_CHECK(photonTightIsEMSelector.setProperty("OutputLevel", mylevel));
+     ANA_CHECK(photonTightIsEMSelector.initialize());
      // Loop over the events:
      for( Long64_t entry = 0; entry < entries; ++entry ) {
        
        // Tell the object which entry to look at:
        pers.getEntry( entry );
-       MSG_INFO("============================");
-       MSG_INFO("Event: " <<entry);
+       ANA_MSG_INFO("============================");
+       ANA_MSG_INFO("Event: " <<entry);
        
        const xAOD::PhotonContainer* photons;
-       CHECK(pers.retrieve(photons, "Photons"));
+       ANA_CHECK(pers.retrieve(photons, "Photons"));
        unsigned int counter=0;
        for (const xAOD::Photon* ph : *photons) {
-	 if(ph->author() != xAOD::EgammaParameters::AuthorCaloTopo35){
-	   MSG_INFO("---------------------------");
-	   MSG_INFO("Photon: " << counter);
-	   MSG_INFO("Photon Tight accept result: " <<m_photonTightIsEMSelector->accept(*ph));
-	   ++counter;       
-	 }
+	 ANA_MSG_INFO("---------------------------");
+	 ANA_MSG_INFO("Photon: " << counter);
+	 ANA_MSG_INFO("Photon Tight accept result: " <<photonTightIsEMSelector->accept(*ph));
+	 ++counter;       
        }
      }// loop entries
    }
-
-
+    
    xAOD::IOStats::instance().stats().printSmartSlimmingBranchList();
    return 0;
 }
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEMAmbiguityResolver.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEMAmbiguityResolver.cxx
deleted file mode 100644
index 256cde57f9158ad5f27d3057bb2c8bdeb85dbd5c..0000000000000000000000000000000000000000
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/util/testEMAmbiguityResolver.cxx
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// System include(s):
-#include <memory>
-#include <cstdlib>
-
-// ROOT include(s):
-#include <TFile.h>
-#include <TError.h>
-#include <TString.h>
-
-// EDM include(s):
-#include "xAODEgamma/ElectronContainer.h" 
-#include "xAODEgamma/PhotonContainer.h" 
-#include "xAODEgamma/Electron.h" 
-#include "xAODEgamma/Photon.h" 
-#include "xAODEgamma/Egamma.h"
-#include "xAODEgamma/EgammaTruthxAODHelpers.h"
-#include "ElectronPhotonSelectorTools/EGammaAmbiguityTool.h"
-#include "AsgTools/AsgMessaging.h"
-
-// Infrastructure include(s):
-#ifdef ROOTCORE
-#   include "xAODRootAccess/Init.h"
-#   include "xAODRootAccess/TEvent.h"
-#   include "xAODRootAccess/TStore.h"
-#endif // ROOTCORE
-
-//Define msg functionality using AsgMessaging
-//---------------------------------------------------
-namespace{  
-  asg::AsgMessaging dummymsg("");
-}
-#define DUMMY_MSG( lvl, ARG ) {dummymsg.msg(lvl)<<ARG<<endmsg ;}
-#define MSG_DEBUG( ARG ) {DUMMY_MSG(MSG::DEBUG, ARG);}
-#define MSG_INFO( ARG ) {DUMMY_MSG(MSG::INFO, ARG);}
-#define MSG_WARNING( ARG ) {DUMMY_MSG(MSG::WARNING, ARG);}
-#define MSG_ERROR( ARG ) {DUMMY_MSG(MSG::ERROR, ARG);}
-#define MSG_FATAL( ARG ) {DUMMY_MSG(MSG::FATAL, ARG);}
-#define MSG_ABORT( ARG ) {DUMMY_MSG(MSG::FATAL, ARG); std::abort();} 
-#define CHECK( ARG )                                                    \
-  do {                                                                  \
-    const bool result = ARG;                                            \
-    if( ! result ) {                                                    \
-      MSG_ERROR("FAILED  to execute" <<#ARG);                           \
-      return EXIT_FAILURE;                                              \
-    }                                                                   \
-  } while( false )
-
-
-//---------------------------------------------------
-
-//main test code
-int main( int argc, char* argv[] ) {
-
-   // The application's name:
-   const char* APP_NAME = argv[ 0 ];
-
-   MSG::Level mylevel=MSG::DEBUG;
-   dummymsg.msg().setLevel(mylevel);
-   dummymsg.msg().setName(APP_NAME);
-   // Check if we received a file name:
-   if( argc < 2 ) {
-     MSG_ERROR("No file name received!" );
-     MSG_ERROR( "  Usage: %s [xAOD file name]");
-     return EXIT_FAILURE;
-   }
-   
-   // Initialise the application:
-   CHECK( xAOD::Init( APP_NAME ) );
-
-   // Open the input file:
-   const TString fileName = argv[ 1 ];
-   Info( APP_NAME, "Opening file: %s", fileName.Data() );
-   std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
-   CHECK( ifile.get() );
- 
-   // Create a TEvent object (persistent store)
-   xAOD::TEvent pers( xAOD::TEvent::kClassAccess );
-   // Create a TStore object (transient store)
-   xAOD::TStore trans;
-   CHECK( pers.readFrom( ifile.get() ) );
-   //
-   MSG_INFO("Number of events in the file: "<< pers.getEntries());
-
-   // Decide how many events to run over:
-   Long64_t entries = pers.getEntries();
-   if( argc > 2 ) {
-      const Long64_t e = atoll( argv[ 2 ] );
-      if( e < entries ) {
-         entries = e;
-      }
-   }
-
-   //Initialise Ambiguity Tool
-   EGammaAmbiguityTool myAmbiguity("myEGammaAmbiguityTool");
-   myAmbiguity.msg().setLevel(mylevel);
-   CHECK(myAmbiguity.initialize());
-
-   // Loop over the events:
-   for( Long64_t entry = 0; entry < entries; ++entry ) {
-     
-     // Tell the object which entry to look at:
-     pers.getEntry( entry );
-     MSG_INFO("============================");
-     MSG_INFO("Event: " <<entry);
-
-     const xAOD::ElectronContainer* electrons;
-     CHECK(pers.retrieve(electrons, "Electrons"));
-
-     const xAOD::PhotonContainer* photons;
-     CHECK(pers.retrieve(photons, "Photons"));
-
-     unsigned int counter=0;
-     for (const xAOD::Electron* el : *electrons) {
-       MSG_INFO("---------------------------");
-       MSG_INFO("Electron: " << counter);
-       MSG_INFO("Initial Author: " << el->author());
-       MSG_INFO("Ambiguity accept result: " << myAmbiguity.accept(*el));
-       static const  SG::AuxElement::Accessor<uint8_t> acc("ambiguityType");    
-       MSG_INFO("Ambiguity Type: " << static_cast<int> (acc(*el)));
-
-       static const SG::AuxElement::Accessor<ElementLink<xAOD::EgammaContainer> > ELink ("ambiguityLink");
-       if(ELink(*el).isValid()){
-	 const xAOD::Photon* overlapPhoton = static_cast<const xAOD::Photon*> (*ELink(*el));
-	 MSG_INFO("Overlap photon pt: " << overlapPhoton->pt());
-       }
-       ++counter;
-     }
-
-     counter=0;
-     for (const xAOD::Photon* ph : *photons) {
-       if(ph->author() != xAOD::EgammaParameters::AuthorCaloTopo35){
-	 MSG_INFO("---------------------------");
-	 MSG_INFO("Photon: " << counter);
-	 MSG_INFO("Initial Author: " << ph->author());
-	 MSG_INFO("Ambiguity accept result: " << myAmbiguity.accept(*ph));
-	 static const  SG::AuxElement::Accessor<uint8_t> acc("ambiguityType");    
-	 MSG_INFO("Ambiguity Type: " << static_cast<int> (acc(*ph)));
-	 
-	 static const SG::AuxElement::Accessor<ElementLink<xAOD::EgammaContainer> > ELink ("ambiguityLink");
-	 if(ELink(*ph).isValid()){
-	   const xAOD::Electron* overlapElectron = static_cast< const xAOD::Electron*> (*ELink(*ph));
-	   MSG_INFO("Overlap Electron pt: " << overlapElectron->pt());
-	 }
-     
-	 ++counter;       
-       }
-     }
-   }
-   CHECK(myAmbiguity.finalize());
-   return 0;
-}
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/CMakeLists.txt
index 50ebf57f8913c3975da24bcb4ebcaceacfa1025b..6e41a90da9a4c10a1cc16979b5152794303a2613 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/CMakeLists.txt
@@ -18,6 +18,7 @@ atlas_depends_on_subdirs(
    Control/AthToolSupport/AsgTools
    Event/xAOD/xAODEgamma
    PhysicsAnalysis/AnalysisCommon/PATInterfaces
+   PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces	
    PRIVATE
    Tools/PathResolver
    ${extra_dep} )
@@ -31,7 +32,7 @@ atlas_add_library( ElectronPhotonShowerShapeFudgeToolLib
    ElectronPhotonShowerShapeFudgeTool/*.icc Root/*.cxx
    PUBLIC_HEADERS ElectronPhotonShowerShapeFudgeTool
    INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-   LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODEgamma PATInterfaces
+   LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODEgamma PATInterfaces EgammaAnalysisInterfacesLib
    PRIVATE_LINK_LIBRARIES PathResolver )
 
 if( NOT XAOD_STANDALONE )
@@ -45,13 +46,5 @@ atlas_add_dictionary( ElectronPhotonShowerShapeFudgeToolDict
    ElectronPhotonShowerShapeFudgeTool/selection.xml
    LINK_LIBRARIES ElectronPhotonShowerShapeFudgeToolLib )
 
-atlas_add_executable( EPSSFT_convertFF util/convertFF.cxx
-   INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-   LINK_LIBRARIES ${ROOT_LIBRARIES} ElectronPhotonShowerShapeFudgeToolLib )
-
-atlas_add_executable( EPSSFT_drawFFs util/drawFFs.cxx
-   INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-   LINK_LIBRARIES ${ROOT_LIBRARIES} ElectronPhotonShowerShapeFudgeToolLib )
-
 # Install files from the package:
 atlas_install_data( data/*.conf data/*.root )
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool.h
index 9e74c795590b4da8f3dd7b72692720efe7900e32..5454a2bb9337fa6c60f81e4e22206d16608a9acd 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool.h
@@ -22,7 +22,7 @@
 #include "ElectronPhotonShowerShapeFudgeTool/FudgeMCTool.h"
 #endif
 #include "ElectronPhotonShowerShapeFudgeTool/TElectronMCShifterTool.h"
-#include "ElectronPhotonShowerShapeFudgeTool/IElectronPhotonShowerShapeFudgeTool.h"
+#include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h"
 #include "TEnv.h"
 
 class ElectronPhotonShowerShapeFudgeTool : public asg::AsgTool, virtual public  IElectronPhotonShowerShapeFudgeTool
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/IElectronPhotonShowerShapeFudgeTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/IElectronPhotonShowerShapeFudgeTool.h
index 19c4b8508d8aa6cd89f6f7c2aeed05c5ee0c0f9a..cd1f465e1757f9c1ba077b6d0d2e3e30be8100e1 100644
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/IElectronPhotonShowerShapeFudgeTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonShowerShapeFudgeTool/ElectronPhotonShowerShapeFudgeTool/IElectronPhotonShowerShapeFudgeTool.h
@@ -5,45 +5,7 @@
 #ifndef _IELECTRONPHOTONSHOWERSHAPEFUDGETOOL_H
 #define _IELECTRONPHOTONSHOWERSHAPEFUDGETOOL_H
 
-/**
-   @class AsgFudgeMCTool
-   @brief Tool to fudge photon MC shower shapes.
-
-   @author Rob Roy Fletcher (University of Pennsylvania) rob.fletcher@cern.ch
-   @date   August 2014
-
-
-*/
-
-// Framework include(s):
-#include "AsgTools/IAsgTool.h"
-
-// EDM include(s):
-#include "xAODEgamma/EgammaFwd.h"
-#include "xAODEgamma/PhotonFwd.h"
-#include "xAODEgamma/ElectronFwd.h"
-
-// Local include(s):
-#include "PATInterfaces/CorrectionCode.h"
-
-
-class IElectronPhotonShowerShapeFudgeTool : public virtual asg::IAsgTool {
-
-   /// Declare the interface that the class provides
-   ASG_TOOL_INTERFACE(IElectronPhotonShowerShapeFudgeTool)
-
-public:
-   /// Apply the correction on a modifyable object
-   virtual const CP::CorrectionCode applyCorrection(xAOD::Photon& ph ) const = 0;
-
-   virtual const CP::CorrectionCode applyCorrection(xAOD::Electron& el ) const = 0;
-
-   virtual const CP::CorrectionCode correctedCopy( const xAOD::Photon& ph, xAOD::Photon*& output ) const = 0;
-
-   virtual const CP::CorrectionCode correctedCopy( const xAOD::Electron& el, xAOD::Electron*& output ) const = 0;
-
-
-
-}; // class IElectronPhotonShowerShapeFudgeTool
+#include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif // _IASGFUDGEMCTOOL_H
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/ElectronTagTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/ElectronTagTool.h
index 69b92a8953ff33bce2641c4de8e2c2cc42155358..b526ff8099e7cf0041b6af48d9ed7df385ba1d1f 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/ElectronTagTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/ElectronTagTool.h
@@ -103,7 +103,7 @@ private:
   std::string m_vxCandidate;
 
   /** calib tool */
-  //  ToolHandle<CP::IEgammaCalibrationAndSmearingTool> m_EgammaCalibrationAndSmearingTool;
+  // ToolHandle<CP::IEgammaCalibrationAndSmearingTool> m_EgammaCalibrationAndSmearingTool;
   
 };
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/PhotonTagTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/PhotonTagTool.h
index beeebf2194c455c27b8b862f3afd723b5480bbb0..12e7a541840ed810432b47449122d047c88bb025 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/PhotonTagTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/ElectronPhotonTagTools/PhotonTagTool.h
@@ -90,7 +90,7 @@ private:
   ToolHandle<CP::IIsolationSelectionTool> m_fixedcut_tight_isolation;//!
 
   /** calib tool */
-  //  ToolHandle<CP::IEgammaCalibrationAndSmearingTool> m_EgammaCalibrationAndSmearingTool;
+  // ToolHandle<CP::IEgammaCalibrationAndSmearingTool> m_EgammaCalibrationAndSmearingTool;
 
  };
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/ElectronTagTool_jobOptions.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/ElectronTagTool_jobOptions.py
index 81ba0f03855de59be2b218a11b2f9cea312f4e11..1b977cc3b7eeb0cd3ede6abafb2641461024a5e6 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/ElectronTagTool_jobOptions.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/ElectronTagTool_jobOptions.py
@@ -95,5 +95,7 @@ ElectronTagTool = ConfiguredElectronTagTool(
      FixedCutTightIsolation          = FixedCutTightIsoTool      
      )
 
-#ElectronTagTool.EgammaCalibrationAndSmearingTool.ESModel =  "es2015PRE"
-#ToolSvc += ElectronTagTool
+# ElectronTagTool.EgammaCalibrationAndSmearingTool.randomRunNumber = 308047
+# ElectronTagTool.EgammaCalibrationAndSmearingTool.ESModel =  "es2016data_mc15c"
+
+# ToolSvc += ElectronTagTool
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/PhotonTagTool_jobOptions.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/PhotonTagTool_jobOptions.py
index 816b1fea77824617225941eff9df0afb1e640f23..bf20bc2688caeaf2b2adea11577923a87efa7ecf 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/PhotonTagTool_jobOptions.py
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/share/PhotonTagTool_jobOptions.py
@@ -97,5 +97,7 @@ PhotonTagTool = ConfiguredPhotonTagTool(
     FixedCutTightIsoTool         = FixedCutTightIsoTool
     )
 
-#PhotonTagTool.EgammaCalibrationAndSmearingTool.ESModel =  "es2015PRE"
-#ToolSvc += PhotonTagTool
+# PhotonTagTool.EgammaCalibrationAndSmearingTool.randomRunNumber = 308047
+# PhotonTagTool.EgammaCalibrationAndSmearingTool.ESModel =  "es2016data_mc15c"
+
+# ToolSvc += PhotonTagTool
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/ElectronTagTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/ElectronTagTool.cxx
index 43ab06cd5044215f64e4afccefc97dc82e120f7c..416c784d876600b952b7e8a5e42f0ed403a224b8 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/ElectronTagTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/ElectronTagTool.cxx
@@ -53,7 +53,7 @@ ElectronTagTool::ElectronTagTool (const std::string& type, const std::string& na
   m_fixedcut_tight_trackonly_isolation(""),
   m_fixedcut_loose_isolation(""),
   m_fixedcut_tight_isolation("") {
-  //  m_EgammaCalibrationAndSmearingTool("CP::EgammaCalibrationAndSmearingTool/EgammaCalibrationAndSmearingTool", this) {
+  // m_EgammaCalibrationAndSmearingTool("CP::EgammaCalibrationAndSmearingTool/EgammaCalibrationAndSmearingTool", this) {
   
   /** Electron AOD Container Name */
   declareProperty("Container",                 m_containerNames);
@@ -98,7 +98,7 @@ ElectronTagTool::ElectronTagTool (const std::string& type, const std::string& na
   declareProperty ("PrimaryVertexKey", m_vxCandidate = "PrimaryVertices");
 
   /** CP tool to calib objects */
-  //  declareProperty( "EgammaCalibrationAndSmearingTool", m_EgammaCalibrationAndSmearingTool);
+  // declareProperty( "EgammaCalibrationAndSmearingTool", m_EgammaCalibrationAndSmearingTool);
 
   declareInterface<ElectronTagTool>( this );
 }
@@ -133,7 +133,7 @@ StatusCode  ElectronTagTool::initialize() {
   CHECK(m_fixedcut_tight_isolation.retrieve());
 
   /** retreive and check the calibration tool */
-  //  CHECK(m_EgammaCalibrationAndSmearingTool.retrieve());
+  // CHECK(m_EgammaCalibrationAndSmearingTool.retrieve());
 
   if (m_etconeisocutvalues.size() > 4) {
     ATH_MSG_FATAL ("More than four etcone values are not permitted");
@@ -226,11 +226,11 @@ StatusCode ElectronTagTool::execute(TagFragmentCollection& eTagColl, const int&
     for ( xAOD::Electron *shallowCopyElectron : * electronContainerShallowCopy ) {
 
       /** fix calibration using tool */
-      //      ATH_MSG_DEBUG("Un-Calibrated pt = " << shallowCopyElectron->pt());
-      //      if(m_EgammaCalibrationAndSmearingTool->applyCorrection(*shallowCopyElectron) != CP::CorrectionCode::Ok){
-      //          ATH_MSG_WARNING("Cannot calibrate electron");
-      //      }
-      //      ATH_MSG_DEBUG("Calibrated pt = " << shallowCopyElectron->pt()); 
+      // ATH_MSG_DEBUG("Un-Calibrated pt = " << shallowCopyElectron->pt());
+      // if(m_EgammaCalibrationAndSmearingTool->applyCorrection(*shallowCopyElectron) != CP::CorrectionCode::Ok){
+      //    ATH_MSG_WARNING("Cannot calibrate electron");
+      // }
+      // ATH_MSG_DEBUG("Calibrated pt = " << shallowCopyElectron->pt()); 
 
       /** apply isolation fix */
       if (m_isolation_correction_tool->applyCorrection(*shallowCopyElectron) != CP::CorrectionCode::Ok) {
diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/PhotonTagTool.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/PhotonTagTool.cxx
index e913a24e705ff1d4a82fe6f9345a55c44d62bd49..c1428174463fff84805b16a0926591d1ff725428 100755
--- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/PhotonTagTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonTagTools/src/PhotonTagTool.cxx
@@ -25,7 +25,7 @@ Purpose : create a collection of PhotonTag
 #include "TagEvent/PhotonAttributeNames.h"
 #include "AnalysisUtils/AnalysisMisc.h"
 #include "AthContainers/ConstDataVector.h"
-//#include "ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h"
+// #include "ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h"
 
 #include <sstream>
 
@@ -43,7 +43,7 @@ PhotonTagTool::PhotonTagTool (const std::string& type, const std::string& name,
   m_cone40_calo_isolation(""),
   m_cone40_isolation(""),
   m_cone20_isolation("") {
-  //  m_EgammaCalibrationAndSmearingTool("CP::EgammaCalibrationAndSmearingTool/EgammaCalibrationAndSmearingTool", this) {
+  // m_EgammaCalibrationAndSmearingTool("CP::EgammaCalibrationAndSmearingTool/EgammaCalibrationAndSmearingTool", this) {
 
   /** Photon AOD Container Name */
   declareProperty("Container",             m_containerName = "PhotonCollection");
@@ -84,7 +84,7 @@ PhotonTagTool::PhotonTagTool (const std::string& type, const std::string& name,
   declareProperty("FixedCutTightIsoTool",         m_fixedcut_tight_isolation);
 
   /** CP tool to calib objects */
-  //  declareProperty( "EgammaCalibrationAndSmearingTool", m_EgammaCalibrationAndSmearingTool);
+  // declareProperty( "EgammaCalibrationAndSmearingTool", m_EgammaCalibrationAndSmearingTool);
 
   declareInterface<PhotonTagTool>( this );
 }
@@ -117,7 +117,7 @@ StatusCode  PhotonTagTool::initialize() {
   CHECK(m_fixedcut_tight_isolation.retrieve());
   
   /** retrieve and check the calibration tool */
-  //  CHECK(m_EgammaCalibrationAndSmearingTool.retrieve());
+  // CHECK(m_EgammaCalibrationAndSmearingTool.retrieve());
 
   if (m_etconeisocutvalues.size() > 4) {
     ATH_MSG_FATAL ("More than four Etcone values are not permitted");
@@ -214,15 +214,17 @@ StatusCode PhotonTagTool::execute(TagFragmentCollection& pTagColl, const int& ma
     if (m_isFullsim) CP::CorrectionCode correctionCode = m_shower_shape_fudge->applyCorrection(*shallowCopyPhoton);
 
     /** fix calibration using tool */
-//    if ((shallowCopyPhoton->author() & xAOD::EgammaParameters::AuthorCaloTopo35) > 0) {
-//      ATH_MSG_DEBUG("Author " <<xAOD::EgammaParameters::AuthorCaloTopo35<< " photon pt = " << shallowCopyPhoton->pt() << " do not calibrate, not supported "); 
-//    } else {
-//      ATH_MSG_DEBUG("Un-Calibrated pt = " << shallowCopyPhoton->pt()); 
-//      if(m_EgammaCalibrationAndSmearingTool->applyCorrection(*shallowCopyPhoton) != CP::CorrectionCode::Ok){
-//	ATH_MSG_WARNING("Cannot calibrate electron");
-//      }
-//      ATH_MSG_DEBUG("Calibrated pt = " << shallowCopyPhoton->pt()); 
-//    }
+    /**
+    if ((shallowCopyPhoton->author() & xAOD::EgammaParameters::AuthorCaloTopo35) > 0) {
+      ATH_MSG_DEBUG("Author " <<xAOD::EgammaParameters::AuthorCaloTopo35<< " photon pt = " << shallowCopyPhoton->pt() << " do not calibrate, not supported "); 
+    } else {
+      ATH_MSG_DEBUG("Un-Calibrated pt = " << shallowCopyPhoton->pt()); 
+      if(m_EgammaCalibrationAndSmearingTool->applyCorrection(*shallowCopyPhoton) != CP::CorrectionCode::Ok){
+	ATH_MSG_WARNING("Cannot calibrate electron");
+      }
+      ATH_MSG_DEBUG("Calibrated pt = " << shallowCopyPhoton->pt()); 
+    }
+    */
 
     /** apply isolation fix */
     if (m_isolation_correction_tool->applyCorrection(*shallowCopyPhoton) != CP::CorrectionCode::Ok) {
diff --git a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/CMakeLists.txt
index 325787bd1272f4783425fcb7ef7b0e92184f1549..caf9e4bf21891f1dc5f4011025085a800acb18cb 100644
--- a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 788319 2016-12-07 01:04:30Z christos $
 ################################################################################
 # Package: IsolationCorrections
 ################################################################################
@@ -31,8 +30,8 @@ atlas_depends_on_subdirs(
 
 # External dependencies:
 find_package( ROOT COMPONENTS Core Hist RIO )
+find_package( Boost )
 
-# Component(s) in the package:
 atlas_add_library( IsolationCorrectionsLib
    IsolationCorrections/*.h Root/*.cxx
    PUBLIC_HEADERS IsolationCorrections
diff --git a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx
index 333f080299629b95e74a3a045c1c34c0f1f211c2..225f4810d9678214fddb2f7c5b3d02849123e503 100644
--- a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx
@@ -10,11 +10,11 @@
 #include "xAODMetaData/FileMetaData.h"
 #include "PATInterfaces/SystematicRegistry.h"
 #include "PathResolver/PathResolver.h"
+#include <boost/algorithm/string.hpp>
 
 #ifndef ROOTCORE
 #include "AthAnalysisBaseComps/AthAnalysisHelper.h"
 #include "AthAnalysisBaseComps/AthAnalysisAlgorithm.h"
-#include <boost/algorithm/string.hpp>
 #endif //ROOTCORE
 
 namespace CP {
@@ -120,6 +120,8 @@ namespace CP {
 
     //default result
     result = PATCore::ParticleDataType::Data;
+    //
+    std::string simType("");
     
 #ifndef ROOTCORE
     //Athena environent
@@ -137,7 +139,6 @@ namespace CP {
     //
     //if not data  determine Fast/FullSim
     ATH_MSG_DEBUG("IS_SIMULATION");
-    std::string simType("");
     if( AthAnalysisHelper::retrieveMetadata("/Simulation/Parameters", "SimulationFlavour", simType, inputMetaStore()).isFailure() ) {
       return StatusCode::FAILURE;    
     }
@@ -147,6 +148,7 @@ namespace CP {
       return StatusCode::SUCCESS;
     }
 #endif    
+
     //Here is the RootCore or to be dual use , assumes we have not returned before for Athena
     std::string simulationType("");
     if (!inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) {
@@ -157,11 +159,12 @@ namespace CP {
     //
     const bool s = fmd->value(xAOD::FileMetaData::simFlavour, simulationType);
     if (!s) { 
-      //no simFlavour metadata failure
+      ATH_MSG_DEBUG("no sim flavour from metadata: must be data");
       return StatusCode::FAILURE;    
     }
     else {
-      result = (simulationType == "FullSim" ? PATCore::ParticleDataType::Full : PATCore::ParticleDataType::Fast);
+      boost::to_upper(simType);
+      result = (simType.find("ATLFASTII")==std::string::npos) ?  PATCore::ParticleDataType::Full : PATCore::ParticleDataType::Fast;
       return StatusCode::SUCCESS;    
     }
     //
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/CMakeLists.txt
index 310138bd99ea091f48c75df017440de3899f2bf1..a1c24c78b8269e50fef166abf7fbd3254a5bf33f 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 796691 2017-02-11 10:15:48Z ludovica $
 
 # The name of the package:
 atlas_subdir( PhotonEfficiencyCorrection )
@@ -18,6 +17,7 @@ atlas_depends_on_subdirs(
    Event/xAOD/xAODEgamma
    PhysicsAnalysis/AnalysisCommon/PATCore
    PhysicsAnalysis/AnalysisCommon/PATInterfaces
+   PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces	
    PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection
    PRIVATE
    Event/xAOD/xAODCore
@@ -33,8 +33,8 @@ find_package( ROOT COMPONENTS Core Hist RIO MathCore )
 atlas_add_library( PhotonEfficiencyCorrectionLib
    PhotonEfficiencyCorrection/*.h Root/*.cxx
    PUBLIC_HEADERS PhotonEfficiencyCorrection
-   INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
-   LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools xAODEgamma
+   INCLUDE_DIRS ${BOOST_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
+   LINK_LIBRARIES ${BOOST_LIBRARIES} ${ROOT_LIBRARIES} EgammaAnalysisInterfacesLib AsgTools xAODEgamma
    PATCoreLib PATInterfaces ElectronEfficiencyCorrectionLib
    PRIVATE_LINK_LIBRARIES xAODEventInfo PathResolver )
 
@@ -53,8 +53,8 @@ atlas_add_dictionary( PhotonEfficiencyCorrectionDict
 # Executable(s) in the package:
 atlas_add_executable( PrintPhotonSF
    util/PrintPhotonSF.cxx
-   INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
-   LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES}
+   INCLUDE_DIRS ${BOOST_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
+   LINK_LIBRARIES ${BOOST_LIBRARIES} ${ROOT_LIBRARIES}
    PhotonEfficiencyCorrectionLib )
 
 if( XAOD_STANDALONE )
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h
index 0f216ac0b330f91fe8e2a7c3eea15ffeb9c0eb44..df0d569eafd298770cb230c1a21b85e56c12c6f2 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h
@@ -33,7 +33,7 @@
 #include "PATInterfaces/SystematicRegistry.h"
 #include "PATInterfaces/CorrectionCode.h"
 #include "PhotonEfficiencyCorrection/TPhotonEfficiencyCorrectionTool.h"
-#include "PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
 
 #include "xAODEgamma/Egamma.h"
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h
index e5d2c938e8c135a3539d5e657076f231ccb0e05c..dcf194cde6ce4e444e7b97e817234f889a32a846 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h
@@ -6,38 +6,8 @@
 #ifndef __IASGPHOTONEFFICIENCYCORRECTION__
 #define __IASGPHOTONEFFICIENCYCORRECTION__
 
-// Framework include(s):
-#include "AsgTools/IAsgTool.h"
-
-// EDM include(s):
-#include "xAODEgamma/Egamma.h"
-
-// Local include(s):
-#include "PATInterfaces/CorrectionCode.h"
-#include "PATInterfaces/ISystematicsTool.h"
-
-namespace xAOD{
-  class IParticle;
-}
-
-class IAsgPhotonEfficiencyCorrectionTool : virtual public asg::IAsgTool, virtual public CP::ISystematicsTool
-{
-  ASG_TOOL_INTERFACE(IAsgPhotonEfficiencyCorrectionTool)
-
-  public:  
-  //virtual StatusCode initialize() = 0;
-  
-  /// Get the "photon scale factor" as a return value
-  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Egamma&, double&) const = 0;
-  
-  /// Get the "photon scale factor error" as a return value
-  virtual CP::CorrectionCode getEfficiencyScaleFactorError(const xAOD::Egamma&, double&) const = 0;
-  
-  /// Decorate the photon with its scale factor
-  virtual CP::CorrectionCode applyEfficiencyScaleFactor(xAOD::Egamma&) const = 0;
-  
-  virtual ~IAsgPhotonEfficiencyCorrectionTool() {}  
-}; // class IAsgPhotonEfficiencyCorrectionTool
+#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
+#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces"
 
 #endif
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/PhotonEfficiencyCorrectionDict.h b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/PhotonEfficiencyCorrectionDict.h
index acc3328b9d888b342dfbf8db743a5a6f63301274..5dce4590a645117a504e011dc7ae6cfe29436f80 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/PhotonEfficiencyCorrectionDict.h
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/PhotonEfficiencyCorrectionDict.h
@@ -16,7 +16,5 @@
 */
 
 #include "PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h"
-#include "PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h"
-#include "PhotonEfficiencyCorrection/TPhotonEfficiencyCorrectionTool.h"
 
 #endif
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/selection.xml b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/selection.xml
index 443e66d1c67983e93f613e10c2020e3a30f1673e..6b6f10e07b36494e5ae97085dfcd5901c10b748b 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/selection.xml
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/selection.xml
@@ -1,5 +1,3 @@
 <lcgdict>
-    <class name="Root::TPhotonEfficiencyCorrectionTool" />
     <class name="AsgPhotonEfficiencyCorrectionTool" />
-    <class name="IAsgPhotonEfficiencyCorrectionTool" />
 </lcgdict>
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/components/PhotonEfficiencyCorrection_load.cxx b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/components/PhotonEfficiencyCorrection_load.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..7a66e563646b86a194c48f39b4bc4ce7341cea65
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/components/PhotonEfficiencyCorrection_load.cxx
@@ -0,0 +1,2 @@
+#include "GaudiKernel/LoadFactoryEntries.h"
+LOAD_FACTORY_ENTRIES(PhotonEfficiencyCorrection)
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx
index 3b9a0f3ad2b06956733a40b2610822af3d17e83d..3c8f8ed6051ae928c55106aa1a6f02cd1847949e 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx
@@ -10,7 +10,7 @@
 #include "xAODEgamma/PhotonAuxContainer.h"
 #include "xAODCore/ShallowCopy.h"
 
-#include "PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
 
 testAthenaPhotonAlg::testAthenaPhotonAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ),  m_photonSF("AsgPhotonEfficiencyCorrectionTool/AsgPhotonEfficiencyCorrectionTool",this){
 
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt
index 784caba0c22273f6fff2747d573f98a60d92ff9c..1088ceea41eba1e4e327ae354e8467af8c84a70d 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 787369 2016-11-30 14:31:24Z krasznaa $
 ################################################################################
 # Package: PhotonVertexSelection
 ################################################################################
diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/src/components/PhotonVertexSelection_load.cxx b/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/src/components/PhotonVertexSelection_load.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..50a7acfbe9e2321f0d343f57b9422a64230a3d72
--- /dev/null
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/src/components/PhotonVertexSelection_load.cxx
@@ -0,0 +1,5 @@
+// Gaudi/Athena include(s):
+#include "GaudiKernel/LoadFactoryEntries.h"
+
+// Declare the library to the infrastructure:
+LOAD_FACTORY_ENTRIES(PhotonVertexSelection)
diff --git a/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/CMakeLists.txt b/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/CMakeLists.txt
index 350dc8a1edff06e373409d499e93bc8ba14678e7..cdc460813d27684755b7136de56032fa58604fe7 100644
--- a/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/CMakeLists.txt
+++ b/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/CMakeLists.txt
@@ -1,4 +1,3 @@
-# $Id: CMakeLists.txt 782748 2016-11-07 13:28:06Z will $
 
 # The name of the package:
 atlas_subdir( AsgAnalysisInterfaces )
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/CMakeLists.txt b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..d584bbc81cf9f9ada8be0bcde4bd1340614572fc
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/CMakeLists.txt
@@ -0,0 +1,29 @@
+# The name of the package:
+atlas_subdir( EgammaAnalysisInterfaces )
+
+# The dependencies of the package:
+atlas_depends_on_subdirs(
+   PUBLIC
+   Control/AthToolSupport/AsgTools
+   Event/xAOD/xAODEgamma
+   PhysicsAnalysis/AnalysisCommon/PATInterfaces 
+   PhysicsAnalysis/AnalysisCommon/PATCore
+)
+
+# External(s):
+find_package( ROOT COMPONENTS Core )
+
+# Component(s) in the package:
+atlas_add_library( EgammaAnalysisInterfacesLib
+   EgammaAnalysisInterfaces/*.h
+   INTERFACE
+   PUBLIC_HEADERS EgammaAnalysisInterfaces
+   INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+   LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODEgamma PATInterfaces PATCoreLib)
+
+atlas_add_dictionary( EgammaAnalysisInterfacesDict
+   EgammaAnalysisInterfaces/EgammaAnalysisInterfacesDict.h
+   EgammaAnalysisInterfaces/selection.xml
+   LINK_LIBRARIES EgammaAnalysisInterfacesLib )
+
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfacesDict.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfacesDict.h
new file mode 100644
index 0000000000000000000000000000000000000000..7b91c9c6b9b1486306199e53b680f680d2f22bb0
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfacesDict.h
@@ -0,0 +1,25 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef __EGAMMAANALYSISINTERRFACESDICT__
+#define __EGAMMAANALYSISINTERRFACESDICT__
+#include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronMultiLeptonSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h"
+#include "EgammaAnalysisInterfaces/IAsgDeadHVCellRemovalTool.h"
+
+#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
+
+#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
+
+#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
+
+#include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h"
+
+
+#endif
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgDeadHVCellRemovalTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgDeadHVCellRemovalTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed86179af7a0f01bbc50269b163f45db9557e6ab
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgDeadHVCellRemovalTool.h
@@ -0,0 +1,28 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// Dear emacs, this is -*-c++-*-
+#ifndef EGAMMAANALYSISINTERFACES__IASGDEADHVCELLREMOVALTOOL__
+#define EGAMMAANALYSISINTERFACES__IASGDEADHVCELLREMOVALTOOL__
+
+#include "AsgTools/IAsgTool.h"
+#include "xAODEgamma/EgammaFwd.h"
+
+class IAsgDeadHVCellRemovalTool : virtual public asg::IAsgTool
+{
+  ASG_TOOL_INTERFACE(IAsgDeadHVCellRemovalTool)
+public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgDeadHVCellRemovalTool() {};
+
+  virtual bool accept( const xAOD::Egamma* part ) const = 0;
+
+  virtual bool accept( const xAOD::Egamma& part ) const = 0;
+
+}; 
+// End: class definition
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h
new file mode 100644
index 0000000000000000000000000000000000000000..b32941041c4fc26de49abfaf1c4ac1f6d04465b8
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h
@@ -0,0 +1,64 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// Dear emacs, this is -*-c++-*-
+
+#ifndef EGAMMAANALYSISINTERFACES__IASGEGAMMAISEMSELECTOR__
+#define EGAMMAANALYSISINTERFACES__IASGEGAMMAISEMSELECTOR__
+
+/**
+   @class IAsgEGammaIsEMSelector
+   @brief Interface to tool to select photons
+
+   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
+   @date   Dec 2011 - Fab 2012
+
+   11-MAR-2014, convert to ASGTool
+*/
+
+// Include the interfaces
+#include "PATCore/IAsgSelectionTool.h"
+
+// Forward declarations
+namespace Root{
+  class TAccept;
+}
+#include "xAODEgamma/EgammaFwd.h"
+#include "xAODEgamma/PhotonFwd.h"
+#include "xAODEgamma/ElectronFwd.h"
+
+class IAsgEGammaIsEMSelector : virtual public IAsgSelectionTool
+{
+
+  ASG_TOOL_INTERFACE(IAsgEGammaIsEMSelector)
+
+public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgEGammaIsEMSelector() {};
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
+
+  /////Egammma IsEM specific methods
+
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
+
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
+
+  virtual unsigned int IsemValue() const =0;
+
+  /** Method to get the operating point */
+  virtual std::string getOperatingPointName( ) const =0;
+ 
+}; // End: class definition
+
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..4a76f71b96ecfe8a788b380d6516be334cf1778b
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h
@@ -0,0 +1,32 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+//IAsgElectronEfficiencyCorrection.h to be used in the tool.
+#ifndef EGAMMAANALYSISINTERFACES__IASGELECTRONEFFICIENCYCORRECTION__
+#define EGAMMAANALYSISINTERFACES__IASGELECTRONEFFICIENCYCORRECTION__
+
+#include "AsgTools/IAsgTool.h"
+#include "xAODEgamma/ElectronFwd.h"
+#include "PATInterfaces/CorrectionCode.h"
+#include "PATInterfaces/ISystematicsTool.h"
+namespace xAOD{
+  class IParticle;
+}
+
+
+class IAsgElectronEfficiencyCorrectionTool : virtual public CP::ISystematicsTool
+{
+  ASG_TOOL_INTERFACE(IAsgElectronEfficiencyCorrectionTool)
+
+  public:
+  ///The interface for Scale Factors
+  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Electron& inputObject, double& efficiencyScaleFactor) const = 0;
+  virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::Electron& inputObject) const = 0;
+  virtual int systUncorrVariationIndex( const xAOD::Electron &inputObject) const =0;
+  virtual ~IAsgElectronEfficiencyCorrectionTool() {}
+
+};
+
+
+#endif
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h
new file mode 100644
index 0000000000000000000000000000000000000000..ae224757983925b87d112c28b3de284fd3fb4b2f
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h
@@ -0,0 +1,84 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// Dear emacs, this is -*-c++-*-
+
+#ifndef EGAMMAANALYSISINTERFACES__IASGELECTRONISEMSELECTOR__
+#define EGAMMAANALYSISINTERFACES__IASGELECTRONISEMSELECTOR__
+
+/**
+   @class IAsgElectronIsEMSelector
+   @brief Interface to tool to select electrons
+
+   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
+   @date   Dec 2011 - Fab 2012
+
+   11-MAR-2014, convert to ASGTool
+*/
+
+// Include the interfaces
+#include "PATCore/IAsgSelectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h"
+// Forward declarations
+namespace Root{
+  class TAccept;
+}
+#include "xAODEgamma/ElectronFwd.h"
+#include "xAODEgamma/PhotonFwd.h"
+#include "xAODEgamma/EgammaFwd.h"
+
+class IAsgElectronIsEMSelector : virtual public IAsgEGammaIsEMSelector
+{
+
+  ASG_TOOL_INTERFACE(IAsgElectronIsEMSelector)
+  
+  public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgElectronIsEMSelector() {};
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
+  
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
+
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
+
+  /** Accept with Photon objects */
+  virtual const Root::TAccept& accept( const xAOD::Photon* part ) const = 0;
+
+  /** Accept with Photon objects */
+  virtual const Root::TAccept& accept( const xAOD::Photon& part ) const = 0;
+
+  /** Accept with Electron objects */
+  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
+
+  /** Accept with Electron objects */
+  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
+
+
+  ///////////////Expert methods //////////////////////////////////////
+
+  
+  //The main execute method
+  virtual StatusCode execute(const xAOD::Egamma* eg) const =0;
+
+  //////////////////////////////////////////////////////////////
+  virtual unsigned int IsemValue() const = 0;
+  
+  /** Method to get the operating point */
+  virtual std::string getOperatingPointName( ) const =0;
+
+
+
+}; // End: class definition
+
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..47011688eb52e89b71e538e646950a6e322a76d4
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h
@@ -0,0 +1,101 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+
+#ifndef EGAMMAANALYSISINTERFACES__IASGELECTRONLIKELIHOODSELECTOR__
+#define EGAMMAANALYSISINTERFACES__IASGELECTRONLIKELIHOODSELECTOR__
+
+/**
+   @class IAsgElectronLikelihoodTool
+   @brief Interface to tool to select electrons
+
+   12-MAR-2014, convert to ASG tool
+
+*/
+
+// CONSIDER MERGING THIS WITH IASGELECTRONMULTILEPTONSELECTOR, SINCE THE INTERFACE
+// IS EXACTLY THE SAME. LEAVING THEM SEPERATE FOR NOW IN CASE THEY DIVERGE
+
+// Include the interfaces
+#include "PATCore/IAsgSelectionTool.h"
+// Forward declarations
+namespace Root{
+  class TAccept;
+  class TResult;
+}
+#include "xAODEgamma/ElectronFwd.h"
+#include "xAODEgamma/EgammaFwd.h"
+
+class IAsgElectronLikelihoodTool : virtual public IAsgSelectionTool
+{
+
+  ASG_TOOL_INTERFACE(IAsgElectronLikelihoodTool)
+
+  public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgElectronLikelihoodTool() {};
+
+
+  /** The main accept method: using the generic interface , with pointers*/
+  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Egamma* part ) const = 0;
+
+  /** The main accept method: in case mu not in EventInfo online */
+  virtual const Root::TAccept& accept( const xAOD::Electron* part, double mu ) const = 0;
+
+  /** The main accept method: in case mu not in EventInfo online */
+  virtual const Root::TAccept& accept( const xAOD::Egamma* part, double mu ) const = 0;
+
+
+  /** The main accept method: using the generic interface, with reference */
+  virtual const Root::TAccept& accept( const xAOD::IParticle& part) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Egamma& part ) const = 0;
+
+  /** The main accept method: in case mu not in EventInfo online */
+  virtual const Root::TAccept& accept( const xAOD::Electron& part, double mu ) const = 0;
+
+  /** The main accept method: in case mu not in EventInfo online */
+  virtual const Root::TAccept& accept( const xAOD::Egamma& part, double mu ) const = 0;
+
+
+  /** The main result method: the actual likelihood is calculated here */
+  virtual const Root::TResult& calculate( const xAOD::IParticle* part ) const = 0;
+
+  /** The main result method: the actual likelihood is calculated here */
+  virtual const Root::TResult& calculate( const xAOD::Electron* eg ) const = 0;
+
+  /** The main result method: the actual likelihood is calculated here */
+  virtual const Root::TResult& calculate( const xAOD::Egamma* eg ) const = 0;
+
+  /** The main result method: in case mu not in EventInfo online */
+  virtual const Root::TResult& calculate( const xAOD::Electron* eg, double mu ) const = 0;
+
+  /** The main result method: in case mu not in EventInfo online */
+  virtual const Root::TResult& calculate( const xAOD::Egamma* eg, double mu ) const = 0;
+
+
+  /** Method to get the plain TResult */
+  virtual const Root::TResult& getTResult( ) const=0;
+
+  /** Method to get the operating point */
+  virtual std::string getOperatingPointName( ) const =0;
+
+  //virtual const Root::TAccept& getTAccept( ) const =0; // in base
+
+}; // End: class definition
+
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronMultiLeptonSelector.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronMultiLeptonSelector.h
new file mode 100644
index 0000000000000000000000000000000000000000..386c61cd1771886c48aba381ddc051e4f6f93a8b
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgElectronMultiLeptonSelector.h
@@ -0,0 +1,50 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef EGAMMAANALYSISINTERFACES__IASGELECTRONMULTILEPTONSELECTOR__
+#define EGAMMAANALYSISINTERFACES__IASGELECTRONMULTILEPTONSELECTOR__
+
+/**
+   @class IAsgElectronMultiLeptonSelector
+   @brief Interface to tool to select electrons
+
+   12-MAR-2014, convert to ASG tool
+
+*/
+// Include the interfaces
+#include "PATCore/IAsgSelectionTool.h"
+// Forward declarations
+namespace Root{
+  class TAccept;
+}
+#include "xAODEgamma/ElectronFwd.h"
+
+class IAsgElectronMultiLeptonSelector : virtual public IAsgSelectionTool
+{
+
+  ASG_TOOL_INTERFACE(IAsgElectronMultiLeptonSelector)
+
+public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgElectronMultiLeptonSelector() {};
+
+  /** The main accept method: using the generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
+  /** The main accept method: using the generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
+
+  /** Method to get the operating point */
+  virtual std::string getOperatingPointName( ) const=0;
+
+}; // End: class definition
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h
new file mode 100644
index 0000000000000000000000000000000000000000..5bb78ebb245e9818ee1c700666fc484775bb3ea1
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h
@@ -0,0 +1,83 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef EGAMMAANALYSISINTERFACES__IASGFORWARDELECTRONISEMSELECTOR__
+#define EGAMMAANALYSISINTERFACES__IASGFORWARDELECTRONISEMSELECTOR__
+
+/**
+   @class IAsgForwardElectronIsEMSelector
+   @brief Interface to tool to select electrons
+
+   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
+   @date   Dec 2011 - Fab 2012
+
+   11-MAR-2014, convert to ASGTool
+*/
+
+// Include the interfaces
+#include "PATCore/IAsgSelectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h"
+
+// Forward declarations
+namespace Root{
+  class TAccept;
+}
+#include "xAODEgamma/ElectronFwd.h"
+#include "xAODEgamma/PhotonFwd.h"
+#include "xAODEgamma/EgammaFwd.h"
+
+class IAsgForwardElectronIsEMSelector : virtual public IAsgEGammaIsEMSelector
+{
+
+  ASG_TOOL_INTERFACE(IAsgForwardElectronIsEMSelector)
+  
+  public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgForwardElectronIsEMSelector() {};
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
+  
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
+
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
+
+  /** Accept with Photon objects */
+  virtual const Root::TAccept& accept( const xAOD::Photon* part ) const = 0;
+
+  /** Accept with Photon objects */
+  virtual const Root::TAccept& accept( const xAOD::Photon& part ) const = 0;
+
+  /** Accept with Electron objects */
+  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
+
+  /** Accept with Electron objects */
+  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
+
+
+  ///////////////Expert methods //////////////////////////////////////
+
+  
+  //The main execute method
+  virtual StatusCode execute(const xAOD::Egamma* eg) const =0;
+
+  //////////////////////////////////////////////////////////////
+  virtual unsigned int IsemValue() const = 0;
+  
+  /** Method to get the operating point */
+  virtual std::string getOperatingPointName( ) const =0;
+
+
+
+}; // End: class definition
+
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..aa3a1000b38776eb7aafb0a9f187259775cc6fb9
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h
@@ -0,0 +1,42 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+//IAsgPhotonEfficiencyCorrection.h to be used in the tool.
+#ifndef EGAMMAANALYSISINTERFACES__IASGPHOTONEFFICIENCYCORRECTION__
+#define EGAMMAANALYSISINTERFACES__IASGPHOTONEFFICIENCYCORRECTION__
+
+// Framework include(s):
+#include "AsgTools/IAsgTool.h"
+// EDM include(s):
+#include "xAODEgamma/Egamma.h"
+
+// Local include(s):
+#include "PATInterfaces/CorrectionCode.h"
+#include "PATInterfaces/ISystematicsTool.h"
+
+namespace xAOD{
+  class IParticle;
+}
+
+class IAsgPhotonEfficiencyCorrectionTool : virtual public asg::IAsgTool, virtual public CP::ISystematicsTool
+{
+  ASG_TOOL_INTERFACE(IAsgPhotonEfficiencyCorrectionTool)
+
+  public:  
+  //virtual StatusCode initialize() = 0;
+  
+  /// Get the "photon scale factor" as a return value
+  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Egamma&, double&) const = 0;
+  
+  /// Get the "photon scale factor error" as a return value
+  virtual CP::CorrectionCode getEfficiencyScaleFactorError(const xAOD::Egamma&, double&) const = 0;
+  
+  /// Decorate the photon with its scale factor
+  virtual CP::CorrectionCode applyEfficiencyScaleFactor(xAOD::Egamma&) const = 0;
+  
+  virtual ~IAsgPhotonEfficiencyCorrectionTool() {}  
+}; // class IAsgPhotonEfficiencyCorrectionTool
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h
new file mode 100644
index 0000000000000000000000000000000000000000..c7a754db19972c026fd5f2abd1470394152a8fd0
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h
@@ -0,0 +1,78 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef EGAMMAANALYSISINTERFACES__IASGPHOTONISEMSELECTOR__
+#define EGAMMAANALYSISINTERFACES__IASGPHOTONISEMSELECTOR__
+
+/**
+   @class IAsgPhotonIsEMSelector
+   @brief Interface to tool to select photons
+
+   @author Jovan Mitrevski (UCSC) Karsten Koeneke (CERN)
+   @date   Dec 2011 - Fab 2012
+
+   11-MAR-2014, convert to ASGTool
+*/
+
+// Include the interfaces
+#include "PATCore/IAsgSelectionTool.h"
+#include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h"
+
+// Forward declarations
+namespace Root{
+  class TAccept;
+}
+#include "xAODEgamma/EgammaFwd.h"
+#include "xAODEgamma/PhotonFwd.h"
+#include "xAODEgamma/ElectronFwd.h"
+
+class IAsgPhotonIsEMSelector : virtual public IAsgEGammaIsEMSelector
+{
+
+  ASG_TOOL_INTERFACE(IAsgPhotonIsEMSelector)
+
+public:
+
+  /**Virtual Destructor*/
+  virtual ~IAsgPhotonIsEMSelector() {};
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle* part ) const = 0;
+
+  /** Accept with generic interface */
+  virtual const Root::TAccept& accept( const xAOD::IParticle& part ) const = 0;
+  
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma* part) const = 0;
+
+  /** Accept with Egamma objects */
+  virtual const Root::TAccept& accept( const xAOD::Egamma& part) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Photon* part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Photon& part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Electron* part ) const = 0;
+
+  /** The main accept method: the actual cuts are applied here */
+  virtual const Root::TAccept& accept( const xAOD::Electron& part ) const = 0;
+
+
+  ////Expert methods /////////////////////////////////////
+  /** The isem potentially for the trigger */
+  virtual StatusCode execute(const xAOD::Egamma* eg) const =0;
+
+  virtual unsigned int IsemValue() const =0;
+
+  /** Method to get the operating point */
+  virtual std::string getOperatingPointName( ) const =0;
+ 
+}; // End: class definition
+
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..5cbbd4734f56b262d063188415eaea51363254c3
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h
@@ -0,0 +1,82 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef EGAMMAANALYSISINTERFACES__IEGammaAmbiguityTool__
+#define EGAMMAANALYSISINTERFACES__IEGammaAmbiguityTool__
+
+/**
+   @class EGammaAmbiguityTool
+   @brief Electron / photon ambiguity resolution. Dual-use version, interface
+
+   @author Bruno Lenzi
+   @date   May 2015
+*/
+
+// Include the interfaces
+#include "AsgTools/IAsgTool.h"
+
+// Forward declarations
+#include "xAODCaloEvent/CaloClusterFwd.h"
+#include "xAODTracking/VertexFwd.h"
+#include "xAODTracking/TrackParticleFwd.h"
+#include "xAODEgamma/EgammaFwd.h"
+#include "xAODEgamma/EgammaContainerFwd.h"
+
+//This will need to be copied over to EgammaEnums.h
+//under xAODEgamma
+//Plus Set/Get true Accessor methods when we have 
+//finalise the design.
+namespace xAOD {
+  namespace AmbiguityTool {
+    /// @name Ambiguity types
+    enum AmbiguityType {
+      electron = 0,
+      ambiguousTrackEoverPBetterThanVertexEoverP=1,
+      ambiguousTrackLowPt=2,
+      ambiguousTrackLowEoverP=3,
+      ambiguousTrackNoPixel =4,
+      ambiguousVertexEoverPBetterThanTrackEoverP=5,
+      photon=6,
+      unknown=7
+    };
+  }
+}
+
+
+
+class IEGammaAmbiguityTool : virtual public asg::IAsgTool
+{
+  ASG_TOOL_INTERFACE(IEGammaAmbiguityTool)
+
+public:
+
+  /**Virtual Destructor*/
+  virtual ~IEGammaAmbiguityTool() {};
+
+  /** Return value: AuthorElectron, AuthorPhoton, AuthorAmbiguous, AuthorUnknown */
+  virtual unsigned int ambiguityResolve(const xAOD::CaloCluster* cluster,
+                                        const xAOD::Vertex* vx,
+                                        const xAOD::TrackParticle* tp, xAOD::AmbiguityTool::AmbiguityType& type) const = 0;
+
+  /** Return value: AuthorElectron, AuthorPhoton, AuthorAmbiguous, AuthorUnknown 
+      Needed because of cliets
+      implementation calls method above
+   */
+  virtual unsigned int ambiguityResolve(const xAOD::CaloCluster* cluster,
+                                        const xAOD::Vertex* vx,
+                                        const xAOD::TrackParticle* tp) const = 0;
+
+  /** Redo the ambiguity resolution of central electrons and photons and return
+    * AuthorElectron, AuthorPhoton, AuthorAmbiguous, AuthorUnknown 
+    * or the author of the object if no overlapping object is found **/
+  virtual unsigned int ambiguityResolve(const xAOD::Egamma& egamma) const = 0;
+
+  /** Accept or reject egamma object based on ambiguity resolution */
+  virtual bool accept( const xAOD::Egamma& egamma, bool acceptAmbiguous = true) const = 0;
+  
+}; // End: class definition
+
+
+#endif
+
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..f8fc1fd928543e38b084df9ece2eaed16a9e27b5
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h
@@ -0,0 +1,54 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+
+#ifndef EGAMMAANALYSISINTERFACES__IEGAMMA_CALIB_TOOL_H_
+#define EGAMMAANALYSISINTERFACES__IEGAMMA_CALIB_TOOL_H_
+
+#include "AsgTools/IAsgTool.h"
+//xAOD
+#include "xAODEgamma/ElectronFwd.h"
+#include "xAODEgamma/PhotonFwd.h"
+#include "xAODEgamma/EgammaFwd.h"
+#include "PATInterfaces/CorrectionCode.h"
+#include "PATInterfaces/ISystematicsTool.h"
+// PAT includes
+#include "PATCore/PATCoreEnums.h"
+
+
+namespace EgammaCalibPeriodRunNumbersExample {
+  const int run_2016 = 297730;
+  const int run_2015 = 252604;
+  struct ROOT6_NamespaceAutoloadHook{};
+}
+
+
+namespace CP {
+
+  class IEgammaCalibrationAndSmearingTool : public CP::ISystematicsTool{
+    /// Declare the interface that the class provides
+    ASG_TOOL_INTERFACE( IEgammaCalibrationAndSmearingTool )
+    public:
+    
+    virtual ~IEgammaCalibrationAndSmearingTool() {};
+    
+    virtual StatusCode initialize() = 0;
+    
+    //Apply the correction on a modifyable egamma object (xAOD::Electron or xAOD::Photon)
+    virtual CP::CorrectionCode applyCorrection(xAOD::Egamma &) = 0;
+    
+    //Create a corrected copy from a constant egamma object
+    virtual CP::CorrectionCode correctedCopy(const xAOD::Electron&, xAOD::Electron*&) = 0;
+    virtual CP::CorrectionCode correctedCopy(const xAOD::Photon&, xAOD::Photon*&) = 0;
+    
+    //functions to be used per-event
+    virtual void setRandomSeed(unsigned seed) = 0;
+    
+    virtual double resolution( double energy, double cl_eta, double cl_etaCalo,
+			       PATCore::ParticleType::Type ptype = PATCore::ParticleType::Electron, bool withCT=false) const = 0;
+    virtual double getResolution(const xAOD::Egamma& particle, bool withCT=true) const = 0;
+  };
+  
+}
+#endif
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..25fde02ba2c96b3dbc6fbc6c74a39d0db8b3a588
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h
@@ -0,0 +1,49 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef EGAMMAANALYSISINTERFACES_IELECTRONPHOTONSHOWERSHAPEFUDGETOOL_H
+#define EGAMMAANALYSISINTERFACES_IELECTRONPHOTONSHOWERSHAPEFUDGETOOL_H
+
+/**
+   @class AsgFudgeMCTool
+   @brief Tool to fudge photon MC shower shapes.
+
+   @author Rob Roy Fletcher (University of Pennsylvania) rob.fletcher@cern.ch
+   @date   August 2014
+
+
+*/
+
+// Framework include(s):
+#include "AsgTools/IAsgTool.h"
+
+// EDM include(s):
+#include "xAODEgamma/EgammaFwd.h"
+#include "xAODEgamma/PhotonFwd.h"
+#include "xAODEgamma/ElectronFwd.h"
+
+// Local include(s):
+#include "PATInterfaces/CorrectionCode.h"
+
+
+class IElectronPhotonShowerShapeFudgeTool : public virtual asg::IAsgTool {
+
+   /// Declare the interface that the class provides
+   ASG_TOOL_INTERFACE(IElectronPhotonShowerShapeFudgeTool)
+
+public:
+   /// Apply the correction on a modifyable object
+   virtual const CP::CorrectionCode applyCorrection(xAOD::Photon& ph ) const = 0;
+
+   virtual const CP::CorrectionCode applyCorrection(xAOD::Electron& el ) const = 0;
+
+   virtual const CP::CorrectionCode correctedCopy( const xAOD::Photon& ph, xAOD::Photon*& output ) const = 0;
+
+   virtual const CP::CorrectionCode correctedCopy( const xAOD::Electron& el, xAOD::Electron*& output ) const = 0;
+
+
+
+}; // class IElectronPhotonShowerShapeFudgeTool
+
+#endif // _IASGFUDGEMCTOOL_H
diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/selection.xml b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/selection.xml
new file mode 100644
index 0000000000000000000000000000000000000000..042c1d9ed007d15fb82972e70be0fa8b860c2bfb
--- /dev/null
+++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/selection.xml
@@ -0,0 +1,21 @@
+<lcgdict>
+  <class name="IAsgEGammaIsEMSelector" /> 
+  <class name="IAsgElectronIsEMSelector" /> 
+  <class name="IAsgForwardElectronIsEMSelector" /> 
+  <class name="IAsgPhotonIsEMSelector" />
+  <class name="IAsgElectronMultiLeptonSelector" /> 
+  <class name="IAsgElectronLikelihoodTool" /> 
+  <class name="IEGammaAmbiguityTool" />
+  <class name="IAsgDeadHVCellRemovalTool" /> 
+
+  <class name="IAsgElectronEfficiencyCorrectionTool" /> 
+
+  <class name="IEgammaCalibrationAndSmearingTool" />   
+  <variable pattern="EgammaCalibPeriodRunNumbersExample::*"/>
+  <class name="EgammaCalibPeriodRunNumbersExample::ROOT6_NamespaceAutoloadHook" /> 
+
+  <class name="IAsgPhotonEfficiencyCorrectionTool" /> 
+
+  <class name="IElectronPhotonShowerShapeFudgeTool" /> 
+
+<lcgdict>
diff --git a/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/CMakeLists.txt b/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/CMakeLists.txt
index e54346078a7c82a4fbe99d048f6a40c3303ff87f..67260204686c2e95e6628ab486c155aea2f91644 100644
--- a/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/CMakeLists.txt
+++ b/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/CMakeLists.txt
@@ -13,7 +13,7 @@ atlas_depends_on_subdirs(
 	
 # External(s):
 find_package( ROOT COMPONENTS Core )
-	
+
 # Component(s) in the package:
 atlas_add_library( TriggerAnalysisInterfaces
    TriggerAnalysisInterfaces/*.h
diff --git a/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/TriggerAnalysisInterfaces/ITrigGlobalEfficiencyCorrectionTool.h b/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/TriggerAnalysisInterfaces/ITrigGlobalEfficiencyCorrectionTool.h
index 7063cd6bf7ec103001e4e3a2189ca1e405ea30d8..d51299044f54fcc756181ea018ddb84279fa2b1b 100644
--- a/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/TriggerAnalysisInterfaces/ITrigGlobalEfficiencyCorrectionTool.h
+++ b/PhysicsAnalysis/Interfaces/TriggerAnalysisInterfaces/TriggerAnalysisInterfaces/ITrigGlobalEfficiencyCorrectionTool.h
@@ -32,4 +32,4 @@ public:
 			const std::vector<const xAOD::Muon*>& muons, double& efficiencyData, double& efficiencyMc) = 0;	
 };
 
-#endif //> !TRIGGERANALYSISINTERFACES_ITRIGGLOBALEFFICIENCYCORRECTIONTOOL_H
\ No newline at end of file
+#endif //> !TRIGGERANALYSISINTERFACES_ITRIGGLOBALEFFICIENCYCORRECTIONTOOL_H
diff --git a/PhysicsAnalysis/RingerSelectorTools/CMakeLists.txt b/PhysicsAnalysis/RingerSelectorTools/CMakeLists.txt
index 73a967c8152d59be26502eae82ef202168ea91d2..567e3ce34b8f5c6fbbdcbc626db3f805031b4c05 100644
--- a/PhysicsAnalysis/RingerSelectorTools/CMakeLists.txt
+++ b/PhysicsAnalysis/RingerSelectorTools/CMakeLists.txt
@@ -14,7 +14,7 @@ atlas_depends_on_subdirs( PUBLIC
                           Event/xAOD/xAODEgamma
                           Event/xAOD/xAODTracking
                           PhysicsAnalysis/AnalysisCommon/PATCore
-                          PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools
+                          PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces
                           PRIVATE
                           Control/AthContainers
                           Event/xAOD/xAODBase
@@ -35,19 +35,19 @@ atlas_add_library( RingerSelectorToolsLib
                    Root/tools/*.cxx
                    PUBLIC_HEADERS RingerSelectorTools
                    INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
-                   LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools AthenaKernel CxxUtils xAODCaloRings xAODEgamma xAODTracking PATCoreLib ElectronPhotonSelectorToolsLib
+                   LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools AthenaKernel CxxUtils xAODCaloRings xAODEgamma xAODTracking PATCoreLib EgammaAnalysisInterfacesLib
                    PRIVATE_LINK_LIBRARIES AthContainers xAODBase GaudiKernel PathResolver TrkTrackSummary )
 
 atlas_add_component( RingerSelectorTools
                      src/components/*.cxx
                      INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools AthenaKernel CxxUtils xAODCaloRings xAODEgamma xAODTracking PATCoreLib ElectronPhotonSelectorToolsLib AthContainers xAODBase GaudiKernel PathResolver TrkTrackSummary RingerSelectorToolsLib )
+                     LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools AthenaKernel CxxUtils xAODCaloRings xAODEgamma xAODTracking PATCoreLib EgammaAnalysisInterfacesLib AthContainers xAODBase GaudiKernel PathResolver TrkTrackSummary RingerSelectorToolsLib )
 
 atlas_add_dictionary( RingerSelectorToolsDict
                       RingerSelectorTools/RingerSelectorToolsDict.h
                       RingerSelectorTools/selection.xml
                       INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
-                      LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools AthenaKernel CxxUtils xAODCaloRings xAODEgamma xAODTracking PATCoreLib ElectronPhotonSelectorToolsLib AthContainers xAODBase GaudiKernel PathResolver TrkTrackSummary RingerSelectorToolsLib )
+                      LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools AthenaKernel CxxUtils xAODCaloRings xAODEgamma xAODTracking PATCoreLib EgammaAnalysisInterfacesLib AthContainers xAODBase GaudiKernel PathResolver TrkTrackSummary RingerSelectorToolsLib )
 
 # Install files from the package:
 atlas_install_python_modules( python/*.py )
diff --git a/PhysicsAnalysis/RingerSelectorTools/RingerSelectorTools/AsgElectronRingerSelector.h b/PhysicsAnalysis/RingerSelectorTools/RingerSelectorTools/AsgElectronRingerSelector.h
index 3fe36544a830abcbd8b833075039b0913897eb90..331072068a28f875b73abc93db59039d2d8bc96e 100644
--- a/PhysicsAnalysis/RingerSelectorTools/RingerSelectorTools/AsgElectronRingerSelector.h
+++ b/PhysicsAnalysis/RingerSelectorTools/RingerSelectorTools/AsgElectronRingerSelector.h
@@ -18,7 +18,7 @@
 #include "PATCore/TResult.h"
 #include "AsgTools/AsgMetadataTool.h"
 #include "AsgTools/ToolHandle.h"
-#include "ElectronPhotonSelectorTools/IAsgElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
 
 // xAOD includes:
 #include "xAODCaloRings/CaloRingsContainer.h" // needed for caloRingsReader_t
diff --git a/Reconstruction/HeavyIonRec/HIMonitoring/HIMonitoring/HIMonitoringPhotonsTool.h b/Reconstruction/HeavyIonRec/HIMonitoring/HIMonitoring/HIMonitoringPhotonsTool.h
index 5564561e6bf8850e4ae510c56d0a43118c3087b3..1205cf1670fe5dc4e6e30fb735e2025b28eecafa 100755
--- a/Reconstruction/HeavyIonRec/HIMonitoring/HIMonitoring/HIMonitoringPhotonsTool.h
+++ b/Reconstruction/HeavyIonRec/HIMonitoring/HIMonitoring/HIMonitoringPhotonsTool.h
@@ -18,6 +18,7 @@
 #include <xAODEgamma/PhotonContainer.h>
 
 #include "ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h"
+#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
 
 class TH1;
 class TGraph;
diff --git a/Reconstruction/egamma/egammaAlgs/CMakeLists.txt b/Reconstruction/egamma/egammaAlgs/CMakeLists.txt
index db078903330a4727cb3c1231ace7628e88e3c823..0ed9bf5bc781b4d518bdb666f0ff4121a2561c4b 100644
--- a/Reconstruction/egamma/egammaAlgs/CMakeLists.txt
+++ b/Reconstruction/egamma/egammaAlgs/CMakeLists.txt
@@ -24,7 +24,7 @@ atlas_depends_on_subdirs( PRIVATE
                           Event/xAOD/xAODTracking
                           InnerDetector/InDetRecTools/InDetConversionFinderTools
                           InnerDetector/InDetRecTools/InDetRecToolInterfaces
-                          PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools
+                          PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces
                           Reconstruction/Particle
                           Reconstruction/ParticleTruth
                           Reconstruction/egamma/egammaInterfaces
@@ -44,7 +44,7 @@ atlas_add_component( egammaAlgs
 		     src/*.cxx
                      src/components/*.cxx
                      INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps EventKernel xAODCaloEvent xAODEgamma xAODTruth GaudiKernel MCTruthClassifierLib CaloGeoHelpers CaloUtilsLib AthenaKernel CxxUtils StoreGateLib SGtests xAODTracking ElectronPhotonSelectorToolsLib egammaRecEvent egammaUtils egammaMVACalibLib PathResolver Particle ParticleTruth TrkToolInterfaces InDetRecToolInterfaces FourMomUtils TrkTrack TrkPseudoMeasurementOnTrack InDetConversionFinderToolsLib )
+                     LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps EventKernel xAODCaloEvent xAODEgamma xAODTruth GaudiKernel MCTruthClassifierLib CaloGeoHelpers CaloUtilsLib AthenaKernel CxxUtils StoreGateLib SGtests xAODTracking EgammaAnalysisInterfacesLib egammaRecEvent egammaUtils egammaMVACalibLib PathResolver Particle ParticleTruth TrkToolInterfaces InDetRecToolInterfaces FourMomUtils TrkTrack TrkPseudoMeasurementOnTrack InDetConversionFinderToolsLib )
 
 # Install files from the package:
 atlas_install_python_modules( python/*.py )
diff --git a/Reconstruction/egamma/egammaAlgs/src/egammaBuilder.h b/Reconstruction/egamma/egammaAlgs/src/egammaBuilder.h
index e87671249c9b53def2f431a1e121f89dc1be175d..1cf3e61b728ff573b679c0470cc85db7464d5288 100755
--- a/Reconstruction/egamma/egammaAlgs/src/egammaBuilder.h
+++ b/Reconstruction/egamma/egammaAlgs/src/egammaBuilder.h
@@ -40,7 +40,7 @@
 #include "xAODCaloEvent/CaloClusterContainer.h"
 #include "egammaRecEvent/egammaRecContainer.h"
 
-#include "ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h"
+#include "EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h"
 #include "egammaInterfaces/IegammaBaseTool.h" 
 #include "egammaInterfaces/IEMTrackMatchBuilder.h"
 #include "egammaInterfaces/IEMConversionBuilder.h"
diff --git a/Reconstruction/egamma/egammaAlgs/src/egammaForwardBuilder.h b/Reconstruction/egamma/egammaAlgs/src/egammaForwardBuilder.h
index 0419829cab2901c8b047c191d8581c98ad521d23..6da01af9ced29ddde1bd75ada322fac3ee987cb6 100755
--- a/Reconstruction/egamma/egammaAlgs/src/egammaForwardBuilder.h
+++ b/Reconstruction/egamma/egammaAlgs/src/egammaForwardBuilder.h
@@ -38,7 +38,7 @@
 
 #include "egammaInterfaces/IegammaBaseTool.h"
 #include "egammaInterfaces/IEMFourMomBuilder.h"
-#include "ElectronPhotonSelectorTools/IAsgForwardElectronIsEMSelector.h"
+#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
 
 #include <string>
 
diff --git a/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.h b/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.h
index 7b792721c722ace2421f914ae53d9eb897a1d8d3..77678039d062a1c1ad94f7956553608218da650c 100755
--- a/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.h
+++ b/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.h
@@ -27,7 +27,7 @@
 #include "xAODCaloEvent/CaloClusterContainer.h"
 #include "egammaRecEvent/egammaRecContainer.h"
 
-#include "ElectronPhotonSelectorTools/IEGammaAmbiguityTool.h"
+#include "EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h"
 #include "egammaInterfaces/IegammaBaseTool.h" 
 
 class egammaRec;
diff --git a/Reconstruction/egamma/egammaMVACalib/CMakeLists.txt b/Reconstruction/egamma/egammaMVACalib/CMakeLists.txt
index 64d19722c12fc53c8fb6ccdd31d5b3f7c1fcc8fc..0af29ebf67d598aa05fd584b94925a114cd82940 100644
--- a/Reconstruction/egamma/egammaMVACalib/CMakeLists.txt
+++ b/Reconstruction/egamma/egammaMVACalib/CMakeLists.txt
@@ -69,7 +69,9 @@ endif()
 atlas_add_test( mem_test SCRIPT test/mem_test.py
                 EXTRA_PATTERNS " GB$" )
 if( XAOD_STANDALONE )
-   atlas_add_test( ut_test SCRIPT test/ut_test.py )
+# Disable until we have reasonable input/to check 
+# against 
+#  atlas_add_test( ut_test SCRIPT test/ut_test.py)
 endif()
 
 # Install files from the package:
diff --git a/Reconstruction/egamma/egammaMVACalib/Root/egammaMVATool.cxx b/Reconstruction/egamma/egammaMVACalib/Root/egammaMVATool.cxx
index 803f1c8bbac61a7df149eee3dd7fc172b211faad..515a05bddef8c3d5d9bc1134b396872e51ebd104 100644
--- a/Reconstruction/egamma/egammaMVACalib/Root/egammaMVATool.cxx
+++ b/Reconstruction/egamma/egammaMVACalib/Root/egammaMVATool.cxx
@@ -191,49 +191,28 @@ StatusCode egammaMVATool::hltexecute(xAOD::CaloCluster* cluster, const std::stri
   return StatusCode::SUCCESS;
 }
 
-float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const std::string& egType){
-
-  // Check for errors...
-  if ( !cluster ){
-    ATH_MSG_WARNING("no xAOD::CaloCluster object provided");
+float egammaMVATool::getEnergy(const xAOD::Egamma* eg){
+  if (!eg){
+    ATH_MSG_WARNING("no xAOD::Egamma object provided");
     return 0;
   }
-
-
-  if (egType == "Electron") {
-    ATH_MSG_DEBUG("Processing for HLT electron");
-    m_MVATreeElectron->update(nullptr, cluster);
-    return m_mvaElectron->getMVAEnergy();
-  }
-  else if(egType == "Photon"){
-    ATH_MSG_DEBUG("Processing for HLT photon");
-    m_MVATreePhoton->update(nullptr, cluster);
-    return m_mvaPhoton->getMVAEnergy();
-  }
-  else {
-    ATH_MSG_WARNING("Unknown particle type");
-  }
-  return 0;
-  
-
+  return getEnergy(eg->caloCluster(),eg);
 }
 
-float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Egamma* eg){
+float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, 
+			       const xAOD::Egamma* eg){
   ATH_MSG_DEBUG("In execute...");
-
   // Check for errors...
   if ( !eg ){
     ATH_MSG_WARNING("no xAOD::Egamma object provided");
     return 0;
   }
-
   if( eg->type() == xAOD::Type::Electron  ){
-    ATH_MSG_DEBUG("Processing for electron...");
+    ATH_MSG_DEBUG("Processing for electron");
     return getEnergy(cluster, static_cast<const xAOD::Electron*>(eg));
   }
   else if (eg->type() == xAOD::Type::Photon ){
-    ATH_MSG_DEBUG("Processing for photon...");
-
+    ATH_MSG_DEBUG("Processing for photon");
     // this is because topo seeded electron (author == 128) have cluster in
     // another collection, which is not decorated with etaCalo, m_cl_phiCalo
     // needed by the MVA calibration
@@ -245,11 +224,43 @@ float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Ega
   else{
     ATH_MSG_INFO("Unknown Type");
   }
+  return 0;
+}
+
 
+float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, 
+			       const std::string& egType){
+  // Check for errors...
+  if ( !cluster ){
+    ATH_MSG_WARNING("no xAOD::CaloCluster object provided");
+    return 0;
+  }
+  if (egType == "Electron") {
+    ATH_MSG_DEBUG("Processing  for type electron");
+    m_MVATreeElectron->update(nullptr, cluster);
+    return m_mvaElectron->getMVAEnergy();
+  }
+  else if(egType == "Photon"){
+    ATH_MSG_DEBUG("Processing for type photon");
+    m_MVATreePhoton->update(nullptr, cluster);
+    return m_mvaPhoton->getMVAEnergy();
+  }
+  else {
+    ATH_MSG_WARNING("Unknown particle type");
+  }
   return 0;
 }
 
-float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Electron* el){
+float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, 
+			       const xAOD::EgammaParameters::EgammaType egType){
+  return  ( (egType==xAOD::EgammaParameters::electron) ?  
+	   getEnergy(cluster, "Electron") : 
+	   getEnergy(cluster, "Photon"));
+}
+
+
+float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, 
+			       const xAOD::Electron* el){
   if(!el){
     ATH_MSG_ERROR("No electron passed");
     return 0;
@@ -259,17 +270,14 @@ float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Ele
   return m_mvaElectron->getMVAEnergy();
 }
 
-float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Photon* ph){
+float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, 
+			       const xAOD::Photon* ph){
   if(!ph){
     ATH_MSG_ERROR("No photon passed");
     return 0;
   }
-
   ATH_MSG_DEBUG("updating variables photon");
   m_MVATreePhoton->update(ph, cluster);
   return m_mvaPhoton->getMVAEnergy();
 }
 
-float egammaMVATool::getEnergy(const xAOD::CaloCluster* cluster, const xAOD::EgammaParameters::EgammaType egType){
-  return  ( (egType==xAOD::EgammaParameters::electron) ?  getEnergy(cluster, "Electron") : getEnergy(cluster, "Photon") );
-}
diff --git a/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/IegammaMVATool.h b/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/IegammaMVATool.h
index 302040aa3cbd39bff9ddd4e43661e2610b2d1c6a..ba2f6f7c45a8f757876becdf3c4c40af4dbc41f0 100644
--- a/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/IegammaMVATool.h
+++ b/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/IegammaMVATool.h
@@ -33,6 +33,18 @@ public:
   virtual StatusCode execute(xAOD::CaloCluster* cluster,const xAOD::Egamma* eg)=0;
   virtual StatusCode execute(xAOD::CaloCluster* cluster,const xAOD::EgammaParameters::EgammaType egType)=0;
   virtual StatusCode hltexecute(xAOD::CaloCluster* cluster, const std::string& egType)=0;
+
+  virtual float getEnergy(const xAOD::Egamma* eg)=0;
+  virtual float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Egamma*)=0;
+  virtual float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::EgammaParameters::EgammaType egType)=0;
+
+  virtual float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Electron*)=0;
+  virtual float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Photon*)=0;
+  virtual float getEnergy(const xAOD::CaloCluster* cluster, const std::string&)=0;
+
+
+
+
 };
 
 #endif
diff --git a/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/egammaMVATool.h b/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/egammaMVATool.h
index 45dade09c4f65395518b49cb2decd4067e35cf3a..fd4f22006d37c35c14f4704b801e5da3f9f5246b 100644
--- a/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/egammaMVATool.h
+++ b/Reconstruction/egamma/egammaMVACalib/egammaMVACalib/egammaMVATool.h
@@ -46,10 +46,12 @@ public:
   StatusCode execute(xAOD::CaloCluster* cluster, const xAOD::EgammaParameters::EgammaType egType);
   StatusCode hltexecute(xAOD::CaloCluster* cluster, const std::string& egType);
 
+  float getEnergy(const xAOD::Egamma* eg);
   float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Egamma*);
+  float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::EgammaParameters::EgammaType egType);
+
   float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Electron*);
   float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::Photon*);
-  float getEnergy(const xAOD::CaloCluster* cluster, const xAOD::EgammaParameters::EgammaType egType);
   float getEnergy(const xAOD::CaloCluster* cluster, const std::string&);
 
 private:
diff --git a/Reconstruction/egamma/egammaMVACalib/test/mem_test.py b/Reconstruction/egamma/egammaMVACalib/test/mem_test.py
index 9e21e679bf515e70a6b783555756311c549f9899..9f358b8d496fc7c65f35d92fd57bb178f900f375 100755
--- a/Reconstruction/egamma/egammaMVACalib/test/mem_test.py
+++ b/Reconstruction/egamma/egammaMVACalib/test/mem_test.py
@@ -25,4 +25,5 @@ memUsage.append( Vmem() )
 m = ROOT.egammaMVACalib(0, True, 'egammaMVACalib/online/v3')
 memUsage.append( Vmem() )
 
-print np.diff(memUsage)/1e6, 'GB'
+for i in memUsage:
+  print i/1e6 , 'GB'
diff --git a/Reconstruction/egamma/egammaMVACalib/util/mem_test_initialize.cxx b/Reconstruction/egamma/egammaMVACalib/util/mem_test_initialize.cxx
index cb3ffef6effcc705a081980793d908bd8c55fb61..47dfe3aa578c04c985880ccaefd35b9ccaca98f3 100644
--- a/Reconstruction/egamma/egammaMVACalib/util/mem_test_initialize.cxx
+++ b/Reconstruction/egamma/egammaMVACalib/util/mem_test_initialize.cxx
@@ -4,10 +4,12 @@
 
 #include "egammaMVACalib/egammaMVATool.h"
 
+
 int main()
 {
   egammaMVATool myMVATool("myMVATool");
   myMVATool.setProperty("folder", "egammaMVACalib/online/v3");
   myMVATool.initialize();
+
   return 0;
 }
diff --git a/Reconstruction/egamma/egammaTools/CMakeLists.txt b/Reconstruction/egamma/egammaTools/CMakeLists.txt
index 58d4fe7100cdcc35fa9fcc6a564207b46a737d29..30906cef3667b1084b8461b1cf1665ed1260760f 100644
--- a/Reconstruction/egamma/egammaTools/CMakeLists.txt
+++ b/Reconstruction/egamma/egammaTools/CMakeLists.txt
@@ -38,9 +38,9 @@ atlas_depends_on_subdirs( PRIVATE
                           LArCalorimeter/LArCabling
                           LumiBlock/LumiBlockComps
                           PhysicsAnalysis/AnalysisCommon/PATCore
-                          PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection
-                          PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools
-                          Reconstruction/Particle
+                          PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces
+			  PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection
+                          Reconstruction/Particle	
                           Reconstruction/ParticleTruth
                           Reconstruction/egamma/egammaInterfaces
                           Reconstruction/egamma/egammaMVACalib
@@ -64,7 +64,7 @@ atlas_add_component( egammaTools
                      src/*.cxx
                      src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} CaloConditions CaloEvent  CaloIdentifier CaloRecLib CaloUtilsLib AthenaBaseComps AthenaKernel CxxUtils AthContainers SGTools StoreGateLib SGtests Identifier EventKernel EventPrimitives FourMom FourMomUtils NavFourMom xAODCaloEvent  xAODEgamma xAODTracking xAODTruth GaudiKernel InDetConversionFinderToolsLib InDetRecToolInterfaces LArRecConditions LArCablingLib LumiBlockCompsLib PATCoreLib ElectronPhotonFourMomentumCorrectionLib ElectronPhotonSelectorToolsLib Particle ParticleTruth egammaMVACalibLib egammaRecEvent egammaUtils TrkEventPrimitives TrkMaterialOnTrack TrkParticleBase TrkPseudoMeasurementOnTrack TrkTrack VxVertex TrkToolInterfaces )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} CaloConditions CaloEvent  CaloIdentifier CaloRecLib CaloUtilsLib AthenaBaseComps AthenaKernel CxxUtils AthContainers SGTools StoreGateLib SGtests Identifier EventKernel EventPrimitives FourMom FourMomUtils NavFourMom xAODCaloEvent  xAODEgamma xAODTracking xAODTruth GaudiKernel InDetConversionFinderToolsLib InDetRecToolInterfaces LArRecConditions LArCablingLib LumiBlockCompsLib PATCoreLib EgammaAnalysisInterfacesLib ElectronPhotonFourMomentumCorrectionLib Particle ParticleTruth egammaMVACalibLib egammaRecEvent egammaUtils TrkEventPrimitives TrkMaterialOnTrack TrkParticleBase TrkPseudoMeasurementOnTrack TrkTrack VxVertex TrkToolInterfaces )
 
 # Install files from the package:
 atlas_install_headers( egammaTools )