37 #include <xercesc/parsers/XercesDOMParser.hpp> 38 #include <xercesc/dom/DOM.hpp> 39 #include <xercesc/sax/HandlerBase.hpp> 40 #include <xercesc/util/XMLString.hpp> 41 #include <xercesc/util/PlatformUtils.hpp> 153 void ParseXML(ParseType,
155 const std::unique_ptr<TotemDAQMapping> &,
156 const std::unique_ptr<TotemAnalysisMask> &);
159 void ParseTreeRP(ParseType,
162 unsigned int parentID,
163 const std::unique_ptr<TotemDAQMapping> &,
164 const std::unique_ptr<TotemAnalysisMask> &);
167 void ParseTreeDiamond(ParseType,
170 unsigned int parentID,
171 const std::unique_ptr<TotemDAQMapping> &,
172 const std::unique_ptr<TotemAnalysisMask> &);
175 void ParseTreeTotemTiming(ParseType,
178 unsigned int parentID,
179 const std::unique_ptr<TotemDAQMapping> &,
180 const std::unique_ptr<TotemAnalysisMask> &);
183 void ParseTreeTotemT2(ParseType,
186 unsigned int parentID,
187 const std::unique_ptr<TotemDAQMapping> &,
188 const std::unique_ptr<TotemAnalysisMask> &);
192 string CompleteFileName(
const string &
fn);
200 NodeType GetNodeType(xercesc::DOMNode *);
214 void GetChannels(xercesc::DOMNode *
n, std::set<unsigned char> &
channels);
217 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nRPPlane) || (
type == nChip));
221 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nDiamondPlane) ||
222 (
type == nDiamondCh));
226 return ((
type == nArm) || (
type == nRPStation) || (
type == nRPPot) || (
type == nSampicBoard) ||
227 (
type == nSampicChannel) || (
type == nTotemTimingPlane) || (
type == nTotemTimingCh));
280 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
283 packedPayload(conf.getParameter<
bool>(
"multipleChannelsPerPayload")),
285 currentBlockValid(
false) {
286 for (
const auto &it : conf.
getParameter<vector<ParameterSet>>(
"configuration")) {
288 b.validityRange = it.getParameter<
EventRange>(
"validityRange");
289 b.mappingFileNames = it.getParameter<vector<string>>(
"mappingFileNames");
290 b.maskFileNames = it.getParameter<vector<string>>(
"maskFileNames");
295 findingRecord<TotemReadoutRcd>();
303 LogVerbatim(
"TotemDAQMappingESSourceXML") <<
">> TotemDAQMappingESSourceXML::setIntervalFor(" <<
key.name() <<
")";
317 if (
range.startEventID().luminosityBlock() == 0 &&
range.startEventID().event() == 1)
329 <<
range.startEventID() <<
" - " <<
range.endEventID() <<
")";
336 throw cms::Exception(
"TotemDAQMappingESSourceXML::setIntervalFor")
337 <<
"No configuration for event " << iosv.
eventID();
359 auto mapping = std::make_unique<TotemDAQMapping>();
360 auto mask = std::make_unique<TotemAnalysisMask>();
376 }
catch (
const XMLException &
e) {
377 throw cms::Exception(
"XMLDocument") <<
"cms::concurrency::xercesInitialize failed because of " 379 }
catch (
const SAXException &
e) {
381 }
catch (
const DOMException &
e) {
393 const std::unique_ptr<TotemDAQMapping> &
mapping,
394 const std::unique_ptr<TotemAnalysisMask> &
mask) {
395 unique_ptr<XercesDOMParser>
parser(
new XercesDOMParser());
398 DOMDocument *domDoc =
parser->getDocument();
402 <<
"Cannot parse file `" <<
file <<
"' (domDoc = NULL).";
404 DOMElement *elementRoot = domDoc->getDocumentElement();
407 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseXML") <<
"File `" <<
file <<
"' is empty.";
423 unsigned int parentID,
424 const std::unique_ptr<TotemDAQMapping> &
mapping,
425 const std::unique_ptr<TotemAnalysisMask> &
mask) {
427 printf(
">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n",
435 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
437 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
453 expectedParentType =
nTop;
456 expectedParentType =
nArm;
462 expectedParentType =
nRPPot;
468 expectedParentType =
nChip;
475 if (expectedParentType != parentType) {
482 unsigned int id = 0, hw_id = 0;
483 bool id_set =
false, hw_id_set =
false;
484 bool fullMask =
false;
485 DOMNamedNodeMap *attr =
n->getAttributes();
487 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
488 DOMNode *
a = attr->item(
j);
515 <<
"Plane IDs range from 0 to 9. id = " <<
id <<
" is invalid.";
518 printf(
"\tID found: 0x%x\n",
id);
525 vfatInfo.
hwID = hw_id;
527 const unsigned int armIdx = (parentID / 1000) % 10;
528 const unsigned int stIdx = (parentID / 100) % 10;
529 const unsigned int rpIdx = (parentID / 10) % 10;
530 const unsigned int plIdx = parentID % 10;
534 mapping->insert(framepos, vfatInfo);
541 const unsigned int armIdx = (parentID / 1000) % 10;
542 const unsigned int stIdx = (parentID / 100) % 10;
543 const unsigned int rpIdx = (parentID / 10) % 10;
544 const unsigned int plIdx = parentID % 10;
553 mask->insert(symbId, am);
568 unsigned int parentID,
569 const std::unique_ptr<TotemDAQMapping> &
mapping,
570 const std::unique_ptr<TotemAnalysisMask> &
mask) {
572 printf(
">> TotemDAQMappingESSourceXML::ParseTreeDiamond(%s, %u, %u)\n",
580 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
582 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
597 expectedParentType =
nTop;
600 expectedParentType =
nArm;
606 expectedParentType =
nRPPot;
616 if (expectedParentType != parentType) {
623 unsigned int id = 0, hw_id = 0;
624 bool id_set =
false, hw_id_set =
false;
625 DOMNamedNodeMap *attr =
n->getAttributes();
627 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
628 DOMNode *
a = attr->item(
j);
643 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
647 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
651 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeDiamond")
652 <<
"Plane IDs range from 0 to 3. id = " <<
id <<
" is invalid.";
655 printf(
"\tID found: 0x%x\n",
id);
663 vfatInfo.
hwID = hw_id;
666 unsigned int ArmNum = (parentID / 10000) % 10;
667 unsigned int StationNum = (parentID / 1000) % 10;
668 unsigned int RpNum = (parentID / 100) % 10;
669 unsigned int PlaneNum = (parentID % 100);
674 mapping->insert(framepos, vfatInfo);
679 unsigned int childId;
681 childId = parentID * 100 +
id;
683 childId = parentID * 10 +
id;
694 unsigned int parentID,
695 const std::unique_ptr<TotemDAQMapping> &
mapping,
696 const std::unique_ptr<TotemAnalysisMask> &
mask) {
700 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
706 DOMNamedNodeMap *attr =
parent->getAttributes();
707 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
708 DOMNode *
a = attr->item(
j);
715 unsigned int hwId = 0;
716 attr =
child->getAttributes();
717 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
718 DOMNode *
a = attr->item(
j);
729 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
731 if (
n->getNodeType() != DOMNode::ELEMENT_NODE)
743 expectedParentType =
nTop;
746 expectedParentType =
nArm;
752 expectedParentType =
nRPPot;
758 expectedParentType =
nRPPot;
768 if (expectedParentType != parentType) {
777 DOMNamedNodeMap *attr =
n->getAttributes();
779 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
780 DOMNode *
a = attr->item(
j);
790 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
793 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemTiming")
794 <<
"SampicBoard IDs range from 0 to 5. id = " <<
id <<
" is invalid.";
801 unsigned int ArmNum = (parentID / 10000) % 10;
802 unsigned int StationNum = (parentID / 1000) % 10;
803 unsigned int RpNum = (parentID / 100) % 10;
812 mapping->insert(framepos, vfatInfo);
817 unsigned int childId;
819 childId = parentID * 100 +
id;
821 childId = parentID * 10 +
id;
832 unsigned int parentID,
833 const std::unique_ptr<TotemDAQMapping> &
mapping,
834 const std::unique_ptr<TotemAnalysisMask> &
mask) {
837 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
839 if (
child->getNodeType() != DOMNode::ELEMENT_NODE)
851 expectedParentType =
nTop;
854 expectedParentType =
nArm;
864 if (expectedParentType != parentType) {
872 DOMNamedNodeMap *attr =
child->getAttributes();
874 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
875 DOMNode *
a = attr->item(
j);
883 unsigned int hw_id = 0;
884 bool hw_id_set =
false;
885 unsigned int channel_in_payload = 0;
886 bool payload_set =
false;
887 DOMNamedNodeMap *attr =
child->getAttributes();
889 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
890 DOMNode *
a = attr->item(
j);
903 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemT2")
906 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemT2")
909 throw cms::Exception(
"TotemDAQMappingESSourceXML::ParseTreeTotemT2")
917 vfatInfo.
hwID = hw_id;
918 unsigned int arm = parentID / 10, plane = parentID % 10;
921 edm::LogWarning(
"Totem") <<
"Print T2 frame pos (payload):" << framepos <<
" (" 922 << (
packedPayload ?
"true" :
"false") <<
") hw_id / T2 DetID" << hw_id <<
"/" 927 mapping->insert(framepos, vfatInfo);
929 mapping->insert(frameposSingle, vfatInfo);
942 unsigned char attributeFlag = 0;
944 DOMNamedNodeMap *attr = chipnode->getAttributes();
945 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
946 DOMNode *
a = attr->item(
j);
947 if (
fp.setXMLAttribute(
955 if (!
fp.checkXMLAttributeFlag(attributeFlag)) {
957 <<
"Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag <<
").";
967 unsigned char attributeFlag = 0;
969 DOMNamedNodeMap *attr = chipnode->getAttributes();
970 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
971 DOMNode *
a = attr->item(
j);
972 if (
fp.setXMLAttribute(
980 if (!
fp.checkXMLAttributeFlag(attributeFlag)) {
982 <<
"Wrong/incomplete T2 DAQ channel specification (attributeFlag = " << attributeFlag <<
").";
1029 if (
Test(
n,
"trigger_vfat"))
1039 DOMNodeList *
children =
n->getChildNodes();
1040 for (
unsigned int i = 0;
i <
children->getLength();
i++) {
1042 if (
n->getNodeType() != DOMNode::ELEMENT_NODE || !
Test(
n,
"channel"))
1045 DOMNamedNodeMap *attr =
n->getAttributes();
1047 for (
unsigned int j = 0;
j < attr->getLength();
j++) {
1048 DOMNode *
a = attr->item(
j);
1051 unsigned int id = 0;
1060 throw cms::Exception(
"TotemDAQMappingESSourceXML::GetChannels") <<
"Channel tags must have an `id' attribute.";
1070 desc.addUntracked<
unsigned int>(
"verbosity", 0);
1071 desc.addUntracked<
std::string>(
"subSystem",
"")->setComment(
"set it to: TrackingStrip, ...");
1072 desc.add<
unsigned int>(
"sampicSubDetId");
1073 desc.add<
bool>(
"multipleChannelsPerPayload",
false);
1077 vpsd1.
add<std::vector<std::string>>(
"mappingFileNames", {});
1078 vpsd1.
add<std::vector<std::string>>(
"maskFileNames", {});
1079 std::vector<edm::ParameterSet> temp1;
1084 temp2.
addParameter<std::vector<std::string>>(
"mappingFileNames", {});
1085 temp2.
addParameter<std::vector<std::string>>(
"maskFileNames", {});
1086 temp1.push_back(temp2);
1088 desc.addVPSet(
"configuration", vpsd1, temp1)->setComment(
"validityRange, mappingFileNames and maskFileNames");
1090 descriptions.
add(
"totemDAQMappingESSourceXML",
desc);
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
#define XERCES_CPP_NAMESPACE_QUALIFIER
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
static std::string to_string(const XMLCh *ch)
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
void addParameter(std::string const &name, T const &value)
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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 &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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
Log< level::Warning, false > LogWarning
static void fillDescriptions(edm::ConfigurationDescriptions &)
void GetChannels(xercesc::DOMNode *n, std::set< unsigned char > &channels)
Contains mappind data related to a VFAT.
EventNumber_t event() const
TotemT2FramePosition ChipT2FramePosition(xercesc::DOMNode *chipnode)
extracts VFAT's DAQ channel from XML attributes for packed T2 payload
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 ...