18 #include "Riostream.h"
19 #include "TObjString.h"
20 #include "TDOMParser.h"
22 #include "TXMLDocument.h"
38 , m_logger(
"TGoodRunsListReader" )
46 , m_logger(
"TGoodRunsListReader" )
63 m_dataCardList.clear();
64 m_xmlstringList.clear();
73 Bool_t xmlInterpret(kTRUE);
75 if (m_dataCardList.empty() && m_xmlstringList.empty()) {
76 m_logger <<
kWARNING <<
"No xml data-card or string set. Return false." <<
GEndl;
81 TDOMParser* xmlparser =
new TDOMParser();
86 for (
unsigned int j=0; j<m_dataCardList.size() && xmlInterpret; ++j) {
87 m_dataCardName = m_dataCardList[j];
89 if (!m_dataCardName.IsNull()) {
90 m_logger <<
kDEBUG <<
"Read xml data-card: \"" << m_dataCardName <<
"\"" <<
GEndl;
91 xmlparser->SetValidate(kFALSE);
92 parseCode = xmlparser->ParseFile( m_dataCardName );
94 m_logger <<
kWARNING <<
"No xml data-card set. Skip." <<
GEndl;
98 m_logger <<
kDEBUG <<
"XML parser returned code: " << parseCode <<
GEndl;
100 m_logger <<
kERROR <<
"loading of xml document failed" <<
GEndl;
101 xmlInterpret = kFALSE;
104 TXMLDocument* xmldoc = xmlparser->GetXMLDocument();
106 TXMLNode* jobConfig_node = xmldoc->GetRootNode();
107 TXMLNode* jobConfig_elem = jobConfig_node->GetChildren();
109 while (jobConfig_elem != 0) {
110 if (jobConfig_elem->GetNodeName() == TString(
"NamedLumiRange")) {
111 this->ReadNamedLumiRange ( jobConfig_elem );
114 jobConfig_elem = jobConfig_elem->GetNextNode();
118 m_dataCardList.clear();
123 for (
unsigned int j=0; j<m_xmlstringList.size() && xmlInterpret; ++j) {
124 m_xmlstring = m_xmlstringList[j];
126 if (!m_xmlstring.IsNull()) {
128 xmlparser->SetValidate(kFALSE);
129 parseCode = xmlparser->ParseBuffer( m_xmlstring.Data(), m_xmlstring.Length() );
135 m_logger <<
kDEBUG <<
"XML parser returned code: " << parseCode <<
GEndl;
136 if (parseCode != 0) {
137 m_logger <<
kERROR <<
"loading of xml document failed" <<
GEndl;
138 xmlInterpret = kFALSE;
141 TXMLDocument* xmldoc = xmlparser->GetXMLDocument();
143 TXMLNode* jobConfig_node = xmldoc->GetRootNode();
144 TXMLNode* jobConfig_elem = jobConfig_node->GetChildren();
146 while (jobConfig_elem != 0) {
147 if (jobConfig_elem->GetNodeName() == TString(
"NamedLumiRange")) {
148 this->ReadNamedLumiRange ( jobConfig_elem );
151 jobConfig_elem = jobConfig_elem->GetNextNode();
155 m_xmlstringList.clear();
168 if (!
node->HasAttributes())
return;
170 TListIter attribIt(
node->GetAttributes() );
171 TXMLAttr* curAttr( 0 );
172 while ((curAttr = (TXMLAttr*)attribIt()) != 0) {
173 m_logger <<
kDEBUG <<
node->GetNodeName() <<
": " << curAttr->GetName()
174 <<
" = \"" << curAttr->GetValue() <<
"\"" <<
GEndl;
184 TXMLNode*
node = dataNode->GetChildren();
189 if (TString(
"Run")==
node->GetNodeName()) {
190 m_logger <<
kDEBUG <<
"subchild node value: " <<
node->GetText() <<
GEndl;
194 if (TString(
"LBRange")==
node->GetNodeName() &&
node->HasAttributes()) {
195 TXMLAttr* curAttr( 0 );
196 TListIter attribIt(
node->GetAttributes());
197 while ((curAttr = (TXMLAttr*)attribIt()) != 0) {
198 if (TString(
"Start")==curAttr->GetName()) {
199 m_logger <<
kDEBUG <<
node->GetNodeName() <<
": " << curAttr->GetName()
200 <<
" = \"" << curAttr->GetValue() <<
"\"" <<
GEndl;
201 }
else if (TString(
"End")==curAttr->GetName()) {
202 m_logger <<
kDEBUG <<
node->GetNodeName() <<
": " << curAttr->GetName()
203 <<
" = \"" << curAttr->GetValue() <<
"\"" <<
GEndl;
217 if (!dataNode->HasChildren()) {
218 m_logger <<
kWARNING <<
"<Data> ... </Data> Part does not contain any parameters" <<
GEndl;
223 TXMLNode*
node = dataNode->GetChildren();
227 if (TString(
"Run")==
node->GetNodeName()) {
228 m_logger <<
kDEBUG <<
"subchild node value: " <<
node->GetText() <<
GEndl;
232 if (TString(
"LBRange")==
node->GetNodeName() &&
node->HasAttributes()) {
235 TXMLAttr* curAttr( 0 );
236 TListIter attribIt(
node->GetAttributes());
237 while ((curAttr = (TXMLAttr*)attribIt()) != 0) {
238 if (TString(
"Start")==curAttr->GetName()) {
239 m_logger <<
kDEBUG <<
node->GetNodeName() <<
": " << curAttr->GetName()
240 <<
" = \"" << curAttr->GetValue() <<
"\"" <<
GEndl;
242 }
else if (TString(
"End")==curAttr->GetName()) {
243 m_logger <<
kDEBUG <<
node->GetNodeName() <<
": " << curAttr->GetName()
244 <<
" = \"" << curAttr->GetValue() <<
"\"" <<
GEndl;
248 if (!lbr.
IsEmpty()) goodrun.push_back(lbr);
261 if (!dataNode->HasChildren()) {
262 m_logger <<
kWARNING <<
"<Data> ... </Data> Part does not contain any parameters" <<
GEndl;
267 TXMLNode*
node = dataNode->GetChildren();
269 std::string nameStr, valueStr;
273 if (TString(
"Name") ==
node->GetNodeName()) {
274 if (
node->GetText()!=0) {
275 m_logger <<
kDEBUG <<
"child node value: " <<
node->GetText() <<
GEndl;
276 nameStr=
node->GetText();
277 }
else { nameStr=
""; }
279 grl.SetName(nameStr.c_str());
282 else if (TString(
"Version") ==
node->GetNodeName()) {
283 if (
node->GetText()!=0) {
284 m_logger <<
kDEBUG <<
"child node value: " <<
node->GetText() <<
GEndl;
285 valueStr=
node->GetText();
286 }
else { valueStr=
""; }
288 grl.SetVersion(valueStr);
291 else if (TString(
"Metadata") ==
node->GetNodeName()) {
293 this->ReadAttribs(
node);
295 if (
node->HasAttributes()) {
296 TListIter attribIt(
node->GetAttributes() );
297 TXMLAttr* curAttr( 0 );
298 while ((curAttr = (TXMLAttr*)attribIt()) != 0) {
299 if (curAttr->GetValue()!=0) { nameStr=curAttr->GetValue(); }
else { nameStr=
""; }
300 if (
node->GetText()!=0) { valueStr=
node->GetText(); }
else { valueStr=
""; }
302 if (!nameStr.empty() && !valueStr.empty())
grl.AddMetaData(nameStr,valueStr);
307 else if (TString(
"LumiBlockCollection") ==
node->GetNodeName()) {
313 if (!
grl.IsEmpty()) m_grlvec.push_back(
grl);
320 return m_grlvec.GetMergedGoodRunsList(operation);
327 return m_grlvec.GetGoodRunsList(
idx);