ATLAS Offline Software
Loading...
Searching...
No Matches
InDetTrackSystematicsTool.h
Go to the documentation of this file.
1// -*- c++ -*-
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
5
6#ifndef INDETTRACKSYSTEMATICSTOOLS_INDETTRACKSYSTEMATICSTOOL_H
7#define INDETTRACKSYSTEMATICSTOOLS_INDETTRACKSYSTEMATICSTOOL_H
8
9#include <cstdint>
10#include <string>
11#include <map>
12#include <memory>
13
15#include "AsgTools/AsgTool.h"
18
19#include <TFile.h>
20#include <TH2.h>
21
22namespace InDet {
23
25
28 public:
29 InDetTrackSystematicsTool( const std::string& );
30 virtual ~InDetTrackSystematicsTool() = default;
31
32 virtual StatusCode initialize() override;
33
35 virtual bool isAffectedBySystematic( const CP::SystematicVariation& ) const override;
37 virtual CP::SystematicSet affectingSystematics() const override = 0;
39 virtual CP::SystematicSet recommendedSystematics() const override;
41 virtual StatusCode applySystematicVariation( const CP::SystematicSet& ) override;
42
43
44 protected:
46 std::unique_ptr<TFile> getFile( const std::string& ) const;
47
49 template <class T> StatusCode initObject(std::unique_ptr<T>& obj, const std::string& rootFileName, const std::string& objName) const;
50
51 // a map from a general set to a set that is filtered for the ones we use
52 // note that SystematicSet caches its hashes so this is probably not as slow as it might seem
53 std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap;
54
56
57 bool isActive( TrackSystematic ) const;
58
65 const CP::SystematicSet& syst) const;
66
69 bool isActive(TrackSystematic syst,
70 const CP::SystematicSet& filtered) const;
71
74 static uint64_t variationMask(const CP::SystematicSet& filtered);
76 uint64_t activeVariationMask() const;
77
78 };
79
80}
81
82// must define template function in header
83template <class T>
84StatusCode InDet::InDetTrackSystematicsTool::initObject(std::unique_ptr<T>& obj, const std::string& rootFileName, const std::string& objName) const
85{
86 if (obj != nullptr) ATH_MSG_WARNING( obj->GetName() << " is not null, yet we are now attempting to initialize from " << rootFileName );
87 std::unique_ptr<TFile> F = getFile(rootFileName);
88 if(!F || F->IsZombie()) {
89 ATH_MSG_ERROR( "Could not open file " << rootFileName );
90 return StatusCode::FAILURE;
91 }
92 T* tempObj = nullptr;
93 F->GetObject(objName.data(), tempObj);
94 if(tempObj==nullptr) {
95 ATH_MSG_ERROR( "Could not retrieve " << objName << " from file " << rootFileName );
96 return StatusCode::FAILURE;
97 }
98 obj = std::unique_ptr<T>(static_cast<T*>(tempObj->Clone()));
99 obj->SetDirectory(0);
100 F->Clear();
101 F->Close();
102 return StatusCode::SUCCESS;
103}
104
105#endif
#define ASG_TOOL_CLASS2(CLASSNAME, INT1, INT2)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define F(x, y, z)
Definition MD5.cxx:112
interface for all CP tools supporting systematic variations within a reentrant algorithm
Interface for all CP tools supporting systematic variations.
Class to wrap a set of SystematicVariations.
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.
static uint64_t variationMask(const CP::SystematicSet &filtered)
Extra per-track PRNG seed term so each variation draws independent random numbers: one bit per active...
StatusCode initObject(std::unique_ptr< T > &obj, const std::string &rootFileName, const std::string &objName) const
a function to initialize an object from a root file
const CP::SystematicSet * getFilteredSysts(const CP::SystematicSet &syst) const
Look up the pre-filtered systematic set for syst.
virtual CP::SystematicSet affectingSystematics() const override=0
returns: list of systematics this tool can be affected by
virtual ASG_TOOL_CLASS2(InDetTrackSystematicsTool, CP::ISystematicsTool, CP::IReentrantSystematicsTool) public ~InDetTrackSystematicsTool()=default
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
uint64_t activeVariationMask() const
variationMask() of the set activated by applySystematicVariation()
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
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Primary Vertex Finder.