ATLAS Offline Software
InDetTrackSystematicsTool.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 /*
3  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 #ifndef INDETTRACKSYSTEMATICSTOOLS_INDETTRACKSYSTEMATICSTOOL_H
7 #define INDETTRACKSYSTEMATICSTOOLS_INDETTRACKSYSTEMATICSTOOL_H
8 
9 #include <string>
10 #include <map>
11 #include <memory>
12 
14 #include "AsgTools/AsgTool.h"
17 
18 #include <TFile.h>
19 
20 namespace InDet {
21 
23 
26  public:
27  InDetTrackSystematicsTool( const std::string& );
28  virtual ~InDetTrackSystematicsTool() = default;
29 
30  virtual StatusCode initialize() override;
31 
33  virtual bool isAffectedBySystematic( const CP::SystematicVariation& ) const override;
35  virtual CP::SystematicSet affectingSystematics() const override = 0;
37  virtual CP::SystematicSet recommendedSystematics() const override;
39  virtual StatusCode applySystematicVariation( const CP::SystematicSet& ) override;
40 
41 
42  protected:
44  std::unique_ptr<TFile> getFile( const std::string& ) const;
45 
47  template <class T> StatusCode initObject(T*& obj, const std::string& rootFileName, const std::string& objName) const;
48 
49  // a map from a general set to a set that is filtered for the ones we use
50  // note that SystematicSet caches its hashes so this is probably not as slow as it might seem
51  std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap;
52 
53  const CP::SystematicSet* m_activeSysts = nullptr;
54 
55  bool isActive( TrackSystematic ) const;
56 
57  };
58 
59 }
60 
61 // must define template function in header
62 template <class T>
63 StatusCode InDet::InDetTrackSystematicsTool::initObject(T*& obj, const std::string& rootFileName, const std::string& objName) const
64 {
65  if (obj != nullptr) ATH_MSG_WARNING( obj->GetName() << " is not null, yet we are now attempting to initialize from " << rootFileName );
66  std::unique_ptr<TFile> F = getFile(rootFileName);
67  if(!F || F->IsZombie()) {
68  ATH_MSG_ERROR( "Could not open file " << rootFileName );
69  return StatusCode::FAILURE;
70  }
71  T* tempObj = nullptr;
72  F->GetObject(objName.data(), tempObj);
73  if(tempObj==nullptr) {
74  ATH_MSG_ERROR( "Could not retrieve " << objName << " from file " << rootFileName );
75  return StatusCode::FAILURE;
76  }
77  obj = static_cast<T*>(tempObj->Clone());
78  obj->SetDirectory(0);
79  F->Clear();
80  F->Close();
81  return StatusCode::SUCCESS;
82 }
83 
84 #endif
InDet::InDetTrackSystematicsTool
Definition: InDetTrackSystematicsTool.h:22
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
ASG_TOOL_CLASS2
#define ASG_TOOL_CLASS2(CLASSNAME, INT1, INT2)
Definition: AsgToolMacros.h:77
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::InDetTrackSystematicsTool::initObject
StatusCode initObject(T *&obj, const std::string &rootFileName, const std::string &objName) const
a function to initialize an object from a root file
Definition: InDetTrackSystematicsTool.h:63
InDet::InDetTrackSystematicsTool::isActive
bool isActive(TrackSystematic) const
Definition: InDetTrackSystematicsTool.cxx:98
SystematicSet.h
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
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::m_activeSysts
const CP::SystematicSet * m_activeSysts
Definition: InDetTrackSystematicsTool.h:53
ISystematicsTool.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::TrackSystematic
TrackSystematic
Definition: InDetTrackSystematics.h:14
InDet::InDetTrackSystematicsTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override=0
returns: list of systematics this tool can be affected by
InDet::InDetTrackSystematicsTool::m_sysFilterMap
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap
Definition: InDetTrackSystematicsTool.h:51
InDet::InDetTrackSystematicsTool::getFile
std::unique_ptr< TFile > getFile(const std::string &) const
open and return a file with the given name.
Definition: InDetTrackSystematicsTool.cxx:108
InDet::InDetTrackSystematicsTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
returns: list of recommended systematics to use with this tool
Definition: InDetTrackSystematicsTool.cxx:36
CP::ISystematicsTool
Interface for all CP tools supporting systematic variations.
Definition: ISystematicsTool.h:32
InDetTrackSystematics.h
InDet::InDetTrackSystematicsTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: InDetTrackSystematicsTool.cxx:17
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
F
#define F(x, y, z)
Definition: MD5.cxx:112
CP::IReentrantSystematicsTool
interface for all CP tools supporting systematic variations within a reentrant algorithm
Definition: IReentrantSystematicsTool.h:58
AsgTool.h
python.PyAthena.obj
obj
Definition: PyAthena.py:135
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
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35