ATLAS Offline Software
TPyStore.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 // Local include(s).
7 
9 
10 // ROOT include(s).
11 #include <TClass.h>
12 #include <TError.h>
13 
14 namespace xAOD {
15 
28 bool TPyStore::pyContains(const std::string& key,
29  const std::string& type) const {
30 
31  // Try to access the dictionary of this type.
32  ::TClass* cl = ::TClass::GetClass(type.c_str());
33  if (cl == nullptr) {
34  ::Warning("xAOD::TPyStore::pyContains", "Type name \"%s\" not known",
35  type.c_str());
36  return false;
37  }
38 
39  // Check if the dictionary can return a type_info.
40  const std::type_info* ti = cl->GetTypeInfo();
41  if (!ti) {
42  ::Warning("xAOD::TPyStore::pyContains",
43  "Type \"%s\" doesn't have a proper dictionary", type.c_str());
44  return false;
45  }
46 
47  // Use the base class to answer the question.
48  return TStore::contains(key, *ti);
49 }
50 
63 bool TPyStore::pyIsConst(const std::string& key,
64  const std::string& type) const {
65 
66  // Try to access the dictionary of this type.
67  ::TClass* cl = ::TClass::GetClass(type.c_str());
68  if (cl == nullptr) {
69  ::Warning("xAOD::TPyStore::pyIsConst", "Type name \"%s\" not known",
70  type.c_str());
71  return false;
72  }
73 
74  // Check if the dictionary can return a type_info.
75  const std::type_info* ti = cl->GetTypeInfo();
76  if (ti == nullptr) {
77  ::Warning("xAOD::TPyStore::pyIsConst",
78  "Type \"%s\" doesn't have a proper dictionary", type.c_str());
79  return false;
80  }
81 
82  // Use the base class to answer the question.
83  return TStore::isConst(key, *ti);
84 }
85 
103 StatusCode TPyStore::pyRecord(void* obj, const std::string& key,
104  const std::string& type) {
105 
106  // Simply forward the call to the appropriate function from the base
107  // class.
108  static constexpr bool IS_OWNER = true;
109  static constexpr bool IS_CONST = false;
110  RETURN_CHECK("xAOD::TPyStore::pyRecord",
111  TStore::record(obj, key, type, IS_OWNER, IS_CONST));
112 
113  // Return gracefully:
114  return StatusCode::SUCCESS;
115 }
116 
121 void TPyStore::dump() const {
122 
123  print();
124  return;
125 }
126 
127 } // namespace xAOD
RETURN_CHECK
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition: ReturnCheck.h:26
xAOD::TPyStore::dump
void dump() const
Print the contents of the store using a Python friendly function.
Definition: TPyStore.cxx:121
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
ReturnCheck.h
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
xAOD::TStore::contains
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.
xAOD::TPyStore::pyIsConst
bool pyIsConst(const std::string &key, const std::string &type) const
Function checking if an object with a given key and type is constant.
Definition: TPyStore.cxx:63
xAOD::TStore::isConst
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TPyStore.h
xAOD::TStore::print
void print() const
Print the current contents of the transient store.
Definition: TStore.cxx:124
xAOD::TStore::record
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
xAOD::TPyStore::pyContains
bool pyContains(const std::string &key, const std::string &type) const
Function checking if an object with a given key and type is available.
Definition: TPyStore.cxx:28
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::TPyStore::pyRecord
StatusCode pyRecord(void *obj, const std::string &key, const std::string &type)
Record an object into the store in a typeless way.
Definition: TPyStore.cxx:103
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:25
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37