Skip to content

Commit 563952f

Browse files
committed
Use concurrency to initialise/deactivate xerces in OMFT XMLConfigReader/Writer
1 parent e04f43e commit 563952f

File tree

8 files changed

+27
-31
lines changed

8 files changed

+27
-31
lines changed

L1Trigger/L1TMuonOverlap/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
</export>
44
<use name="xerces-c"/>
55
<use name="root"/>
6+
<use name="Utilities/Xerces"/>
67
<use name="DataFormats/L1DTTrackFinder"/>
78
<use name="L1Trigger/RPCTrigger"/>
89
<use name="DataFormats/L1TMuon"/>

L1Trigger/L1TMuonOverlap/interface/XMLConfigWriter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class XMLConfigWriter {
2929
public:
3030
XMLConfigWriter(const OMTFConfiguration* aOMTFConfig);
3131

32+
~XMLConfigWriter();
33+
3234
void initialiseXMLDocument(const std::string& docName);
3335

3436
void finaliseXMLDocument(const std::string& fName);

L1Trigger/L1TMuonOverlap/src/XMLConfigReader.cc

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "FWCore/MessageLogger/interface/MessageLogger.h"
1414

15+
#include "Utilities/Xerces/interface/Xerces.h"
16+
1517
#include "xercesc/framework/StdOutFormatTarget.hpp"
1618
#include "xercesc/framework/LocalFileFormatTarget.hpp"
1719
#include "xercesc/parsers/XercesDOMParser.hpp"
@@ -39,20 +41,11 @@ inline XMLCh *_toDOMS(std::string temp) {
3941
}
4042
////////////////////////////////////
4143
////////////////////////////////////
42-
XMLConfigReader::XMLConfigReader() {
43-
//XMLPlatformUtils::Initialize();
44-
45-
///Initialise XML parser
46-
//parser = new XercesDOMParser();
47-
//parser->setValidationScheme(XercesDOMParser::Val_Auto);
48-
//parser->setDoNamespaces(false);
49-
50-
//doc = 0;
51-
}
44+
XMLConfigReader::XMLConfigReader() { cms::concurrency::xercesInitialize(); }
5245

5346
XMLConfigReader::~XMLConfigReader() {
5447
// delete parser;
55-
//XMLPlatformUtils::Terminate();
48+
cms::concurrency::xercesTerminate();
5649
}
5750
//////////////////////////////////////////////////
5851
//////////////////////////////////////////////////
@@ -134,7 +127,6 @@ unsigned int XMLConfigReader::getPatternsVersion() const {
134127
return 0;
135128

136129
unsigned int version = 0;
137-
XMLPlatformUtils::Initialize();
138130
{
139131
XercesDOMParser parser;
140132
parser.setValidationScheme(XercesDOMParser::Val_Auto);
@@ -154,7 +146,6 @@ unsigned int XMLConfigReader::getPatternsVersion() const {
154146
XMLString::release(&xmlVersion);
155147
parser.resetDocumentPool();
156148
}
157-
XMLPlatformUtils::Terminate();
158149

159150
return version;
160151
}
@@ -163,8 +154,6 @@ unsigned int XMLConfigReader::getPatternsVersion() const {
163154
std::vector<std::shared_ptr<GoldenPattern>> XMLConfigReader::readPatterns(const L1TMuonOverlapParams &aConfig) {
164155
aGPs.clear();
165156

166-
XMLPlatformUtils::Initialize();
167-
168157
XMLCh *xmlGP = _toDOMS("GP");
169158
std::array<XMLCh *, 4> xmliPt = {{_toDOMS("iPt1"), _toDOMS("iPt2"), _toDOMS("iPt3"), _toDOMS("iPt4")}};
170159

@@ -222,8 +211,6 @@ std::vector<std::shared_ptr<GoldenPattern>> XMLConfigReader::readPatterns(const
222211
XMLString::release(&xmliPt[2]);
223212
XMLString::release(&xmliPt[3]);
224213

225-
XMLPlatformUtils::Terminate();
226-
227214
return aGPs;
228215
}
229216
//////////////////////////////////////////////////
@@ -338,7 +325,6 @@ std::vector<std::vector<int>> XMLConfigReader::readEvent(unsigned int iEvent, un
338325
//////////////////////////////////////////////////
339326
//////////////////////////////////////////////////
340327
void XMLConfigReader::readConfig(L1TMuonOverlapParams *aConfig) const {
341-
XMLPlatformUtils::Initialize();
342328
{
343329
XercesDOMParser parser;
344330
parser.setValidationScheme(XercesDOMParser::Val_Auto);
@@ -632,7 +618,6 @@ void XMLConfigReader::readConfig(L1TMuonOverlapParams *aConfig) const {
632618
XMLString::release(&xmlnGoldenPatterns);
633619
XMLString::release(&xmlConnectionMap);
634620
}
635-
XMLPlatformUtils::Terminate();
636621
}
637622
//////////////////////////////////////////////////
638623
//////////////////////////////////////////////////

L1Trigger/L1TMuonOverlap/src/XMLConfigWriter.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "L1Trigger/L1TMuonOverlap/interface/AlgoMuon.h"
1010
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
1111

12+
#include "Utilities/Xerces/interface/Xerces.h"
13+
1214
#include <iostream>
1315
#include <sstream>
1416
#include <cmath>
@@ -86,13 +88,16 @@ inline XMLCh* _toDOMS(std::string temp) {
8688
////////////////////////////////////
8789
////////////////////////////////////
8890
XMLConfigWriter::XMLConfigWriter(const OMTFConfiguration* aOMTFConfig) {
89-
XMLPlatformUtils::Initialize();
91+
cms::concurrency::xercesInitialize();
9092

9193
///Initialise XML document
9294
domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
9395

9496
myOMTFConfig = aOMTFConfig;
9597
}
98+
////////////////////////////////////
99+
////////////////////////////////////
100+
XMLConfigWriter::~XMLConfigWriter() { cms::concurrency::xercesTerminate(); }
96101
//////////////////////////////////////////////////
97102
//////////////////////////////////////////////////
98103
void XMLConfigWriter::initialiseXMLDocument(const std::string& docName) {

L1Trigger/L1TMuonOverlapPhase1/BuildFile.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<use name="Geometry/RPCGeometry"/>
1010
<use name="root"/>
1111
<use name="xerces-c"/>
12+
<use name="Utilities/Xerces"/>
1213
</export>
1314

1415
<flags ADD_SUBDIR="1"/>
@@ -34,3 +35,4 @@
3435
<use name="roofit"/>
3536
<use name="root"/>
3637
<use name="xerces-c"/>
38+
<use name="Utilities/Xerces"/>

L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigWriter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class XMLConfigWriter {
3131
bool writePdfThresholds = false,
3232
bool writeMeanDistPhi1 = false);
3333

34+
~XMLConfigWriter();
35+
3436
void initialiseXMLDocument(const std::string& docName);
3537

3638
void finaliseXMLDocument(const std::string& fName);

L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigReader.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"
88
#include "FWCore/MessageLogger/interface/MessageLogger.h"
99

10+
#include "Utilities/Xerces/interface/Xerces.h"
11+
1012
#include <iostream>
1113
#include <cmath>
1214
#include <algorithm>
@@ -42,9 +44,9 @@ inline XMLCh *_toDOMS(std::string temp) {
4244
}
4345
////////////////////////////////////
4446
////////////////////////////////////
45-
XMLConfigReader::XMLConfigReader() {}
47+
XMLConfigReader::XMLConfigReader() { cms::concurrency::xercesInitialize(); }
4648

47-
XMLConfigReader::~XMLConfigReader() {}
49+
XMLConfigReader::~XMLConfigReader() { cms::concurrency::xercesTerminate(); }
4850
//////////////////////////////////////////////////
4951
//////////////////////////////////////////////////
5052
void XMLConfigReader::readLUTs(std::vector<l1t::LUT *> luts,
@@ -207,7 +209,6 @@ unsigned int XMLConfigReader::getPatternsVersion() const {
207209
return 0;
208210

209211
unsigned int version = 0;
210-
XMLPlatformUtils::Initialize();
211212
{
212213
XercesDOMParser parser;
213214
parser.setValidationScheme(XercesDOMParser::Val_Auto);
@@ -227,7 +228,6 @@ unsigned int XMLConfigReader::getPatternsVersion() const {
227228
XMLString::release(&xmlVersion);
228229
parser.resetDocumentPool();
229230
}
230-
XMLPlatformUtils::Terminate();
231231

232232
return version;
233233
}
@@ -241,8 +241,6 @@ GoldenPatternVec<GoldenPatternType> XMLConfigReader::readPatterns(const L1TMuonO
241241
GoldenPatternVec<GoldenPatternType> aGPs;
242242
aGPs.clear();
243243

244-
XMLPlatformUtils::Initialize();
245-
246244
if (resetNumbering) {
247245
iGPNumber = 0;
248246
iPatternGroup = 0;
@@ -305,8 +303,6 @@ GoldenPatternVec<GoldenPatternType> XMLConfigReader::readPatterns(const L1TMuonO
305303
XMLString::release(&xmliPt[2]);
306304
XMLString::release(&xmliPt[3]);
307305

308-
XMLPlatformUtils::Terminate();
309-
310306
return aGPs;
311307
}
312308
//////////////////////////////////////////////////
@@ -469,7 +465,6 @@ std::vector<std::vector<int> > XMLConfigReader::readEvent(unsigned int iEvent, u
469465
//////////////////////////////////////////////////
470466
//////////////////////////////////////////////////
471467
void XMLConfigReader::readConfig(L1TMuonOverlapParams *aConfig) const {
472-
XMLPlatformUtils::Initialize();
473468
{
474469
XercesDOMParser parser;
475470
parser.setValidationScheme(XercesDOMParser::Val_Auto);
@@ -763,7 +758,6 @@ void XMLConfigReader::readConfig(L1TMuonOverlapParams *aConfig) const {
763758
XMLString::release(&xmlnGoldenPatterns);
764759
XMLString::release(&xmlConnectionMap);
765760
}
766-
XMLPlatformUtils::Terminate();
767761
}
768762
//////////////////////////////////////////////////
769763
//////////////////////////////////////////////////

L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigWriter.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "FWCore/Framework/interface/Event.h"
1010
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
1111

12+
#include "Utilities/Xerces/interface/Xerces.h"
13+
1214
#include <iostream>
1315
#include <sstream>
1416
#include <cmath>
@@ -87,7 +89,7 @@ inline XMLCh* _toDOMS(std::string temp) {
8789
////////////////////////////////////
8890
XMLConfigWriter::XMLConfigWriter(const OMTFConfiguration* aOMTFConfig, bool writePdfThresholds, bool writeMeanDistPhi1)
8991
: writePdfThresholds(writePdfThresholds), writeMeanDistPhi1(writeMeanDistPhi1) {
90-
XMLPlatformUtils::Initialize();
92+
cms::concurrency::xercesInitialize();
9193

9294
///Initialise XML document
9395
domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
@@ -96,6 +98,9 @@ XMLConfigWriter::XMLConfigWriter(const OMTFConfiguration* aOMTFConfig, bool writ
9698
}
9799
//////////////////////////////////////////////////
98100
//////////////////////////////////////////////////
101+
XMLConfigWriter::~XMLConfigWriter() { cms::concurrency::xercesTerminate(); }
102+
//////////////////////////////////////////////////
103+
//////////////////////////////////////////////////
99104
void XMLConfigWriter::initialiseXMLDocument(const std::string& docName) {
100105
theDoc = domImpl->createDocument(nullptr, _toDOMS(docName), nullptr);
101106
theTopElement = theDoc->getDocumentElement();

0 commit comments

Comments
 (0)