CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
MuonsGrabber Class Reference

#include <L1Trigger/RPCTrigger/interface/MuonsGrabber.h>

Public Member Functions

void addMuon (RPCTBMuon &mu, int lvl, int region, int hs, int index)
 
void setRPCBasicTrigConfig (RPCBasicTrigConfig *c)
 
void startNewEvent (int event, int bx)
 
void writeDataForRelativeBX (int bx)
 

Static Public Member Functions

static MuonsGrabberInstance ()
 

Private Member Functions

std::string IntToString (int i)
 
 MuonsGrabber ()
 
 MuonsGrabber (const MuonsGrabber &)=delete
 
const MuonsGrabberoperator= (const MuonsGrabber &)=delete
 
virtual ~MuonsGrabber ()
 

Private Attributes

int m_currentBX
 
int m_currentEvent
 
XERCES_CPP_NAMESPACE::DOMElement * m_currEvent
 
XERCES_CPP_NAMESPACE::DOMDocument * m_doc
 
XERCES_CPP_NAMESPACE::DOMImplementation * m_dom
 
std::vector< RPCMuonExtraStructm_muons
 
XERCES_CPP_NAMESPACE::DOMElement * m_rootElem
 
RPCBasicTrigConfigm_trigConfig
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 53 of file MuonsGrabber.h.

Constructor & Destructor Documentation

MuonsGrabber::MuonsGrabber ( )
private

Definition at line 70 of file MuonsGrabber.cc.

References Exception, AlCaHLTBitMon_QueryRunRegistry::string, X, and cms::concurrency::xercesInitialize().

71 {
72 
73  try {
75  }
76  catch(const XMLException &toCatch) {
77  throw std::string("Error during Xerces-c Initialization: "
78  + std::string(XMLString::transcode(toCatch.getMessage())));
79  }
80 
81  m_dom = DOMImplementationRegistry::getDOMImplementation(X("Core"));
82  if (m_dom == nullptr) throw cms::Exception("RPCMuonsGrabber") << "Cannot get DOM" << std::endl;
83 
84  m_doc = m_dom->createDocument(
85  nullptr, // root element namespace URI.
86  X("rpctDataStream"), // root element name
87  nullptr); // document type object (DTD).
88 
89  m_rootElem = m_doc->getDocumentElement();
90 
91  m_currEvent = nullptr;
92 }
XERCES_CPP_NAMESPACE::DOMImplementation * m_dom
Definition: MuonsGrabber.h:80
#define X(str)
Definition: MuonsGrabber.cc:48
void xercesInitialize()
Definition: Xerces.cc:18
XERCES_CPP_NAMESPACE::DOMElement * m_rootElem
Definition: MuonsGrabber.h:82
XERCES_CPP_NAMESPACE::DOMDocument * m_doc
Definition: MuonsGrabber.h:81
XERCES_CPP_NAMESPACE::DOMElement * m_currEvent
Definition: MuonsGrabber.h:83
MuonsGrabber::~MuonsGrabber ( )
privatevirtual

Definition at line 100 of file MuonsGrabber.cc.

References X, and cms::concurrency::xercesTerminate().

101 {
102 
103  // save xmlfile
104  XMLCh tempStr[100];
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"));
112 
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\""));
117 
118  m_doc->insertBefore(xmlstylesheet, m_rootElem);
119  theSerializer->write(m_doc, outputDesc);
120 
121  delete theSerializer;
122  delete myFormTarget;
123  m_doc->release();
125 }
void xercesTerminate()
Definition: Xerces.cc:23
#define X(str)
Definition: MuonsGrabber.cc:48
XERCES_CPP_NAMESPACE::DOMElement * m_rootElem
Definition: MuonsGrabber.h:82
XERCES_CPP_NAMESPACE::DOMDocument * m_doc
Definition: MuonsGrabber.h:81
MuonsGrabber::MuonsGrabber ( const MuonsGrabber )
privatedelete

Member Function Documentation

void MuonsGrabber::addMuon ( RPCTBMuon mu,
int  lvl,
int  region,
int  hs,
int  index 
)

Definition at line 141 of file MuonsGrabber.cc.

References RPCMuon::getPtCode().

Referenced by RPCHalfSorter::run(), RPCFinalSorter::run(), RPCTriggerBoard::runCone(), RPCPacTrigger::runEvent(), and RPCTriggerCrate::runTCGBSorter().

141  {
142 
143  if (mu.getPtCode()>0) m_muons.push_back( RPCMuonExtraStruct(lvl, region, hs, index, mu) );
144 }
int getPtCode() const
Definition: RPCMuon.cc:66
std::vector< RPCMuonExtraStruct > m_muons
Definition: MuonsGrabber.h:75
MuonsGrabber & MuonsGrabber::Instance ( )
static

