ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoSimulation
src
AthenaL1TopoHistSvc.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
#include "
./AthenaL1TopoHistSvc.h
"
6
#include "TH1.h"
7
#include "TH2.h"
8
9
#include "
TrigConfBase/TrigConfMessaging.h
"
10
11
12
#include "
AthenaMonitoring/IMonitorToolBase.h
"
13
14
#include "GaudiKernel/ITHistSvc.h"
15
16
#include "
StoreGate/ReadHandleKey.h
"
17
18
19
#include <iostream>
20
using namespace
std
;
21
22
23
class
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl
:
public
TrigConf::TrigConfMessaging
24
{
25
public
:
26
27
AthenaL1TopoHistSvcImpl
(
const
ServiceHandle<ITHistSvc>
& histSvc) :
28
TrigConfMessaging
(
"AthenaL1TopoHistSvc"
),
29
m_histSvc
(histSvc)
30
{
31
TRG_MSG_INFO
(
"Activating"
);
32
}
33
34
~AthenaL1TopoHistSvcImpl
()
35
{}
36
37
38
void
registerHist
(TH1 *
h
) {
39
TRG_MSG_DEBUG
(
"Registration of "
<<
h
->GetName() );
40
if
(
m_histSvc
) {
41
string
histName =
h
->GetName();
42
auto
colPos = histName.find_first_of(
'/'
);
43
const
string
key = histName;
44
const
string
fullName(
m_baseDir
+ histName );
45
h
->SetName(histName.substr(colPos+1).c_str());
46
std::unique_ptr<TH1> uhist(
h
);
47
LockedHandle<TH1> lh;
48
if
( !
m_histSvc
->regShared(fullName, std::move(uhist), lh).isSuccess() ) {
49
TRG_MSG_WARNING
(
"Could not register histogram "
<< fullName <<
" with "
<<
m_histSvc
->name() );
50
}
51
else
52
{ m_hist1D[key] = lh; }
53
}
else
{
54
TRG_MSG_WARNING
(
"No THistSvc available, can't register histogram"
);
55
}
56
}
57
58
void
registerHist
(TH2 *
h
) {
59
TRG_MSG_DEBUG
(
"Registration of "
<<
h
->GetName() );
60
if
(
m_histSvc
) {
61
string
histName =
h
->GetName();
62
auto
colPos = histName.find_first_of(
'/'
);
63
const
string
key = histName;
64
const
string
fullName(
m_baseDir
+ histName );
65
h
->SetName(histName.substr(colPos+1).c_str());
66
std::unique_ptr<TH2> uhist(
h
);
67
LockedHandle<TH2> lh;
68
if
( !
m_histSvc
->regShared(fullName, std::move(uhist), lh).isSuccess() ) {
69
TRG_MSG_WARNING
(
"Could not register histogram "
<< fullName <<
" with "
<<
m_histSvc
->name() );
70
}
71
else
72
{ m_hist2D[key] = lh; }
73
}
else
{
74
TRG_MSG_WARNING
(
"No THistSvc available, can't register histogram"
);
75
}
76
}
77
78
TH1 *
findHist
(
const
std::string & histName) {
79
TH1 *
h
;
80
string
fullName(
m_baseDir
+ histName );
81
if
( !
m_histSvc
->getHist(fullName,
h
).isSuccess() )
82
{
TRG_MSG_WARNING
(
"Could not find histogram with name : "
<< fullName ); }
83
else
84
{
TRG_MSG_DEBUG
(
"findHist("
<< histName <<
") found: "
<< (
void
*)
h
); }
85
return
h
;
86
}
87
88
void
fillHist1D
(
const
std::string & histName,
double
x
) {
89
const
string
key = histName;
90
if
(m_hist1D.find(key) == m_hist1D.end()) {
91
TRG_MSG_ERROR
(
"1D-hist with registration key "
<< key <<
" does not exist"
);
92
}
93
else
{ m_hist1D[key]->Fill(
x
); }
94
}
95
96
void
fillHist2D
(
const
std::string & histName,
double
x
,
double
y
) {
97
const
string
key = histName;
98
if
(m_hist2D.find(key) == m_hist2D.end()) {
99
TRG_MSG_ERROR
(
"2D-hist with registration key "
<< key <<
" does not exist"
);
100
}
101
else
102
{ m_hist2D[key]->Fill(
x
,
y
); }
103
}
104
105
void
setBaseDir
(
const
std::string & baseDir) {
106
auto
colPos = baseDir.find_last_of(
':'
);
107
if
( colPos != string::npos ) {
108
m_baseDir
= baseDir.substr(colPos+1);
109
}
else
{
110
m_baseDir
= baseDir;
111
}
112
if
(
'/'
!=
m_baseDir
[
m_baseDir
.size()-1] ) {
113
// add a '/' at the end
114
m_baseDir
+=
"/"
;
115
}
116
}
117
118
private
:
119
ServiceHandle<ITHistSvc>
m_histSvc
;
120
string
m_baseDir
{
""
};
121
122
std::unordered_map<std::string, LockedHandle<TH1>> m_hist1D
ATLAS_THREAD_SAFE
;
123
std::unordered_map<std::string, LockedHandle<TH2>> m_hist2D
ATLAS_THREAD_SAFE
;
124
125
126
};
127
128
129
AthenaL1TopoHistSvc::AthenaL1TopoHistSvc
(
const
ServiceHandle<ITHistSvc>
& histSvc) :
130
m_impl
(new
AthenaL1TopoHistSvc
::
AthenaL1TopoHistSvcImpl
(histSvc))
131
{}
132
133
AthenaL1TopoHistSvc::~AthenaL1TopoHistSvc
()
134
{}
135
136
void
137
AthenaL1TopoHistSvc::registerHist
(TH1 *
h
) {
138
m_impl
->registerHist(
h
);
139
}
140
141
void
142
AthenaL1TopoHistSvc::registerHist
(TH2 *
h
) {
143
m_impl
->registerHist(
h
);
144
}
145
146
TH1 *
147
AthenaL1TopoHistSvc::findHist
(
const
std::string & histName) {
148
return
m_impl
->findHist( histName );
149
}
150
151
void
152
AthenaL1TopoHistSvc::fillHist1D
(
const
std::string & histName,
double
x
) {
153
m_impl
->fillHist1D(histName,
x
);
154
}
155
156
void
157
AthenaL1TopoHistSvc::fillHist2D
(
const
std::string & histName,
double
x
,
double
y
) {
158
m_impl
->fillHist2D(histName,
x
,
y
);
159
}
160
161
void
162
AthenaL1TopoHistSvc::setBaseDir
(
const
std::string & baseDir) {
163
m_impl
->setBaseDir( baseDir );
164
}
165
166
void
167
AthenaL1TopoHistSvc::save
() {
168
// not implemented
169
}
AthenaL1TopoHistSvc.h
IMonitorToolBase.h
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
TrigConfMessaging.h
Messaging base class for TrigConf code shared with Lvl1 ( AthMessaging).
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TRG_MSG_WARNING
#define TRG_MSG_WARNING(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:28
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
y
#define y
x
#define x
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl
Definition
AthenaL1TopoHistSvc.cxx:24
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::AthenaL1TopoHistSvcImpl
AthenaL1TopoHistSvcImpl(const ServiceHandle< ITHistSvc > &histSvc)
Definition
AthenaL1TopoHistSvc.cxx:27
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition
AthenaL1TopoHistSvc.cxx:119
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::findHist
TH1 * findHist(const std::string &histName)
Definition
AthenaL1TopoHistSvc.cxx:78
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::~AthenaL1TopoHistSvcImpl
~AthenaL1TopoHistSvcImpl()
Definition
AthenaL1TopoHistSvc.cxx:34
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::setBaseDir
void setBaseDir(const std::string &baseDir)
Definition
AthenaL1TopoHistSvc.cxx:105
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::registerHist
void registerHist(TH2 *h)
Definition
AthenaL1TopoHistSvc.cxx:58
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::m_baseDir
string m_baseDir
Definition
AthenaL1TopoHistSvc.cxx:120
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::fillHist2D
void fillHist2D(const std::string &histName, double x, double y)
Definition
AthenaL1TopoHistSvc.cxx:96
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::registerHist
void registerHist(TH1 *h)
Definition
AthenaL1TopoHistSvc.cxx:38
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::ATLAS_THREAD_SAFE
std::unordered_map< std::string, LockedHandle< TH1 > > m_hist1D ATLAS_THREAD_SAFE
Definition
AthenaL1TopoHistSvc.cxx:122
AthenaL1TopoHistSvc::AthenaL1TopoHistSvcImpl::fillHist1D
void fillHist1D(const std::string &histName, double x)
Definition
AthenaL1TopoHistSvc.cxx:88
AthenaL1TopoHistSvc::~AthenaL1TopoHistSvc
virtual ~AthenaL1TopoHistSvc()
Definition
AthenaL1TopoHistSvc.cxx:133
AthenaL1TopoHistSvc::save
virtual void save() override
Definition
AthenaL1TopoHistSvc.cxx:167
AthenaL1TopoHistSvc::m_impl
std::unique_ptr< AthenaL1TopoHistSvcImpl > m_impl
Definition
AthenaL1TopoHistSvc.h:38
AthenaL1TopoHistSvc::AthenaL1TopoHistSvc
AthenaL1TopoHistSvc(const ServiceHandle< ITHistSvc > &histSvc)
Definition
AthenaL1TopoHistSvc.cxx:129
AthenaL1TopoHistSvc::registerHist
virtual void registerHist(TH1 *h) override
Definition
AthenaL1TopoHistSvc.cxx:137
AthenaL1TopoHistSvc::fillHist2D
virtual void fillHist2D(const std::string &histName, double x, double y) override
Definition
AthenaL1TopoHistSvc.cxx:157
AthenaL1TopoHistSvc::setBaseDir
virtual void setBaseDir(const std::string &baseDir) override
Definition
AthenaL1TopoHistSvc.cxx:162
AthenaL1TopoHistSvc::findHist
virtual TH1 * findHist(const std::string &histName) override
Definition
AthenaL1TopoHistSvc.cxx:147
AthenaL1TopoHistSvc::fillHist1D
virtual void fillHist1D(const std::string &histName, double x) override
Definition
AthenaL1TopoHistSvc.cxx:152
ServiceHandle
Definition
ClusterMakerTool.h:36
TrigConf::TrigConfMessaging
Class to provide easy access to TrigConf::MsgStream for TrigConf classes.
Definition
TrigConfMessaging.h:28
TrigConf::TrigConfMessaging::TrigConfMessaging
TrigConfMessaging(const std::string &name)
Constructor with parameters.
Definition
TrigConfMessaging.h:34
h
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0