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>
136 void ParseXML(ParseType,
138 const std::unique_ptr<TotemDAQMapping> &,
139 const std::unique_ptr<TotemAnalysisMask> &);
142 void ParseTreeRP(ParseType,
145 unsigned int parentID,
146 const std::unique_ptr<TotemDAQMapping> &,
147 const std::unique_ptr<TotemAnalysisMask> &);
150 void ParseTreeDiamond(ParseType,
153 unsigned int parentID,
154 const std::unique_ptr<TotemDAQMapping> &,
155 const std::unique_ptr<TotemAnalysisMask> &);
158 void ParseTreeTotemTiming(ParseType,
161 unsigned int parentID,
162 const std::unique_ptr<TotemDAQMapping> &,
163 const std::unique_ptr<TotemAnalysisMask> &);
167 string CompleteFileName(
const string &
fn);
175 NodeType GetNodeType(xercesc::DOMNode *);
186 void GetChannels(xercesc::DOMNode *
n, std::set<unsigned char> &
channels);
189 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nRPPlane) || (
type == nChip));
193 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nDiamondPlane) ||
194 (
type == nDiamondCh));
198 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nSampicBoard) ||
199 (
type == nSampicChannel) || (
type == nTotemTimingPlane) || (
type == nTotemTimingCh));
215 using namespace xercesc;
246 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
249 currentBlockValid(
false) {
250 for (
const auto &it : conf.
getParameter<vector<ParameterSet>>(
"configuration")) {
252 b.validityRange = it.getParameter<
EventRange>(
"validityRange");
253 b.mappingFileNames = it.getParameter<vector<string>>(
"mappingFileNames");
254 b.maskFileNames = it.getParameter<vector<string>>(
"maskFileNames");
259 findingRecord<TotemReadoutRcd>();
267 LogVerbatim(
"TotemDAQMappingESSourceXML") <<
">> TotemDAQMappingESSourceXML::setIntervalFor(" <<
key.name() <<
")";
281 if (
range.startEventID().luminosityBlock() == 0 &&
range.startEventID().event() == 1)
293 <<
range.startEventID() <<
" - " <<
range.endEventID() <<
")";
300 throw cms::Exception(
"TotemDAQMappingESSourceXML::setIntervalFor")
301 <<
"No configuration for event " << iosv.
eventID();
322 auto mapping = std::make_unique<TotemDAQMapping>();
323 auto mask = std::make_unique<TotemAnalysisMask>();
347 const std::unique_ptr<TotemDAQMapping> &
mapping,
348 const std::unique_ptr<TotemAnalysisMask> &mask) {
349 unique_ptr<XercesDOMParser>
parser(
new XercesDOMParser());
352 DOMDocument *domDoc =
parser->getDocument();
356 <<
"Cannot parse file `" <<
file <<
"' (domDoc = NULL).";
358 DOMElement *elementRoot = domDoc->getDocumentElement();
361 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseXML") <<
"File `" <<
file <<
"' is empty.";
375 unsigned int parentID,
376 const std::unique_ptr<TotemDAQMapping> &
mapping,
377 const std::unique_ptr<TotemAnalysisMask> &mask) {
379 printf(
">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n",
387 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
389 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
405 expectedParentType =
nTop;
408 expectedParentType =
nArm;
414 expectedParentType =
nRPPot;
420 expectedParentType =
nChip;
427 if (expectedParentType != parentType) {
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();
439 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
440 DOMNode *
a = attr->item(
j);
467 <<
"Plane IDs range from 0 to 9. id = " <<
id <<
" is invalid.";
470 printf(
"\tID found: 0x%x\n",
id);
477 vfatInfo.
hwID = hw_id;
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;
486 mapping->insert(framepos, vfatInfo);
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;
505 mask->insert(symbId, am);
520 unsigned int parentID,
521 const std::unique_ptr<TotemDAQMapping> &
mapping,
522 const std::unique_ptr<TotemAnalysisMask> &mask) {
524 printf(
">> TotemDAQMappingESSourceXML::ParseTreeDiamond(%s, %u, %u)\n",
532 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
534 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
549 expectedParentType =
nTop;
552 expectedParentType =
nArm;
558 expectedParentType =
nRPPot;
568 if (expectedParentType != parentType) {
575 unsigned int id = 0, hw_id = 0;
576 bool id_set =
false, hw_id_set =
false;
577 DOMNamedNodeMap *attr =
n->getAttributes();
579 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
580 DOMNode *
a = attr->item(
j);
595 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
599 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
603 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
604 <<
"Plane IDs range from 0 to 3. id = " <<
id <<
" is invalid.";
607 printf(
"\tID found: 0x%x\n",
id);
615 vfatInfo.
hwID = hw_id;
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);
626 mapping->insert(framepos, vfatInfo);
631 unsigned int childId;
633 childId = parentID * 100 +
id;
635 childId = parentID * 10 +
id;
646 unsigned int parentID,
647 const std::unique_ptr<TotemDAQMapping> &
mapping,
648 const std::unique_ptr<TotemAnalysisMask> &mask) {
652 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
658 DOMNamedNodeMap *attr =
parent->getAttributes();
659 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
660 DOMNode *
a = attr->item(
j);
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);
681 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
683 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
695 expectedParentType =
nTop;
698 expectedParentType =
nArm;
704 expectedParentType =
nRPPot;
710 expectedParentType =
nRPPot;
720 if (expectedParentType != parentType) {
729 DOMNamedNodeMap *attr =
n->getAttributes();
731 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
732 DOMNode *
a = attr->item(
j);
742 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
745 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
746 <<
"SampicBoard IDs range from 0 to 5. id = " <<
id <<
" is invalid.";
753 unsigned int ArmNum = (parentID / 10000) % 10;
754 unsigned int StationNum = (parentID / 1000) % 10;
755 unsigned int RpNum = (parentID / 100) % 10;
760 mapping->insert(framepos, vfatInfo);
765 unsigned int childId;
767 childId = parentID * 100 +
id;
769 childId = parentID * 10 +
id;
779 unsigned char attributeFlag = 0;
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(
792 if (!
fp.checkXMLAttributeFlag(attributeFlag)) {
794 <<
"Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag <<
").";
836 if (
Test(
n,
"trigger_vfat"))
846 DOMNodeList *
children =
n->getChildNodes();
847 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
849 if (
n->getNodeType() != DOMNode::ELEMENT_NODE || !
Test(
n,
"channel"))
852 DOMNamedNodeMap *attr =
n->getAttributes();
854 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
855 DOMNode *
a = attr->item(
j);
867 throw cms::Exception(
"TotemDAQMappingESSourceXML::GetChannels") <<
"Channel tags must have an `id' attribute.";