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> 139 void ParseXML(ParseType,
141 const std::unique_ptr<TotemDAQMapping> &,
142 const std::unique_ptr<TotemAnalysisMask> &);
145 void ParseTreeRP(ParseType,
148 unsigned int parentID,
149 const std::unique_ptr<TotemDAQMapping> &,
150 const std::unique_ptr<TotemAnalysisMask> &);
153 void ParseTreeDiamond(ParseType,
156 unsigned int parentID,
157 const std::unique_ptr<TotemDAQMapping> &,
158 const std::unique_ptr<TotemAnalysisMask> &);
161 void ParseTreeTotemTiming(ParseType,
164 unsigned int parentID,
165 const std::unique_ptr<TotemDAQMapping> &,
166 const std::unique_ptr<TotemAnalysisMask> &);
170 string CompleteFileName(
const string &
fn);
178 NodeType GetNodeType(xercesc::DOMNode *);
189 void GetChannels(xercesc::DOMNode *
n, std::set<unsigned char> &
channels);
192 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nRPPlane) || (
type == nChip));
196 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nDiamondPlane) ||
197 (
type == nDiamondCh));
201 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nSampicBoard) ||
202 (
type == nSampicChannel) || (
type == nTotemTimingPlane) || (
type == nTotemTimingCh));
249 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
253 currentBlockValid(
false) {
254 for (
const auto &it : conf.
getParameter<vector<ParameterSet>>(
"configuration")) {
256 b.validityRange = it.getParameter<
EventRange>(
"validityRange");
257 b.mappingFileNames = it.getParameter<vector<string>>(
"mappingFileNames");
258 b.maskFileNames = it.getParameter<vector<string>>(
"maskFileNames");
263 findingRecord<TotemReadoutRcd>();
271 LogVerbatim(
"TotemDAQMappingESSourceXML") <<
">> TotemDAQMappingESSourceXML::setIntervalFor(" <<
key.name() <<
")";
285 if (
range.startEventID().luminosityBlock() == 0 &&
range.startEventID().event() == 1)
297 <<
range.startEventID() <<
" - " <<
range.endEventID() <<
")";
304 throw cms::Exception(
"TotemDAQMappingESSourceXML::setIntervalFor")
305 <<
"No configuration for event " << iosv.
eventID();
326 auto mapping = std::make_unique<TotemDAQMapping>();
327 auto mask = std::make_unique<TotemAnalysisMask>();
351 const std::unique_ptr<TotemDAQMapping> &
mapping,
352 const std::unique_ptr<TotemAnalysisMask> &
mask) {
353 unique_ptr<XercesDOMParser>
parser(
new XercesDOMParser());
356 DOMDocument *domDoc =
parser->getDocument();
360 <<
"Cannot parse file `" <<
file <<
"' (domDoc = NULL).";
362 DOMElement *elementRoot = domDoc->getDocumentElement();
365 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseXML") <<
"File `" <<
file <<
"' is empty.";
379 unsigned int parentID,
380 const std::unique_ptr<TotemDAQMapping> &
mapping,
381 const std::unique_ptr<TotemAnalysisMask> &
mask) {
383 printf(
">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n",
391 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
393 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
409 expectedParentType =
nTop;
412 expectedParentType =
nArm;
418 expectedParentType =
nRPPot;
424 expectedParentType =
nChip;
431 if (expectedParentType != parentType) {
438 unsigned int id = 0, hw_id = 0;
439 bool id_set =
false, hw_id_set =
false;
440 bool fullMask =
false;
441 DOMNamedNodeMap *attr =
n->getAttributes();
443 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
444 DOMNode *
a = attr->item(
j);
471 <<
"Plane IDs range from 0 to 9. id = " <<
id <<
" is invalid.";
474 printf(
"\tID found: 0x%x\n",
id);
481 vfatInfo.
hwID = hw_id;
483 const unsigned int armIdx = (parentID / 1000) % 10;
484 const unsigned int stIdx = (parentID / 100) % 10;
485 const unsigned int rpIdx = (parentID / 10) % 10;
486 const unsigned int plIdx = parentID % 10;
490 mapping->insert(framepos, vfatInfo);
497 const unsigned int armIdx = (parentID / 1000) % 10;
498 const unsigned int stIdx = (parentID / 100) % 10;
499 const unsigned int rpIdx = (parentID / 10) % 10;
500 const unsigned int plIdx = parentID % 10;
509 mask->insert(symbId, am);
524 unsigned int parentID,
525 const std::unique_ptr<TotemDAQMapping> &
mapping,
526 const std::unique_ptr<TotemAnalysisMask> &
mask) {
528 printf(
">> TotemDAQMappingESSourceXML::ParseTreeDiamond(%s, %u, %u)\n",
536 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
538 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
553 expectedParentType =
nTop;
556 expectedParentType =
nArm;
562 expectedParentType =
nRPPot;
572 if (expectedParentType != parentType) {
579 unsigned int id = 0, hw_id = 0;
580 bool id_set =
false, hw_id_set =
false;
581 DOMNamedNodeMap *attr =
n->getAttributes();
583 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
584 DOMNode *
a = attr->item(
j);
599 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
603 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
607 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
608 <<
"Plane IDs range from 0 to 3. id = " <<
id <<
" is invalid.";
611 printf(
"\tID found: 0x%x\n",
id);
619 vfatInfo.
hwID = hw_id;
622 unsigned int ArmNum = (parentID / 10000) % 10;
623 unsigned int StationNum = (parentID / 1000) % 10;
624 unsigned int RpNum = (parentID / 100) % 10;
625 unsigned int PlaneNum = (parentID % 100);
630 mapping->insert(framepos, vfatInfo);
635 unsigned int childId;
637 childId = parentID * 100 +
id;
639 childId = parentID * 10 +
id;
650 unsigned int parentID,
651 const std::unique_ptr<TotemDAQMapping> &
mapping,
652 const std::unique_ptr<TotemAnalysisMask> &
mask) {
656 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
662 DOMNamedNodeMap *attr =
parent->getAttributes();
663 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
664 DOMNode *
a = attr->item(
j);
671 unsigned int hwId = 0;
672 attr =
child->getAttributes();
673 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
674 DOMNode *
a = attr->item(
j);
685 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
687 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
699 expectedParentType =
nTop;
702 expectedParentType =
nArm;
708 expectedParentType =
nRPPot;
714 expectedParentType =
nRPPot;
724 if (expectedParentType != parentType) {
733 DOMNamedNodeMap *attr =
n->getAttributes();
735 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
736 DOMNode *
a = attr->item(
j);
746 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
749 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
750 <<
"SampicBoard IDs range from 0 to 5. id = " <<
id <<
" is invalid.";
757 unsigned int ArmNum = (parentID / 10000) % 10;
758 unsigned int StationNum = (parentID / 1000) % 10;
759 unsigned int RpNum = (parentID / 100) % 10;
768 mapping->insert(framepos, vfatInfo);
773 unsigned int childId;
775 childId = parentID * 100 +
id;
777 childId = parentID * 10 +
id;
787 unsigned char attributeFlag = 0;
789 DOMNamedNodeMap *attr = chipnode->getAttributes();
790 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
791 DOMNode *
a = attr->item(
j);
792 if (
fp.setXMLAttribute(
800 if (!
fp.checkXMLAttributeFlag(attributeFlag)) {
802 <<
"Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag <<
").";
844 if (
Test(
n,
"trigger_vfat"))
854 DOMNodeList *
children =
n->getChildNodes();
855 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
857 if (
n->getNodeType() != DOMNode::ELEMENT_NODE || !
Test(
n,
"channel"))
860 DOMNamedNodeMap *attr =
n->getAttributes();
862 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
863 DOMNode *
a = attr->item(
j);
875 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={})
Contains data on masked channels of a VFAT.
static const std::string tagChannel
bool CommonNode(NodeType type)
T getParameter(std::string const &) const
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.
static const std::string tagDiamondPlane
diamond specific tags
edm::ESProducts< std::unique_ptr< TotemDAQMapping >, std::unique_ptr< TotemAnalysisMask > > produce(const TotemReadoutRcd &)
std::string fullPath() const
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&... args)
unsigned int sampicSubDetId
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
static const std::string tagVFAT
static const std::string tagChip1
COMMON Chip XML tags.
string subSystemName
label of the CTPPS sub-system
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
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
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
TotemDAQMappingESSourceXML(const edm::ParameterSet &)
string GetNodeValue(xercesc::DOMNode *node)
returns the value of the node
const EventID & eventID() const
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...
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)
Contains mappind data related to a VFAT.
EventNumber_t event() const
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 ...