Commit 0c283610 authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Walter Lampl
Browse files

Migrate egammaMVACalib package, i.e the MT compliant egamma MVA calibration to...

Migrate egammaMVACalib package, i.e the MT compliant egamma MVA calibration to be dual use. This targets migrating the new package , but not yet removing the legacy egammaMVACalibAnalysis
parent 4bfb7f00
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
# The name of the package:
atlas_subdir( EgammaAnalysisInterfaces )
......@@ -8,7 +8,8 @@ atlas_add_library( EgammaAnalysisInterfacesLib
EgammaAnalysisInterfaces/*.h
INTERFACE
PUBLIC_HEADERS EgammaAnalysisInterfaces
LINK_LIBRARIES AsgTools xAODCaloEvent xAODEgamma xAODTracking PATInterfaces PATCoreLib )
LINK_LIBRARIES AsgTools AsgServicesLib xAODCaloEvent
xAODEgamma xAODTracking AsgMessagingLib PATInterfaces PATCoreLib )
atlas_add_dictionary( EgammaAnalysisInterfacesDict
EgammaAnalysisInterfaces/EgammaAnalysisInterfacesDict.h
......
......@@ -15,6 +15,8 @@
#include "EgammaAnalysisInterfaces/IAsgElectronEfficiencyCorrectionTool.h"
#include "EgammaAnalysisInterfaces/IegammaMVACalibTool.h"
#include "EgammaAnalysisInterfaces/IegammaMVASvc.h"
#include "EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h"
#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h"
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EGAMMAINTERFACES_iEGAMMAMVACALIBTOOL_H
#define EGAMMAINTERFACES_iEGAMMAMVACALIBTOOL_H
#ifndef EGAMMAANALYSISINTERFACES_IEGAMMAMVACALIBTOOL_H
#define EGAMMAANALYSISINTERFACES_IEGAMMAMVACALIBTOOL_H
#include "GaudiKernel/IAlgTool.h"
#include "AsgTools/IAsgTool.h"
// EDM includes
#include "xAODEgamma/EgammaFwd.h"
......@@ -14,16 +14,15 @@
* @class IegammaMVACalibTool
* @brief A tool used by the egammaMVASvc to help manage the MVAs.
**/
class IegammaMVACalibTool : virtual public IAlgTool {
class IegammaMVACalibTool : virtual public asg::IAsgTool{
ASG_TOOL_INTERFACE(IegammaMVACalibTool)
public:
DeclareInterfaceID(IegammaMVACalibTool, 1, 0);
virtual ~IegammaMVACalibTool() override {};
///Return MVA energy for the given cluster, an eg object is optional
virtual float getEnergy(const xAOD::CaloCluster& clus,
const xAOD::Egamma* eg) const = 0;
};
};
#endif
// Dear Emacs, this is -*- C++ -*-
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EGAMMAINTERFACES_IEGAMMAMVASVC_H
#define EGAMMAINTERFACES_IEGAMMAMVASVC_H
#include "GaudiKernel/IService.h"
#ifndef EGAMMAANALYSISINTERFACES_IEGAMMAMVASVC_H
#define EGAMMAANALYSISINTERFACES_IEGAMMAMVASVC_H
#include "AsgServices/IAsgService.h"
#include "AsgMessaging/StatusCode.h"
// EDM includes
#include "xAODEgamma/EgammaFwd.h"
#include "xAODEgamma/EgammaEnums.h"
#include "xAODCaloEvent/CaloClusterFwd.h"
class IegammaMVASvc : virtual public IService {
class IegammaMVASvc : virtual public asg::IAsgService {
ASG_SERVICE_INTERFACE(IegammaMVASvc)
public:
DeclareInterfaceID(IegammaMVASvc, 1, 0);
virtual ~IegammaMVASvc() override {};
......
......@@ -9,13 +9,15 @@
<class name="IAsgDeadHVCellRemovalTool" />
<class name="IAsgElectronEfficiencyCorrectionTool" />
<class name="IegammaMVACalibTool" />
<class name="IegammaMVASvc" />
<class name="IEgammaCalibrationAndSmearingTool" />
<variable pattern="EgammaCalibPeriodRunNumbersExample::*"/>
<class name="EgammaCalibPeriodRunNumbersExample::ROOT6_NamespaceAutoloadHook" />
<class name="IAsgPhotonEfficiencyCorrectionTool" />
<class name="IElectronPhotonShowerShapeFudgeTool" />
<lcgdict>
......@@ -15,7 +15,7 @@
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "CaloUtils/CaloCellDetPos.h"
#include "egammaInterfaces/IegammaCheckEnergyDepositTool.h"
#include "egammaInterfaces/IegammaMVASvc.h"
#include "EgammaAnalysisInterfaces/IegammaMVASvc.h"
#include "egammaInterfaces/IegammaSwTool.h"
#include "egammaRecEvent/egammaRecContainer.h"
#include "xAODCaloEvent/CaloClusterFwd.h"
......
......@@ -29,7 +29,6 @@
#include "egammaInterfaces/IegammaShowerShape.h"
#include "egammaInterfaces/IegammaStripsShape.h"
#include "egammaInterfaces/IegammaSwTool.h"
#include "egammaInterfaces/IegammaMVASvc.h"
#include "egammaInterfaces/IegammaOQFlagsBuilder.h"
#ifndef XAOD_ANALYSIS
# include "egammaInterfaces/IEMExtrapolationTools.h"
......
......@@ -16,7 +16,6 @@
<class name="IegammaStripsShape" />
<class name="IegammaSwTool" />
<class name="IegammaTrkRefitterTool" />
<class name="IegammaMVASvc" />
<class name="IegammaOQFlagsBuilder" />
</lcgdict>
......@@ -17,14 +17,20 @@ atlas_add_library( egammaMVACalibLib
egammaMVACalib/*.h Root/*.cxx
PUBLIC_HEADERS egammaMVACalib
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AsgMessagingLib xAODCaloEvent xAODEgamma
LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools AsgServicesLib AsgMessagingLib
xAODCaloEvent xAODEgamma xAODTracking MVAUtils PathResolver EgammaAnalysisInterfacesLib
${extra_libs} )
atlas_add_dictionary( egammaMVACalibDict
egammaMVACalib/egammaMVACalibDict.h
egammaMVACalib/selection.xml
LINK_LIBRARIES egammaMVACalibLib )
if( NOT XAOD_STANDALONE )
atlas_add_component( egammaMVACalib
src/*.cxx src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel MVAUtils PathResolver egammaInterfacesLib egammaMVACalibLib xAODCaloEvent xAODEgamma xAODTracking )
LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel egammaMVACalibLib)
endif()
# Install files from the package:
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "egammaMVACalibTool.h"
#include "egammaMVACalib/egammaMVACalibTool.h"
#include "xAODEgamma/Egamma.h"
#include "xAODCaloEvent/CaloCluster.h"
......@@ -23,8 +23,8 @@ using Gaudi::Units::GeV;
#define GeV 1000
#endif
egammaMVACalibTool::egammaMVACalibTool(const std::string& type, const std::string& name, const IInterface* parent) :
base_class(type, name, parent)
egammaMVACalibTool::egammaMVACalibTool(const std::string& name) :
asg::AsgTool(name)
{
}
......@@ -81,11 +81,6 @@ StatusCode egammaMVACalibTool::initialize()
return StatusCode::SUCCESS;
}
StatusCode egammaMVACalibTool::finalize()
{
return StatusCode::SUCCESS;
}
StatusCode egammaMVACalibTool::setupBDT(const egammaMVAFunctions::funcMap_t& funcLibrary,
const std::string& fileName)
{
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "egammaMVASvc.h"
#include "egammaMVACalib/egammaMVASvc.h"
#include "xAODEgamma/Egamma.h"
#include "xAODCaloEvent/CaloCluster.h"
#include "xAODEgamma/EgammaDefs.h"
......@@ -12,7 +12,7 @@
egammaMVASvc::egammaMVASvc(const std::string& name, ISvcLocator* svc) :
base_class( name, svc )
asg::AsgService( name, svc )
{
}
......@@ -20,7 +20,7 @@ StatusCode egammaMVASvc::initialize()
{
ATH_MSG_DEBUG("In initialize of " << name() << "..." );
if (m_mvaElectron.isEnabled()) {
if (!m_mvaElectron.empty()) {
ATH_MSG_DEBUG("Retrieving mvaElectron");
ATH_CHECK(m_mvaElectron.retrieve());
} else {
......@@ -28,7 +28,7 @@ StatusCode egammaMVASvc::initialize()
m_mvaElectron.disable();
}
if (m_mvaUnconvertedPhoton.isEnabled()) {
if (!m_mvaUnconvertedPhoton.empty()) {
ATH_MSG_DEBUG("Retrieving mvaUnconvertedPhoton");
ATH_CHECK(m_mvaUnconvertedPhoton.retrieve());
} else {
......@@ -36,7 +36,7 @@ StatusCode egammaMVASvc::initialize()
m_mvaUnconvertedPhoton.disable();
}
if (m_mvaConvertedPhoton.isEnabled()) {
if (!m_mvaConvertedPhoton.empty()) {
ATH_MSG_DEBUG("Retrieving mvaConvertedPhoton");
ATH_CHECK(m_mvaConvertedPhoton.retrieve());
} else {
......@@ -47,12 +47,6 @@ StatusCode egammaMVASvc::initialize()
return StatusCode::SUCCESS;
}
StatusCode egammaMVASvc::finalize(){
ATH_MSG_DEBUG( "in finalize" );
return StatusCode::SUCCESS;
}
StatusCode egammaMVASvc::execute(xAOD::CaloCluster& cluster,
const xAOD::Egamma& eg) const
{
......@@ -62,7 +56,7 @@ StatusCode egammaMVASvc::execute(xAOD::CaloCluster& cluster,
float mvaE = 0.0;
if (xAOD::EgammaHelpers::isElectron(&eg)) {
if (m_mvaElectron.isEnabled()) {
if (!m_mvaElectron.empty()) {
mvaE = m_mvaElectron->getEnergy(cluster, &eg);
} else {
ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
......@@ -70,14 +64,14 @@ StatusCode egammaMVASvc::execute(xAOD::CaloCluster& cluster,
}
} else if (xAOD::EgammaHelpers::isConvertedPhoton(&eg) &&
xAOD::EgammaHelpers::conversionRadius(static_cast<const xAOD::Photon*>(&eg)) < m_maxConvR) {
if (m_mvaConvertedPhoton.isEnabled()) {
if (!m_mvaConvertedPhoton.empty()) {
mvaE = m_mvaConvertedPhoton->getEnergy(cluster, &eg);
} else {
ATH_MSG_FATAL("Trying to calibrate a converted photon, but disabled");
return StatusCode::FAILURE;
}
} else if (xAOD::EgammaHelpers::isPhoton(&eg)) {
if (m_mvaUnconvertedPhoton.isEnabled()) {
if (!m_mvaUnconvertedPhoton.empty()) {
mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster, &eg);
} else {
ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
......@@ -109,7 +103,7 @@ StatusCode egammaMVASvc::execute(xAOD::CaloCluster& cluster,
float mvaE = 0.0;
switch (egType) {
case xAOD::EgammaParameters::electron:
if (m_mvaElectron.isEnabled()) {
if (!m_mvaElectron.empty()) {
mvaE = m_mvaElectron->getEnergy(cluster,nullptr);
} else {
ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
......@@ -119,7 +113,7 @@ StatusCode egammaMVASvc::execute(xAOD::CaloCluster& cluster,
case xAOD::EgammaParameters::convertedPhoton:
case xAOD::EgammaParameters::unconvertedPhoton:
// treat converted photons like unconverted photons since don't have access to vertex
if (m_mvaUnconvertedPhoton.isEnabled()) {
if (!m_mvaUnconvertedPhoton.empty()) {
mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster,nullptr);
} else {
ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EGAMMAMVACALIB_EGAMMAMVACALIBDICT_H
#define EGAMMAMVACALIB_EGAMMAMVACALIBDICT_H
#include "egammaMVACalib/egammaMVACalibTool.h"
#include "egammaMVACalib/egammaMVASvc.h"
#endif // EGAMMAMVACALIB_EGAMMAMVACALIBDICT_H
......@@ -6,13 +6,16 @@
#define EGAMMAMVACALIB_EGAMMAMVACALIBTOOL_H
// Package includes
#include "egammaInterfaces/IegammaMVACalibTool.h"
#include "EgammaAnalysisInterfaces/IegammaMVACalibTool.h"
#include "xAODEgamma/EgammaEnums.h"
#include "MVAUtils/BDT.h"
#include "egammaMVACalib/egammaMVAFunctions.h"
// Framework includes
#include "AthenaBaseComps/AthAlgTool.h"
#include "AsgTools/AsgTool.h"
#include "AsgTools/PropertyWrapper.h"
//Root includes
#include "TH2Poly.h"
#include "TObject.h"
#include "TString.h"
......@@ -52,21 +55,21 @@
* Each TObjString is a string which represent the formula to compute the shift
* (used to construct a TFormula). The variables is the Et in GeV after the calibration.
* The value of the shift is divided by the energy calibrated by the BDT.
*
*
*
*
* On data the property use_layer_corrected should be set to true. In reconstruction
* this flag is always false. In PhysicsAnalysis it should be set appropriately.
* When set to true when using the layer energies as input the data-driver-corrected
* version are used.
**/
class egammaMVACalibTool : public extends<AthAlgTool, IegammaMVACalibTool> {
class egammaMVACalibTool : public asg::AsgTool, virtual public IegammaMVACalibTool{
ASG_TOOL_CLASS(egammaMVACalibTool, IegammaMVACalibTool)
public:
egammaMVACalibTool(const std::string& type, const std::string& name, const IInterface* parent);
egammaMVACalibTool(const std::string& type);
virtual ~egammaMVACalibTool() override;
virtual StatusCode initialize() override;
virtual StatusCode finalize() override;
/** how the output of the BDT is used
* correctEaccordion: energy = raw energy * BDT
......
......@@ -8,29 +8,27 @@
#define EGAMMAMVACALIB_EGAMMAMVASVC_H
#include "xAODEgamma/EgammaEnums.h"
#include "egammaInterfaces/IegammaMVASvc.h"
#include "egammaInterfaces/IegammaMVACalibTool.h"
#include "AthenaBaseComps/AthService.h"
#include "EgammaAnalysisInterfaces/IegammaMVASvc.h"
#include "EgammaAnalysisInterfaces/IegammaMVACalibTool.h"
// Framework includes
#include "AsgServices/AsgService.h"
#include "AsgTools/PropertyWrapper.h"
#include <string>
class egammaMVASvc : public extends1<AthService, IegammaMVASvc>
class egammaMVASvc : public asg::AsgService, virtual public IegammaMVASvc
{
public:
egammaMVASvc( const std::string& name, ISvcLocator* svc );
ASG_SERVICE_CLASS1(egammaMVASvc, IegammaMVASvc)
virtual ~egammaMVASvc() override {};
virtual StatusCode initialize() override;
virtual StatusCode finalize() override;
/** Main execute. We need to calibrate the cluster.
Use full egamma object instead of Type
As we employ further variables than the ones present in the cluster
This method needs to be valid also for reconstruction
*/
StatusCode execute(xAOD::CaloCluster& cluster,
const xAOD::Egamma& eg) const override final;
......
<lcgdict>
<class name="egammaMVACalibTool" />
<class name="egammaMVASvc" />
</lcgdict>
#include "../egammaMVASvc.h"
#include "../egammaMVACalibTool.h"
#include "egammaMVACalib/egammaMVASvc.h"
#include "egammaMVACalib/egammaMVACalibTool.h"
DECLARE_COMPONENT( egammaMVASvc )
DECLARE_COMPONENT( egammaMVACalibTool )
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EGAMMATOOLS_EMCLUSTERTOOL_H
......@@ -11,7 +11,7 @@
#include "egammaBaseTool.h"
#include "egammaInterfaces/IEMClusterTool.h"
#include "egammaInterfaces/IegammaMVASvc.h"
#include "EgammaAnalysisInterfaces/IegammaMVASvc.h"
#include "egammaInterfaces/IegammaSwTool.h"
#include "StoreGate/WriteHandleKey.h"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment