|
ATLAS Offline Software
|
Go to the documentation of this file.
7 #include "GaudiKernel/ISvcLocator.h"
12 #include "hltinterface/IInfoRegister.h"
30 static TROOT
root(
"root",
"ROOT I/O");
38 m_excludeTypeRegex =
boost::regex(m_excludeType.value());
39 m_includeTypeRegex =
boost::regex(m_includeType.value());
40 m_excludeNameRegex =
boost::regex(m_excludeName.value());
41 m_includeNameRegex =
boost::regex(m_includeName.value());
48 return StatusCode::SUCCESS;
56 return StatusCode::SUCCESS;
65 return StatusCode::SUCCESS;
77 return StatusCode::FAILURE;
80 if (hist_unique->Class()->InheritsFrom(TH1::Class())) {
81 T*
hist = hist_unique.release();
83 auto [iter,inserted] =
m_hists.try_emplace(
id,
id,
hist);
85 ATH_MSG_ERROR(
"Histogram with name " <<
id <<
" already registered");
86 return StatusCode::FAILURE;
88 if (shared) iter->second.mutex =
new std::mutex;
91 <<
hist->GetName() <<
" registered under " <<
id <<
" " <<
name());
94 ATH_MSG_ERROR(
"Registration of " <<
hist->ClassName() <<
" with IInfoRegister failed");
96 return StatusCode::FAILURE;
101 <<
" because it does not inherit from TH1");
102 return StatusCode::FAILURE;
104 return StatusCode::SUCCESS;
107 template <
typename T>
112 LockedHandle<T>
lh(
nullptr,
nullptr);
117 T* phist =
hist.get();
119 if (
regHist_i(std::move(
hist),
id,
true, phid).isSuccess()) {
125 if (
h->second.mutex ==
nullptr) {
126 ATH_MSG_ERROR(
"regShared: previously registered histogram \"" <<
id
127 <<
"\" was not marked shared");
129 T* phist =
dynamic_cast<T*
>(
h->second.obj);
130 if (phist ==
nullptr) {
131 ATH_MSG_ERROR(
"regShared: unable to dcast retrieved shared hist \""
132 <<
id <<
"\" of type " <<
h->second.obj->IsA()->GetName()
133 <<
" to requested type " << System::typeinfoName(
typeid(
T)));
136 lh.set(phist,
h->second.mutex);
143 template <
typename T>
154 T* phist =
dynamic_cast<T*
>(
h->second.obj);
155 if (phist ==
nullptr) {
156 ATH_MSG_ERROR(
"getHist: unable to dcast retrieved shared hist \""
157 <<
id <<
"\" of type " <<
h->second.obj->IsA()->GetName() <<
" to requested type "
158 << System::typeinfoName(
typeid(
T)));
167 for (
const auto& [
id,
h] :
m_hists) {
172 return StatusCode::SUCCESS;
175 template <
typename T>
181 if (
h->second.mutex ==
nullptr) {
183 <<
"\", but it's not marked as shared");
186 T* phist =
dynamic_cast<T*
>(
h->second.obj);
187 if (phist ==
nullptr) {
188 ATH_MSG_ERROR(
"getShared: unable to dcast retrieved shared hist \""
189 <<
id <<
"\" of type " <<
h->second.obj->IsA()->GetName()
190 <<
" to requested type " << System::typeinfoName(
typeid(
T)));
193 return LockedHandle<T>(phist,
h->second.mutex);
195 ATH_MSG_ERROR(
"getShared: cannot find histogram with id \"" <<
id <<
"\"");
204 if (histid.obj == optr) {
206 <<
" and will deregister it");
210 return StatusCode::FAILURE;
220 return StatusCode::SUCCESS;
226 std::vector<std::string>
l;
228 for (
const auto&
h :
m_hists)
l.push_back(
h.first);
238 <<
" does NOT match IncludeType \"" <<
m_includeType <<
"\"");
243 ATH_MSG_WARNING(
"Object " <<
path <<
" of type " << o->ClassName() <<
" matches ExcludeType \""
263 return (getHist_i<TH1>(
name, 0,
true) !=
nullptr);
272 std::unique_ptr<TH1>
hist =
nullptr;
286 std::unique_ptr<TH1>
hist(hist_ptr);
294 hist = getHist_i<TH1>(
id,
ind);
295 return (
hist !=
nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE);
300 hist = getHist_i<TH2>(
id,
ind);
301 return (
hist !=
nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE);
306 hist = getHist_i<TH3>(
id,
ind);
307 return (
hist !=
nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE);
327 ATH_MSG_DEBUG(
"Recursive flag and automatic registration flag is not "
328 "supported in this implementation");
335 ATH_MSG_DEBUG(
"Recursive flag and automatic registration flag is not "
336 "supported in this implementation");
343 LockedHandle<TH1>&
lh)
345 lh = regShared_i<TH1>(
id, std::move(
hist));
346 return (
lh ? StatusCode::SUCCESS : StatusCode::FAILURE);
350 LockedHandle<TH2>&
lh)
352 lh = regShared_i<TH2>(
id, std::move(
hist));
353 return (
lh ? StatusCode::SUCCESS : StatusCode::FAILURE);
357 LockedHandle<TH3>&
lh)
359 lh = regShared_i<TH3>(
id, std::move(
hist));
360 return (
lh ? StatusCode::SUCCESS : StatusCode::FAILURE);
367 lh = getShared_i<TH1>(
id);
368 return (
lh ? StatusCode::SUCCESS : StatusCode::FAILURE);
373 lh = getShared_i<TH2>(
id);
374 return (
lh ? StatusCode::SUCCESS : StatusCode::FAILURE);
379 lh = getShared_i<TH3>(
id);
380 return (
lh ? StatusCode::SUCCESS : StatusCode::FAILURE);
std::unordered_map< std::string, THistID > m_hists
Registered histograms.
T * getHist_i(const std::string &id, const size_t &ind, bool quiet=false) const
OH histogram lock header file.
Helper struct that bundles the histogram, name and mutex.
Gaudi::Property< std::string > m_excludeName
path
python interpreter configuration --------------------------------------—
std::string find(const std::string &s)
return a remapped string
Gaudi::Property< std::string > m_includeName
boost::regex m_excludeTypeRegex
virtual std::vector< std::string > getHists() const override
std::recursive_mutex m_svcMut
Protect access to histogram list.
virtual StatusCode regShared(const std::string &, std::unique_ptr< TH1 >, LockedHandle< TH1 > &) override
boost::regex m_excludeNameRegex
#define ATH_MSG_VERBOSE(x)
LockedHandle< T > regShared_i(const std::string &id, std::unique_ptr< T > hist)
def recurse(rdir, dqregion, ignorepath, reffile=None)
Gaudi::Property< std::string > m_excludeType
TrigMonTHistSvc(const std::string &name, ISvcLocator *svc)
virtual StatusCode getShared(const std::string &, LockedHandle< TH1 > &) const override
StatusCode TrigMonTHistSvc::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
virtual StatusCode deReg(TObject *obj) override
boost::regex m_includeTypeRegex
::StatusCode StatusCode
StatusCode definition for legacy code.
static void reset_histogram_mutex()
Reset (disable) histogram mutex.
bool isObjectAllowed(const std::string &path, const TObject *o) const
Does the histogram follow the naming rules ?
virtual bool existsHist(const std::string &name) const override
virtual StatusCode regHist(const std::string &name) override
AthROOTErrorHandlerSvc * svc
virtual StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
StatusCode getTHists_i(const std::string &name, TList &) const
Get TList of registered histograms.
virtual StatusCode getHist(const std::string &id, TH1 *&hist, size_t ind) const override
LockedHandle< T > getShared_i(const std::string &id) const
StatusCode regHist_i(std::unique_ptr< T > hist, const std::string &name, bool shared, THistID *&phid)
Gaudi::Property< std::string > m_includeType
virtual StatusCode stop() override
#define ATH_MSG_WARNING(x)
boost::regex m_includeNameRegex
static void set_histogram_mutex(std::mutex &mutex)
Set mutex to be used in oh_lock_histogram.
Define macros for attributes used to control the static checker.
virtual StatusCode finalize() override