Definition at line 58 of file MuonsGrabber.cc.

Referenced by RPCTrigger::produce(), RPCHalfSorter::run(), RPCFinalSorter::run(), RPCTriggerBoard::runCone(), RPCPacTrigger::runEvent(), and RPCTriggerCrate::runTCGBSorter().

58  {
59 
60  static MuonsGrabber grabber;
61  return grabber;
62 
63 
64 }
std::string MuonsGrabber::IntToString ( int  i)
private

Definition at line 314 of file MuonsGrabber.cc.

References mps_fire::i.

314  {
315 
316  std::stringstream ss;
317  ss << i;
318 
319  return ss.str();
320 
321 }
const MuonsGrabber& MuonsGrabber::operator= ( const MuonsGrabber )
privatedelete
void MuonsGrabber::setRPCBasicTrigConfig ( RPCBasicTrigConfig c)
inline

Definition at line 61 of file MuonsGrabber.h.

References EnergyCorrector::c, mps_fire::i, RPCpg::mu, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by RPCTrigger::produce().

61 {m_trigConfig = c;};
RPCBasicTrigConfig * m_trigConfig
Definition: MuonsGrabber.h:76
void MuonsGrabber::startNewEvent ( int  event,
int  bx 
)

Definition at line 127 of file MuonsGrabber.cc.

References event(), and X.

Referenced by RPCTrigger::produce().

127  {
128 
129  //<event bx="0" num="0">
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);
134 
135 
137  m_currentBX = bx;
138 }
std::string IntToString(int i)
#define X(str)
Definition: MuonsGrabber.cc:48
XERCES_CPP_NAMESPACE::DOMElement * m_rootElem
Definition: MuonsGrabber.h:82
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
XERCES_CPP_NAMESPACE::DOMDocument * m_doc
Definition: MuonsGrabber.h:81
XERCES_CPP_NAMESPACE::DOMElement * m_currEvent
Definition: MuonsGrabber.h:83
int m_currentEvent
Definition: MuonsGrabber.h:78
Definition: event.py:1
void MuonsGrabber::writeDataForRelativeBX ( int  bx)

Definition at line 146 of file MuonsGrabber.cc.

References Exception, createfilelist::int, hcalDigis_cfi::level, RPCMuonExtraStruct::lvlCompare(), RPCpg::mu, and X.

Referenced by RPCTrigger::produce().

