ATLAS Offline Software
TauRecToolBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 // ROOT include(s)
9 #include "TEnv.h"
10 #include "THashList.h"
11 
12 #include <sys/types.h>
13 #include <unistd.h>
14 #include <string>
15 #include <sstream>
16 #include <cstdlib>
17 
18 
19 std::string TauRecToolBase::find_file(const std::string& fname) const {
20  std::string full_path;
21  //offline calib files are in GroupData
22  //online calib files are in release
24  if(full_path.empty()) full_path = PathResolverFindCalibFile(fname);
25  return full_path;
26 }
28  // Sanity check to see if property ConfigPath is declared for a tool. Might be
29  // removed once all tools are updated to have a config path declared.
30  // in athena getProperties returns std::vector<Gaudi::Details::PropertyBase*>
31  // in rc getProperties returns std::map<std::string,Property*>
32 #ifndef XAOD_STANDALONE
33  bool configPathDeclared = false;
34  for (Gaudi::Details::PropertyBase* property : getProperties())
35  {
36  if (property->name() == "ConfigPath")
37  {
38  configPathDeclared = true;
39  break;
40  }
41  }
42  if (!configPathDeclared)
43 #elif defined(XAOD_STANDALONE)
44  PropertyMgr::PropMap_t property_map = getPropertyMgr()->getProperties();
45  if (property_map.find("ConfigPath") == property_map.end())
46 #else
47 # error "What environment are we in?!?"
48 #endif // XAOD_STANDALONE
49  {
50  ATH_MSG_INFO("No config file path property declared yet, this is not recommended");
51  return StatusCode::SUCCESS;
52  }
53 
54  // get configured config path and load file via TEnv
55  const std::string* config_file_path_property;
56  // if (getProperty("ConfigPath", config_file_path).isFailure())
57  // return StatusCode::FAILURE;
58  config_file_path_property = getProperty<std::string>("ConfigPath");
59  std::string config_file_path = find_file(*config_file_path_property);
60  TEnv env;
61  env.ReadFile(PathResolverFindCalibFile(config_file_path).c_str(),kEnvAll);
62 
63  THashList* lList = env.GetTable();
64  for( Int_t i = 0; lList && i < lList->GetEntries(); ++i )
65  {
66  StatusCode sc;
67  // types of properties are handled differently as well
68 #ifndef XAOD_STANDALONE
69  // get type of variable with the entry name
70  const std::type_info* type = getProperty(lList->At( i )->GetName()).type_info();
71 
72  // search for type is needed by env.GetValue function (needs a variable of the correct type as 2nd argument)
73  if (*type == typeid(bool))
74  sc = this->setProperty(lList->At( i )->GetName(),
75  bool(env.GetValue(lList->At( i )->GetName(),bool(true))));
76  else if (*type == typeid(int))
77  sc = this->setProperty(lList->At( i )->GetName(),
78  env.GetValue(lList->At( i )->GetName(),int(0)));
79  else if (*type == typeid(float))
80  sc = this->setProperty(lList->At( i )->GetName(),
81  env.GetValue(lList->At( i )->GetName(),float(0)));
82  else if (*type == typeid(double))
83  sc = this->setProperty(lList->At( i )->GetName(),
84  env.GetValue(lList->At( i )->GetName(),double(0)));
85  else if (*type == typeid(std::string))
86  sc = this->setProperty(lList->At( i )->GetName(),
87  env.GetValue(lList->At( i )->GetName(),""));
88 #else
89  // get type of variable with the entry name
90  Property::Type type = getPropertyMgr()->getProperty(lList->At( i )->GetName())->type();
91 
92  if (type == Property::BOOL)
93  sc = this->setProperty(lList->At( i )->GetName(),
94  bool(env.GetValue(lList->At( i )->GetName(),bool(true))));
95  else if (type == Property::INT)
96  sc = this->setProperty(lList->At( i )->GetName(),
97  env.GetValue(lList->At( i )->GetName(),int(0)));
98  else if (type == Property::FLOAT)
99  sc = this->setProperty(lList->At( i )->GetName(),
100  env.GetValue(lList->At( i )->GetName(),float(0)));
101  else if (type == Property::DOUBLE)
102  sc = this->setProperty(lList->At( i )->GetName(),
103  env.GetValue(lList->At( i )->GetName(),double(0)));
104  else if (type == Property::STRING)
105  sc = this->setProperty(lList->At( i )->GetName(),
106  env.GetValue(lList->At( i )->GetName(),""));
107 #endif // XAOD_STANDALONE
108  else
109  {
110 #ifndef XAOD_STANDALONE
111  ATH_MSG_FATAL("there was a problem to find the correct type enum: "<<type->name());
112 #else
113  ATH_MSG_FATAL("there was a problem to find the correct type enum: "<<type);
114 #endif // XAOD_STANDALONE
115  return StatusCode::FAILURE;
116  }
117  if (!sc.isSuccess()) {
118  ATH_MSG_FATAL("failed to set property: " << lList->At( i )->GetName());
119  return StatusCode::FAILURE;
120  }
121  }
122  return StatusCode::SUCCESS;
123 }
124 
126  asg::AsgTool(name) {
127 }
128 
130  return StatusCode::SUCCESS;
131 }
132 
134  return StatusCode::SUCCESS;
135 }
136 
137 //________________________________________
139  ATH_MSG_ERROR("function not implemented");
140  return StatusCode::FAILURE;
141 }
142 
143 #ifdef XAOD_ANALYSIS
144 StatusCode TauRecToolBase::executeDev(xAOD::TauJet&) {
145  ATH_MSG_ERROR("function not implemented");
146  return StatusCode::FAILURE;
147 }
148 #else
149 StatusCode TauRecToolBase::executePi0CreateROI(xAOD::TauJet& /*pTau*/, CaloConstCellContainer& /*caloCellContainer*/, boost::dynamic_bitset<>& /*map*/ ) const {
150  ATH_MSG_ERROR("function not implemented");
151  return StatusCode::FAILURE;
152 }
153 #endif
154 
156  ATH_MSG_ERROR("function not implemented");
157  return StatusCode::FAILURE;
158 }
159 
161  ATH_MSG_ERROR("function not implemented");
162  return StatusCode::FAILURE;
163 }
164 
166  ATH_MSG_ERROR("function not implemented");
167  return StatusCode::FAILURE;
168 }
169 
170 StatusCode TauRecToolBase::executeShotFinder(xAOD::TauJet& /*pTau*/, xAOD::CaloClusterContainer& /*shotClusterContainer*/, xAOD::PFOContainer& /*PFOContainer*/ ) const {
171  ATH_MSG_ERROR("function not implemented");
172  return StatusCode::FAILURE;
173 }
174 
176  xAOD::PFOContainer& /*hadronicPFOContainer*/,
177  const xAOD::CaloClusterContainer& /*pCaloClusterContainer*/ ) const {
178  ATH_MSG_ERROR("function not implemented");
179  return StatusCode::FAILURE;
180 }
181 
183  ATH_MSG_ERROR("function not implemented");
184  return StatusCode::FAILURE;
185 }
186 
187 StatusCode TauRecToolBase::executePi0ClusterScaler(xAOD::TauJet& /*pTau*/, xAOD::PFOContainer& /*neutralPFOContainer*/, xAOD::PFOContainer& /*chargedPFOContainer*/ ) const {
188  ATH_MSG_ERROR("function not implemented");
189  return StatusCode::FAILURE;
190 }
191 
192 StatusCode TauRecToolBase::executePi0nPFO(xAOD::TauJet& /*pTau*/, xAOD::PFOContainer& /*neutralPFOContainer*/) const {
193  ATH_MSG_ERROR("function not implemented");
194  return StatusCode::FAILURE;
195 }
196 
197 StatusCode TauRecToolBase::executePanTau(xAOD::TauJet& /*pTau*/, xAOD::ParticleContainer& /*particleContainer*/, xAOD::PFOContainer& /*neutralPFOContainer*/) const {
198  ATH_MSG_ERROR("function not implemented");
199  return StatusCode::FAILURE;
200 }
201 
203  return StatusCode::SUCCESS;
204 }
205 
207  return StatusCode::SUCCESS;
208 }
Property::BOOL
@ BOOL
Definition: Property.h:29
Property::Type
Type
Property type enumeration.
Definition: Property.h:27
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Property::STRING
@ STRING
Definition: Property.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TauRecToolBase.h
asg
Definition: DataHandleTestTool.h:28
TauRecToolBase::m_tauRecToolsTag
Gaudi::Property< std::string > m_tauRecToolsTag
Definition: TauRecToolBase.h:79
asg::AsgTool::getProperty
const T * getProperty(const std::string &name) const
Get one of the tool's properties.
TauRecToolBase::executePi0ClusterCreator
virtual StatusCode executePi0ClusterCreator(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer, xAOD::PFOContainer &hadronicPFOContainer, const xAOD::CaloClusterContainer &pCaloClusterContainer) const override
Definition: TauRecToolBase.cxx:175
TauRecToolBase::readConfig
virtual StatusCode readConfig() override
Definition: TauRecToolBase.cxx:27
TauRecToolBase::eventInitialize
virtual StatusCode eventInitialize() override
Event initializer - called at the beginning of each event.
Definition: TauRecToolBase.cxx:133
TauRecToolBase::executeTrackClassifier
virtual StatusCode executeTrackClassifier(xAOD::TauJet &pTau, xAOD::TauTrackContainer &tauTrackContainer) const override
Definition: TauRecToolBase.cxx:165
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Property::DOUBLE
@ DOUBLE
Definition: Property.h:32
TauRecToolBase::executePanTau
virtual StatusCode executePanTau(xAOD::TauJet &pTau, xAOD::ParticleContainer &particleContainer, xAOD::PFOContainer &neutralPFOContainer) const override
Definition: TauRecToolBase.cxx:197
TauRecToolBase::executeShotFinder
virtual StatusCode executeShotFinder(xAOD::TauJet &pTau, xAOD::CaloClusterContainer &shotClusterContainer, xAOD::PFOContainer &PFOContainer) const override
Definition: TauRecToolBase.cxx:170
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TauRecToolBase::executeVertexVariables
virtual StatusCode executeVertexVariables(xAOD::TauJet &pTau, xAOD::VertexContainer &vertexContainer) const override
Definition: TauRecToolBase.cxx:182
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
TauRecToolBase::eventFinalize
virtual StatusCode eventFinalize() override
Event finalizer - called at the end of each event.
Definition: TauRecToolBase.cxx:202
TauRecToolBase::TauRecToolBase
TauRecToolBase(const std::string &name)
Definition: TauRecToolBase.cxx:125
TauRecToolBase::execute
virtual StatusCode execute(xAOD::TauJet &pTau) const override
Execute - called for each tau candidate.
Definition: TauRecToolBase.cxx:138
TauRecToolBase::executePi0CreateROI
virtual StatusCode executePi0CreateROI(xAOD::TauJet &pTau, CaloConstCellContainer &caloCellContainer, boost::dynamic_bitset<> &map) const override
Definition: TauRecToolBase.cxx:149
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TauRecToolBase::executePi0nPFO
virtual StatusCode executePi0nPFO(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer) const override
Definition: TauRecToolBase.cxx:192
Property::INT
@ INT
Definition: Property.h:30
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Property::FLOAT
@ FLOAT
Definition: Property.h:31
TauRecToolBase::find_file
std::string find_file(const std::string &fname) const
Definition: TauRecToolBase.cxx:19
TauRecToolBase::finalize
virtual StatusCode finalize() override
Finalizer.
Definition: TauRecToolBase.cxx:206
TauRecToolBase::executeVertexFinder
virtual StatusCode executeVertexFinder(xAOD::TauJet &pTau, const xAOD::VertexContainer *vertexContainer=nullptr) const override
Definition: TauRecToolBase.cxx:155
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
TauRecToolBase::executeTrackFinder
virtual StatusCode executeTrackFinder(xAOD::TauJet &pTau, xAOD::TauTrackContainer &tauTrackContainer) const override
Definition: TauRecToolBase.cxx:160
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
TauRecToolBase::executePi0ClusterScaler
virtual StatusCode executePi0ClusterScaler(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer, xAOD::PFOContainer &chargedPFOContainer) const override
Definition: TauRecToolBase.cxx:187
CaloConstCellContainer
CaloCellContainer that can accept const cell pointers.
Definition: CaloConstCellContainer.h:45
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TauRecToolBase::initialize
virtual StatusCode initialize() override
Tool initializer.
Definition: TauRecToolBase.cxx:129
python.DataFormatRates.env
env
Definition: DataFormatRates.py:32