ATLAS Offline Software
Loading...
Searching...
No Matches
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
8#include "TFile.h"
9
10namespace InDet {
11
12 InDetTrackSystematicsTool::InDetTrackSystematicsTool( const std::string& name )
13 : asg::AsgTool(name)
14 {
15 }
16
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
31 {
32 auto affSysts = affectingSystematics();
33 return ( affSysts.find(systematic) != affSysts.end() );
34 }
35
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
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;
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 std::unique_ptr<TFile> InDetTrackSystematicsTool::getFile(const std::string& filename) const
100 {
101 // now the files are stored in the calibration area
102 // filename is configurable in each tool and should include the path starting from the package name
103 // but defaults to recommendation for current release
104 std::string filenameWithFullPath = PathResolverFindCalibFile(filename);
105
106 return std::unique_ptr<TFile>(TFile::Open(filenameWithFullPath.data(), "READ"));;
107 }
108
109}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static const std::vector< std::string > systematics
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
const_iterator end() const
description: const iterator to the end of the set
iterator find(const SystematicVariation &sys) const
description: find an element in the set
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
virtual bool isAffectedBySystematic(const CP::SystematicVariation &) const override
returns: whether the tool is affected by the systematic
virtual CP::SystematicSet recommendedSystematics() const override
returns: list of recommended systematics to use with this tool
std::unique_ptr< TFile > getFile(const std::string &) const
open and return a file with the given name.
virtual CP::SystematicSet affectingSystematics() const override=0
returns: list of systematics this tool can be affected by
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual StatusCode applySystematicVariation(const CP::SystematicSet &) override
configure the tool to apply a given list of systematic variations
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap
Primary Vertex Finder.