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)),
247 subSystemName(conf.getUntrackedParameter<
string>(
"subSystem")),
249 currentBlockValid(
false) {
250 for (
const auto &it : conf.
getParameter<vector<ParameterSet>>(
"configuration")) {
254 b.
maskFileNames = it.getParameter<vector<string>>(
"maskFileNames");
259 findingRecord<TotemReadoutRcd>();
267 LogVerbatim(
"TotemDAQMappingESSourceXML") <<
">> TotemDAQMappingESSourceXML::setIntervalFor(" << key.
name() <<
")";
273 for (
unsigned int idx = 0; idx <
configuration.size(); ++idx) {
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());
350 parser->parse(file.c_str());
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",
385 DOMNodeList *children = parent->getChildNodes();
387 for (
unsigned int i = 0;
i < children->getLength();
i++) {
388 DOMNode *
n = children->item(
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);
511 ParseTreeRP(pType, n, type, parentID * 10 +
id, mapping, mask);
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",
530 DOMNodeList *children = parent->getChildNodes();
532 for (
unsigned int i = 0;
i < children->getLength();
i++) {
533 DOMNode *
n = children->item(
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) {
649 DOMNodeList *children = parent->getChildNodes();
652 for (
unsigned int i = 0;
i < children->getLength();
i++) {
653 DOMNode *
child = children->item(
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++) {
682 DOMNode *
n = children->item(
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);
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++) {
848 DOMNode *n = children->item(
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.";
Detector ID class for TOTEM Si strip detectors.
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
EventNumber_t event() const
Contains data on masked channels of a VFAT.
static const std::string tagChannel
bool CommonNode(NodeType type)
string GetNodeContent(xercesc::DOMNode *parent)
returns the content of the node
bool contains(EventRange const &lh, EventID const &rh)
Loads TotemDAQMapping and TotemAnalysisMask from two XML files.
uint16_t *__restrict__ id
static const std::string tagDiamondPlane
diamond specific tags
edm::ESProducts< std::unique_ptr< TotemDAQMapping >, std::unique_ptr< TotemAnalysisMask > > produce(const TotemReadoutRcd &)
const EventID & eventID() const
bool TotemTimingNode(NodeType type)
edm::EventRange validityRange
validity interval
bool RPNode(NodeType type)
EventSetup record for TOTEM readout-related information.
bool currentBlockValid
flag whether the 'currentBlock' index is valid
NodeType
enumeration of XML node types
std::pair< Time_t, Time_t > ValidityInterval
TotemSymbID symbolicID
the symbolic id
static const std::string tagSampicCh
NodeType GetNodeType(xercesc::DOMNode *)
determines node type
std::vector< std::string > mappingFileNames
the mapping files
LuminosityBlockNumber_t luminosityBlock() const
static const std::string tagVFAT
static const std::string tagChip1
COMMON Chip XML tags.
string subSystemName
label of the CTPPS sub-system
ESProducts< std::remove_reference_t< TArgs >...> products(TArgs &&...args)
const uint16_t range(const Frame &aFrame)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
sets infinite validity of this data
std::string toString(XMLCh const *toTranscode)
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
vector< ConfigBlock > configuration
Symbolic ID describing an entity of a TOTEM subdetector.
static const std::string tagTotemTimingPlane
static const std::string tagDiamondCh
EventID startEventID() const
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
static const std::string tagRPStation
RP XML tags.
TotemFramePosition ChipFramePosition(xercesc::DOMNode *chipnode)
extracts VFAT's DAQ channel from XML attributes
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
const char * name() const
tuple key
prepare the HTCondor submission files and eventually submit them
EventID endEventID() const
std::vector< std::string > maskFileNames
the mask files
bool DiamondNode(NodeType type)
bool fullMask
whether all channels of the VFAT shall be masked
unsigned int symbolicID
chip ID, raw integer representation of DetId class
Hw Id mapping for Totem Timing (dynamical mapping in Sampic)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
static const std::string tagArm
Common position tags.
unsigned int hwID
the hardware ID (16 bit)
void ParseXML(ParseType, const string &file, const std::unique_ptr< TotemDAQMapping > &, const std::unique_ptr< TotemAnalysisMask > &)
parses XML file
T getParameter(std::string const &) const
TotemDAQMappingESSourceXML(const edm::ParameterSet &)
string GetNodeValue(xercesc::DOMNode *node)
returns the value of the node
ParseType
whether to parse a mapping of a mask XML
bool Test(xercesc::DOMNode *node, const std::string &name)
returns true iff the node is of the given name
static const std::string tagAnalysisMask
static const std::string tagChip2
std::set< unsigned char > maskedChannels
list of channels to be masked
unsigned int currentBlock
index of the current block in 'configuration' array
static const std::string tagSampicBoard
totem timing specific tags
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
std::string fullPath() const
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
static const std::string tagRPPot
static const std::string tagRPPlane
std::vector< std::string > mappingFileNames
the mapping files
static const std::string tagTotemTimingCh
~TotemDAQMappingESSourceXML() override
void GetChannels(xercesc::DOMNode *n, std::set< unsigned char > &channels)
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
Contains mappind data related to a VFAT.
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
string CompleteFileName(const string &fn)
adds the path prefix, if needed
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...