CMS 3D CMS Logo

Functions
StandaloneTrackerTopology Namespace Reference

Functions

TrackerTopology fromTrackerParametersXML (const std::string &xmlFileName)
 

Function Documentation

TrackerTopology StandaloneTrackerTopology::fromTrackerParametersXML ( const std::string &  xmlFileName)

Construct a TrackerTopology from a trackerParameters.xml file

WARNING: this method has been introduced to construct a TrackerTopology object only for the rare cases where it cannot be retrieved from an edm::EventSetup (e.g. ROOT macros).

Definition at line 69 of file StandaloneTrackerTopology.cc.

References TrackerTopology::PixelEndcapValues::bladeMask_, TrackerTopology::PixelEndcapValues::bladeStartBit_, TrackerTopology::PixelEndcapValues::diskMask_, TrackerTopology::PixelEndcapValues::diskStartBit_, common_cff::doc, Exception, TrackerTopology::PixelBarrelValues::ladderMask_, TrackerTopology::PixelBarrelValues::ladderStartBit_, TrackerTopology::PixelBarrelValues::layerMask_, TrackerTopology::TIBValues::layerMask_, TrackerTopology::TOBValues::layerMask_, TrackerTopology::PixelBarrelValues::layerStartBit_, TrackerTopology::TIBValues::layerStartBit_, TrackerTopology::TOBValues::layerStartBit_, TrackerTopology::TIDValues::module_fw_bwMask_, TrackerTopology::TIDValues::module_fw_bwStartBit_, TrackerTopology::PixelBarrelValues::moduleMask_, TrackerTopology::PixelEndcapValues::moduleMask_, TrackerTopology::TECValues::moduleMask_, TrackerTopology::TIBValues::moduleMask_, TrackerTopology::TIDValues::moduleMask_, TrackerTopology::TOBValues::moduleMask_, TrackerTopology::PixelBarrelValues::moduleStartBit_, TrackerTopology::PixelEndcapValues::moduleStartBit_, TrackerTopology::TECValues::moduleStartBit_, TrackerTopology::TIBValues::moduleStartBit_, TrackerTopology::TIDValues::moduleStartBit_, TrackerTopology::TOBValues::moduleStartBit_, TrackerTopology::PixelEndcapValues::panelMask_, TrackerTopology::PixelEndcapValues::panelStartBit_, createfilelist::parser, TrackerTopology::TECValues::petal_fw_bwMask_, TrackerTopology::TECValues::petal_fw_bwStartBit_, TrackerTopology::TECValues::petalMask_, TrackerTopology::TECValues::petalStartBit_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::TECValues::ringMask_, TrackerTopology::TIDValues::ringMask_, TrackerTopology::TECValues::ringStartBit_, TrackerTopology::TIDValues::ringStartBit_, TrackerTopology::TOBValues::rod_fw_bwMask_, TrackerTopology::TOBValues::rod_fw_bwStartBit_, TrackerTopology::TOBValues::rodMask_, TrackerTopology::TOBValues::rodStartBit_, TrackerTopology::PixelEndcapValues::sideMask_, TrackerTopology::TECValues::sideMask_, TrackerTopology::TIDValues::sideMask_, TrackerTopology::PixelEndcapValues::sideStartBit_, TrackerTopology::TECValues::sideStartBit_, TrackerTopology::TIDValues::sideStartBit_, TrackerTopology::TECValues::sterMask_, TrackerTopology::TIBValues::sterMask_, TrackerTopology::TIDValues::sterMask_, TrackerTopology::TOBValues::sterMask_, TrackerTopology::TECValues::sterStartBit_, TrackerTopology::TIBValues::sterStartBit_, TrackerTopology::TIDValues::sterStartBit_, TrackerTopology::TOBValues::sterStartBit_, TrackerTopology::TIBValues::str_fw_bwMask_, TrackerTopology::TIBValues::str_fw_bwStartBit_, TrackerTopology::TIBValues::str_int_extMask_, TrackerTopology::TIBValues::str_int_extStartBit_, AlCaHLTBitMon_QueryRunRegistry::string, TrackerTopology::TIBValues::strMask_, TrackerTopology::TIBValues::strStartBit_, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, create_public_pileup_plots::vals, TrackerTopology::TECValues::wheelMask_, TrackerTopology::TIDValues::wheelMask_, TrackerTopology::TECValues::wheelStartBit_, TrackerTopology::TIDValues::wheelStartBit_, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

