ATLAS Offline Software
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>
7 
8 using namespace std;
9 
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 
31 }
32 
33 void
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
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
108 
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
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
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
263 
264  m_myfile.open(filename.c_str());
265 
266  m_myfile.close();
267 
268 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
checkFileSG.line
line
Definition: checkFileSG.py:75
dqm_algorithms::tools::DumpConfig::~DumpConfig
~DumpConfig()
Definition: DumpConfig.cxx:30
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:36
dqm_algorithms::tools::DumpConfig::DumpOfflineConfig
void DumpOfflineConfig(const std::string &filename)
Definition: DumpConfig.cxx:262
dqm_algorithms::tools::DumpConfig::DumpAgent
void DumpAgent()
Definition: DumpConfig.cxx:53
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
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 &regionname="")
Definition: DumpConfig.cxx:11
dqm_algorithms::tools::DumpConfig::DumpOnlineConfig
void DumpOnlineConfig(const std::string &filename, bool dumpAgent=true)
Definition: DumpConfig.cxx:162
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
dqm_algorithms::tools::DumpConfig::DumpThresholds
void DumpThresholds()
Definition: DumpConfig.cxx:107
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
dqm_algorithms::tools::DumpConfig::DumpRegion
void DumpRegion()
Definition: DumpConfig.cxx:34
dqm_algorithms::tools::DumpConfig::DumpParams
void DumpParams()
Definition: DumpConfig.cxx:136
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
Name
JetDumper::Name Name
Definition: JetDumper.cxx:19
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
DumpConfig.h