Skip to content
Snippets Groups Projects
Commit 5887fbb4 authored by Tadej Novak's avatar Tadej Novak
Browse files

Merge branch 'master-h4l-physlite' into 'master'

PhysLite improvements from h4l

See merge request !63381
parents 46c16b37 dc45afd1
No related branches found
No related tags found
13 merge requests!66406ZDC & ZDC LED monitoring updates,!66102ZDC & RPD monitoring update,!65937Draft: Updated post-processing and plotting scripts for 2023 data in ZLumi_Scripts directory,!65537ZDC - Fix problem with swapping of low and high gain data,!64732Add hypo for time-significance based selection of HLT jets,!64579Draft: Replace status() with functions from TruthUtils,!64531gFex Simulation Updates,!64529gFEX simulation updates,!64426CREST server URL parameter added in IOVDbSvc,!64423CREST server URL parameter added in IOVDbSvc,!64345potential bug,!64193Fix WriteDecorHandleKey type for ftag electron barcode decorators,!63381PhysLite improvements from h4l
Showing
with 332 additions and 221 deletions
......@@ -9,11 +9,7 @@
#include "TruthUtils/MagicNumbers.h"
xAODtoHepMCTool::xAODtoHepMCTool(const std::string &name)
: asg::AsgTool(name),
m_momFac(1.), //<-- MeV/GeV conversion factor
m_lenFac(1.), //<-- length conversion factor
m_signalOnly(true),
m_maxCount(0)
: asg::AsgTool(name)
{
}
......
......@@ -20,35 +20,44 @@
class xAODtoHepMCTool: public asg::AsgTool, public virtual IxAODtoHepMCTool {
public:
ASG_TOOL_CLASS( xAODtoHepMCTool , IxAODtoHepMCTool )
xAODtoHepMCTool( const std::string& name );
virtual ~xAODtoHepMCTool () { };
virtual StatusCode initialize() override;
StatusCode finalize () override;
public:
std::vector<HepMC::GenEvent> getHepMCEvents(const xAOD::TruthEventContainer* xTruthEventContainer, const xAOD::EventInfo* eventInfo) const override;
private:
HepMC::GenEvent createHepMCEvent(const xAOD::TruthEvent* xEvt, const xAOD::EventInfo* eventInfo) const;
HepMC::GenVertexPtr vertexHelper(const xAOD::TruthVertex*,std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr>&,bool&) const;
HepMC::GenParticlePtr createHepMCParticle(const xAOD::TruthParticle*) const;
HepMC::GenVertexPtr createHepMCVertex(const xAOD::TruthVertex*) const;
void printxAODEvent(const xAOD::TruthEvent* event, const xAOD::EventInfo* eventInfo) const;
public:
ASG_TOOL_CLASS( xAODtoHepMCTool , IxAODtoHepMCTool )
xAODtoHepMCTool( const std::string& name );
virtual ~xAODtoHepMCTool () { };
virtual StatusCode initialize() override;
StatusCode finalize () override;
public:
std::vector<HepMC::GenEvent> getHepMCEvents(const xAOD::TruthEventContainer* xTruthEventContainer, const xAOD::EventInfo* eventInfo) const override;
private:
HepMC::GenEvent createHepMCEvent(const xAOD::TruthEvent* xEvt, const xAOD::EventInfo* eventInfo) const;
HepMC::GenVertexPtr vertexHelper(const xAOD::TruthVertex*,std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr>&,bool&) const;
HepMC::GenParticlePtr createHepMCParticle(const xAOD::TruthParticle*) const;
HepMC::GenVertexPtr createHepMCVertex(const xAOD::TruthVertex*) const;
void printxAODEvent(const xAOD::TruthEvent* event, const xAOD::EventInfo* eventInfo) const;
private:
/// Input container key (job property)
float m_momFac,m_lenFac;
bool m_signalOnly;
int m_maxCount;
/// Counters
//not sure if these need to be atomic but just in case this will run in MT
mutable std::atomic<int> m_evtCount;
mutable std::atomic<int> m_badSuggest;
int m_noProdVtx;
int m_badBeams;
private:
/// Input container key (job property)
Gaudi::Property<float> m_momFac {
this, "MomentFactor", 0.001,
"Scale factor to be applied to truth energy and momenta to convert from MeV, e.g. 0.001 to go to GeV"};
Gaudi::Property<float> m_lenFac {
this, "LengthFactor", 1.0,
"Scale factor to be applied to truth lengths to convert from mm, e.g. 0.01 to go to cm"};
Gaudi::Property<bool> m_signalOnly {
this, "SignalOnly", true,
"Convert only the signal event (true), or all events found"};
Gaudi::Property<int> m_maxCount {
this, "PrintNevents", 0,
"Maximum number of events to print out"};
/// Counters
//not sure if these need to be atomic but just in case this will run in MT
mutable std::atomic<int> m_evtCount;
mutable std::atomic<int> m_badSuggest;
int m_noProdVtx;
int m_badBeams;
};
......
......@@ -9,6 +9,7 @@
#define ASG_ANALYSIS_ALGORITHMS__ASG_ANALYSIS_ALGORITHMS_DICT_H
#include <AsgAnalysisAlgorithms/AsgFlagSelectionTool.h>
#include <AsgAnalysisAlgorithms/AsgMaskSelectionTool.h>
#include <AsgAnalysisAlgorithms/AsgPtEtaSelectionTool.h>
#include <AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h>
#include <AsgAnalysisAlgorithms/AsgPriorityDecorationAlg.h>
......@@ -25,7 +26,6 @@
#include <AsgAnalysisAlgorithms/EventFlagSelectionAlg.h>
#include <AsgAnalysisAlgorithms/EventStatusSelectionAlg.h>
#include <AsgAnalysisAlgorithms/EventSelectionByObjectFlagAlg.h>
#include <AsgAnalysisAlgorithms/IsolationCloseByCorrectionAlg.h>
#include <AsgAnalysisAlgorithms/KinematicHistAlg.h>
#include <AsgAnalysisAlgorithms/ObjectCutFlowHistAlg.h>
#include <AsgAnalysisAlgorithms/OverlapRemovalAlg.h>
......
......@@ -72,7 +72,7 @@ namespace CP
/// tool properties
/// \{
private:
std::vector<std::string> m_selFlags;
std::vector<bool> m_invertFlags;
std::vector<std::unique_ptr<ISelectionReadAccessor> > m_acc_selFlags;
......
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
/// @author RD Schaffer
#ifndef ASG_ANALYSIS_ALGORITHMS__ASG_MASK_SELECTION_TOOL_H
#define ASG_ANALYSIS_ALGORITHMS__ASG_MASK_SELECTION_TOOL_H
#include <AsgTools/AsgTool.h>
#include <PATCore/IAsgSelectionTool.h>
#include <SelectionHelpers/ISelectionReadAccessor.h>
#include <xAODBase/IParticle.h>
#include <memory>
#include <string>
#include <vector>
namespace CP
{
/// \brief an \ref IAsgSelectionTool that cuts on int decorations with mask
///
/// Can provide two lists of variables and masks, for each variable,
/// apply mask as selection
class AsgMaskSelectionTool final
: public asg::AsgTool, virtual public IAsgSelectionTool
{
//
// public interface
//
// Create a proper constructor for Athena
ASG_TOOL_CLASS( AsgMaskSelectionTool, IAsgSelectionTool )
/// \brief standard constructor
/// \par Guarantee
/// strong
/// \par Failures
/// out of memory II
public:
AsgMaskSelectionTool (const std::string& name);
//
// inherited interface
//
virtual StatusCode initialize () override;
virtual const asg::AcceptInfo& getAcceptInfo( ) const override;
virtual asg::AcceptData accept( const xAOD::IParticle* part ) const override;
//
// private interface
//
/// tool properties
/// \{
private:
std::vector<std::string> m_selVars;
std::vector<unsigned int> m_selMasks;
std::vector<std::unique_ptr<ISelectionReadAccessor> > m_acc_selVars;
/// \}
/// \brief the \ref asg::AcceptInfo we are using
private:
asg::AcceptInfo m_accept;
};
}
#endif
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
/// @author Nils Krumnack
#ifndef ASG_ANALYSIS_ALGORITHMS__ISOLATION_CLOSE_BY_CORRECTION_ALG_H
#define ASG_ANALYSIS_ALGORITHMS__ISOLATION_CLOSE_BY_CORRECTION_ALG_H
#include <AnaAlgorithm/AnaAlgorithm.h>
#include <CxxUtils/checker_macros.h>
#include <IsolationSelection/IIsolationCloseByCorrectionTool.h>
#include <SelectionHelpers/OutOfValidityEventHelper.h>
#include <SystematicsHandles/SysCopyHandle.h>
#include <SystematicsHandles/SysListHandle.h>
namespace CP
{
/// \brief an algorithm for calling \ref IIsolationCloseByCorrectionTool
class ATLAS_NOT_THREAD_SAFE IsolationCloseByCorrectionAlg final : public EL::AnaAlgorithm
// ^ use of IsolationCloseByCorrectionTool
{
/// \brief the standard constructor
public:
IsolationCloseByCorrectionAlg (const std::string& name,
ISvcLocator* pSvcLocator);
public:
StatusCode initialize () override;
public:
StatusCode execute () override;
/// The OR toolbox
private:
ToolHandle<IIsolationCloseByCorrectionTool> m_isolationCorrectionTool {
"CP::IsolationCloseByCorrectionTool", this};
/// \brief the systematics list we run
private:
SysListHandle m_systematicsList {this};
private:
SysCopyHandle<xAOD::ElectronContainer> m_electronsHandle {
this, "electrons", "", "the electrons container to use"};
SysCopyHandle<xAOD::MuonContainer> m_muonsHandle {
this, "muons", "", "the muons container to use"};
SysCopyHandle<xAOD::PhotonContainer> m_photonsHandle {
this, "photons", "", "the photons container to use"};
/// \brief the helper for OutOfValidity results
private:
OutOfValidityEventHelper m_outOfValidity {this};
};
}
#endif
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
/// @author RD Schaffer
//
// includes
//
#include <AsgAnalysisAlgorithms/AsgMaskSelectionTool.h>
#include <cmath>
//
// method implementations
//
namespace CP
{
AsgMaskSelectionTool ::
AsgMaskSelectionTool (const std::string& name)
: AsgTool (name)
{
declareProperty ("selectionVars", m_selVars, "list of variables to use as selection criteria");
declareProperty ("selectionMasks", m_selMasks, "list of masks, one per variable, for applying the selection");
}
StatusCode AsgMaskSelectionTool ::
initialize ()
{
if(m_selVars.size() != m_selMasks.size()) {
ATH_MSG_ERROR("Property selectionMasks has different size to selectionVars. Please check your configuration");
return StatusCode::FAILURE;
}
// Could also warn if there are fewer values, but we don't have to force users to set where irrelevant.
// Maybe warn unless the size is 0, in which case assume all default?
for(size_t index=0; index<m_selVars.size(); ++index) {
const std::string& thisVar = m_selVars[index];
if (thisVar.empty()) {
ATH_MSG_ERROR("Empty string passed as selection variable!");
return StatusCode::FAILURE;
} else {
// Setup acceptInfo and create accessor to read variable on execute
m_accept.addCut (thisVar, thisVar);
std::unique_ptr<ISelectionReadAccessor> accessor;
ATH_CHECK (makeSelectionReadAccessor (thisVar, accessor));
m_acc_selVars.push_back (std::move (accessor));
}
}
return StatusCode::SUCCESS;
}
const asg::AcceptInfo& AsgMaskSelectionTool ::
getAcceptInfo () const
{
return m_accept;
}
asg::AcceptData AsgMaskSelectionTool ::
accept (const xAOD::IParticle *particle) const
{
asg::AcceptData accept (&m_accept);
for(std::size_t cutIndex=0; cutIndex<m_accept.getNCuts(); ++cutIndex) {
// Apply mask and test
int mask = m_selMasks[cutIndex];
ATH_MSG_VERBOSE("Now testing var \"" << m_selVars[cutIndex] << "\" requiring value " << mask);
accept.setCutResult (cutIndex, ((m_acc_selVars[cutIndex]->getBits (*particle) & mask ) == 0 ));
}
return accept;
}
}
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
/// @author Nils Krumnack
//
// includes
//
#include <AsgAnalysisAlgorithms/IsolationCloseByCorrectionAlg.h>
//
// method implementations
//
namespace CP
{
IsolationCloseByCorrectionAlg ::
IsolationCloseByCorrectionAlg (const std::string& name,
ISvcLocator* pSvcLocator)
: AnaAlgorithm (name, pSvcLocator)
{
declareProperty ("isolationCorrectionTool", m_isolationCorrectionTool);
}
StatusCode IsolationCloseByCorrectionAlg ::
initialize ()
{
ANA_CHECK (m_isolationCorrectionTool.retrieve());
ANA_CHECK (m_electronsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_muonsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_photonsHandle.initialize (m_systematicsList, SG::AllowEmpty));
ANA_CHECK (m_systematicsList.initialize());
ANA_CHECK (m_outOfValidity.initialize());
return StatusCode::SUCCESS;
}
StatusCode IsolationCloseByCorrectionAlg ::
execute ()
{
for (const auto& sys : m_systematicsList.systematicsVector())
{
xAOD::ElectronContainer *electrons {nullptr};
if (m_electronsHandle)
ANA_CHECK (m_electronsHandle.getCopy (electrons, sys));
xAOD::MuonContainer *muons {nullptr};
if (m_muonsHandle)
ANA_CHECK (m_muonsHandle.getCopy (muons, sys));
xAOD::PhotonContainer *photons {nullptr};
if (m_photonsHandle)
ANA_CHECK (m_photonsHandle.getCopy (photons, sys));
ANA_CHECK_CORRECTION_EVENT
(m_outOfValidity, m_isolationCorrectionTool->getCloseByIsoCorrection
(electrons, muons, photons));
}
return StatusCode::SUCCESS;
}
}
......@@ -5,6 +5,7 @@
/// @author Nils Krumnack
#include <AsgAnalysisAlgorithms/AsgFlagSelectionTool.h>
#include <AsgAnalysisAlgorithms/AsgMaskSelectionTool.h>
#include <AsgAnalysisAlgorithms/AsgPtEtaSelectionTool.h>
#include <AsgAnalysisAlgorithms/AsgCutBookkeeperAlg.h>
#include <AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h>
......@@ -21,7 +22,6 @@
#include <AsgAnalysisAlgorithms/EventFlagSelectionAlg.h>
#include <AsgAnalysisAlgorithms/EventStatusSelectionAlg.h>
#include <AsgAnalysisAlgorithms/EventSelectionByObjectFlagAlg.h>
#include <AsgAnalysisAlgorithms/IsolationCloseByCorrectionAlg.h>
#include <AsgAnalysisAlgorithms/KinematicHistAlg.h>
#include <AsgAnalysisAlgorithms/ObjectCutFlowHistAlg.h>
#include <AsgAnalysisAlgorithms/OverlapRemovalAlg.h>
......@@ -32,6 +32,7 @@
#include <AsgAnalysisAlgorithms/TreeMakerAlg.h>
DECLARE_COMPONENT (CP::AsgFlagSelectionTool)
DECLARE_COMPONENT (CP::AsgMaskSelectionTool)
DECLARE_COMPONENT (CP::AsgPtEtaSelectionTool)
DECLARE_COMPONENT (CP::AsgClassificationDecorationAlg)
DECLARE_COMPONENT (CP::AsgPriorityDecorationAlg)
......@@ -48,7 +49,6 @@ DECLARE_COMPONENT (CP::AsgxAODMetNTupleMakerAlg)
DECLARE_COMPONENT (CP::EventFlagSelectionAlg)
DECLARE_COMPONENT (CP::EventStatusSelectionAlg)
DECLARE_COMPONENT (CP::EventSelectionByObjectFlagAlg)
DECLARE_COMPONENT (CP::IsolationCloseByCorrectionAlg)
DECLARE_COMPONENT (CP::KinematicHistAlg)
DECLARE_COMPONENT (CP::ObjectCutFlowHistAlg)
DECLARE_COMPONENT (CP::OverlapRemovalAlg)
......
......@@ -147,23 +147,32 @@ class ElectronWorkingPointConfig (ConfigBlock) :
# It is safe to do this before calibration, as the cluster E is used
alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronLikelihoodAlg' + postfix )
alg.selectionDecoration = 'selectLikelihood' + selectionPostfix + ',as_bits'
if self.recomputeLikelihood:
# Rerun the likelihood ID
config.addPrivateTool( 'selectionTool', 'AsgElectronLikelihoodTool' )
alg.selectionTool.primaryVertexContainer = 'PrimaryVertices'
# Here we have to match the naming convention of EGSelectorConfigurationMapping.h
if self.isRun3Geo:
alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron'
else:
alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron_Run2'
algDecorCount = 7
else:
# Select from Derivation Framework flags
config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
dfFlag = "DFCommonElectronsLH" + self.likelihoodWP.split('LH')[0]
dfFlag = dfFlag.replace("BLayer","BL")
alg.selectionTool.selectionFlags = [dfFlag]
if 'SiHits' in self.likelihoodWP:
# Select from Derivation Framework IsEM bits
config.addPrivateTool( 'selectionTool', 'CP::AsgMaskSelectionTool' )
dfVar = "DFCommonElectronsLHLooseBLIsEMValue"
alg.selectionTool.selectionVars = [dfVar]
mask = int( 0 | 0x1 << 1 | 0x1 << 2)
alg.selectionTool.selectionMasks = [mask]
algDecorCount = 1
else:
if self.recomputeLikelihood:
# Rerun the likelihood ID
config.addPrivateTool( 'selectionTool', 'AsgElectronLikelihoodTool' )
alg.selectionTool.primaryVertexContainer = 'PrimaryVertices'
# Here we have to match the naming convention of EGSelectorConfigurationMapping.h
if self.isRun3Geo:
alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron'
else:
alg.selectionTool.WorkingPoint = self.likelihoodWP + 'Electron_Run2'
algDecorCount = 7
else:
# Select from Derivation Framework flags
config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
dfFlag = "DFCommonElectronsLH" + self.likelihoodWP.split('LH')[0]
dfFlag = dfFlag.replace("BLayer","BL")
alg.selectionTool.selectionFlags = [dfFlag]
algDecorCount = 1
else:
# Set up the DNN ID selection algorithm
alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronDNNAlg' + postfix )
......
......@@ -238,19 +238,28 @@ def makeElectronWorkingPointSequence( seq, dataType, workingPoint,
# It is safe to do this before calibration, as the cluster E is used
alg = createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronLikelihoodAlg' + postfix )
alg.selectionDecoration = 'selectLikelihood' + postfix + ',as_bits'
if recomputeLikelihood:
# Rerun the likelihood ID
addPrivateTool( alg, 'selectionTool', 'AsgElectronLikelihoodTool' )
alg.selectionTool.primaryVertexContainer = 'PrimaryVertices'
alg.selectionTool.WorkingPoint = likelihoodWP
algDecorCount = 7
else:
# Select from Derivation Framework flags
addPrivateTool( alg, 'selectionTool', 'CP::AsgFlagSelectionTool' )
dfFlag = "DFCommonElectronsLH" + likelihoodWP.split('LH')[0]
dfFlag = dfFlag.replace("BLayer","BL")
alg.selectionTool.selectionFlags = [dfFlag]
if 'SiHits' in likelihoodWP:
# Select from Derivation Framework IsEM bits
addPrivateTool( alg, 'selectionTool', 'CP::AsgMaskSelectionTool' )
dfVar = "DFCommonElectronsLHLooseBLIsEMValue"
alg.selectionTool.selectionVars = [dfVar]
mask = int( 0 | 0x1 << 1 | 0x1 << 2)
alg.selectionTool.selectionMasks = [mask]
algDecorCount = 1
else:
if recomputeLikelihood:
# Rerun the likelihood ID
addPrivateTool( alg, 'selectionTool', 'AsgElectronLikelihoodTool' )
alg.selectionTool.primaryVertexContainer = 'PrimaryVertices'
alg.selectionTool.WorkingPoint = likelihoodWP
algDecorCount = 7
else:
# Select from Derivation Framework flags
addPrivateTool( alg, 'selectionTool', 'CP::AsgFlagSelectionTool' )
dfFlag = "DFCommonElectronsLH" + likelihoodWP.split('LH')[0]
dfFlag = dfFlag.replace("BLayer","BL")
alg.selectionTool.selectionFlags = [dfFlag]
algDecorCount = 1
else:
# Set up the DNN ID selection algorithm
alg = createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronDNNAlg' + postfix )
......
......@@ -11,7 +11,7 @@ if ( NOT XAOD_STANDALONE)
set(extra_libs MuonTesterTreeLib)
endif()
if ( NOT XAOD_STANDALONE AND NOT XAOD_ANALYSIS )
set(extra_libs ${extra_libs} TrkExUtils)
set(extra_libs ${extra_libs} TrkExUtils TrackToCaloLib)
endif()
# Libraries in the package:
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ISOLATIONSELECTION_IISOLATIONCLOSEBYCORRECTIONTOOL_H
......@@ -36,10 +36,17 @@ namespace CP {
const std::vector<xAOD::Iso::IsolationType>& types,
const xAOD::IParticleContainer& closePar) const = 0;
virtual CorrectionCode getCloseByIsoCorrection ATLAS_NOT_THREAD_SAFE (xAOD::ElectronContainer* Electrons = nullptr, xAOD::MuonContainer* Muons = nullptr,
xAOD::PhotonContainer* Photons = nullptr) const = 0;
virtual CorrectionCode subtractCloseByContribution(xAOD::IParticle& x, const xAOD::IParticleContainer& closebyPar) const = 0;
// This function calculates the values of the corrections for close-by objects and applies them to the isolation variables and
// writes them out as a new decoration of the particles. This requires a suffix to be specified for the new decoration, otherwise
// an ERROR will be returned.
virtual CorrectionCode getCloseByIsoCorrection (
#ifndef XAOD_ANALYSIS
const EventContext& ctx,
#endif
const xAOD::ElectronContainer* Electrons = nullptr,
const xAOD::MuonContainer* Muons = nullptr,
const xAOD::PhotonContainer* Photons = nullptr
) const = 0;
virtual float getOriginalIsolation(const xAOD::IParticle& P, IsoType type) const = 0;
virtual float getOriginalIsolation(const xAOD::IParticle* P, IsoType type) const = 0;
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ISOLATIONSELECTION_ISOVARIABLEHELPER_H
......@@ -18,15 +18,15 @@ namespace CP {
class IsoVariableHelper {
public:
CorrectionCode getOrignalIsolation(const xAOD::IParticle* particle, float& value) const;
CorrectionCode getOriginalIsolation(const xAOD::IParticle* particle, float& value) const;
CorrectionCode getIsolation(const xAOD::IParticle* particle, float& value) const;
CorrectionCode backupIsolation(const xAOD::IParticle* particle) const;
CorrectionCode setIsolation(xAOD::IParticle* P, float value) const;
CorrectionCode setIsolation(const xAOD::IParticle* P, float value) const;
IsoType isotype() const;
std::string name() const;
IsoVariableHelper(IsoType type, const std::string& BackupPreFix);
IsoVariableHelper(IsoType type, const std::string& backupPreFix, const std::string& isoDecSuffix = "");
private:
CorrectionCode getIsolationFromOriginal(const xAOD::IParticle* particle, float& value) const;
......
......@@ -11,6 +11,11 @@
#include <AsgTools/PropertyWrapper.h>
#include <AsgTools/ToolHandle.h>
#include <CxxUtils/checker_macros.h>
#ifndef XAOD_ANALYSIS
#include <StoreGate/ReadDecorHandleKeyArray.h>
#include <StoreGate/WriteDecorHandleKeyArray.h>
#include "RecoToolInterfaces/IParticleCaloExtensionTool.h"
#endif
#include <InDetTrackSelectionTool/IInDetTrackSelectionTool.h>
#include <IsolationSelection/Defs.h>
......@@ -18,6 +23,7 @@
#include <IsolationSelection/IsoVariableHelper.h>
#include <IsolationSelection/IsolationWP.h>
#include "IsolationSelection/IIsolationSelectionTool.h"
#include "TrackVertexAssociationTool/ITrackVertexAssociationTool.h"
#include "xAODEgamma/ElectronContainer.h"
......@@ -55,10 +61,13 @@ namespace CP {
virtual asg::AcceptData acceptCorrected(const xAOD::IParticle& x, const xAOD::IParticleContainer& closePar) const override;
/// not thread-safe because of const_cast
virtual CorrectionCode getCloseByIsoCorrection ATLAS_NOT_THREAD_SAFE (xAOD::ElectronContainer* Electrons, xAOD::MuonContainer* Muons,
xAOD::PhotonContainer* Photons) const override;
virtual CorrectionCode subtractCloseByContribution(xAOD::IParticle& x, const xAOD::IParticleContainer& closebyPar) const override;
virtual CorrectionCode getCloseByIsoCorrection (
#ifndef XAOD_ANALYSIS
const EventContext& ctx,
#endif
const xAOD::ElectronContainer* Electrons,
const xAOD::MuonContainer* Muons,
const xAOD::PhotonContainer* Photons) const override;
virtual float getOriginalIsolation(const xAOD::IParticle& P, IsoType type) const override;
virtual float getOriginalIsolation(const xAOD::IParticle* particle, IsoType type) const override;
......@@ -79,6 +88,7 @@ namespace CP {
ObjectCache() = default;
const xAOD::Vertex* prim_vtx{nullptr};
PrimaryCollection prim_parts{};
PrimaryCollection not_sel_parts{};
TrackSet tracks{};
ClusterSet clusters{};
PflowSet flows{};
......@@ -96,13 +106,13 @@ namespace CP {
// Function to pipe each container given by the interfaces through. It loops over all
// particles and removes the isolation overlap between the objects
CorrectionCode performCloseByCorrection ATLAS_NOT_THREAD_SAFE (const EventContext& ctx, ObjectCache& cache) const;
CorrectionCode performCloseByCorrection (const EventContext& ctx, ObjectCache& cache) const;
// Helper function to obtain the isolation cones to use for a given particle
const IsoVector& getIsolationTypes(const xAOD::IParticle* particle) const;
// Functions to perfrom the isolation correction directly
CorrectionCode subtractCloseByContribution(const EventContext& ctx, xAOD::IParticle* P, const ObjectCache& cache) const;
CorrectionCode subtractCloseByContribution(const EventContext& ctx, const xAOD::IParticle* P, const ObjectCache& cache) const;
// Remove close-by tracks from the track isolation variables
CorrectionCode getCloseByCorrectionTrackIso(const xAOD::IParticle* primary, const IsoType type, const ObjectCache& cache,
float& isoValue) const;
......@@ -112,12 +122,20 @@ namespace CP {
// Remove close-by flow elements from the neflow isolation variables
CorrectionCode getCloseByCorrectionPflowIso(const EventContext& ctx, const xAOD::IParticle* primary, const IsoType type,
const ObjectCache& cache, float& isoValue) const;
// For primary particles not selected, copy isolation value to output decorator
CorrectionCode copyIsoValuesForPartsNotSelected(const xAOD::IParticle* part) const;
/// Loads the topo clusters associated with the primary IParticle
ClusterSet getAssociatedClusters(const EventContext& ctx, const xAOD::IParticle* particle) const;
/// Loads the pflow elements associated with the primary IParticle
PflowSet getAssocFlowElements(const EventContext& ctx, const xAOD::IParticle* particle) const;
#ifndef XAOD_ANALYSIS
/// helper to get eta,phi of muon extrap
bool getExtrapEtaPhi(const EventContext& ctx, const xAOD::TrackParticle* tp, float& eta, float& phi) const;
#endif
// Returns the Size of the Isolation cone
float coneSize(const xAOD::IParticle* particle, IsoType Cone) const;
// Retrieves the uncalibrated pt from the particle
......@@ -198,6 +216,9 @@ namespace CP {
Gaudi::Property<std::string> m_backup_prefix{
this, "BackupPrefix", "", "Prefix in front of the isolation variables, if the original cone values need to be backuped"};
Gaudi::Property<std::string> m_isoDecSuffix{
this, "IsoDecSuffix", "", "Suffix added to output isolation variable nanes for close by corrections"};
/// EXPERT PROPERTIES
Gaudi::Property<int> m_caloModel{this, "CaloCorrectionModel", TopoConeCorrectionModel::SubtractObjectsDirectly};
// The core of the topoEt variables. Clusters within the core shall not be
......@@ -228,7 +249,28 @@ namespace CP {
"order to account for extrapolation effects"}; // Extend - shrink the cone size to account for extrapolation effects
Gaudi::Property<bool> m_declareCaloDecors{this, "declareCaloDecors", false, "If set to true, the data dependency on the calo/pflow decors will be declared"};
/// Declare the data dependencies of the Input containers.
/// The isolation variables used in the working point calculation are declared to the avalanche scheduler.
/// This is not needed for the AthAnalysis nor AnalysisBase releases.
#ifndef XAOD_ANALYSIS
Gaudi::Property<std::vector<std::string>> m_elecKeys{
this, "EleContainers", {}, "Pipe the list of electron containers given later to the tool"};
Gaudi::Property<std::vector<std::string>> m_muonKeys{
this, "MuoContainers", {}, "Pipe the list of muon containers given later to the tool"};
Gaudi::Property<std::vector<std::string>> m_photKeys{
this, "PhoContainers", {}, "Pipe the list of photon containers given later to the tool"};
SG::ReadDecorHandleKeyArray<xAOD::IParticleContainer> m_isoVarKeys{
this, "IsoVarKeys", {}, "The list is filled during the initialization"};
SG::WriteDecorHandleKeyArray<xAOD::IParticleContainer> m_isoWriteDecVarKeys{
this, "IsoWriteDecVarKeys", {}, "The list is filled during the initialization"};
/// calo extension tool for muon track particle extrapolation to calo
ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtTool {this, "ParticleCaloExtensionTool", "Trk::ParticleCaloExtensionTool/ParticleCaloExtensionTool"};
/// Helper function to declare the data dependencies
void declareDependency(const std::vector<std::string>& containers, const IsoVector& types);
#endif
SG::ReadHandleKey<xAOD::VertexContainer> m_VtxKey{this, "VertexContainer", "PrimaryVertices",
"Name of the primary vertex container"};
SG::ReadHandleKey<xAOD::CaloClusterContainer> m_CaloClusterKey{this, "CaloClusterContainer", "CaloCalTopoClusters",
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ISOLATIONSELECTION_ISOLATIONCONDITION_H
......@@ -26,10 +26,10 @@ struct strObj {
namespace CP {
class IsolationCondition {
public:
IsolationCondition(const std::string& name, xAOD::Iso::IsolationType isoType);
IsolationCondition(const std::string& name, const std::vector<xAOD::Iso::IsolationType>& isoTypes);
IsolationCondition(const std::string& name, std::string& isoType);
IsolationCondition(const std::string& name, const std::vector<std::string>& isoTypes);
IsolationCondition(const std::string& name, xAOD::Iso::IsolationType isoType, std::string isoDecSuffix = "");
IsolationCondition(const std::string& name, const std::vector<xAOD::Iso::IsolationType>& isoTypes, std::string isoDecSuffix = "");
IsolationCondition(const std::string& name, std::string& isoType, std::string isoDecSuffix = "");
IsolationCondition(const std::string& name, const std::vector<std::string>& isoTypes, std::string isoDecSuffix = "");
IsolationCondition(const IsolationCondition& rhs) = delete;
IsolationCondition& operator=(const IsolationCondition& rhs) = delete;
......@@ -48,6 +48,9 @@ namespace CP {
std::string m_name;
std::vector<xAOD::Iso::IsolationType> m_isolationType;
std::vector<FloatAccessor> m_acc;
protected:
std::string m_isoDecSuffix{};
};
} // namespace CP
#endif
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ISOLATIONSELECTION_ISOLATIONCONDITIONCOMBINED_H
......@@ -13,7 +13,7 @@ namespace CP {
class IsolationConditionCombined : public IsolationCondition {
public:
IsolationConditionCombined(const std::string& name, const std::vector<xAOD::Iso::IsolationType>& isoType,
std::unique_ptr<TF1> isoFunction, const std::string& cutFunction);
std::unique_ptr<TF1> isoFunction, const std::string& cutFunction, std::string isoDecSuffix = "");
virtual ~IsolationConditionCombined() = default;
bool accept(const xAOD::IParticle& x) const override;
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ISOLATIONSELECTION_ISOLATIONCONDITIONFORMULA_H
......@@ -19,8 +19,8 @@ namespace CP {
class IsolationConditionFormula : public IsolationCondition {
public:
IsolationConditionFormula(std::string name, xAOD::Iso::IsolationType isoType, const std::string& cutFunction,
bool invertCut = false);
IsolationConditionFormula(std::string name, std::string isoType, const std::string& cutFunction, bool invertCut = false);
bool invertCut = false, std::string isoDecSuffix = "");
IsolationConditionFormula(std::string name, std::string isoType, const std::string& cutFunction, bool invertCut = false, std::string isoDecSuffix = "");
virtual ~IsolationConditionFormula() = default;
virtual bool accept(const xAOD::IParticle& x) const override;
......
......@@ -85,6 +85,9 @@ namespace CP {
"path of the cut map for electron"};
Gaudi::Property<std::string> m_phWPKey{this, "PhotonKey", "/ElectronPhoton/LHTight/el_cutValues_",
"path of the cut map for photon"};
Gaudi::Property<std::string> m_isoDecSuffix{
this, "IsoDecSuffix", "", "Suffix added to output isolation variables to allow to NOT overwrite existing values"};
/// input file
Gaudi::Property<std::string> m_calibFileName{this, "CalibFileName", "", " The config to use"};
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ISOLATIONSELECTION_TESTMARCOHELPERS_H
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment