ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
dqm_algorithms
tools
DumpConfig.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <vector>
6
#include <
dqm_algorithms/tools/DumpConfig.h
>
7
8
using namespace
std
;
9
10
dqm_algorithms::tools::DumpConfig::DumpConfig
11
(
const
std::string& ParameterName,
12
dqm_core::test::DummyAlgorithmConfig & config,
13
const
std::string& algorithmname,
14
const
std::string& histogramname,
15
const
std::string& reffilename,
16
const
std::string& refhistogramname,
17
float
weight,
18
const
std::string& regionname) :
19
m_ParameterName
(ParameterName),
20
m_config
(config),
21
m_regionname
(regionname),
22
m_algorithmname
(algorithmname),
23
m_histogramname
(histogramname),
24
m_refhistogramname
(refhistogramname),
25
m_reffilename
(reffilename),
26
m_weight
(weight)
27
{
28
}
29
30
dqm_algorithms::tools::DumpConfig::~DumpConfig
(){
31
}
32
33
void
34
dqm_algorithms::tools::DumpConfig::DumpRegion
() {
35
m_myfile
<<
"<obj class=\"DQRegion\" id=\""
+
m_regionname
+
"\">\n"
;
36
m_myfile
<<
"<attr name=\"InputDataSource\" type=\"string\">\"\"</attr>\n"
;
37
m_myfile
<<
"<attr name=\"Weight\" type=\"float\">1</attr>\n"
;
38
m_myfile
<<
"<attr name=\"Action\" type=\"string\">\"\"</attr>\n"
;
39
m_myfile
<<
"<rel name=\"Algorithm\">\"DQAlgorithm\" \"SimpleSummary\"</rel>\n"
;
40
m_myfile
<<
"<rel name=\"AlgorithmParameters\" num=\"0\"></rel>\n"
;
41
m_myfile
<<
"<rel name=\"References\" num=\"0\"></rel>\n"
;
42
m_myfile
<<
"<rel name=\"GreenThresholds\" num=\"0\"></rel>\n"
;
43
m_myfile
<<
"<rel name=\"RedThresholds\" num=\"0\"></rel>\n"
;
44
m_myfile
<<
"<rel name=\"DQRegions\" num=\"0\"></rel>\n"
;
45
m_myfile
<<
"<rel name=\"DQParameters\" num=\"1\">\n"
;
46
m_myfile
<<
" \"DQParameter\" \""
+
m_ParameterName
+
"\"\n"
;
47
m_myfile
<<
"</rel>\n"
;
48
m_myfile
<<
"</obj>\n\n"
;
49
50
}
51
52
void
53
dqm_algorithms::tools::DumpConfig::DumpAgent
() {
54
m_myfile
<<
"<obj class=\"DQAgent\" id=\""
+
m_regionname
+
"\">\n"
;
55
m_myfile
<<
"<attr name=\"Parameters\" type=\"string\">\"-n "
+
m_regionname
+
" -p ${TDAQ_PARTITION}\"</attr>\n"
;
56
m_myfile
<<
"<attr name=\"RestartParameters\" type=\"string\">\"-n "
+
m_regionname
+
" -p ${TDAQ_PARTITION}\"</attr>\n"
;
57
m_myfile
<<
"<attr name=\"ControlledByOnline\" type=\"bool\">1</attr>\n"
;
58
m_myfile
<<
"<attr name=\"IfDies\" type=\"enum\">\"Restart\"</attr>\n"
;
59
m_myfile
<<
"<attr name=\"IfFailed\" type=\"enum\">\"Restart\"</attr>\n"
;
60
m_myfile
<<
"<attr name=\"StartAt\" type=\"enum\">\"Boot\"</attr>\n"
;
61
m_myfile
<<
"<attr name=\"StopAt\" type=\"enum\">\"Shutdown\"</attr>\n"
;
62
m_myfile
<<
"<attr name=\"InitTimeout\" type=\"u32\">0</attr>\n"
;
63
m_myfile
<<
"<attr name=\"StartIn\" type=\"string\">\"\"</attr>\n"
;
64
m_myfile
<<
"<attr name=\"InputDevice\" type=\"string\">\"\"</attr>\n"
;
65
m_myfile
<<
"<attr name=\"Logging\" type=\"bool\">1</attr>\n"
;
66
m_myfile
<<
"<rel name=\"InitializationDependsFrom\" num=\"0\">\n"
;
67
m_myfile
<<
"</rel>\n"
;
68
m_myfile
<<
"<rel name=\"ShutdownDependsFrom\" num=\"0\"></rel>\n"
;
69
m_myfile
<<
"<rel name=\"Program\">\"Binary\" \"dqmf_agent\"</rel>\n"
;
70
m_myfile
<<
"<rel name=\"ExplicitTag\">\"\" \"\"</rel>\n"
;
71
m_myfile
<<
"<rel name=\"Uses\" num=\"0\"></rel>\n"
;
72
m_myfile
<<
"<rel name=\"ProcessEnvironment\" num=\"0\">\n"
;
73
m_myfile
<<
"</rel>\n"
;
74
m_myfile
<<
"<rel name=\"RunsOn\">\"\" \"\"</rel>\n"
;
75
m_myfile
<<
"<rel name=\"DQRegions\" num=\"1\">\n"
;
76
m_myfile
<<
" \"DQRegion\" \""
+
m_regionname
+
"\"\n"
;
77
m_myfile
<<
"</rel>\n"
;
78
m_myfile
<<
"</obj>\n"
;
79
80
81
}
82
83
84
void
85
dqm_algorithms::tools::DumpConfig::WriteThresholdFromMap
(
const
std::map<std::string,double>&
object
,
const
std::string& ParameterName,
const
std::string&
Name
){
86
int
objsize=
object
.size();
87
char
line[500];
88
sprintf(line,
"<rel name=\"%sThresholds\" num=\"%d\">\n"
,
Name
.c_str(),objsize);
89
m_myfile
<<line;
90
std::map<std::string,double>::const_iterator iter;
91
92
for
(iter=
object
.begin();iter!=
object
.end();++iter){
93
if
(
Name
==
"Red"
){
94
m_red_id
.push_back(
Name
+
"Thresh_"
+ParameterName+
"_"
+iter->first);
95
}
else
{
96
m_green_id
.push_back(
Name
+
"Thresh_"
+ParameterName+
"_"
+iter->first);
97
}
98
99
m_myfile
<<
" \"DQThreshold\" \""
+
Name
+
"Thresh_"
+ParameterName+
"_"
+iter->first+
"\"\n"
;
100
101
}
102
m_myfile
<<
"</rel>\n"
;
103
104
}
105
106
void
107
dqm_algorithms::tools::DumpConfig::DumpThresholds
(){
108
109
std::map<std::string,double>::iterator iter;
110
int
count
=0;
111
char
line[500];
112
std::map<std::string,double> thresh;
113
std::vector<std::string> id;
114
for
(
int
i=0; i<2;++i){
115
if
(i== 0 ) {
116
thresh=
m_gthresh
;
117
id
=
m_green_id
;
118
}
else
{
119
thresh=
m_rthresh
;
120
id
=
m_red_id
;
121
}
122
123
for
(iter=thresh.begin();iter!=thresh.end();++iter){
124
m_myfile
<<
"<obj class=\"DQThreshold\" id=\""
+
id
[
count
]+
"\">\n"
;
125
m_myfile
<<
" <attr name=\"Name\" type=\"string\">\""
+iter->first+
"\"</attr>\n"
;
126
sprintf(line,
" <attr name=\"Value\" type=\"double\">%4.2f</attr>\n</obj>\n\n"
,iter->second);
127
m_myfile
<<line;
128
++
count
;
129
}
130
count
=0;
131
}
132
133
}
134
135
void
136
dqm_algorithms::tools::DumpConfig::DumpParams
(){
137
138
char
pline[500];
139
int
count
=0;
140
141
for
(
auto
& param :
m_params
) {
142
m_myfile
<<
"<obj class=\"DQAlgorithmParameter\" id=\""
+
m_param_id
[
count
]+
"\">\n"
;
143
m_myfile
<<
" <attr name=\"Name\" type=\"string\">\""
+param.first+
"\"</attr>\n"
;
144
sprintf(pline,
" <attr name=\"Value\" type=\"double\" num=\"1\">%4.2f</attr>\n</obj>\n\n"
,param.second);
145
m_myfile
<<pline;
146
++
count
;
147
}
148
149
for
(
auto
& param :
m_strParams
) {
150
m_myfile
<<
"<obj class=\"DQAlgorithmParameter\" id=\""
+
m_param_id
[
count
]+
"\">\n"
;
151
m_myfile
<<
" <attr name=\"Name\" type=\"string\">\""
+param.first+
"\"</attr>\n"
;
152
m_myfile
<<
" <attr name=\"Value\" type=\"string\" num=\"1\">"
+param.second+
"</attr>\n"
;
153
m_myfile
<<
"</obj>\n\n"
;
154
++
count
;
155
}
156
157
}
158
159
160
161
void
162
dqm_algorithms::tools::DumpConfig::DumpOnlineConfig
(
const
std::string& filename,
bool
dumpAgent) {
163
164
m_myfile
.open(filename.c_str());
165
//open file
166
int
length
;
167
char
* buffer;
168
169
ifstream is;
170
is.open (
"../share/oks-xml-header.txt"
, ios::in );
171
172
// get length of file:
173
is.seekg (0, ios::end);
174
length
= is.tellg();
175
is.seekg (0, ios::beg);
176
177
// allocate memory:
178
buffer =
new
char
[
length
];
179
180
// read data as a block:
181
is.read (buffer,
length
);
182
is.close();
183
184
m_myfile
.write (buffer,
length
);
185
186
delete
[] buffer;
187
188
if
(
m_regionname
!=
""
){
189
DumpRegion
();
190
if
(dumpAgent) {
191
DumpAgent
();
192
}
193
}
194
195
m_myfile
<<
"<obj class=\"DQParameter\" id=\""
+
m_ParameterName
+
"\">\n"
;
196
m_myfile
<<
"<attr name=\"InputDataSource\" type=\"string\">\"Histogramming.PT."
+
m_histogramname
+
"\"</attr>\n"
;
197
198
char
weightline [500];
199
sprintf(weightline,
"<attr name=\"Weight\" type=\"float\">%f</attr>\n"
,
m_weight
);
200
m_myfile
<<weightline;
201
m_myfile
<<
"<rel name=\"Algorithm\"> \"DQAlgorithm\" \""
+
m_algorithmname
+
"\"</rel>\n"
;
202
m_myfile
<<
"<attr name=\"Action\" type=\"string\">\"\"</attr>\n"
;
203
204
// Parameters....
205
m_params
=
m_config
.getParameters();
206
int
paramsize=
m_params
.size();
207
m_strParams
=
m_config
.getGenericParameters();
208
paramsize+=
m_strParams
.size();
209
210
char
paramsline [500];
211
sprintf(paramsline,
"<rel name=\"AlgorithmParameters\" num=\"%d\">\n"
, paramsize);
212
m_myfile
<<paramsline;
213
214
std::map<std::string,double>::const_iterator iter;
215
for
(
auto
& param :
m_params
) {
216
m_myfile
<<
" \"DQAlgorithmParameter\" \"Params_"
+
m_ParameterName
+
"_"
+param.first+
"\"\n"
;
217
m_param_id
.push_back(
"Params_"
+
m_ParameterName
+
"_"
+param.first);
218
}
219
for
(
auto
& param :
m_strParams
) {
220
m_myfile
<<
" \"DQAlgorithmParameter\" \"Params_"
+
m_ParameterName
+
"_"
+param.first+
"\"\n"
;
221
m_param_id
.push_back(
"Params_"
+
m_ParameterName
+
"_"
+param.first);
222
}
223
m_myfile
<<
"</rel>\n"
;
224
225
// Reference histogram
226
if
(
m_refhistogramname
==
""
&&
m_reffilename
==
""
) {
227
m_myfile
<<
"<rel name=\"References\" num=\"0\"> </rel>\n"
;
228
}
else
{
229
m_myfile
<<
"<rel name=\"References\" num=\"1\">\"DQReference\" \"ref_"
+
m_ParameterName
+
"\"</rel>\n"
;
230
}
231
232
//Green Threshold............
233
m_gthresh
=
m_config
.getGreenThresholds();
234
WriteThresholdFromMap
(
m_gthresh
,
m_ParameterName
,
"Green"
);
235
236
//Red Threshold............
237
m_rthresh
=
m_config
.getRedThresholds();
238
DumpConfig::WriteThresholdFromMap
(
m_rthresh
,
m_ParameterName
,
"Red"
);
239
240
m_myfile
<<
"</obj>\n\n\n"
;
241
242
//References
243
if
(
m_refhistogramname
!=
""
&&
m_reffilename
!=
""
) {
244
m_myfile
<<
"<obj class=\"DQReference\" id=\"ref_"
+
m_ParameterName
+
"\">\n"
;
245
m_myfile
<<
"<attr name=\"Reference\" type=\"string\">\""
+
m_reffilename
+
":"
+
m_refhistogramname
+
"\"</attr>\n"
;
246
m_myfile
<<
"<attr name=\"ExternalConditionName\" type=\"string\">\"\"</attr>\n"
;
247
m_myfile
<<
"<attr name=\"ExternalConditionValue\" type=\"double\">0</attr>\n"
;
248
m_myfile
<<
"</obj>\n\n"
;
249
}
250
DumpThresholds
();
251
252
DumpParams
();
253
254
255
m_myfile
<<
"</oks-data>"
;
256
257
m_myfile
.close();
258
259
}
260
261
void
262
dqm_algorithms::tools::DumpConfig::DumpOfflineConfig
(
const
std::string& filename) {
263
264
m_myfile
.open(filename.c_str());
265
266
m_myfile
.close();
267
268
}
DumpConfig.h
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
Name
JetDumper::Name Name
Definition
JetDumper.cxx:19
dqm_algorithms::tools::DumpConfig::m_myfile
std::ofstream m_myfile
Definition
DumpConfig.h:44
dqm_algorithms::tools::DumpConfig::~DumpConfig
~DumpConfig()
Definition
DumpConfig.cxx:30
dqm_algorithms::tools::DumpConfig::m_config
dqm_core::test::DummyAlgorithmConfig m_config
Definition
DumpConfig.h:54
dqm_algorithms::tools::DumpConfig::m_weight
float m_weight
Definition
DumpConfig.h:60
dqm_algorithms::tools::DumpConfig::m_params
std::map< std::string, double > m_params
Definition
DumpConfig.h:45
dqm_algorithms::tools::DumpConfig::m_regionname
std::string m_regionname
Definition
DumpConfig.h:55
dqm_algorithms::tools::DumpConfig::DumpRegion
void DumpRegion()
Definition
DumpConfig.cxx:34
dqm_algorithms::tools::DumpConfig::DumpThresholds
void DumpThresholds()
Definition
DumpConfig.cxx:107
dqm_algorithms::tools::DumpConfig::m_strParams
std::map< std::string, std::string > m_strParams
Definition
DumpConfig.h:46
dqm_algorithms::tools::DumpConfig::DumpConfig
DumpConfig(const std::string &ParameterName, dqm_core::test::DummyAlgorithmConfig &config, const std::string &algorithmname, const std::string &histogramname, const std::string &reffilename="", const std::string &refhistogramname="", float weight=1., const std::string ®ionname="")
Definition
DumpConfig.cxx:11
dqm_algorithms::tools::DumpConfig::DumpOfflineConfig
void DumpOfflineConfig(const std::string &filename)
Definition
DumpConfig.cxx:262
dqm_algorithms::tools::DumpConfig::m_reffilename
std::string m_reffilename
Definition
DumpConfig.h:59
dqm_algorithms::tools::DumpConfig::DumpAgent
void DumpAgent()
Definition
DumpConfig.cxx:53
dqm_algorithms::tools::DumpConfig::DumpOnlineConfig
void DumpOnlineConfig(const std::string &filename, bool dumpAgent=true)
Definition
DumpConfig.cxx:162
dqm_algorithms::tools::DumpConfig::m_gthresh
std::map< std::string, double > m_gthresh
Definition
DumpConfig.h:47
dqm_algorithms::tools::DumpConfig::m_algorithmname
std::string m_algorithmname
Definition
DumpConfig.h:56
dqm_algorithms::tools::DumpConfig::m_green_id
std::vector< std::string > m_green_id
Definition
DumpConfig.h:50
dqm_algorithms::tools::DumpConfig::m_param_id
std::vector< std::string > m_param_id
Definition
DumpConfig.h:51
dqm_algorithms::tools::DumpConfig::m_ParameterName
std::string m_ParameterName
Definition
DumpConfig.h:53
dqm_algorithms::tools::DumpConfig::DumpParams
void DumpParams()
Definition
DumpConfig.cxx:136
dqm_algorithms::tools::DumpConfig::m_refhistogramname
std::string m_refhistogramname
Definition
DumpConfig.h:58
dqm_algorithms::tools::DumpConfig::m_red_id
std::vector< std::string > m_red_id
Definition
DumpConfig.h:49
dqm_algorithms::tools::DumpConfig::m_rthresh
std::map< std::string, double > m_rthresh
Definition
DumpConfig.h:48
dqm_algorithms::tools::DumpConfig::WriteThresholdFromMap
void WriteThresholdFromMap(const std::map< std::string, double > &object, const std::string &ParameterName, const std::string &Name)
Definition
DumpConfig.cxx:85
dqm_algorithms::tools::DumpConfig::m_histogramname
std::string m_histogramname
Definition
DumpConfig.h:57
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0