ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
PileupReweighting
src
PileupReweightingProvider.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef PILEUPREWEIGHTINGPROVIDER
6
#define PILEUPREWEIGHTINGPROVIDER
7
8
#include "
AsgAnalysisInterfaces/IPileupReweightingTool.h
"
9
#include "
AthenaBaseComps/AthAlgorithm.h
"
10
#include "GaudiKernel/ToolHandle.h"
11
12
#include "
xAODEventInfo/EventInfoAuxContainer.h
"
13
14
#include "
PATInterfaces/SystematicRegistry.h
"
15
16
namespace
CP
{
17
18
class
PileupReweightingProvider
:
public
AthAlgorithm
{
19
20
public
:
21
PileupReweightingProvider
(
const
std::string&
name
, ISvcLocator* svcloc) :
AthAlgorithm
(
name
,svcloc),
m_tool
(
"CP::PileupReweightingTool/auto"
) {
22
declareProperty
(
"Tool"
,
m_tool
,
"The configured PileupReweightingTool"
);
23
declareProperty
(
"Input"
,
m_inputKey
=
""
,
"Specify a specific EventInfo object"
);
24
declareProperty
(
"Output"
,
m_outputKey
=
""
,
"Specify an output EventInfo object. If differs from input, will create a clone of EventInfo and decorate that"
);
25
declareProperty
(
"ConfigOutputStream"
,
m_configStream
=
""
,
"Specify the stream to output config file to"
);
26
declareProperty
(
"RunSystematics"
,
m_systematics
=
true
,
"Enable systematics during run"
);
27
}
28
29
~PileupReweightingProvider
() { }
30
31
virtual
StatusCode
initialize
() {
32
CHECK
(
m_tool
.retrieve() );
33
34
IProperty* myTool =
dynamic_cast<
IProperty*
>
(&*
m_tool
);
35
if
(!myTool)
36
return
StatusCode::FAILURE;
37
CHECK
( myTool->setProperty(
"ConfigOutputStream"
,
m_configStream
) );
38
39
//get the list of systematics
40
CP::SystematicRegistry
& registry =
CP::SystematicRegistry::getInstance
();
41
m_allSysts
= registry.recommendedSystematics();
42
43
if
(
m_configStream
!=
""
)
ATH_MSG_INFO
(
"Now running config file making .... please be patient! ... "
);
44
45
return
StatusCode::SUCCESS;
46
}
47
virtual
StatusCode
execute
(
const
EventContext&
/*ctx*/
) {
48
const
xAOD::EventInfo
* evtInfo =0;
49
50
if
(
m_inputKey
.length()>0)
ATH_CHECK
(
evtStore
()->retrieve(evtInfo,
m_inputKey
));
51
else
{
52
#ifdef XAOD_STANDALONE
53
ATH_CHECK
(
evtStore
()->retrieve(evtInfo,
""
) );
//apparently TEvent can't do keyless retrieves!!??
54
#else
55
ATH_CHECK
(
evtStore
()->retrieve(evtInfo));
56
#endif
57
}
58
59
//do we need to make a copy??
60
if
(
m_inputKey
!=
m_outputKey
&&
m_outputKey
!=
""
) {
61
xAOD::EventInfo
* evtInfoCopy =
new
xAOD::EventInfo
( *evtInfo );
62
xAOD::EventInfoAuxContainer
* aux =
new
xAOD::EventInfoAuxContainer
;
63
evtInfoCopy->setStore(aux);
64
ATH_CHECK
(
evtStore
()->record( evtInfoCopy ,
m_outputKey
) );
65
ATH_CHECK
(
evtStore
()->record( aux ,
m_outputKey
+
"Aux."
) );
66
evtInfo = evtInfoCopy;
67
}
68
69
CHECK
(
m_tool
->apply(*evtInfo) );
70
71
72
//here's an example of systematic variations
73
if
(
m_systematics
){
74
for
(
auto
& syst :
m_allSysts
) {
75
ATH_MSG_VERBOSE
(
"Doing systematic : "
<< syst.name());
76
if
(!
m_tool
->isAffectedBySystematic( syst ))
continue
;
77
CP::SystematicSet
tmp; tmp.insert( syst );
78
if
(
m_tool
->applySystematicVariation( tmp ) != StatusCode::SUCCESS )
continue
;
79
CHECK
(
m_tool
->apply(*evtInfo) );
80
}
81
//make sure we leave the tool in the nominal mode
82
if
(
m_tool
->applySystematicVariation(
CP::SystematicSet
() ) != StatusCode::SUCCESS )
return
StatusCode::FAILURE;
83
}
84
85
return
StatusCode::SUCCESS;
86
}
87
88
private
:
89
ToolHandle<IPileupReweightingTool>
m_tool
;
90
91
std::string
m_inputKey
,
m_outputKey
,
m_configStream
;
92
93
CP::SystematicSet
m_allSysts
;
94
95
bool
m_systematics
;
96
97
};
98
99
}
//end of CP namespace
100
101
#endif
AthAlgorithm.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
EventInfoAuxContainer.h
IPileupReweightingTool.h
SystematicRegistry.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CP::PileupReweightingProvider::m_configStream
std::string m_configStream
Definition
PileupReweightingProvider.h:91
CP::PileupReweightingProvider::m_allSysts
CP::SystematicSet m_allSysts
Definition
PileupReweightingProvider.h:93
CP::PileupReweightingProvider::m_inputKey
std::string m_inputKey
Definition
PileupReweightingProvider.h:91
CP::PileupReweightingProvider::~PileupReweightingProvider
~PileupReweightingProvider()
Definition
PileupReweightingProvider.h:29
CP::PileupReweightingProvider::m_tool
ToolHandle< IPileupReweightingTool > m_tool
Definition
PileupReweightingProvider.h:89
CP::PileupReweightingProvider::initialize
virtual StatusCode initialize()
Definition
PileupReweightingProvider.h:31
CP::PileupReweightingProvider::m_outputKey
std::string m_outputKey
Definition
PileupReweightingProvider.h:91
CP::PileupReweightingProvider::PileupReweightingProvider
PileupReweightingProvider(const std::string &name, ISvcLocator *svcloc)
Definition
PileupReweightingProvider.h:21
CP::PileupReweightingProvider::execute
virtual StatusCode execute(const EventContext &)
Execute method.
Definition
PileupReweightingProvider.h:47
CP::PileupReweightingProvider::m_systematics
bool m_systematics
Definition
PileupReweightingProvider.h:95
CP::SystematicRegistry
This module implements the central registry for handling systematic uncertainties with CP tools.
Definition
SystematicRegistry.h:25
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition
SystematicRegistry.cxx:25
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition
SystematicSet.h:31
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
xAOD::EventInfoAuxContainer
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.
Definition
EventInfoAuxContainer.h:16
Generated on
for ATLAS Offline Software by
1.17.0