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;
68 m_doc = m_dom->createDocument(
nullptr,
72 m_rootElem = m_doc->getDocumentElement();
74 m_currEvent =
nullptr;
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\""));
98 m_doc->insertBefore(xmlstylesheet, m_rootElem);
99 theSerializer->write(m_doc, outputDesc);
101 delete theSerializer;
109 m_currEvent = m_doc->createElement(
X(
"event"));
110 m_currEvent->setAttribute(
X(
"num"),
X(IntToString(event).c_str()));
111 m_currEvent->setAttribute(
X(
"bx"),
X(IntToString(bx).c_str()));
112 m_rootElem->appendChild(m_currEvent);
114 m_currentEvent =
event;
128 DOMElement* currRelBx = m_doc->createElement(
X(
"bxData"));
129 currRelBx->setAttribute(
X(
"num"),
X(IntToString(bx).c_str()));
130 m_currEvent->appendChild(currRelBx);
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();
154 while (it != m_muons.end()) {
155 int muSegment = it->_mu.getLogSegment();
158 int muTBno = m_trigConfig->getTBNum(it->_mu.getConeCrdnts());
159 int muPACChipNo = m_trigConfig->getTowerNumOnTb(it->_mu.getConeCrdnts());
160 int muTC = m_trigConfig->getTCNum(it->_mu.getConeCrdnts());
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);
176 tc->setAttribute(
X(
"num"),
X(IntToString(tcNum).c_str()));
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"));
184 tb->setAttribute(
X(
"num"),
X(IntToString(tbNum).c_str()));
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) {
202 mu->setAttribute(
X(
"num"),
X(IntToString(muSegment).c_str()));
203 pac->appendChild(mu);
205 mu->setAttribute(
X(
"num"),
X(IntToString(
int(it->_index)).c_str()));
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;
218 it = m_muons.erase(it);
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;
232 while (it != m_muons.end()) {
233 if ((
int(it->_level) !=
level) ||
int(it->_hsHalf) != half ||
int(it->_region) != be) {
240 hs = m_doc->createElement(
X(
"hs"));
241 hs->setAttribute(
X(
"num"),
X(IntToString(half).c_str()));
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;
247 hs->setAttribute(
X(
"be"),
X(IntToString(be).c_str()));
248 currRelBx->appendChild(hs);
251 DOMElement*
mu = m_doc->createElement(
X(
"mu"));
253 mu->setAttribute(
X(
"num"),
X(IntToString(
int(it->_index)).c_str()));
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()));
265 it = m_muons.erase(it);
272 if (!m_muons.empty()) {
273 throw cms::Exception(
"RPCMuonsGrabber") <<
" There are still some muons in muons vec" << std::endl;
278 std::stringstream
ss;
const XMLCh * unicodeForm() const
std::string IntToString(int i)
static MuonsGrabber & Instance()
void startNewEvent(int event, int bx)
XStr(const char *const toTranscode)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void addMuon(RPCTBMuon &mu, int lvl, int region, int hs, int index)
void writeDataForRelativeBX(int bx)