CMS 3D CMS Logo

TotemDAQMappingESSourceXML.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Maciej Wróbel (wroblisko@gmail.com)
6 * Jan Kašpar (jan.kaspar@cern.ch)
7 * Marcin Borratynski (mborratynski@gmail.com)
8 * Seyed Mohsen Etesami (setesami@cern.ch)
9 * Laurent Forthomme
10 ****************************************************************************/
11 
22 
26 
33 
34 #include <xercesc/parsers/XercesDOMParser.hpp>
35 #include <xercesc/dom/DOM.hpp>
36 #include <xercesc/sax/HandlerBase.hpp>
37 #include <xercesc/util/XMLString.hpp>
38 #include <xercesc/util/PlatformUtils.hpp>
39 
40 #include <memory>
41 #include <sstream>
42 
43 //#define DEBUG 1
44 
45 //----------------------------------------------------------------------------------------------------
46 
47 using namespace std;
48 
53 public:
54  static const std::string tagVFAT;
55  static const std::string tagChannel;
57 
59  static const std::string tagArm;
60 
62  static const std::string tagRPStation;
63  static const std::string tagRPPot;
64  static const std::string tagRPPlane;
65 
67  static const std::string tagChip1;
68  static const std::string tagChip2;
69 
72  static const std::string tagDiamondCh;
73 
76  static const std::string tagSampicCh;
79 
81  ~TotemDAQMappingESSourceXML() override;
82 
83  edm::ESProducts<std::unique_ptr<TotemDAQMapping>, std::unique_ptr<TotemAnalysisMask>> produce(const TotemReadoutRcd &);
84 
85 private:
86  unsigned int verbosity;
87 
89  string subSystemName;
90 
92  std::vector<std::string> mappingFileNames;
93 
94  struct ConfigBlock {
97 
99  std::vector<std::string> mappingFileNames;
100 
102  std::vector<std::string> maskFileNames;
103  };
104 
105  vector<ConfigBlock> configuration;
106 
108  unsigned int currentBlock;
109 
112 
114  enum NodeType {
129  nTotemTimingCh
130  };
131 
133  enum ParseType { pMapping, pMask };
134 
136  void ParseXML(ParseType,
137  const string &file,
138  const std::unique_ptr<TotemDAQMapping> &,
139  const std::unique_ptr<TotemAnalysisMask> &);
140 
142  void ParseTreeRP(ParseType,
143  xercesc::DOMNode *,
144  NodeType,
145  unsigned int parentID,
146  const std::unique_ptr<TotemDAQMapping> &,
147  const std::unique_ptr<TotemAnalysisMask> &);
148 
150  void ParseTreeDiamond(ParseType,
151  xercesc::DOMNode *,
152  NodeType,
153  unsigned int parentID,
154  const std::unique_ptr<TotemDAQMapping> &,
155  const std::unique_ptr<TotemAnalysisMask> &);
156 
158  void ParseTreeTotemTiming(ParseType,
159  xercesc::DOMNode *,
160  NodeType,
161  unsigned int parentID,
162  const std::unique_ptr<TotemDAQMapping> &,
163  const std::unique_ptr<TotemAnalysisMask> &);
164 
165 private:
167  string CompleteFileName(const string &fn);
168 
170  bool Test(xercesc::DOMNode *node, const std::string &name) {
171  return !(name.compare(cms::xerces::toString(node->getNodeName())));
172  }
173 
175  NodeType GetNodeType(xercesc::DOMNode *);
176 
178  string GetNodeContent(xercesc::DOMNode *parent) { return string(cms::xerces::toString(parent->getTextContent())); }
179 
181  string GetNodeValue(xercesc::DOMNode *node) { return cms::xerces::toString(node->getNodeValue()); }
182 
184  TotemFramePosition ChipFramePosition(xercesc::DOMNode *chipnode);
185 
186  void GetChannels(xercesc::DOMNode *n, std::set<unsigned char> &channels);
187 
189  return ((type == nArm) || (type == nRPStation) || (type == nRPPot) || (type == nRPPlane) || (type == nChip));
190  }
191 
193  return ((type == nArm) || (type == nRPStation) || (type == nRPPot) || (type == nDiamondPlane) ||
194  (type == nDiamondCh));
195  }
196 
198  return ((type == nArm) || (type == nRPStation) || (type == nRPPot) || (type == nSampicBoard) ||
199  (type == nSampicChannel) || (type == nTotemTimingPlane) || (type == nTotemTimingCh));
200  }
201 
202  bool CommonNode(NodeType type) { return ((type == nChip) || (type == nArm)); }
203 
204 protected:
206  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
207  const edm::IOVSyncValue &,
208  edm::ValidityInterval &) override;
209 };
210 
211 //----------------------------------------------------------------------------------------------------
212 
213 using namespace std;
214 using namespace edm;
215 using namespace xercesc;
216 
217 const string TotemDAQMappingESSourceXML::tagVFAT = "vfat";
218 const string TotemDAQMappingESSourceXML::tagChannel = "channel";
219 const string TotemDAQMappingESSourceXML::tagAnalysisMask = "analysisMask";
220 
221 // common XML position tags
222 const string TotemDAQMappingESSourceXML::tagArm = "arm";
223 
224 // common XML Chip tags
225 const string TotemDAQMappingESSourceXML::tagChip1 = "vfat";
226 const string TotemDAQMappingESSourceXML::tagChip2 = "test_vfat";
227 
228 // specific RP XML tags
229 const string TotemDAQMappingESSourceXML::tagRPStation = "station";
230 const string TotemDAQMappingESSourceXML::tagRPPot = "rp_detector_set";
231 const string TotemDAQMappingESSourceXML::tagRPPlane = "rp_plane";
232 
233 // specific tags for diamond
234 const string TotemDAQMappingESSourceXML::tagDiamondPlane = "rp_plane_diamond";
235 const string TotemDAQMappingESSourceXML::tagDiamondCh = "diamond_channel";
236 
237 // specific tags for totem timing
238 const string TotemDAQMappingESSourceXML::tagSampicBoard = "rp_sampic_board";
239 const string TotemDAQMappingESSourceXML::tagSampicCh = "rp_sampic_channel";
240 const string TotemDAQMappingESSourceXML::tagTotemTimingCh = "timing_channel";
241 const string TotemDAQMappingESSourceXML::tagTotemTimingPlane = "timing_plane";
242 
243 //----------------------------------------------------------------------------------------------------
244 
246  : verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
247  subSystemName(conf.getUntrackedParameter<string>("subSystem")),
248  currentBlock(0),
249  currentBlockValid(false) {
250  for (const auto &it : conf.getParameter<vector<ParameterSet>>("configuration")) {
251  ConfigBlock b;
252  b.validityRange = it.getParameter<EventRange>("validityRange");
253  b.mappingFileNames = it.getParameter<vector<string>>("mappingFileNames");
254  b.maskFileNames = it.getParameter<vector<string>>("maskFileNames");
255  configuration.push_back(b);
256  }
257 
259  findingRecord<TotemReadoutRcd>();
260 }
261 
262 //----------------------------------------------------------------------------------------------------
263 
265  const edm::IOVSyncValue &iosv,
266  edm::ValidityInterval &oValidity) {
267  LogVerbatim("TotemDAQMappingESSourceXML") << ">> TotemDAQMappingESSourceXML::setIntervalFor(" << key.name() << ")";
268 
269  LogVerbatim("TotemDAQMappingESSourceXML")
270  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
271 
272  currentBlockValid = false;
273  for (unsigned int idx = 0; idx < configuration.size(); ++idx) {
274  const auto &bl = configuration[idx];
275 
276  edm::EventRange range = bl.validityRange;
277 
278  // If "<run>:min" is specified in python config, it is translated into event <run>:0:1.
279  // However, the truly minimal event id often found in data is <run>:0:0. Therefore the
280  // adjustment below is needed.
281  if (range.startEventID().luminosityBlock() == 0 && range.startEventID().event() == 1)
282  range = edm::EventRange(edm::EventID(range.startEventID().run(), 0, 0), range.endEventID());
283 
284  if (edm::contains(range, iosv.eventID())) {
285  currentBlockValid = true;
286  currentBlock = idx;
287 
288  const IOVSyncValue begin(range.startEventID());
289  const IOVSyncValue end(range.endEventID());
290  oValidity = edm::ValidityInterval(begin, end);
291 
292  LogVerbatim("TotemDAQMappingESSourceXML") << " block found: index=" << currentBlock << ", interval=("
293  << range.startEventID() << " - " << range.endEventID() << ")";
294 
295  return;
296  }
297  }
298 
299  if (!currentBlockValid) {
300  throw cms::Exception("TotemDAQMappingESSourceXML::setIntervalFor")
301  << "No configuration for event " << iosv.eventID();
302  }
303 }
304 
305 //----------------------------------------------------------------------------------------------------
306 
308 
309 //----------------------------------------------------------------------------------------------------
310 
312  FileInPath fip(fn);
313  return fip.fullPath();
314 }
315 
316 //----------------------------------------------------------------------------------------------------
317 
318 edm::ESProducts<std::unique_ptr<TotemDAQMapping>, std::unique_ptr<TotemAnalysisMask>>
321 
322  auto mapping = std::make_unique<TotemDAQMapping>();
323  auto mask = std::make_unique<TotemAnalysisMask>();
324 
325  // initialize Xerces
327 
328  // load mapping files
329  for (const auto &fn : configuration[currentBlock].mappingFileNames)
331 
332  // load mask files
333  for (const auto &fn : configuration[currentBlock].maskFileNames)
335 
336  // release Xerces
338 
339  // commit the products
341 }
342 
343 //----------------------------------------------------------------------------------------------------
344 
346  const string &file,
347  const std::unique_ptr<TotemDAQMapping> &mapping,
348  const std::unique_ptr<TotemAnalysisMask> &mask) {
349  unique_ptr<XercesDOMParser> parser(new XercesDOMParser());
350  parser->parse(file.c_str());
351 
352  DOMDocument *domDoc = parser->getDocument();
353 
354  if (!domDoc)
355  throw cms::Exception("TotemDAQMappingESSourceXML::ParseXML")
356  << "Cannot parse file `" << file << "' (domDoc = NULL).";
357 
358  DOMElement *elementRoot = domDoc->getDocumentElement();
359 
360  if (!elementRoot)
361  throw cms::Exception("TotemDAQMappingESSourceXML::ParseXML") << "File `" << file << "' is empty.";
362 
363  ParseTreeRP(pType, elementRoot, nTop, 0, mapping, mask);
364 
365  ParseTreeDiamond(pType, elementRoot, nTop, 0, mapping, mask);
366 
367  ParseTreeTotemTiming(pType, elementRoot, nTop, 0, mapping, mask);
368 }
369 
370 //-----------------------------------------------------------------------------------------------------------
371 
373  xercesc::DOMNode *parent,
374  NodeType parentType,
375  unsigned int parentID,
376  const std::unique_ptr<TotemDAQMapping> &mapping,
377  const std::unique_ptr<TotemAnalysisMask> &mask) {
378 #ifdef DEBUG
379  printf(">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n",
380  cms::xerces::toString(parent->getNodeName()),
381  parentType,
382  parentID);
383 #endif
384 
385  DOMNodeList *children = parent->getChildNodes();
386 
387  for (unsigned int i = 0; i < children->getLength(); i++) {
388  DOMNode *n = children->item(i);
389  if (n->getNodeType() != DOMNode::ELEMENT_NODE)
390  continue;
391 
393 
394 #ifdef DEBUG
395  printf("\tname = %s, type = %u\n", cms::xerces::toString(n->getNodeName()), type);
396 #endif
397 
398  // structure control
399  if (!RPNode(type))
400  continue;
401 
402  NodeType expectedParentType;
403  switch (type) {
404  case nArm:
405  expectedParentType = nTop;
406  break;
407  case nRPStation:
408  expectedParentType = nArm;
409  break;
410  case nRPPot:
411  expectedParentType = nRPStation;
412  break;
413  case nRPPlane:
414  expectedParentType = nRPPot;
415  break;
416  case nChip:
417  expectedParentType = nRPPlane;
418  break;
419  case nChannel:
420  expectedParentType = nChip;
421  break;
422  default:
423  expectedParentType = nUnknown;
424  break;
425  }
426 
427  if (expectedParentType != parentType) {
428  throw cms::Exception("TotemDAQMappingESSourceXML")
429  << "Node " << cms::xerces::toString(n->getNodeName()) << " not allowed within "
430  << cms::xerces::toString(parent->getNodeName()) << " block.\n";
431  }
432 
433  // parse tag attributes
434  unsigned int id = 0, hw_id = 0;
435  bool id_set = false, hw_id_set = false;
436  bool fullMask = false;
437  DOMNamedNodeMap *attr = n->getAttributes();
438 
439  for (unsigned int j = 0; j < attr->getLength(); j++) {
440  DOMNode *a = attr->item(j);
441 
442  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id")) {
443  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
444  id_set = true;
445  }
446 
447  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "hw_id")) {
448  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%x", &hw_id);
449  hw_id_set = true;
450  }
451 
452  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "full_mask"))
453  fullMask = (strcmp(cms::xerces::toString(a->getNodeValue()).c_str(), "no") != 0);
454  }
455 
456  // content control
457  if (!id_set)
458  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP")
459  << "id not given for element `" << cms::xerces::toString(n->getNodeName()) << "'";
460 
461  if (!hw_id_set && type == nChip && pType == pMapping)
462  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP")
463  << "hw_id not given for element `" << cms::xerces::toString(n->getNodeName()) << "'";
464 
465  if (type == nRPPlane && id > 9)
466  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP")
467  << "Plane IDs range from 0 to 9. id = " << id << " is invalid.";
468 
469 #ifdef DEBUG
470  printf("\tID found: 0x%x\n", id);
471 #endif
472 
473  // store mapping data
474  if (pType == pMapping && type == nChip) {
475  const TotemFramePosition &framepos = ChipFramePosition(n);
476  TotemVFATInfo vfatInfo;
477  vfatInfo.hwID = hw_id;
478 
479  const unsigned int armIdx = (parentID / 1000) % 10;
480  const unsigned int stIdx = (parentID / 100) % 10;
481  const unsigned int rpIdx = (parentID / 10) % 10;
482  const unsigned int plIdx = parentID % 10;
483 
484  vfatInfo.symbolicID.symbolicID = TotemRPDetId(armIdx, stIdx, rpIdx, plIdx, id);
485 
486  mapping->insert(framepos, vfatInfo);
487 
488  continue;
489  }
490 
491  // store mask data
492  if (pType == pMask && type == nChip) {
493  const unsigned int armIdx = (parentID / 1000) % 10;
494  const unsigned int stIdx = (parentID / 100) % 10;
495  const unsigned int rpIdx = (parentID / 10) % 10;
496  const unsigned int plIdx = parentID % 10;
497 
498  TotemSymbID symbId;
499  symbId.symbolicID = TotemRPDetId(armIdx, stIdx, rpIdx, plIdx, id);
500 
502  am.fullMask = fullMask;
504 
505  mask->insert(symbId, am);
506 
507  continue;
508  }
509 
510  // recursion (deeper in the tree)
511  ParseTreeRP(pType, n, type, parentID * 10 + id, mapping, mask);
512  }
513 }
514 
515 //----------------------------------------------------------------------------------------------------
516 
518  xercesc::DOMNode *parent,
519  NodeType parentType,
520  unsigned int parentID,
521  const std::unique_ptr<TotemDAQMapping> &mapping,
522  const std::unique_ptr<TotemAnalysisMask> &mask) {
523 #ifdef DEBUG
524  printf(">> TotemDAQMappingESSourceXML::ParseTreeDiamond(%s, %u, %u)\n",
525  cms::xerces::toString(parent->getNodeName()),
526  parentType,
527  parentID);
528 #endif
529 
530  DOMNodeList *children = parent->getChildNodes();
531 
532  for (unsigned int i = 0; i < children->getLength(); i++) {
533  DOMNode *n = children->item(i);
534  if (n->getNodeType() != DOMNode::ELEMENT_NODE)
535  continue;
536 
538 #ifdef DEBUG
539  printf("\tname = %s, type = %u\n", cms::xerces::toString(n->getNodeName()), type);
540 #endif
541 
542  // structure control
543  if (!DiamondNode(type))
544  continue;
545 
546  NodeType expectedParentType;
547  switch (type) {
548  case nArm:
549  expectedParentType = nTop;
550  break;
551  case nRPStation:
552  expectedParentType = nArm;
553  break;
554  case nRPPot:
555  expectedParentType = nRPStation;
556  break;
557  case nDiamondPlane:
558  expectedParentType = nRPPot;
559  break;
560  case nDiamondCh:
561  expectedParentType = nDiamondPlane;
562  break;
563  default:
564  expectedParentType = nUnknown;
565  break;
566  }
567 
568  if (expectedParentType != parentType) {
569  throw cms::Exception("TotemDAQMappingESSourceXML")
570  << "Node " << cms::xerces::toString(n->getNodeName()) << " not allowed within "
571  << cms::xerces::toString(parent->getNodeName()) << " block.\n";
572  }
573 
574  // parse tag attributes
575  unsigned int id = 0, hw_id = 0;
576  bool id_set = false, hw_id_set = false;
577  DOMNamedNodeMap *attr = n->getAttributes();
578 
579  for (unsigned int j = 0; j < attr->getLength(); j++) {
580  DOMNode *a = attr->item(j);
581 
582  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id")) {
583  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
584  id_set = true;
585  }
586 
587  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "hw_id")) {
588  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%x", &hw_id);
589  hw_id_set = true;
590  }
591  }
592 
593  // content control
594  if (!id_set)
595  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeDiamond")
596  << "id not given for element `" << cms::xerces::toString(n->getNodeName()) << "'";
597 
598  if (!hw_id_set && type == nDiamondCh && pType == pMapping)
599  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeDiamond")
600  << "hw_id not given for element `" << cms::xerces::toString(n->getNodeName()) << "'";
601 
602  if (type == nDiamondPlane && id > 3)
603  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeDiamond")
604  << "Plane IDs range from 0 to 3. id = " << id << " is invalid.";
605 
606 #ifdef DEBUG
607  printf("\tID found: 0x%x\n", id);
608 #endif
609 
610  // store mapping data
611  if (pType == pMapping && type == nDiamondCh) {
612  const TotemFramePosition &framepos = ChipFramePosition(n);
613 
614  TotemVFATInfo vfatInfo;
615  vfatInfo.hwID = hw_id;
616 
617  if (type == nDiamondCh) {
618  unsigned int ArmNum = (parentID / 10000) % 10;
619  unsigned int StationNum = (parentID / 1000) % 10;
620  unsigned int RpNum = (parentID / 100) % 10;
621  unsigned int PlaneNum = (parentID % 100);
622 
623  vfatInfo.symbolicID.symbolicID = CTPPSDiamondDetId(ArmNum, StationNum, RpNum, PlaneNum, id);
624  }
625 
626  mapping->insert(framepos, vfatInfo);
627 
628  continue;
629  }
630 
631  unsigned int childId;
632  if (pType == pMapping && type == nDiamondPlane)
633  childId = parentID * 100 + id;
634  else
635  childId = parentID * 10 + id;
636 
637  ParseTreeDiamond(pType, n, type, childId, mapping, mask);
638  }
639 }
640 
641 //----------------------------------------------------------------------------------------------------
642 
644  xercesc::DOMNode *parent,
645  NodeType parentType,
646  unsigned int parentID,
647  const std::unique_ptr<TotemDAQMapping> &mapping,
648  const std::unique_ptr<TotemAnalysisMask> &mask) {
649  DOMNodeList *children = parent->getChildNodes();
650 
651  // Fill map hwId -> TotemTimingPlaneChannelPair
652  for (unsigned int i = 0; i < children->getLength(); i++) {
653  DOMNode *child = children->item(i);
654  if ((child->getNodeType() != DOMNode::ELEMENT_NODE) || (GetNodeType(child) != nTotemTimingCh))
655  continue;
656 
657  int plane = -1;
658  DOMNamedNodeMap *attr = parent->getAttributes();
659  for (unsigned int j = 0; j < attr->getLength(); j++) {
660  DOMNode *a = attr->item(j);
661 
662  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id"))
663  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%d", &plane);
664  }
665 
666  int channel = -1;
667  unsigned int hwId = 0;
668  attr = child->getAttributes();
669  for (unsigned int j = 0; j < attr->getLength(); j++) {
670  DOMNode *a = attr->item(j);
671 
672  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id"))
673  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%d", &channel);
674  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "hwId"))
675  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%x", &hwId);
676  }
677 
678  mapping->totemTimingChannelMap[(uint8_t)hwId] = TotemDAQMapping::TotemTimingPlaneChannelPair(plane, channel);
679  }
680 
681  for (unsigned int i = 0; i < children->getLength(); i++) {
682  DOMNode *n = children->item(i);
683  if (n->getNodeType() != DOMNode::ELEMENT_NODE)
684  continue;
685 
687 
688  // structure control
689  if (!TotemTimingNode(type))
690  continue;
691 
692  NodeType expectedParentType;
693  switch (type) {
694  case nArm:
695  expectedParentType = nTop;
696  break;
697  case nRPStation:
698  expectedParentType = nArm;
699  break;
700  case nRPPot:
701  expectedParentType = nRPStation;
702  break;
703  case nSampicBoard:
704  expectedParentType = nRPPot;
705  break;
706  case nSampicChannel:
707  expectedParentType = nSampicBoard;
708  break;
709  case nTotemTimingPlane:
710  expectedParentType = nRPPot;
711  break;
712  case nTotemTimingCh:
713  expectedParentType = nTotemTimingPlane;
714  break;
715  default:
716  expectedParentType = nUnknown;
717  break;
718  }
719 
720  if (expectedParentType != parentType) {
721  throw cms::Exception("TotemDAQMappingESSourceXML")
722  << "Node " << cms::xerces::toString(n->getNodeName()) << " not allowed within "
723  << cms::xerces::toString(parent->getNodeName()) << " block.\n";
724  }
725 
726  // parse tag attributes
727  unsigned int id = 0;
728  bool id_set = false;
729  DOMNamedNodeMap *attr = n->getAttributes();
730 
731  for (unsigned int j = 0; j < attr->getLength(); j++) {
732  DOMNode *a = attr->item(j);
733 
734  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id")) {
735  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
736  id_set = true;
737  }
738  }
739 
740  // content control
741  if (!id_set)
742  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
743  << "id not given for element `" << cms::xerces::toString(n->getNodeName()) << "'";
744  if (type == nSampicBoard && id > 5)
745  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
746  << "SampicBoard IDs range from 0 to 5. id = " << id << " is invalid.";
747 
748  // store mapping data
749  if (pType == pMapping && type == nSampicChannel) {
750  const TotemFramePosition &framepos = ChipFramePosition(n);
751 
752  TotemVFATInfo vfatInfo;
753  unsigned int ArmNum = (parentID / 10000) % 10;
754  unsigned int StationNum = (parentID / 1000) % 10;
755  unsigned int RpNum = (parentID / 100) % 10;
756 
758  ArmNum, StationNum, RpNum, 0, TotemTimingDetId::ID_NOT_SET); //Dynamical: it is encoded in the frame
759 
760  mapping->insert(framepos, vfatInfo);
761 
762  continue;
763  }
764 
765  unsigned int childId;
766  if (pType == pMapping && type == nSampicBoard)
767  childId = parentID * 100 + id;
768  else
769  childId = parentID * 10 + id;
770 
771  ParseTreeTotemTiming(pType, n, type, childId, mapping, mask);
772  }
773 }
774 
775 //----------------------------------------------------------------------------------------------------
776 
779  unsigned char attributeFlag = 0;
780 
781  DOMNamedNodeMap *attr = chipnode->getAttributes();
782  for (unsigned int j = 0; j < attr->getLength(); j++) {
783  DOMNode *a = attr->item(j);
784  if (fp.setXMLAttribute(
785  cms::xerces::toString(a->getNodeName()), cms::xerces::toString(a->getNodeValue()), attributeFlag) > 1) {
786  throw cms::Exception("TotemDAQMappingESSourceXML")
787  << "Unrecognized tag `" << cms::xerces::toString(a->getNodeName()) << "' or incompatible value `"
788  << cms::xerces::toString(a->getNodeValue()) << "'.";
789  }
790  }
791 
792  if (!fp.checkXMLAttributeFlag(attributeFlag)) {
793  throw cms::Exception("TotemDAQMappingESSourceXML")
794  << "Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag << ").";
795  }
796 
797  return fp;
798 }
799 
800 //----------------------------------------------------------------------------------------------------
801 
803  // common node types
804  if (Test(n, tagArm))
805  return nArm;
806  if (Test(n, tagChip1))
807  return nChip;
808  if (Test(n, tagChip2))
809  return nChip;
810 
811  // RP node types
812  if (Test(n, tagRPStation))
813  return nRPStation;
814  if (Test(n, tagRPPot))
815  return nRPPot;
816  if (Test(n, tagRPPlane))
817  return nRPPlane;
818 
819  //diamond specifics
820  if (Test(n, tagDiamondCh))
821  return nDiamondCh;
822  if (Test(n, tagDiamondPlane))
823  return nDiamondPlane;
824 
825  //totem timing specifics
826  if (Test(n, tagSampicBoard))
827  return nSampicBoard;
828  if (Test(n, tagSampicCh))
829  return nSampicChannel;
830  if (Test(n, tagTotemTimingCh))
831  return nTotemTimingCh;
832  if (Test(n, tagTotemTimingPlane))
833  return nTotemTimingPlane;
834 
835  // for backward compatibility
836  if (Test(n, "trigger_vfat"))
837  return nSkip;
838 
839  throw cms::Exception("TotemDAQMappingESSourceXML::GetNodeType")
840  << "Unknown tag `" << cms::xerces::toString(n->getNodeName()) << "'.\n";
841 }
842 
843 //----------------------------------------------------------------------------------------------------
844 
845 void TotemDAQMappingESSourceXML::GetChannels(xercesc::DOMNode *n, set<unsigned char> &channels) {
846  DOMNodeList *children = n->getChildNodes();
847  for (unsigned int i = 0; i < children->getLength(); i++) {
848  DOMNode *n = children->item(i);
849  if (n->getNodeType() != DOMNode::ELEMENT_NODE || !Test(n, "channel"))
850  continue;
851 
852  DOMNamedNodeMap *attr = n->getAttributes();
853  bool idSet = false;
854  for (unsigned int j = 0; j < attr->getLength(); j++) {
855  DOMNode *a = attr->item(j);
856 
857  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id")) {
858  unsigned int id = 0;
859  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
860  channels.insert(id);
861  idSet = true;
862  break;
863  }
864  }
865 
866  if (!idSet) {
867  throw cms::Exception("TotemDAQMappingESSourceXML::GetChannels") << "Channel tags must have an `id' attribute.";
868  }
869  }
870 }
871 
872 //----------------------------------------------------------------------------------------------------
873 
TotemDAQMappingESSourceXML::ParseTreeTotemTiming
void ParseTreeTotemTiming(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::unique_ptr< TotemDAQMapping > &, const std::unique_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
Definition: TotemDAQMappingESSourceXML.cc:643
TotemDAQMappingESSourceXML::subSystemName
string subSystemName
label of the CTPPS sub-system
Definition: TotemDAQMappingESSourceXML.cc:89
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
XercesStrUtils.h
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
TotemReadoutRcd.h
TotemDAQMappingESSourceXML::tagSampicCh
static const std::string tagSampicCh
Definition: TotemDAQMappingESSourceXML.cc:76
TotemDAQMappingESSourceXML::tagDiamondCh
static const std::string tagDiamondCh
Definition: TotemDAQMappingESSourceXML.cc:72
mps_fire.i
i
Definition: mps_fire.py:428
TotemDAQMappingESSourceXML::ParseTreeDiamond
void ParseTreeDiamond(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::unique_ptr< TotemDAQMapping > &, const std::unique_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
Definition: TotemDAQMappingESSourceXML.cc:517
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
TotemDAQMappingESSourceXML::configuration
vector< ConfigBlock > configuration
Definition: TotemDAQMappingESSourceXML.cc:105
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
TotemVFATAnalysisMask::fullMask
bool fullMask
whether all channels of the VFAT shall be masked
Definition: TotemAnalysisMask.h:33
TotemTimingDetId::ID_NOT_SET
Definition: TotemTimingDetId.h:32
TotemDAQMappingESSourceXML::NodeType
NodeType
enumeration of XML node types
Definition: TotemDAQMappingESSourceXML.cc:114
ESHandle.h
TotemDAQMappingESSourceXML::GetNodeType
NodeType GetNodeType(xercesc::DOMNode *)
determines node type
Definition: TotemDAQMappingESSourceXML.cc:802
TotemDAQMappingESSourceXML::tagAnalysisMask
static const std::string tagAnalysisMask
Definition: TotemDAQMappingESSourceXML.cc:56
edm
HLT enums.
Definition: AlignableModifier.h:19
class-composition.children
children
Definition: class-composition.py:88
TotemDAQMapping.h
TotemDAQMappingESSourceXML::ConfigBlock
Definition: TotemDAQMappingESSourceXML.cc:94
TotemDAQMappingESSourceXML::ConfigBlock::maskFileNames
std::vector< std::string > maskFileNames
the mask files
Definition: TotemDAQMappingESSourceXML.cc:102
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
TotemDAQMappingESSourceXML::TotemDAQMappingESSourceXML
TotemDAQMappingESSourceXML(const edm::ParameterSet &)
Definition: TotemDAQMappingESSourceXML.cc:245
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
TotemDAQMappingESSourceXML::~TotemDAQMappingESSourceXML
~TotemDAQMappingESSourceXML() override
Definition: TotemDAQMappingESSourceXML.cc:307
cms::cuda::assert
assert(be >=bs)
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
edm::ESProducts
Definition: ESProducts.h:105
personalPlayback.fp
fp
Definition: personalPlayback.py:523
TotemReadoutRcd
EventSetup record for TOTEM readout-related information.
Definition: TotemReadoutRcd.h:16
TotemDAQMappingESSourceXML::tagChip2
static const std::string tagChip2
Definition: TotemDAQMappingESSourceXML.cc:68
TotemDAQMappingESSourceXML::GetChannels
void GetChannels(xercesc::DOMNode *n, std::set< unsigned char > &channels)
Definition: TotemDAQMappingESSourceXML.cc:845
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
TotemDAQMappingESSourceXML::verbosity
unsigned int verbosity
Definition: TotemDAQMappingESSourceXML.cc:86
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
TotemDAQMappingESSourceXML::tagVFAT
static const std::string tagVFAT
Definition: TotemDAQMappingESSourceXML.cc:54
TotemDAQMappingESSourceXML::nSampicChannel
Definition: TotemDAQMappingESSourceXML.cc:127
TotemDAQMappingESSourceXML::nTop
Definition: TotemDAQMappingESSourceXML.cc:117
edm::es::products
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&... args)
Definition: ESProducts.h:128
TotemVFATInfo
Contains mappind data related to a VFAT.
Definition: TotemDAQMapping.h:23
TotemDAQMappingESSourceXML::CompleteFileName
string CompleteFileName(const string &fn)
adds the path prefix, if needed
Definition: TotemDAQMappingESSourceXML.cc:311
TotemDAQMappingESSourceXML::GetNodeValue
string GetNodeValue(xercesc::DOMNode *node)
returns the value of the node
Definition: TotemDAQMappingESSourceXML.cc:181
TotemDAQMappingESSourceXML::RPNode
bool RPNode(NodeType type)
Definition: TotemDAQMappingESSourceXML.cc:188
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
TotemDAQMappingESSourceXML::nSkip
Definition: TotemDAQMappingESSourceXML.cc:116
TotemDAQMappingESSourceXML::currentBlock
unsigned int currentBlock
index of the current block in 'configuration' array
Definition: TotemDAQMappingESSourceXML.cc:108
TotemDAQMappingESSourceXML::nDiamondPlane
Definition: TotemDAQMappingESSourceXML.cc:122
TotemDAQMappingESSourceXML::ParseTreeRP
void ParseTreeRP(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::unique_ptr< TotemDAQMapping > &, const std::unique_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
Definition: TotemDAQMappingESSourceXML.cc:372
TotemTimingDetId.h
TotemDAQMappingESSourceXML::tagTotemTimingCh
static const std::string tagTotemTimingCh
Definition: TotemDAQMappingESSourceXML.cc:77
mps_fire.end
end
Definition: mps_fire.py:242
TotemDAQMappingESSourceXML::tagRPPot
static const std::string tagRPPot
Definition: TotemDAQMappingESSourceXML.cc:63
TotemDAQMappingESSourceXML
Loads TotemDAQMapping and TotemAnalysisMask from two XML files.
Definition: TotemDAQMappingESSourceXML.cc:52
ctppsRawToDigi_cff.maskFileNames
maskFileNames
Definition: ctppsRawToDigi_cff.py:16
TotemDAQMappingESSourceXML::tagDiamondPlane
static const std::string tagDiamondPlane
diamond specific tags
Definition: TotemDAQMappingESSourceXML.cc:71
TotemAnalysisMask.h
TotemDAQMappingESSourceXML::pMapping
Definition: TotemDAQMappingESSourceXML.cc:133
TotemDAQMapping::TotemTimingPlaneChannelPair
Hw Id mapping for Totem Timing (dynamical mapping in Sampic)
Definition: TotemDAQMapping.h:44
TotemDAQMappingESSourceXML::tagChip1
static const std::string tagChip1
COMMON Chip XML tags.
Definition: TotemDAQMappingESSourceXML.cc:67
b
double b
Definition: hdecay.h:118
TotemDAQMappingESSourceXML::tagSampicBoard
static const std::string tagSampicBoard
totem timing specific tags
Definition: TotemDAQMappingESSourceXML.cc:75
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ESProducts.h
TotemDAQMappingESSourceXML::ConfigBlock::mappingFileNames
std::vector< std::string > mappingFileNames
the mapping files
Definition: TotemDAQMappingESSourceXML.cc:99
TotemTimingDetId
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...
Definition: TotemTimingDetId.h:26
CTPPSDiamondDetId.h
TotemDAQMappingESSourceXML::nChannel
Definition: TotemDAQMappingESSourceXML.cc:125
SourceFactory.h
TotemDAQMappingESSourceXML::GetNodeContent
string GetNodeContent(xercesc::DOMNode *parent)
returns the content of the node
Definition: TotemDAQMappingESSourceXML.cc:178
TotemDAQMappingESSourceXML::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
sets infinite validity of this data
Definition: TotemDAQMappingESSourceXML.cc:264
edm::IOVSyncValue::eventID
const EventID & eventID() const
Definition: IOVSyncValue.h:40
TotemDAQMappingESSourceXML::nRPStation
Definition: TotemDAQMappingESSourceXML.cc:119
CTPPSDiamondDetId
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
Definition: CTPPSDiamondDetId.h:24
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
TotemSymbID
Symbolic ID describing an entity of a TOTEM subdetector.
Definition: TotemSymbId.h:16
TotemDAQMappingESSourceXML::currentBlockValid
bool currentBlockValid
flag whether the 'currentBlock' index is valid
Definition: TotemDAQMappingESSourceXML.cc:111
TotemSymbID::symbolicID
unsigned int symbolicID
chip ID, raw integer representation of DetId class
Definition: TotemSymbId.h:24
TotemDAQMappingESSourceXML::ConfigBlock::validityRange
edm::EventRange validityRange
validity interval
Definition: TotemDAQMappingESSourceXML.cc:96
TotemFramePosition
Definition: TotemFramePosition.h:31
TotemDAQMappingESSourceXML::produce
edm::ESProducts< std::unique_ptr< TotemDAQMapping >, std::unique_ptr< TotemAnalysisMask > > produce(const TotemReadoutRcd &)
Definition: TotemDAQMappingESSourceXML.cc:319
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
TotemDAQMappingESSourceXML::tagChannel
static const std::string tagChannel
Definition: TotemDAQMappingESSourceXML.cc:55
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
TotemFramePosition.h
createfilelist.int
int
Definition: createfilelist.py:10
TotemDAQMappingESSourceXML::tagRPPlane
static const std::string tagRPPlane
Definition: TotemDAQMappingESSourceXML.cc:64
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
Xerces.h
cms::concurrency::xercesTerminate
void xercesTerminate()
Definition: Xerces.cc:23
TotemDAQMappingESSourceXML::pMask
Definition: TotemDAQMappingESSourceXML.cc:133
TotemDAQMappingESSourceXML::CommonNode
bool CommonNode(NodeType type)
Definition: TotemDAQMappingESSourceXML.cc:202
TotemDAQMappingESSourceXML::nChip
Definition: TotemDAQMappingESSourceXML.cc:123
edm::contains
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
TotemDAQMappingESSourceXML::tagTotemTimingPlane
static const std::string tagTotemTimingPlane
Definition: TotemDAQMappingESSourceXML.cc:78
hlx_dqm_sourceclient_cfi.subSystemName
subSystemName
Definition: hlx_dqm_sourceclient_cfi.py:15
TotemDAQMappingESSourceXML::nUnknown
Definition: TotemDAQMappingESSourceXML.cc:115
TotemDAQMappingESSourceXML::ParseXML
void ParseXML(ParseType, const string &file, const std::unique_ptr< TotemDAQMapping > &, const std::unique_ptr< TotemAnalysisMask > &)
parses XML file
Definition: TotemDAQMappingESSourceXML.cc:345
ModuleFactory.h
TotemDAQMappingESSourceXML::mappingFileNames
std::vector< std::string > mappingFileNames
the mapping files
Definition: TotemDAQMappingESSourceXML.cc:92
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TotemVFATInfo::hwID
unsigned int hwID
the hardware ID (16 bit)
Definition: TotemDAQMapping.h:35
TotemDAQMappingESSourceXML::nTotemTimingPlane
Definition: TotemDAQMappingESSourceXML.cc:128
TotemDAQMappingESSourceXML::nDiamondCh
Definition: TotemDAQMappingESSourceXML.cc:124
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
TotemDAQMappingESSourceXML::nRPPlane
Definition: TotemDAQMappingESSourceXML.cc:121
TotemDAQMappingESSourceXML::tagRPStation
static const std::string tagRPStation
RP XML tags.
Definition: TotemDAQMappingESSourceXML.cc:62
Exception
Definition: hltDiff.cc:245
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
TotemDAQMappingESSourceXML::ChipFramePosition
TotemFramePosition ChipFramePosition(xercesc::DOMNode *chipnode)
extracts VFAT's DAQ channel from XML attributes
Definition: TotemDAQMappingESSourceXML.cc:777
TotemDAQMappingESSourceXML::nTotemTimingCh
Definition: TotemDAQMappingESSourceXML.cc:129
TotemRPDetId.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
personalPlayback.fn
fn
Definition: personalPlayback.py:515
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TotemDAQMappingESSourceXML::DiamondNode
bool DiamondNode(NodeType type)
Definition: TotemDAQMappingESSourceXML.cc:192
TotemDAQMappingESSourceXML::nSampicBoard
Definition: TotemDAQMappingESSourceXML.cc:126
edm::ESProducer
Definition: ESProducer.h:104
TotemDAQMappingESSourceXML::tagArm
static const std::string tagArm
Common position tags.
Definition: TotemDAQMappingESSourceXML.cc:59
TotemDAQMappingESSourceXML::TotemTimingNode
bool TotemTimingNode(NodeType type)
Definition: TotemDAQMappingESSourceXML.cc:197
ParameterSet.h
TotemVFATInfo::symbolicID
TotemSymbID symbolicID
the symbolic id
Definition: TotemDAQMapping.h:32
TotemDAQMappingESSourceXML::ParseType
ParseType
whether to parse a mapping of a mask XML
Definition: TotemDAQMappingESSourceXML.cc:133
TotemDAQMappingESSourceXML::Test
bool Test(xercesc::DOMNode *node, const std::string &name)
returns true iff the node is of the given name
Definition: TotemDAQMappingESSourceXML.cc:170
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::EventID
Definition: EventID.h:31
edm::EventRange
Definition: EventRange.h:31
child
Definition: simpleInheritance.h:11
crabWrapper.key
key
Definition: crabWrapper.py:19
cms::concurrency::xercesInitialize
void xercesInitialize()
Definition: Xerces.cc:18
TotemDAQMappingESSourceXML::nRPPot
Definition: TotemDAQMappingESSourceXML.cc:120
taus_updatedMVAIds_cff.mapping
mapping
Definition: taus_updatedMVAIds_cff.py:29
class-composition.parent
parent
Definition: class-composition.py:88
TotemRPDetId
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:29
TotemVFATAnalysisMask
Contains data on masked channels of a VFAT.
Definition: TotemAnalysisMask.h:22
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
TotemDAQMappingESSourceXML::nArm
Definition: TotemDAQMappingESSourceXML.cc:118
TotemVFATAnalysisMask::maskedChannels
std::set< unsigned char > maskedChannels
list of channels to be masked
Definition: TotemAnalysisMask.h:36