ATLAS Offline Software
Loading...
Searching...
No Matches
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
19std::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
23 full_path = PathResolverFindCalibFile(m_tauRecToolsTag+"/"+fname);
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
125TauRecToolBase::TauRecToolBase(const std::string& name) :
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
144StatusCode TauRecToolBase::executeDev(xAOD::TauJet&) {
145 ATH_MSG_ERROR("function not implemented");
146 return StatusCode::FAILURE;
147}
148#else
149StatusCode 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
170StatusCode 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
175StatusCode TauRecToolBase::executePi0ClusterCreator(xAOD::TauJet& /*pTau*/, xAOD::PFOContainer& /*neutralPFOContainer*/,
176 xAOD::PFOContainer& /*hadronicPFOContainer*/,
177 const xAOD::CaloClusterContainer& /*pCaloClusterContainer*/ ) const {
178 ATH_MSG_ERROR("function not implemented");
179 return StatusCode::FAILURE;
180}
181
182StatusCode TauRecToolBase::executeVertexVariables(xAOD::TauJet& /*pTau*/, xAOD::VertexContainer& /*vertexContainer*/ ) const {
183 ATH_MSG_ERROR("function not implemented");
184 return StatusCode::FAILURE;
185}
186
187StatusCode 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
192StatusCode TauRecToolBase::executePi0nPFO(xAOD::TauJet& /*pTau*/, xAOD::PFOContainer& /*neutralPFOContainer*/) const {
193 ATH_MSG_ERROR("function not implemented");
194 return StatusCode::FAILURE;
195}
196
197StatusCode 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}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
static Double_t sc
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
CaloCellContainer that can accept const cell pointers.
Type
Property type enumeration.
Definition Property.h:27
Gaudi::Property< std::string > m_tauRecToolsTag
virtual StatusCode eventInitialize() override
Event initializer - called at the beginning of each event.
virtual StatusCode executeVertexVariables(xAOD::TauJet &pTau, xAOD::VertexContainer &vertexContainer) const override
TauRecToolBase(const std::string &name)
virtual StatusCode execute(xAOD::TauJet &pTau) const override
Execute - called for each tau candidate.
virtual StatusCode initialize() override
Tool initializer.
virtual StatusCode eventFinalize() override
Event finalizer - called at the end of each event.
virtual StatusCode executePi0nPFO(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer) const override
virtual StatusCode executeShotFinder(xAOD::TauJet &pTau, xAOD::CaloClusterContainer &shotClusterContainer, xAOD::PFOContainer &PFOContainer) const override
virtual StatusCode executeTrackClassifier(xAOD::TauJet &pTau, xAOD::TauTrackContainer &tauTrackContainer) const override
virtual StatusCode readConfig() override
virtual StatusCode executePanTau(xAOD::TauJet &pTau, xAOD::ParticleContainer &particleContainer, xAOD::PFOContainer &neutralPFOContainer) const override
virtual StatusCode executeTrackFinder(xAOD::TauJet &pTau, xAOD::TauTrackContainer &tauTrackContainer) const override
virtual StatusCode executePi0ClusterCreator(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer, xAOD::PFOContainer &hadronicPFOContainer, const xAOD::CaloClusterContainer &pCaloClusterContainer) const override
virtual StatusCode finalize() override
Finalizer.
virtual StatusCode executePi0ClusterScaler(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer, xAOD::PFOContainer &chargedPFOContainer) const override
virtual StatusCode executeVertexFinder(xAOD::TauJet &pTau, const xAOD::VertexContainer *vertexContainer=nullptr) const override
std::string find_file(const std::string &fname) const
virtual StatusCode executePi0CreateROI(xAOD::TauJet &pTau, CaloConstCellContainer &caloCellContainer, boost::dynamic_bitset<> &map) const override
const T * getProperty(const std::string &name) const
Get one of the tool's properties.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
ParticleContainer_v1 ParticleContainer
Define the latest version of the particle class.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TauJet_v3 TauJet
Definition of the current "tau version".
TauTrackContainer_v1 TauTrackContainer
Definition of the current TauTrack container version.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
ElementLink_p1< typename GenerateELinkIndexType_p1< typename LINK::index_type >::type > type