70 {
77 
78  try {
80  } catch ( const XMLException& xmlEx ) {
81  throw cms::Exception("StandaloneTrackerTopology",
82  "XML exception at initialization : " + xmlc_to_stdstring(xmlEx.getMessage()));
83  }
84 
85  { // scope for the parser, and all dependent DOM manipulation
86  std::unique_ptr<XercesDOMParser> parser{new XercesDOMParser()};
87  parser->setValidationScheme(XercesDOMParser::Val_Always);
88 
89  std::unique_ptr<ErrorHandler> errHandler{static_cast<ErrorHandler*>(new HandlerBase())};
90  parser->setErrorHandler(errHandler.get());
91 
92  try {
93  parser->parse(xmlFileName.c_str());
94  } catch ( const XMLException& xmlEx ) {
95  throw cms::Exception("StandaloneTrackerTopology",
96  "XML exception when parsing " + xmlFileName + " : " + xmlc_to_stdstring(xmlEx.getMessage()));
97  } catch ( const DOMException& domEx ) {
98  throw cms::Exception("StandaloneTrackerTopology",
99  "DOM exception when parsing " + xmlFileName + " : " + xmlc_to_stdstring(domEx.getMessage()));
100  } catch ( const SAXException& saxEx ) {
101  throw cms::Exception("StandaloneTrackerTopology",
102  "SAX exception when parsing " + xmlFileName + " : " + xmlc_to_stdstring(saxEx.getMessage()));
103  }
104 
105  const std::string subdetName{"Subdetector"};
106  auto_XMLString nm_type{XMLString::transcode("type")};
107  auto_XMLString nm_name{XMLString::transcode("name")};
108  auto_XMLString nm_nEntries{XMLString::transcode("nEntries")};
109 
110  try {
111  DOMDocument* doc{parser->getDocument()};
112  DOMElement* docRootNode{doc->getDocumentElement()};
113  DOMNodeIterator* walker = doc->createNodeIterator(docRootNode, DOMNodeFilter::SHOW_ELEMENT, nullptr, true);
114  for ( DOMNode* currentNode = walker->nextNode(); currentNode; currentNode = walker->nextNode() ) {
115  const auto thisNodeName = xmlc_to_stdstring(currentNode->getNodeName());
116  if ( thisNodeName == "Vector" ) {
117  const auto attrs = currentNode->getAttributes();
118  const auto att_type = getAttr(attrs, nm_type);
119  if ( att_type == "numeric" ) {
120  const auto att_name = getAttr(attrs, nm_name);;
121  if ( 0 == att_name.compare(0, subdetName.size(), subdetName) ) {
122  const auto att_nEntries = getAttr(attrs, nm_nEntries);
123  const std::size_t nEntries = att_nEntries.empty() ? 0 : std::stoul(att_nEntries);
124  const auto vals = split_string_to_uints(xmlc_to_stdstring(currentNode->getTextContent()));
125  if ( nEntries != vals.size() ) {
126  throw cms::Exception("StandaloneTrackerTopology",
127  ("Problem parsing element with name '"+att_name+"' from '"+xmlFileName+"': "+
128  "'nEntries' attribute claims "+std::to_string(nEntries)+" elements, but parsed "+std::to_string(vals.size())));
129  }
130  const auto subDet = std::stoi(att_name.substr(subdetName.size()));
131  switch (subDet) {
132  case PixelSubdetector::PixelBarrel: // layer, ladder module
133  pxbVals.layerStartBit_ = vals[0];
134  pxbVals.ladderStartBit_ = vals[1];
135  pxbVals.moduleStartBit_ = vals[2];
136 
137  pxbVals.layerMask_ = vals[3];
138  pxbVals.ladderMask_ = vals[4];
139  pxbVals.moduleMask_ = vals[5];
140  break;
141 
142  case PixelSubdetector::PixelEndcap: // side, disk, blade, panel, module
143  pxfVals.sideStartBit_ = vals[0];
144  pxfVals.diskStartBit_ = vals[1];
145  pxfVals.bladeStartBit_ = vals[2];
146  pxfVals.panelStartBit_ = vals[3];
147  pxfVals.moduleStartBit_ = vals[4];
148 
149  pxfVals.sideMask_ = vals[5];
150  pxfVals.diskMask_ = vals[6];
151  pxfVals.bladeMask_ = vals[7];
152  pxfVals.panelMask_ = vals[8];
153  pxfVals.moduleMask_ = vals[9];
154  break;
155 
156  case StripSubdetector::TIB: // layer, str_fw_bw, str_int_ext, str, module, ster
157  tibVals.layerStartBit_ = vals[ 0];
158  tibVals.str_fw_bwStartBit_ = vals[ 1];
159  tibVals.str_int_extStartBit_ = vals[ 2];
160  tibVals.strStartBit_ = vals[ 3];
161  tibVals.moduleStartBit_ = vals[ 4];
162  tibVals.sterStartBit_ = vals[ 5];
163 
164  tibVals.layerMask_ = vals[ 6];
165  tibVals.str_fw_bwMask_ = vals[ 7];
166  tibVals.str_int_extMask_ = vals[ 8];
167  tibVals.strMask_ = vals[ 9];
168  tibVals.moduleMask_ = vals[10];
169  tibVals.sterMask_ = vals[11];
170  break;
171 
172  case StripSubdetector::TID: // side, wheel, ring, module_fw_bw, module, ster
173  tidVals.sideStartBit_ = vals[ 0];
174  tidVals.wheelStartBit_ = vals[ 1];
175  tidVals.ringStartBit_ = vals[ 2];
176  tidVals.module_fw_bwStartBit_ = vals[ 3];
177  tidVals.moduleStartBit_ = vals[ 4];
178  tidVals.sterStartBit_ = vals[ 5];
179 
180  tidVals.sideMask_ = vals[ 6];
181  tidVals.wheelMask_ = vals[ 7];
182  tidVals.ringMask_ = vals[ 8];
183  tidVals.module_fw_bwMask_ = vals[ 9];
184  tidVals.moduleMask_ = vals[10];
185  tidVals.sterMask_ = vals[11];
186  break;
187 
188  case StripSubdetector::TOB: // layer, rod_fw_bw, rod, module, ster
189  tobVals.layerStartBit_ = vals[0];
190  tobVals.rod_fw_bwStartBit_ = vals[1];
191  tobVals.rodStartBit_ = vals[2];
192  tobVals.moduleStartBit_ = vals[3];
193  tobVals.sterStartBit_ = vals[4];
194 
195  tobVals.layerMask_ = vals[5];
196  tobVals.rod_fw_bwMask_ = vals[6];
197  tobVals.rodMask_ = vals[7];
198  tobVals.moduleMask_ = vals[8];
199  tobVals.sterMask_ = vals[9];
200  break;
201 
202  case StripSubdetector::TEC: // side, wheel, petal_fw_bw, petal, ring, module, ster
203  tecVals.sideStartBit_ = vals[ 0];
204  tecVals.wheelStartBit_ = vals[ 1];
205  tecVals.petal_fw_bwStartBit_ = vals[ 2];
206  tecVals.petalStartBit_ = vals[ 3];
207  tecVals.ringStartBit_ = vals[ 4];
208  tecVals.moduleStartBit_ = vals[ 5];
209  tecVals.sterStartBit_ = vals[ 6];
210 
211  tecVals.sideMask_ = vals[ 7];
212  tecVals.wheelMask_ = vals[ 8];
213  tecVals.petal_fw_bwMask_ = vals[ 9];
214  tecVals.petalMask_ = vals[10];
215  tecVals.ringMask_ = vals[11];
216  tecVals.moduleMask_ = vals[12];
217  tecVals.sterMask_ = vals[13];
218  break;
219  }
220  }
221  }
222  }
223  }
224  } catch ( const DOMException& domEx ) {
225  throw cms::Exception("StandaloneTrackerTopology",
226  "DOM exception in "+xmlFileName+" : "+xmlc_to_stdstring(domEx.getMessage()));
227  }
228 
229  } // parser and DOM scope
231 
232  return TrackerTopology(pxbVals, pxfVals, tecVals, tibVals, tidVals, tobVals);
233 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
unsigned int module_fw_bwStartBit_