18 #include <xercesc/util/XMLString.hpp> 19 #include <xercesc/dom/DOM.hpp> 20 #include <xercesc/framework/LocalFileFormatTarget.hpp> 29 XStr(
const char*
const toTranscode)
48 #define X(str) XStr(str).unicodeForm() 76 catch(
const XMLException &toCatch) {
77 throw std::string(
"Error during Xerces-c Initialization: " 78 +
std::string(XMLString::transcode(toCatch.getMessage())));
81 m_dom = DOMImplementationRegistry::getDOMImplementation(
X(
"Core"));
82 if (m_dom ==
nullptr)
throw cms::Exception(
"RPCMuonsGrabber") <<
"Cannot get DOM" << std::endl;
84 m_doc = m_dom->createDocument(
89 m_rootElem = m_doc->getDocumentElement();
91 m_currEvent =
nullptr;
105 XMLString::transcode(
"LS", tempStr, 99);
106 DOMImplementation *
impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
107 DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
108 DOMConfiguration *dc = theSerializer->getDomConfig();
109 dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
110 DOMLSOutput *outputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
111 outputDesc->setEncoding(
X(
"UTF-8"));
113 XMLFormatTarget *myFormTarget =
new LocalFileFormatTarget(
X(
"testpulses.xml"));
114 outputDesc->setByteStream(myFormTarget);
115 DOMNode* xmlstylesheet = m_doc->createProcessingInstruction(
X(
"xml-stylesheet"),
116 X(
"type=\"text/xsl\"href=\"default.xsl\""));
118 m_doc->insertBefore(xmlstylesheet, m_rootElem);
119 theSerializer->write(m_doc, outputDesc);
121 delete theSerializer;
130 m_currEvent = m_doc->createElement(
X(
"event"));
131 m_currEvent->setAttribute(
X(
"num"),
X( IntToString(event).c_str()));
132 m_currEvent->setAttribute(
X(
"bx"),
X( IntToString(bx).c_str()));
133 m_rootElem->appendChild(m_currEvent);
136 m_currentEvent =
event;
148 if (m_muons.empty())
return;
151 DOMElement* currRelBx = m_doc->createElement(
X(
"bxData"));
152 currRelBx->setAttribute(
X(
"num"),
X( IntToString(bx).c_str()));
153 m_currEvent->appendChild(currRelBx);
166 for (
int tcNum = 0; tcNum <= 11; ++tcNum ) {
167 DOMElement* tc =
nullptr;
168 DOMElement* tcgs =
nullptr;
169 for (
int tbNum = 0; tbNum <= 10; ++tbNum ) {
170 DOMElement* tb =
nullptr;
171 DOMElement* tbgs =
nullptr;
172 for (
int PAC = 0; PAC <= 4; ++PAC ) {
174 DOMElement* pac =
nullptr;
176 std::vector< RPCMuonExtraStruct >::iterator it = m_muons.begin();
177 while ( it != m_muons.end()) {
178 int muSegment = it->_mu.getLogSegment();
181 int muTBno = m_trigConfig->getTBNum( it->_mu.getConeCrdnts() );
182 int muPACChipNo = m_trigConfig->getTowerNumOnTb(it->_mu.getConeCrdnts() );
183 int muTC = m_trigConfig->getTCNum(it->_mu.getConeCrdnts() );
187 (
int(it->_level) == 0 && tbNum == muTBno && muTC == tcNum && PAC == muPACChipNo)
188 || (
int(it->_level) == 1 && tbNum == muTBno && muTC == tcNum )
189 || (
int(it->_level) == 2 && muTC == tcNum )
203 tc = m_doc->createElement(
X(
"tc"));
204 currRelBx->appendChild(tc);
205 tc->setAttribute(
X(
"num"),
X( IntToString(tcNum).c_str()));
207 tcgs = m_doc->createElement(
X(
"tcgs"));
208 tc->appendChild(tcgs);
211 if (tb==
nullptr &&
int(it->_level) <= 1) {
212 tb = m_doc->createElement(
X(
"tb"));
214 tb->setAttribute(
X(
"num"),
X( IntToString(tbNum).c_str()));
216 tbgs = m_doc->createElement(
X(
"tbgs"));
217 tb->appendChild(tbgs);
220 if (pac ==
nullptr &&
int(it->_level) == 0) {
221 pac =m_doc->createElement(
X(
"pac"));
222 tb->appendChild(pac);
223 pac->setAttribute(
X(
"num"),
X( IntToString(muPACChipNo).c_str()));
226 DOMElement*
mu = m_doc->createElement(
X(
"mu"));
227 mu->setAttribute(
X(
"pt"),
X( IntToString(
int(it->_mu.getPtCode() ) ).c_str()));
228 mu->setAttribute(
X(
"qual"),
X( IntToString(
int(it->_mu.getQuality() ) ).c_str()));
229 mu->setAttribute(
X(
"sign"),
X( IntToString(
int(it->_mu.getSign() ) ).c_str()));
231 if (
int(it->_level) == 0 ) {
232 mu->setAttribute(
X(
"num"),
X( IntToString( muSegment ).c_str()));
233 pac->appendChild(mu);
235 mu->setAttribute(
X(
"num"),
X( IntToString(
int(it->_index) ).c_str()));
236 mu->setAttribute(
X(
"phi"),
X( IntToString(
int(it->_mu.getPhiAddr() ) ).c_str()));
237 mu->setAttribute(
X(
"eta"),
X( IntToString(
int(it->_mu.getEtaAddr() ) ).c_str()));
238 mu->setAttribute(
X(
"gbD"),
X( IntToString(
int(it->_mu.getGBData() ) ).c_str()));
239 if (
int(it->_level) == 1 ) {
240 tbgs->appendChild(mu);
241 }
else if (
int(it->_level) == 2 ) {
242 tcgs->appendChild(mu);
244 throw cms::Exception(
"RPCMuonsGrabber") <<
"xx Unexpected level" << std::endl;
249 it = m_muons.erase(it);
261 for (
int half =0; half <= 1; ++half){
262 for (
int be =0; be <= 1; ++be){
264 std::vector< RPCMuonExtraStruct >::iterator it = m_muons.begin();
265 DOMElement* hs =
nullptr;
266 while ( it != m_muons.end()) {
267 if ( (
int(it->_level) !=
level) ||
int(it->_hsHalf)!=half ||
int(it->_region)!=be ) {
274 hs = m_doc->createElement(
X(
"hs"));
275 hs->setAttribute(
X(
"num"),
X( IntToString(half).c_str()));
276 }
else if (
level ==4 ) {
277 hs = m_doc->createElement(
X(
"fs"));
279 throw cms::Exception(
"RPCMuonsGrabber") <<
"Problem writing out muons - lvl " <<
level << std::endl;
281 hs->setAttribute(
X(
"be"),
X( IntToString(be).c_str()));
282 currRelBx->appendChild(hs);
285 DOMElement*
mu = m_doc->createElement(
X(
"mu"));
287 mu->setAttribute(
X(
"num"),
X( IntToString(
int(it->_index) ).c_str()));
288 mu->setAttribute(
X(
"pt"),
X( IntToString(
int(it->_mu.getPtCode() ) ).c_str()));
289 mu->setAttribute(
X(
"qual"),
X( IntToString(
int(it->_mu.getQuality() ) ).c_str()));
290 mu->setAttribute(
X(
"sign"),
X( IntToString(
int(it->_mu.getSign() ) ).c_str()));
291 mu->setAttribute(
X(
"phi"),
X( IntToString(
int(it->_mu.getPhiAddr() ) ).c_str()));
292 mu->setAttribute(
X(
"eta"),
X( IntToString(
int(it->_mu.getEtaAddr() ) ).c_str()));
293 mu->setAttribute(
X(
"gbD"),
X( IntToString(
int(it->_mu.getGBData() ) ).c_str()));
299 it = m_muons.erase(it);
306 if (!m_muons.empty()) {
307 throw cms::Exception(
"RPCMuonsGrabber") <<
" There are still some muons in muons vec" << std::endl;
316 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)