18 #include <xercesc/util/XMLString.hpp>
19 #include <xercesc/dom/DOM.hpp>
20 #include <xercesc/framework/LocalFileFormatTarget.hpp>
28 XStr(
const char*
const toTranscode) {
fUnicodeForm = XMLString::transcode(toTranscode); }
38 #define X(str) XStr(str).unicodeForm()
59 }
catch (
const XMLException& toCatch) {
60 throw std::string(
"Error during Xerces-c Initialization: " +
61 std::string(XMLString::transcode(toCatch.getMessage())));
64 m_dom = DOMImplementationRegistry::getDOMImplementation(
X(
"Core"));
66 throw cms::Exception(
"RPCMuonsGrabber") <<
"Cannot get DOM" << std::endl;
85 XMLString::transcode(
"LS", tempStr, 99);
86 DOMImplementation*
impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
87 DOMLSSerializer* theSerializer = ((DOMImplementationLS*)
impl)->createLSSerializer();
88 DOMConfiguration* dc = theSerializer->getDomConfig();
89 dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
90 DOMLSOutput* outputDesc = ((DOMImplementationLS*)
impl)->createLSOutput();
91 outputDesc->setEncoding(
X(
"UTF-8"));
93 XMLFormatTarget* myFormTarget =
new LocalFileFormatTarget(
X(
"testpulses.xml"));
94 outputDesc->setByteStream(myFormTarget);
95 DOMNode* xmlstylesheet =
96 m_doc->createProcessingInstruction(
X(
"xml-stylesheet"),
X(
"type=\"text/xsl\"href=\"default.xsl\""));
99 theSerializer->write(
m_doc, outputDesc);
101 delete theSerializer;
119 if (
mu.getPtCode() > 0)
128 DOMElement* currRelBx =
m_doc->createElement(
X(
"bxData"));
143 for (
int tcNum = 0; tcNum <= 11; ++tcNum) {
144 DOMElement* tc =
nullptr;
145 DOMElement* tcgs =
nullptr;
146 for (
int tbNum = 0; tbNum <= 10; ++tbNum) {
147 DOMElement* tb =
nullptr;
148 DOMElement* tbgs =
nullptr;
149 for (
int PAC = 0; PAC <= 4; ++PAC) {
151 DOMElement* pac =
nullptr;
153 std::vector<RPCMuonExtraStruct>::iterator it =
m_muons.begin();
155 int muSegment = it->_mu.getLogSegment();
162 if (!((
int(it->_level) == 0 && tbNum == muTBno && muTC == tcNum && PAC == muPACChipNo) ||
163 (
int(it->_level) == 1 && tbNum == muTBno && muTC == tcNum) || (
int(it->_level) == 2 && muTC == tcNum)))
174 tc =
m_doc->createElement(
X(
"tc"));
175 currRelBx->appendChild(tc);
178 tcgs =
m_doc->createElement(
X(
"tcgs"));
179 tc->appendChild(tcgs);
181 if (tb ==
nullptr &&
int(it->_level) <= 1) {
182 tb =
m_doc->createElement(
X(
"tb"));
186 tbgs =
m_doc->createElement(
X(
"tbgs"));
187 tb->appendChild(tbgs);
190 if (pac ==
nullptr &&
int(it->_level) == 0) {
191 pac =
m_doc->createElement(
X(
"pac"));
192 tb->appendChild(pac);
193 pac->setAttribute(
X(
"num"),
X(
IntToString(muPACChipNo).c_str()));
196 DOMElement*
mu =
m_doc->createElement(
X(
"mu"));
197 mu->setAttribute(
X(
"pt"),
X(
IntToString(
int(it->_mu.getPtCode())).c_str()));
198 mu->setAttribute(
X(
"qual"),
X(
IntToString(
int(it->_mu.getQuality())).c_str()));
199 mu->setAttribute(
X(
"sign"),
X(
IntToString(
int(it->_mu.getSign())).c_str()));
201 if (
int(it->_level) == 0) {
203 pac->appendChild(
mu);
206 mu->setAttribute(
X(
"phi"),
X(
IntToString(
int(it->_mu.getPhiAddr())).c_str()));
207 mu->setAttribute(
X(
"eta"),
X(
IntToString(
int(it->_mu.getEtaAddr())).c_str()));
208 mu->setAttribute(
X(
"gbD"),
X(
IntToString(
int(it->_mu.getGBData())).c_str()));
209 if (
int(it->_level) == 1) {
210 tbgs->appendChild(
mu);
211 }
else if (
int(it->_level) == 2) {
212 tcgs->appendChild(
mu);
214 throw cms::Exception(
"RPCMuonsGrabber") <<
"xx Unexpected level" << std::endl;
227 for (
int half = 0; half <= 1; ++half) {
228 for (
int be = 0;
be <= 1; ++
be) {
230 std::vector<RPCMuonExtraStruct>::iterator it =
m_muons.begin();
231 DOMElement* hs =
nullptr;
233 if ((
int(it->_level) !=
level) ||
int(it->_hsHalf) != half ||
int(it->_region) !=
be) {
240 hs =
m_doc->createElement(
X(
"hs"));
242 }
else if (
level == 4) {
243 hs =
m_doc->createElement(
X(
"fs"));
245 throw cms::Exception(
"RPCMuonsGrabber") <<
"Problem writing out muons - lvl " <<
level << std::endl;
248 currRelBx->appendChild(hs);
251 DOMElement*
mu =
m_doc->createElement(
X(
"mu"));
254 mu->setAttribute(
X(
"pt"),
X(
IntToString(
int(it->_mu.getPtCode())).c_str()));
255 mu->setAttribute(
X(
"qual"),
X(
IntToString(
int(it->_mu.getQuality())).c_str()));
256 mu->setAttribute(
X(
"sign"),
X(
IntToString(
int(it->_mu.getSign())).c_str()));
257 mu->setAttribute(
X(
"phi"),
X(
IntToString(
int(it->_mu.getPhiAddr())).c_str()));
258 mu->setAttribute(
X(
"eta"),
X(
IntToString(
int(it->_mu.getEtaAddr())).c_str()));
259 mu->setAttribute(
X(
"gbD"),
X(
IntToString(
int(it->_mu.getGBData())).c_str()));
273 throw cms::Exception(
"RPCMuonsGrabber") <<
" There are still some muons in muons vec" << std::endl;
278 std::stringstream
ss;