ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
TrackingID
InDetTrackSystematicsTools
Root
InDetTrackSystematicsTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
InDetTrackSystematicsTools/InDetTrackSystematicsTool.h
"
6
#include "
PATInterfaces/SystematicRegistry.h
"
7
#include "
PathResolver/PathResolver.h
"
8
#include "TFile.h"
9
10
namespace
InDet
{
11
12
InDetTrackSystematicsTool::InDetTrackSystematicsTool(
const
std::string& name )
13
: asg::AsgTool(
name
)
14
{
15
}
16
17
StatusCode
InDetTrackSystematicsTool::initialize
()
18
{
19
20
// add the affecting systematics to the registry
21
auto
& registry =
CP::SystematicRegistry::getInstance
();
22
if
(registry.registerSystematics(*
this
) != StatusCode::SUCCESS) {
23
ATH_MSG_ERROR
(
"Unable to register systematics"
);
24
return
StatusCode::FAILURE;
25
}
26
27
return
StatusCode::SUCCESS;
28
}
29
30
bool
InDetTrackSystematicsTool::isAffectedBySystematic
(
const
CP::SystematicVariation
& systematic )
const
31
{
32
auto
affSysts =
affectingSystematics
();
33
return
( affSysts.find(systematic) != affSysts.end() );
34
}
35
36
CP::SystematicSet
InDetTrackSystematicsTool::recommendedSystematics
()
const
37
{
38
// it's probably a good idea to change this behavior to return a more intelligently thought-out list
39
return
affectingSystematics
();
40
}
41
42
StatusCode
InDetTrackSystematicsTool::applySystematicVariation
(
const
CP::SystematicSet
&
systematics
)
43
{
44
45
// first check if we already know this systematic configuration
46
// look for it in our filter map
47
auto
sysMapItr =
m_sysFilterMap
.find(
systematics
);
48
49
if
(sysMapItr ==
m_sysFilterMap
.end()) {
50
51
// filter the input systematic with the affecting systematics
52
const
CP::SystematicSet
affectingSysts =
affectingSystematics
();
53
CP::SystematicSet
filteredSysts;
54
if
(
CP::SystematicSet::filterForAffectingSystematics
55
(
systematics
, affectingSysts, filteredSysts) != StatusCode::SUCCESS ) {
56
ATH_MSG_ERROR
(
"Recieved unsupported systematics: "
<<
systematics
.name() );
57
return
StatusCode::FAILURE;
58
}
59
60
// check in here for incompatible systematics
61
auto
isIn = [&](InDet::TrackSystematic syst) {
62
// helper function to check if a systematic exists in the filtered set
63
return
filteredSysts.
find
( InDet::TrackSystematicMap.at( syst ) ) != filteredSysts.
end
();
64
};
65
bool
isSetTrkLoose = isIn( TRK_FAKE_RATE_LOOSE )
66
|| isIn( TRK_EFF_LOOSE_GLOBAL )
67
|| isIn( TRK_EFF_LOOSE_IBL )
68
|| isIn( TRK_EFF_LOOSE_PP0 )
69
|| isIn( TRK_EFF_LOOSE_PHYSMODEL );
70
bool
isSetTrkTight = isIn( TRK_FAKE_RATE_TIGHT )
71
|| isIn( TRK_EFF_TIGHT_GLOBAL )
72
|| isIn( TRK_EFF_TIGHT_IBL )
73
|| isIn( TRK_EFF_TIGHT_PP0 )
74
|| isIn( TRK_EFF_TIGHT_PHYSMODEL );
75
if
( isSetTrkLoose && isSetTrkTight) {
76
ATH_MSG_ERROR
(
"Both Loose and TightPrimary versions of systematics are simultaneously active."
);
77
return
StatusCode::FAILURE;
78
}
79
80
// if the systematics set looks supported, then insert it into the map for future use
81
sysMapItr =
m_sysFilterMap
.insert(std::make_pair(
systematics
, filteredSysts)).first;
82
}
83
84
m_activeSysts
= &sysMapItr->second;
85
86
return
StatusCode::SUCCESS;
87
}
88
89
bool
InDetTrackSystematicsTool::isActive
( TrackSystematic syst )
const
90
{
91
if
(
m_activeSysts
==
nullptr
) {
92
ATH_MSG_DEBUG
(
"applySystematicsVariation() has not been successfully called."
);
93
return
false
;
94
}
95
const
auto
it_syst =
m_activeSysts
->find(InDet::TrackSystematicMap.at(syst));
96
return
it_syst !=
m_activeSysts
->end();
97
}
98
99
const
CP::SystematicSet
*
100
InDetTrackSystematicsTool::getFilteredSysts
(
101
const
CP::SystematicSet
& syst)
const
102
{
103
// m_sysFilterMap is populated during initialize() (single-threaded)
104
// and is read-only during execute(), so no lock is required.
105
auto
it =
m_sysFilterMap
.find(syst);
106
if
(it ==
m_sysFilterMap
.end()) {
107
ATH_MSG_ERROR
(
"Systematic set '"
<< syst.
name
()
108
<<
"' was not pre-registered. "
109
"Call applySystematicVariation() during initialize()."
);
110
return
nullptr
;
111
}
112
return
&it->second;
113
}
114
115
bool
InDetTrackSystematicsTool::isActive
(
116
TrackSystematic syst,
const
CP::SystematicSet
& filtered)
const
117
{
118
return
filtered.
find
(InDet::TrackSystematicMap.at(syst))
119
!= filtered.
end
();
120
}
121
122
std::unique_ptr<TFile>
InDetTrackSystematicsTool::getFile
(
const
std::string& filename)
const
123
{
124
// now the files are stored in the calibration area
125
// filename is configurable in each tool and should include the path starting from the package name
126
// but defaults to recommendation for current release
127
std::string filenameWithFullPath =
PathResolverFindCalibFile
(filename);
128
129
return
std::unique_ptr<TFile>(TFile::Open(filenameWithFullPath.data(),
"READ"
));;
130
}
131
132
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
InDetTrackSystematicsTool.h
systematics
static const std::vector< std::string > systematics
Definition
MuonTriggerSFFilesTest.cxx:23
PathResolver.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition
PathResolver.cxx:325
SystematicRegistry.h
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::SystematicSet::name
std::string name() const
returns: the systematics joined into a single string.
Definition
SystematicSet.cxx:277
CP::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition
SystematicSet.h:59
CP::SystematicSet::find
iterator find(const SystematicVariation &sys) const
description: find an element in the set
Definition
SystematicSet.h:63
CP::SystematicSet::filterForAffectingSystematics
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Definition
SystematicSet.cxx:212
CP::SystematicVariation
Definition
SystematicVariation.h:47
InDet::InDetTrackSystematicsTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &) const override
returns: whether the tool is affected by the systematic
Definition
InDetTrackSystematicsTool.cxx:30
InDet::InDetTrackSystematicsTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
returns: list of recommended systematics to use with this tool
Definition
InDetTrackSystematicsTool.cxx:36
InDet::InDetTrackSystematicsTool::getFile
std::unique_ptr< TFile > getFile(const std::string &) const
open and return a file with the given name.
Definition
InDetTrackSystematicsTool.cxx:122
InDet::InDetTrackSystematicsTool::m_activeSysts
const CP::SystematicSet * m_activeSysts
Definition
InDetTrackSystematicsTool.h:54
InDet::InDetTrackSystematicsTool::getFilteredSysts
const CP::SystematicSet * getFilteredSysts(const CP::SystematicSet &syst) const
Look up the pre-filtered systematic set for syst.
Definition
InDetTrackSystematicsTool.cxx:100
InDet::InDetTrackSystematicsTool::isActive
bool isActive(TrackSystematic) const
Definition
InDetTrackSystematicsTool.cxx:89
InDet::InDetTrackSystematicsTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override=0
returns: list of systematics this tool can be affected by
InDet::InDetTrackSystematicsTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
InDetTrackSystematicsTool.cxx:17
InDet::InDetTrackSystematicsTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &) override
configure the tool to apply a given list of systematic variations
Definition
InDetTrackSystematicsTool.cxx:42
InDet::InDetTrackSystematicsTool::m_sysFilterMap
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap
Definition
InDetTrackSystematicsTool.h:52
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
extractSporadic.name
name
Definition
extractSporadic.py:101
Generated on
for ATLAS Offline Software by
1.17.0