146  {
147 
148  if (m_muons.empty()) return;
149 
150  //<bxData num="11">
151  DOMElement* currRelBx = m_doc->createElement(X("bxData"));
152  currRelBx->setAttribute(X("num"), X( IntToString(bx).c_str()));
153  m_currEvent->appendChild(currRelBx);
154 
155  //std::cout << "Writing out for relBx " << bx << std::endl;
156 
157  // <hs num="1" be="0">
158  // levels
159  // 0 - PAC
160  // 1 - tbgs
161  // 2 - tcgs
162  // 3 - hs
163  // 4 fs
164 
165  std::sort(m_muons.begin(), m_muons.end(), RPCMuonExtraStruct::lvlCompare) ;
166  for (int tcNum = 0; tcNum <= 11; ++tcNum ) {
167  DOMElement* tc = nullptr;
168  DOMElement* tcgs = nullptr;
169  for (int tbNum = 0; tbNum <= 10; ++tbNum ) { // check actual range, probably till 9 total
170  DOMElement* tb = nullptr;
171  DOMElement* tbgs = nullptr;
172  for (int PAC = 0; PAC <= 4; ++PAC ) { // same here
173 
174  DOMElement* pac = nullptr;
175  // for (int segment = 0; segment <= 11; ++segment ) {
176  std::vector< RPCMuonExtraStruct >::iterator it = m_muons.begin();
177  while ( it != m_muons.end()) {
178  int muSegment = it->_mu.getLogSegment();
179  //if
180 
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() );
184 
185  if (
186  !(
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 )
190  )
191  )
192 
193  {
194  ++it;
195  continue;
196  }
197  // std::cout << int(it->_level) << int(it->_region) << int(it->_hsHalf)
198  // << " " << int(it->_index)
199  // << " " << it->_mu.printDebugInfo(2) << std::endl;
200 
201 
202  if (tc==nullptr) {
203  tc = m_doc->createElement(X("tc"));
204  currRelBx->appendChild(tc);
205  tc->setAttribute(X("num"), X( IntToString(tcNum).c_str()));
206 
207  tcgs = m_doc->createElement(X("tcgs"));
208  tc->appendChild(tcgs);
209 
210  }
211  if (tb==nullptr && int(it->_level) <= 1) {
212  tb = m_doc->createElement(X("tb"));
213  tc->appendChild(tb);
214  tb->setAttribute(X("num"), X( IntToString(tbNum).c_str()));
215 
216  tbgs = m_doc->createElement(X("tbgs"));
217  tb->appendChild(tbgs);
218  }
219 
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()));
224  }
225 
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()));
230 
231  if (int(it->_level) == 0 ) {
232  mu->setAttribute(X("num"), X( IntToString( muSegment ).c_str()));
233  pac->appendChild(mu);
234  } else {
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);
243  } else {
244  throw cms::Exception("RPCMuonsGrabber") << "xx Unexpected level" << std::endl;
245  }
246  }
247 
248 
249  it = m_muons.erase(it);
250 
251  } // muons iter
252  // } // segment
253  } // PAC
254  } // TB
255  } // TC
256 
257 
258 
259 
260  for (int level=3; level<=4;++level) {
261  for (int half =0; half <= 1; ++half){
262  for (int be =0; be <= 1; ++be){ // brl/endcap
263 
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 ) {
268  ++it;
269  continue;
270  }
271 
272  if (hs == nullptr) {
273  if (level == 3) {
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"));
278  } else { // shoudlnt get here
279  throw cms::Exception("RPCMuonsGrabber") << "Problem writing out muons - lvl " << level << std::endl;
280  }
281  hs->setAttribute(X("be"), X( IntToString(be).c_str()));
282  currRelBx->appendChild(hs);
283  }
284 
285  DOMElement* mu = m_doc->createElement(X("mu"));
286  hs->appendChild(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()));
294 
295  //std::cout << int(it->_level) << int(it->_region) << int(it->_hsHalf)
296  // << " " << int(it->_index)
297  // << " " << it->_mu.printDebugInfo(2) << std::endl;
298 
299  it = m_muons.erase(it);
300 
301  } // muons iter
302  } // be iter
303  } //half iteration
304  } // lvl iteration
305 
306  if (!m_muons.empty()) {
307  throw cms::Exception("RPCMuonsGrabber") << " There are still some muons in muons vec" << std::endl;
308 
309  }
310 }
int getTCNum(const RPCConst::l1RpcConeCrdnts &coneCrdnts) override
Returns the index of TC that should run given LogCone.
std::string IntToString(int i)
#define X(str)
Definition: MuonsGrabber.cc:48
static bool lvlCompare(const RPCMuonExtraStruct &a, const RPCMuonExtraStruct &b)
Definition: MuonsGrabber.h:48
RPCBasicTrigConfig * m_trigConfig
Definition: MuonsGrabber.h:76
const int mu
Definition: Constants.h:22
int getTBNum(const RPCConst::l1RpcConeCrdnts &coneCrdnts) override
Returns the index of TB (in TC) that should run given LogCone.
XERCES_CPP_NAMESPACE::DOMDocument * m_doc
Definition: MuonsGrabber.h:81
std::vector< RPCMuonExtraStruct > m_muons
Definition: MuonsGrabber.h:75
XERCES_CPP_NAMESPACE::DOMElement * m_currEvent
Definition: MuonsGrabber.h:83
int getTowerNumOnTb(const RPCConst::l1RpcConeCrdnts &coneCrdnts) override

Member Data Documentation

int MuonsGrabber::m_currentBX
private

Definition at line 79 of file MuonsGrabber.h.

int MuonsGrabber::m_currentEvent
private

Definition at line 78 of file MuonsGrabber.h.

XERCES_CPP_NAMESPACE::DOMElement* MuonsGrabber::m_currEvent
private

Definition at line 83 of file MuonsGrabber.h.

XERCES_CPP_NAMESPACE::DOMDocument* MuonsGrabber::m_doc
private

Definition at line 81 of file MuonsGrabber.h.

XERCES_CPP_NAMESPACE::DOMImplementation* MuonsGrabber::m_dom
private

Definition at line 80 of file MuonsGrabber.h.

std::vector< RPCMuonExtraStruct > MuonsGrabber::m_muons
private

Definition at line 75 of file MuonsGrabber.h.

XERCES_CPP_NAMESPACE::DOMElement* MuonsGrabber::m_rootElem
private

Definition at line 82 of file MuonsGrabber.h.

RPCBasicTrigConfig* MuonsGrabber::m_trigConfig
private

Definition at line 76 of file MuonsGrabber.h.