ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBConditions
TBCondRunPar
src
TBCondRunParTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// TBCondRunParTool.cxx
6
// Richard Hawkings, started 2/7/04
7
8
#include "GaudiKernel/SmartDataPtr.h"
9
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
10
#include "
AthenaPoolUtilities/CondAttrListCollection.h
"
11
#include "
TBCondRunPar/TBCondRunParTool.h
"
12
13
// magic copied from TRT_IdentifierConversionTool
14
static
const
InterfaceID
15
IID_TBCONDRUNPAR_TBCondRunParTool
(
"TBCondRunParTool"
,1,0);
16
17
TBCondRunParTool::TBCondRunParTool
(
const
std::string&
type
,
18
const
std::string&name,
const
IInterface* parent)
19
:
AthAlgTool
(
type
,name,parent)
20
{
21
declareInterface<TBCondRunParTool>(
this
);
22
declareProperty
(
"RunParamFolder"
,
m_runpfolder
);
23
}
24
25
TBCondRunParTool::~TBCondRunParTool
()
26
{}
27
28
const
InterfaceID&
TBCondRunParTool::interfaceID
()
29
{
return
IID_TBCONDRUNPAR_TBCondRunParTool
; }
30
31
StatusCode
TBCondRunParTool::initialize
()
32
{
33
ATH_MSG_INFO
(
"In initialize of TBCondRunParTool"
);
34
ATH_MSG_INFO
(
35
"RunParams will be read from folder: "
<<
m_runpfolder
<<
36
" in COOL database"
);
37
// check StoreGate service available
38
return
StatusCode::SUCCESS;
39
}
40
41
StatusCode
TBCondRunParTool::finalize
() {
42
ATH_MSG_DEBUG
(
"Finalize called"
);
43
return
StatusCode::SUCCESS;
44
}
45
46
bool
TBCondRunParTool::checkcache
() {
47
// find the current run and event - check if data structure may have changed
48
const
EventContext& ctx = Gaudi::Hive::currentContext();
49
int
run
= ctx.eventID().run_number();
50
int
event
= ctx.eventID().event_number();
51
bool
update=
false
;
52
if
(
run
!=
m_crun
|| event!=
m_cevent
) {
53
ATH_MSG_DEBUG
(
"Retrieve new data for run/event "
<<
run
<<
"/"
<< event );
54
m_crun
=
run
;
55
m_cevent
=event;
56
// access the database and update cached values
57
update=
true
;
58
m_run_number
=-1;
59
m_trigger_type
=-1;
60
m_det_mask
=-1;
61
m_beam_type
=-1;
62
m_beam_energy
=-1;
63
m_file_tag
=
""
;
64
65
update=
extractCool
(
run
);
66
}
67
return
update;
68
}
69
70
StatusCode
TBCondRunParTool::getTable
(
const
std::string& table,
const
int
/*irow*/
,
71
const
void
*
/*tblptr*/
,
72
int
& ncol,
int
& nrow, std::vector<std::string>& names,
73
std::vector<std::string>& rows)
const
{
74
// this implementation is dummy - at present it does not return anything
75
//tblptr=0;
76
ncol=0;
77
nrow=0;
78
names.clear();
79
rows.clear();
80
ATH_MSG_DEBUG
(
"getTable: "
<< table );
81
bool
iret =
extractCoolTest
(std::string(
"/TILE/DCS/TILE_LV_62/BEAM"
), 0);
82
// get number of columns and rows
83
if
(!iret)
84
ATH_MSG_DEBUG
(
"extractCoolTest: /TILE/DCS/TILE_LV_62/BEAM failed !"
);
85
return
StatusCode::SUCCESS;
86
}
87
88
StatusCode
TBCondRunParTool::extractVal
(
89
const
std::vector<std::string>& names,
90
const
std::vector<std::string>& rows,
91
const
std::string& name,
int
& ival)
const
{
92
StatusCode found=StatusCode::FAILURE;
93
for
(
unsigned
int
icol=0;icol<names.size();++icol) {
94
ATH_MSG_DEBUG
(
"Check "
<< icol <<
" "
<< names[icol] << rows[icol] );
95
if
(names[icol]==name) {
96
ival=atoi(rows[icol].c_str());
97
found=StatusCode::SUCCESS;
98
break
;
99
}
100
}
101
return
found;
102
}
103
104
StatusCode
TBCondRunParTool::extractVal
(
105
const
std::vector<std::string>& names,
106
const
std::vector<std::string>& rows,
107
const
std::string& name,
float
& fval)
const
{
108
StatusCode found=StatusCode::FAILURE;
109
for
(
unsigned
int
icol=0;icol<names.size();++icol) {
110
ATH_MSG_DEBUG
(
"Check "
<< icol <<
" "
<< names[icol] << rows[icol] );
111
if
(names[icol]==name) {
112
fval=atof(rows[icol].c_str());
113
found=StatusCode::SUCCESS;
114
break
;
115
}
116
}
117
return
found;
118
}
119
120
StatusCode
TBCondRunParTool::extractVal
(
121
const
std::vector<std::string>& names,
122
const
std::vector<std::string>& rows,
123
const
std::string& name,std::string& sval)
const
{
124
StatusCode found=StatusCode::FAILURE;
125
for
(
unsigned
int
icol=0;icol<names.size();++icol) {
126
ATH_MSG_DEBUG
(
"Check "
<< icol <<
" "
<< names[icol] << rows[icol] );
127
if
(names[icol]==name) {
128
sval=rows[icol];
129
found=StatusCode::SUCCESS;
130
break
;
131
}
132
}
133
return
found;
134
}
135
136
void
TBCondRunParTool::printTable
(
const
std::vector<std::string>& names,
137
const
std::vector<std::string>& rows)
const
{
138
for
(
unsigned
int
icol=0;icol<names.size();++icol)
139
ATH_MSG_INFO
(
"Column: "
<< icol <<
" "
<< names[icol] << rows[icol] );
140
}
141
142
StatusCode
TBCondRunParTool::getVal
(
const
std::string& folder,
const
unsigned
int
chnum,
float
& fval){
143
StatusCode found=StatusCode::FAILURE;
144
const
CondAttrListCollection
* atrlist=0;
145
if
(StatusCode::SUCCESS==
detStore
()->retrieve(atrlist,folder)) {
146
CondAttrListCollection::const_iterator
it = atrlist->
begin
();
147
CondAttrListCollection::const_iterator
last = atrlist->
end
();
148
for
(; it != last; ++it) {
149
if
(chnum == (*it).first) {
150
// std::cout << "chan, attr: " << (*it).first << " / "<<(*it).second.toOutputStream(std::cout)<< std::endl;
151
fval = (*it).second[0].data<
float
>();
152
found = StatusCode::SUCCESS;
153
ATH_MSG_DEBUG
(
"chnum: "
<<chnum<<
" chan, attr: "
<< (*it).first <<
" fval: "
<<fval);
154
break
;
155
}
156
}
157
}
158
159
return
found;
160
}
161
162
163
164
bool
TBCondRunParTool::extractCool
(
const
int
run
) {
165
bool
update=
true
;
166
const
AthenaAttributeList
* atrlist=0;
167
std::string table=
m_runpfolder
+
"/RunParams.RunParams"
;
168
if
(StatusCode::SUCCESS==
detStore
()->retrieve(atrlist,table)) {
169
// std::ostringstream atrs;
170
// atrlist->print(atrs);
171
// m_log << "Attribute list contents: " << atrs.str() << endmsg;
172
long
ldata;
173
m_run_number
=(*atrlist)[
"run_number"
].data<
int
>();
174
m_trigger_type
=(*atrlist)[
"trigger_type"
].data<
int
>();
175
m_det_mask
=(*atrlist)[
"detector_mask"
].data<
int
>();
176
m_beam_type
=(*atrlist)[
"beam_type"
].data<
int
>();
177
m_beam_energy
=(*atrlist)[
"beam_energy"
].data<
int
>();
178
m_file_tag
=(*atrlist)[
"filename_tag"
].data<std::string>();
179
// FIXME should be long
180
ldata=(*atrlist)[
"timeSOR"
].data<
int
>();
181
std::ostringstream timeSOR;
182
timeSOR << ldata;
183
m_time_SOR
=timeSOR.str();
184
ATH_MSG_DEBUG
(
"run_number: "
<<
m_run_number
<<
" m_beam_energy: "
<<
m_beam_energy
);
185
// check consistency
186
m_status
=0;
187
if
(
m_run_number
!=
run
)
m_status
=1;
188
}
else
{
189
ATH_MSG_ERROR
(
"Cannot retrieve AttributeList for "
<< table );
190
m_status
=1;
191
}
192
return
update;
193
}
194
195
bool
TBCondRunParTool::extractCoolTest
(
const
std::string& folder,
const
int
/*run*/
)
const
{
196
bool
update=
true
;
197
const
CondAttrListCollection
* atrlist=0;
198
if
(StatusCode::SUCCESS==
detStore
()->retrieve(atrlist,folder)) {
199
// std::ostringstream atrs;
200
ATH_MSG_DEBUG
(
"Attribute list contents: "
);
201
atrlist->
dump
();
202
}
203
return
update;
204
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
AthenaAttributeList.h
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
IID_TBCONDRUNPAR_TBCondRunParTool
static const InterfaceID IID_TBCONDRUNPAR_TBCondRunParTool("TBCondRunParTool", 1, 0)
TBCondRunParTool.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
CondAttrListCollection::end
const_iterator end() const
Definition
CondAttrListCollection.h:314
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition
CondAttrListCollection.h:308
CondAttrListCollection::dump
void dump() const
Dump our contents to std::cout.
Definition
CondAttrListCollection.h:556
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
TBCondRunParTool::~TBCondRunParTool
~TBCondRunParTool()
Definition
TBCondRunParTool.cxx:25
TBCondRunParTool::extractVal
StatusCode extractVal(const std::vector< std::string > &names, const std::vector< std::string > &rows, const std::string &name, int &ival) const
Definition
TBCondRunParTool.cxx:88
TBCondRunParTool::initialize
StatusCode initialize()
Definition
TBCondRunParTool.cxx:31
TBCondRunParTool::m_status
int m_status
Definition
TBCondRunParTool.h:65
TBCondRunParTool::getVal
StatusCode getVal(const std::string &folder, const unsigned int chnum, float &fval)
Definition
TBCondRunParTool.cxx:142
TBCondRunParTool::m_beam_energy
int m_beam_energy
Definition
TBCondRunParTool.h:70
TBCondRunParTool::m_det_mask
int m_det_mask
Definition
TBCondRunParTool.h:68
TBCondRunParTool::extractCoolTest
bool extractCoolTest(const std::string &folder, int run) const
Definition
TBCondRunParTool.cxx:195
TBCondRunParTool::finalize
StatusCode finalize()
Definition
TBCondRunParTool.cxx:41
TBCondRunParTool::m_beam_type
int m_beam_type
Definition
TBCondRunParTool.h:69
TBCondRunParTool::m_time_SOR
std::string m_time_SOR
Definition
TBCondRunParTool.h:72
TBCondRunParTool::m_crun
int m_crun
Definition
TBCondRunParTool.h:61
TBCondRunParTool::m_runpfolder
std::string m_runpfolder
Definition
TBCondRunParTool.h:63
TBCondRunParTool::getTable
StatusCode getTable(const std::string &table, const int irow, const void *tblptr, int &ncol, int &nrow, std::vector< std::string > &names, std::vector< std::string > &rows) const
Definition
TBCondRunParTool.cxx:70
TBCondRunParTool::m_cevent
int m_cevent
Definition
TBCondRunParTool.h:62
TBCondRunParTool::printTable
void printTable(const std::vector< std::string > &names, const std::vector< std::string > &rows) const
Definition
TBCondRunParTool.cxx:136
TBCondRunParTool::TBCondRunParTool
TBCondRunParTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
TBCondRunParTool.cxx:17
TBCondRunParTool::m_run_number
int m_run_number
Definition
TBCondRunParTool.h:66
TBCondRunParTool::m_trigger_type
int m_trigger_type
Definition
TBCondRunParTool.h:67
TBCondRunParTool::interfaceID
static const InterfaceID & interfaceID()
Definition
TBCondRunParTool.cxx:28
TBCondRunParTool::checkcache
bool checkcache()
Definition
TBCondRunParTool.cxx:46
TBCondRunParTool::m_file_tag
std::string m_file_tag
Definition
TBCondRunParTool.h:71
TBCondRunParTool::extractCool
bool extractCool(const int run)
Definition
TBCondRunParTool.cxx:164
type
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0