35 #include <xercesc/parsers/XercesDOMParser.hpp> 36 #include <xercesc/dom/DOM.hpp> 37 #include <xercesc/sax/HandlerBase.hpp> 38 #include <xercesc/util/XMLString.hpp> 39 #include <xercesc/util/PlatformUtils.hpp> 146 void ParseXML(ParseType,
148 const std::unique_ptr<TotemDAQMapping> &,
149 const std::unique_ptr<TotemAnalysisMask> &);
152 void ParseTreeRP(ParseType,
155 unsigned int parentID,
156 const std::unique_ptr<TotemDAQMapping> &,
157 const std::unique_ptr<TotemAnalysisMask> &);
160 void ParseTreeDiamond(ParseType,
163 unsigned int parentID,
164 const std::unique_ptr<TotemDAQMapping> &,
165 const std::unique_ptr<TotemAnalysisMask> &);
168 void ParseTreeTotemTiming(ParseType,
171 unsigned int parentID,
172 const std::unique_ptr<TotemDAQMapping> &,
173 const std::unique_ptr<TotemAnalysisMask> &);
176 void ParseTreeTotemT2(ParseType,
179 unsigned int parentID,
180 const std::unique_ptr<TotemDAQMapping> &,
181 const std::unique_ptr<TotemAnalysisMask> &);
185 string CompleteFileName(
const string &
fn);
193 NodeType GetNodeType(xercesc::DOMNode *);
204 void GetChannels(xercesc::DOMNode *
n, std::set<unsigned char> &
channels);
207 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nRPPlane) || (
type == nChip));
211 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nDiamondPlane) ||
212 (
type == nDiamondCh));
216 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nSampicBoard) ||
217 (
type == nSampicChannel) || (
type == nTotemTimingPlane) || (
type == nTotemTimingCh));
270 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
274 currentBlockValid(
false) {
275 for (
const auto &it : conf.
getParameter<vector<ParameterSet>>(
"configuration")) {
277 b.validityRange = it.getParameter<
EventRange>(
"validityRange");
278 b.mappingFileNames = it.getParameter<vector<string>>(
"mappingFileNames");
279 b.maskFileNames = it.getParameter<vector<string>>(
"maskFileNames");
284 findingRecord<TotemReadoutRcd>();
292 LogVerbatim(
"TotemDAQMappingESSourceXML") <<
">> TotemDAQMappingESSourceXML::setIntervalFor(" <<
key.name() <<
")";
306 if (
range.startEventID().luminosityBlock() == 0 &&
range.startEventID().event() == 1)
318 <<
range.startEventID() <<
" - " <<
range.endEventID() <<
")";
325 throw cms::Exception(
"TotemDAQMappingESSourceXML::setIntervalFor")
326 <<
"No configuration for event " << iosv.
eventID();
347 auto mapping = std::make_unique<TotemDAQMapping>();
348 auto mask = std::make_unique<TotemAnalysisMask>();
372 const std::unique_ptr<TotemDAQMapping> &
mapping,
373 const std::unique_ptr<TotemAnalysisMask> &
mask) {
374 unique_ptr<XercesDOMParser>
parser(
new XercesDOMParser());
377 DOMDocument *domDoc =
parser->getDocument();
381 <<
"Cannot parse file `" <<
file <<
"' (domDoc = NULL).";
383 DOMElement *elementRoot = domDoc->getDocumentElement();
386 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseXML") <<
"File `" <<
file <<
"' is empty.";
402 unsigned int parentID,
403 const std::unique_ptr<TotemDAQMapping> &
mapping,
404 const std::unique_ptr<TotemAnalysisMask> &
mask) {
406 printf(
">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n",
414 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
416 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
432 expectedParentType =
nTop;
435 expectedParentType =
nArm;
441 expectedParentType =
nRPPot;
447 expectedParentType =
nChip;
454 if (expectedParentType != parentType) {
461 unsigned int id = 0, hw_id = 0;
462 bool id_set =
false, hw_id_set =
false;
463 bool fullMask =
false;
464 DOMNamedNodeMap *attr =
n->getAttributes();
466 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
467 DOMNode *
a = attr->item(
j);
494 <<
"Plane IDs range from 0 to 9. id = " <<
id <<
" is invalid.";
497 printf(
"\tID found: 0x%x\n",
id);
504 vfatInfo.
hwID = hw_id;
506 const unsigned int armIdx = (parentID / 1000) % 10;
507 const unsigned int stIdx = (parentID / 100) % 10;
508 const unsigned int rpIdx = (parentID / 10) % 10;
509 const unsigned int plIdx = parentID % 10;
513 mapping->insert(framepos, vfatInfo);
520 const unsigned int armIdx = (parentID / 1000) % 10;
521 const unsigned int stIdx = (parentID / 100) % 10;
522 const unsigned int rpIdx = (parentID / 10) % 10;
523 const unsigned int plIdx = parentID % 10;
532 mask->insert(symbId, am);
547 unsigned int parentID,
548 const std::unique_ptr<TotemDAQMapping> &
mapping,
549 const std::unique_ptr<TotemAnalysisMask> &
mask) {
551 printf(
">> TotemDAQMappingESSourceXML::ParseTreeDiamond(%s, %u, %u)\n",
559 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
561 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
576 expectedParentType =
nTop;
579 expectedParentType =
nArm;
585 expectedParentType =
nRPPot;
595 if (expectedParentType != parentType) {
602 unsigned int id = 0, hw_id = 0;
603 bool id_set =
false, hw_id_set =
false;
604 DOMNamedNodeMap *attr =
n->getAttributes();
606 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
607 DOMNode *
a = attr->item(
j);
622 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
626 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
630 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
631 <<
"Plane IDs range from 0 to 3. id = " <<
id <<
" is invalid.";
634 printf(
"\tID found: 0x%x\n",
id);
642 vfatInfo.
hwID = hw_id;
645 unsigned int ArmNum = (parentID / 10000) % 10;
646 unsigned int StationNum = (parentID / 1000) % 10;
647 unsigned int RpNum = (parentID / 100) % 10;
648 unsigned int PlaneNum = (parentID % 100);
653 mapping->insert(framepos, vfatInfo);
658 unsigned int childId;
660 childId = parentID * 100 +
id;
662 childId = parentID * 10 +
id;
673 unsigned int parentID,
674 const std::unique_ptr<TotemDAQMapping> &
mapping,
675 const std::unique_ptr<TotemAnalysisMask> &
mask) {
679 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
685 DOMNamedNodeMap *attr =
parent->getAttributes();
686 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
687 DOMNode *
a = attr->item(
j);
694 unsigned int hwId = 0;
695 attr =
child->getAttributes();
696 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
697 DOMNode *
a = attr->item(
j);
708 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
710 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
722 expectedParentType =
nTop;
725 expectedParentType =
nArm;
731 expectedParentType =
nRPPot;
737 expectedParentType =
nRPPot;
747 if (expectedParentType != parentType) {
756 DOMNamedNodeMap *attr =
n->getAttributes();
758 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
759 DOMNode *
a = attr->item(
j);
769 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
772 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
773 <<
"SampicBoard IDs range from 0 to 5. id = " <<
id <<
" is invalid.";
780 unsigned int ArmNum = (parentID / 10000) % 10;
781 unsigned int StationNum = (parentID / 1000) % 10;
782 unsigned int RpNum = (parentID / 100) % 10;
791 mapping->insert(framepos, vfatInfo);
796 unsigned int childId;
798 childId = parentID * 100 +
id;
800 childId = parentID * 10 +
id;
811 unsigned int parentID,
812 const std::unique_ptr<TotemDAQMapping> &
mapping,
813 const std::unique_ptr<TotemAnalysisMask> &
mask) {
816 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
818 if (
child->getNodeType() != DOMNode::ELEMENT_NODE)
830 expectedParentType =
nTop;
833 expectedParentType =
nArm;
843 if (expectedParentType != parentType) {
851 DOMNamedNodeMap *attr =
child->getAttributes();
853 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
854 DOMNode *
a = attr->item(
j);
862 unsigned int hw_id = 0;
863 bool hw_id_set =
false;
864 DOMNamedNodeMap *attr =
child->getAttributes();
866 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
867 DOMNode *
a = attr->item(
j);
876 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemT2")
879 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemT2")
885 unsigned int arm = parentID / 10, plane = parentID % 10;
888 mapping->insert(framepos, vfatInfo);
901 unsigned char attributeFlag = 0;
903 DOMNamedNodeMap *attr = chipnode->getAttributes();
904 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
905 DOMNode *
a = attr->item(
j);
906 if (
fp.setXMLAttribute(
914 if (!
fp.checkXMLAttributeFlag(attributeFlag)) {
916 <<
"Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag <<
").";
964 if (
Test(
n,
"trigger_vfat"))
974 DOMNodeList *
children =
n->getChildNodes();
975 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
977 if (
n->getNodeType() != DOMNode::ELEMENT_NODE || !
Test(
n,
"channel"))
980 DOMNamedNodeMap *attr =
n->getAttributes();
982 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
983 DOMNode *
a = attr->item(
j);
995 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.
Detector ID class for Totem T2 detectors. Bits [19:31] : Base CTPPSDetId class attributes Bits [16:18...
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
static const std::string tagTotemT2Tile
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
void ParseTreeTotemT2(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::unique_ptr< TotemDAQMapping > &, const std::unique_ptr< TotemAnalysisMask > &)
recursive method to extract nT2-related information from the DOM tree
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)
static const std::string tagTotemT2Plane
TOTEM nT2 specific tags.
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.
bool TotemT2Node(NodeType type)
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 ...