CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
TotemDAQMappingESSourceXML Class Reference

Loads TotemDAQMapping and TotemAnalysisMask from two XML files. More...

Inheritance diagram for TotemDAQMappingESSourceXML:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Classes

struct  ConfigBlock
 

Public Member Functions

edm::ESProducts< std::shared_ptr< TotemDAQMapping >, std::shared_ptr< TotemAnalysisMask > > produce (const TotemReadoutRcd &)
 
 TotemDAQMappingESSourceXML (const edm::ParameterSet &)
 
 ~TotemDAQMappingESSourceXML () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Attributes

static const std::string tagAnalysisMask ="analysisMask"
 
static const std::string tagArm = "arm"
 Common position tags. More...
 
static const std::string tagChannel ="channel"
 
static const std::string tagChip1 = "vfat"
 COMMON Chip XML tags. More...
 
static const std::string tagChip2 = "test_vfat"
 
static const std::string tagDiamondCh = "diamond_channel"
 
static const std::string tagDiamondPlane = "rp_plane_diamond"
 diamond specific tags More...
 
static const std::string tagRPPlane = "rp_plane"
 
static const std::string tagRPPot = "rp_detector_set"
 
static const std::string tagRPStation = "station"
 RP XML tags. More...
 
static const std::string tagVFAT ="vfat"
 

Protected Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 sets infinite validity of this data More...
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Private Types

enum  NodeType {
  nUnknown, nSkip, nTop, nArm,
  nRPStation, nRPPot, nRPPlane, nDiamondPlane,
  nChip, nDiamondCh, nChannel
}
 enumeration of XML node types More...
 
enum  ParseType { pMapping, pMask }
 whether to parse a mapping of a mask XML More...
 

Private Member Functions

TotemFramePosition ChipFramePosition (xercesc::DOMNode *chipnode)
 extracts VFAT's DAQ channel from XML attributes More...
 
bool CommonNode (NodeType type)
 
string CompleteFileName (const string &fn)
 adds the path prefix, if needed More...
 
bool DiamondNode (NodeType type)
 
void GetChannels (xercesc::DOMNode *n, std::set< unsigned char > &channels)
 
string GetNodeContent (xercesc::DOMNode *parent)
 returns the content of the node More...
 
NodeType GetNodeType (xercesc::DOMNode *)
 determines node type More...
 
string GetNodeValue (xercesc::DOMNode *node)
 returns the value of the node More...
 
void ParseTreeDiamond (ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
 recursive method to extract RP-related information from the DOM tree More...
 
void ParseTreeRP (ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
 recursive method to extract RP-related information from the DOM tree More...
 
void ParseXML (ParseType, const string &file, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
 parses XML file More...
 
bool RPNode (NodeType type)
 
bool Test (xercesc::DOMNode *node, const std::string &name)
 returns true iff the node is of the given name More...
 

Private Attributes

vector< ConfigBlockconfiguration
 
unsigned int currentBlock
 index of the current block in 'configuration' array More...
 
bool currentBlockValid
 flag whether the 'currentBlock' index is valid More...
 
std::vector< std::string > mappingFileNames
 the mapping files More...
 
string subSystemName
 label of the CTPPS sub-system More...
 
unsigned int verbosity
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Loads TotemDAQMapping and TotemAnalysisMask from two XML files.

Definition at line 50 of file TotemDAQMappingESSourceXML.cc.

Member Enumeration Documentation

whether to parse a mapping of a mask XML

Enumerator
pMapping 
pMask 

Definition at line 112 of file TotemDAQMappingESSourceXML.cc.

Constructor & Destructor Documentation

TotemDAQMappingESSourceXML::TotemDAQMappingESSourceXML ( const edm::ParameterSet conf)

Definition at line 203 of file TotemDAQMappingESSourceXML.cc.

References b, configuration, edm::ParameterSet::getParameter(), TotemDAQMappingESSourceXML::ConfigBlock::mappingFileNames, TotemDAQMappingESSourceXML::ConfigBlock::maskFileNames, edm::ESProducer::setWhatProduced(), subSystemName, and TotemDAQMappingESSourceXML::ConfigBlock::validityRange.

203  :
204  verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
205  subSystemName(conf.getUntrackedParameter<string>("subSystem")),
206  currentBlock(0),
207  currentBlockValid(false)
208 {
209  for (const auto it : conf.getParameter<vector<ParameterSet>>("configuration"))
210  {
211  ConfigBlock b;
212  b.validityRange = it.getParameter<EventRange>("validityRange");
213  b.mappingFileNames = it.getParameter< vector<string> >("mappingFileNames");
214  b.maskFileNames = it.getParameter< vector<string> >("maskFileNames");
215  configuration.push_back(b);
216  }
217 
219  findingRecord<TotemReadoutRcd>();
220 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool currentBlockValid
flag whether the &#39;currentBlock&#39; index is valid
string subSystemName
label of the CTPPS sub-system
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
double b
Definition: hdecay.h:120
unsigned int currentBlock
index of the current block in &#39;configuration&#39; array
TotemDAQMappingESSourceXML::~TotemDAQMappingESSourceXML ( )
override

Definition at line 272 of file TotemDAQMappingESSourceXML.cc.

273 {
274 }

Member Function Documentation

TotemFramePosition TotemDAQMappingESSourceXML::ChipFramePosition ( xercesc::DOMNode *  chipnode)
private

extracts VFAT's DAQ channel from XML attributes

Definition at line 607 of file TotemDAQMappingESSourceXML.cc.

References a, TotemFramePosition::checkXMLAttributeFlag(), Exception, TotemFramePosition::setXMLAttribute(), and cms::xerces::toString().

Referenced by ParseTreeDiamond(), and ParseTreeRP().

608 {
610  unsigned char attributeFlag = 0;
611 
612  DOMNamedNodeMap* attr = chipnode->getAttributes();
613  for (unsigned int j = 0; j < attr->getLength(); j++)
614  {
615  DOMNode *a = attr->item(j);
616  if (fp.setXMLAttribute(cms::xerces::toString(a->getNodeName()), cms::xerces::toString(a->getNodeValue()), attributeFlag) > 1)
617  {
618  throw cms::Exception("TotemDAQMappingESSourceXML") <<
619  "Unrecognized tag `" << cms::xerces::toString(a->getNodeName()) <<
620  "' or incompatible value `" << cms::xerces::toString(a->getNodeValue()) <<
621  "'." << endl;
622  }
623  }
624 
625  if (!fp.checkXMLAttributeFlag(attributeFlag))
626  {
627  throw cms::Exception("TotemDAQMappingESSourceXML") <<
628  "Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag << ")." << endl;
629  }
630 
631  return fp;
632 }
std::string toString(XMLCh const *toTranscode)
double a
Definition: hdecay.h:121
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
bool TotemDAQMappingESSourceXML::CommonNode ( NodeType  type)
inlineprivate
string TotemDAQMappingESSourceXML::CompleteFileName ( const string &  fn)
private

adds the path prefix, if needed

Definition at line 278 of file TotemDAQMappingESSourceXML.cc.

References edm::FileInPath::fullPath().

Referenced by produce().

279 {
280  FileInPath fip(fn);
281  return fip.fullPath();
282 }
bool TotemDAQMappingESSourceXML::DiamondNode ( NodeType  type)
inlineprivate
void TotemDAQMappingESSourceXML::GetChannels ( xercesc::DOMNode *  n,
std::set< unsigned char > &  channels 
)
private

Definition at line 661 of file TotemDAQMappingESSourceXML.cc.

References a, class-composition::children, DEFINE_FWK_EVENTSETUP_SOURCE, Exception, mps_fire::i, triggerObjects_cff::id, Test(), and cms::xerces::toString().

Referenced by ParseTreeRP().

662 {
663  DOMNodeList *children = n->getChildNodes();
664  for (unsigned int i = 0; i < children->getLength(); i++)
665  {
666  DOMNode *n = children->item(i);
667  if (n->getNodeType() != DOMNode::ELEMENT_NODE || !Test(n, "channel"))
668  continue;
669 
670  DOMNamedNodeMap* attr = n->getAttributes();
671  bool idSet = false;
672  for (unsigned int j = 0; j < attr->getLength(); j++)
673  {
674  DOMNode *a = attr->item(j);
675 
676  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id"))
677  {
678  unsigned int id = 0;
679  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
680  channels.insert(id);
681  idSet = true;
682  break;
683  }
684  }
685 
686  if (!idSet)
687  {
688  throw cms::Exception("TotemDAQMappingESSourceXML::GetChannels") <<
689  "Channel tags must have an `id' attribute.";
690  }
691  }
692 }
std::string toString(XMLCh const *toTranscode)
bool Test(xercesc::DOMNode *node, const std::string &name)
returns true iff the node is of the given name
double a
Definition: hdecay.h:121
string TotemDAQMappingESSourceXML::GetNodeContent ( xercesc::DOMNode *  parent)
inlineprivate

returns the content of the node

Definition at line 139 of file TotemDAQMappingESSourceXML.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and cms::xerces::toString().

140  {
141  return string(cms::xerces::toString(parent->getTextContent()));
142  }
std::string toString(XMLCh const *toTranscode)
TotemDAQMappingESSourceXML::NodeType TotemDAQMappingESSourceXML::GetNodeType ( xercesc::DOMNode *  n)
private

determines node type

Definition at line 636 of file TotemDAQMappingESSourceXML.cc.

References Exception, nArm, nChip, nDiamondCh, nDiamondPlane, nRPPlane, nRPPot, nRPStation, nSkip, tagArm, tagChip1, tagChip2, tagDiamondCh, tagDiamondPlane, tagRPPlane, tagRPPot, tagRPStation, Test(), and cms::xerces::toString().

Referenced by ParseTreeDiamond(), and ParseTreeRP().

637 {
638  // common node types
639  if (Test(n, tagArm)) return nArm;
640  if (Test(n, tagChip1)) return nChip;
641  if (Test(n, tagChip2)) return nChip;
642 
643  // RP node types
644  if (Test(n, tagRPStation)) return nRPStation;
645  if (Test(n, tagRPPot)) return nRPPot;
646  if (Test(n, tagRPPlane)) return nRPPlane;
647 
648  //diamond specifics
649  if (Test(n, tagDiamondCh)) return nDiamondCh;
650  if (Test(n, tagDiamondPlane)) return nDiamondPlane;
651 
652  // for backward compatibility
653  if (Test(n, "trigger_vfat")) return nSkip;
654 
655  throw cms::Exception("TotemDAQMappingESSourceXML::GetNodeType") << "Unknown tag `"
656  << cms::xerces::toString(n->getNodeName()) << "'.\n";
657 }
static const std::string tagDiamondPlane
diamond specific tags
static const std::string tagChip1
COMMON Chip XML tags.
std::string toString(XMLCh const *toTranscode)
static const std::string tagDiamondCh
static const std::string tagRPStation
RP XML tags.
static const std::string tagArm
Common position tags.
bool Test(xercesc::DOMNode *node, const std::string &name)
returns true iff the node is of the given name
static const std::string tagRPPlane
string TotemDAQMappingESSourceXML::GetNodeValue ( xercesc::DOMNode *  node)
inlineprivate

returns the value of the node

Definition at line 145 of file TotemDAQMappingESSourceXML.cc.

References gen::n, and cms::xerces::toString().

146  {
147  return cms::xerces::toString(node->getNodeValue());
148  }
std::string toString(XMLCh const *toTranscode)
void TotemDAQMappingESSourceXML::ParseTreeDiamond ( ParseType  pType,
xercesc::DOMNode *  parent,
NodeType  parentType,
unsigned int  parentID,
const std::shared_ptr< TotemDAQMapping > &  mapping,
const std::shared_ptr< TotemAnalysisMask > &  mask 
)
private

recursive method to extract RP-related information from the DOM tree

Definition at line 480 of file TotemDAQMappingESSourceXML.cc.

References a, class-composition::children, ChipFramePosition(), DiamondNode(), Exception, GetNodeType(), TotemVFATInfo::hwID, mps_fire::i, triggerObjects_cff::id, gen::n, nArm, nDiamondCh, nDiamondPlane, nRPPot, nRPStation, nTop, nUnknown, pMapping, TotemSymbID::symbolicID, TotemVFATInfo::symbolicID, and cms::xerces::toString().

Referenced by ParseXML().

483 {
484 
485 #ifdef DEBUG
486  printf(">> TotemDAQMappingESSourceXML::ParseTreeDiamond(%s, %u, %u)\n", cms::xerces::toString(parent->getNodeName()),
487  parentType, parentID);
488 #endif
489 
490  DOMNodeList *children = parent->getChildNodes();
491 
492  for (unsigned int i = 0; i < children->getLength(); i++)
493  {
494  DOMNode *n = children->item(i);
495  if (n->getNodeType() != DOMNode::ELEMENT_NODE)
496  continue;
497 
499 #ifdef DEBUG
500  printf("\tname = %s, type = %u\n", cms::xerces::toString(n->getNodeName()), type);
501 #endif
502 
503  // structure control
504  if (!DiamondNode(type))
505  continue;
506 
507  NodeType expectedParentType;
508  switch (type)
509  {
510  case nArm: expectedParentType = nTop; break;
511  case nRPStation: expectedParentType = nArm; break;
512  case nRPPot: expectedParentType = nRPStation; break;
513  case nDiamondPlane: expectedParentType = nRPPot; break;
514  case nDiamondCh: expectedParentType = nDiamondPlane; break;
515  default: expectedParentType = nUnknown; break;
516  }
517 
518  if (expectedParentType != parentType)
519  {
520  throw cms::Exception("TotemDAQMappingESSourceXML") << "Node " << cms::xerces::toString(n->getNodeName())
521  << " not allowed within " << cms::xerces::toString(parent->getNodeName()) << " block.\n";
522  }
523 
524  // parse tag attributes
525  unsigned int id =0,hw_id = 0;
526  bool id_set = false,hw_id_set = false;
527  DOMNamedNodeMap* attr = n->getAttributes();
528 
529  for (unsigned int j = 0; j < attr->getLength(); j++)
530  {
531  DOMNode *a = attr->item(j);
532 
533  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id"))
534  {
535  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
536  id_set = true;
537  }
538 
539  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "hw_id"))
540  {
541  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%x", &hw_id);
542  hw_id_set = true;
543  }
544 
545  }
546 
547  // content control
548  if (!id_set)
549  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeDiamond") << "id not given for element `"
550  << cms::xerces::toString(n->getNodeName()) << "'" << endl;
551 
552 
553  if (!hw_id_set && type == nDiamondCh && pType == pMapping)
554  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeDiamond") << "hw_id not given for element `"
555  << cms::xerces::toString(n->getNodeName()) << "'" << endl;
556 
557  if (type == nDiamondPlane && id > 3)
558  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeDiamond") <<
559  "Plane IDs range from 0 to 3. id = " << id << " is invalid." << endl;
560 
561 #ifdef DEBUG
562  printf("\tID found: 0x%x\n", id);
563 #endif
564 
565  // store mapping data
566  if (pType == pMapping &&type == nDiamondCh)
567  {
568 
569  const TotemFramePosition &framepos = ChipFramePosition(n);
570 
571  TotemVFATInfo vfatInfo;
572  vfatInfo.hwID = hw_id;
573 
574  if (type == nDiamondCh)
575  {
576  unsigned int ArmNum = (parentID/ 10000) % 10;
577  unsigned int StationNum = (parentID / 1000) % 10;
578  unsigned int RpNum = (parentID/ 100) % 10;
579  unsigned int PlaneNum = (parentID % 100) ;
580 
581  vfatInfo.symbolicID.symbolicID = CTPPSDiamondDetId(ArmNum, StationNum, RpNum, PlaneNum, id);
582 
583 
584  }
585 
586 
587  mapping->insert(framepos, vfatInfo);
588 
589  continue;
590  }
591 
592  unsigned int childId;
593  if (pType == pMapping &&type == nDiamondPlane)
594  childId = parentID * 100 + id;
595  else
596  childId = parentID * 10 + id;
597 
598  ParseTreeDiamond(pType,n ,type ,childId ,mapping ,mask);
599 
600  }
601 
602 }
type
Definition: HCALResponse.h:21
NodeType
enumeration of XML node types
TotemSymbID symbolicID
the symbolic id
NodeType GetNodeType(xercesc::DOMNode *)
determines node type
std::string toString(XMLCh const *toTranscode)
TotemFramePosition ChipFramePosition(xercesc::DOMNode *chipnode)
extracts VFAT&#39;s DAQ channel from XML attributes
unsigned int symbolicID
chip ID, raw integer representation of DetId class
Definition: TotemSymbId.h:21
unsigned int hwID
the hardware ID (16 bit)
double a
Definition: hdecay.h:121
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
Contains mappind data related to a VFAT.
void ParseTreeDiamond(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
void TotemDAQMappingESSourceXML::ParseTreeRP ( ParseType  pType,
xercesc::DOMNode *  parent,
NodeType  parentType,
unsigned int  parentID,
const std::shared_ptr< TotemDAQMapping > &  mapping,
const std::shared_ptr< TotemAnalysisMask > &  mask 
)
private

recursive method to extract RP-related information from the DOM tree

Definition at line 346 of file TotemDAQMappingESSourceXML.cc.

References a, class-composition::children, ChipFramePosition(), Exception, TotemVFATAnalysisMask::fullMask, GetChannels(), GetNodeType(), TotemVFATInfo::hwID, mps_fire::i, triggerObjects_cff::id, TotemVFATAnalysisMask::maskedChannels, gen::n, nArm, nChannel, nChip, nRPPlane, nRPPot, nRPStation, nTop, nUnknown, pMapping, pMask, RPNode(), TotemSymbID::symbolicID, TotemVFATInfo::symbolicID, and cms::xerces::toString().

Referenced by ParseXML().

349 {
350 #ifdef DEBUG
351  printf(">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n", cms::xerces::toString(parent->getNodeName()),
352  parentType, parentID);
353 #endif
354 
355  DOMNodeList *children = parent->getChildNodes();
356 
357  for (unsigned int i = 0; i < children->getLength(); i++)
358  {
359  DOMNode *n = children->item(i);
360  if (n->getNodeType() != DOMNode::ELEMENT_NODE)
361  continue;
362 
364 
365 #ifdef DEBUG
366  printf("\tname = %s, type = %u\n", cms::xerces::toString(n->getNodeName()), type);
367 #endif
368 
369  // structure control
370  if (!RPNode(type))
371  continue;
372 
373  NodeType expectedParentType;
374  switch (type)
375  {
376  case nArm: expectedParentType = nTop; break;
377  case nRPStation: expectedParentType = nArm; break;
378  case nRPPot: expectedParentType = nRPStation; break;
379  case nRPPlane: expectedParentType = nRPPot; break;
380  case nChip: expectedParentType = nRPPlane; break;
381  case nChannel: expectedParentType = nChip; break;
382  default: expectedParentType = nUnknown; break;
383  }
384 
385  if (expectedParentType != parentType)
386  {
387  throw cms::Exception("TotemDAQMappingESSourceXML") << "Node " << cms::xerces::toString(n->getNodeName())
388  << " not allowed within " << cms::xerces::toString(parent->getNodeName()) << " block.\n";
389  }
390 
391  // parse tag attributes
392  unsigned int id = 0, hw_id = 0;
393  bool id_set = false, hw_id_set = false;
394  bool fullMask = false;
395  DOMNamedNodeMap* attr = n->getAttributes();
396 
397  for (unsigned int j = 0; j < attr->getLength(); j++)
398  {
399  DOMNode *a = attr->item(j);
400 
401  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id"))
402  {
403  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
404  id_set = true;
405  }
406 
407  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "hw_id"))
408  {
409  sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%x", &hw_id);
410  hw_id_set = true;
411  }
412 
413  if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "full_mask"))
414  fullMask = (strcmp(cms::xerces::toString(a->getNodeValue()).c_str(), "no") != 0);
415  }
416 
417  // content control
418  if (!id_set)
419  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP") << "id not given for element `"
420  << cms::xerces::toString(n->getNodeName()) << "'" << endl;
421 
422  if (!hw_id_set && type == nChip && pType == pMapping)
423  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP") << "hw_id not given for element `"
424  << cms::xerces::toString(n->getNodeName()) << "'" << endl;
425 
426  if (type == nRPPlane && id > 9)
427  throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP") <<
428  "Plane IDs range from 0 to 9. id = " << id << " is invalid." << endl;
429 
430 #ifdef DEBUG
431  printf("\tID found: 0x%x\n", id);
432 #endif
433 
434  // store mapping data
435  if (pType == pMapping && type == nChip)
436  {
437  const TotemFramePosition &framepos = ChipFramePosition(n);
438  TotemVFATInfo vfatInfo;
439  vfatInfo.hwID = hw_id;
440 
441  const unsigned int armIdx = (parentID / 1000) % 10;
442  const unsigned int stIdx = (parentID / 100) % 10;
443  const unsigned int rpIdx = (parentID / 10) % 10;
444  const unsigned int plIdx = parentID % 10;
445 
446  vfatInfo.symbolicID.symbolicID = TotemRPDetId(armIdx, stIdx, rpIdx, plIdx, id);
447 
448  mapping->insert(framepos, vfatInfo);
449 
450  continue;
451  }
452 
453  // store mask data
454  if (pType == pMask && type == nChip)
455  {
456  const unsigned int armIdx = (parentID / 1000) % 10;
457  const unsigned int stIdx = (parentID / 100) % 10;
458  const unsigned int rpIdx = (parentID / 10) % 10;
459  const unsigned int plIdx = parentID % 10;
460 
461  TotemSymbID symbId;
462  symbId.symbolicID = TotemRPDetId(armIdx, stIdx, rpIdx, plIdx, id);
463 
465  am.fullMask = fullMask;
467 
468  mask->insert(symbId, am);
469 
470  continue;
471  }
472 
473  // recursion (deeper in the tree)
474  ParseTreeRP(pType, n, type, parentID * 10 + id, mapping, mask);
475  }
476 }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
type
Definition: HCALResponse.h:21
Contains data on masked channels of a VFAT.
NodeType
enumeration of XML node types
TotemSymbID symbolicID
the symbolic id
NodeType GetNodeType(xercesc::DOMNode *)
determines node type
std::string toString(XMLCh const *toTranscode)
Symbolic ID describing an entity of a TOTEM subdetector.
Definition: TotemSymbId.h:17
TotemFramePosition ChipFramePosition(xercesc::DOMNode *chipnode)
extracts VFAT&#39;s DAQ channel from XML attributes
bool fullMask
whether all channels of the VFAT shall be masked
void ParseTreeRP(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
unsigned int symbolicID
chip ID, raw integer representation of DetId class
Definition: TotemSymbId.h:21
unsigned int hwID
the hardware ID (16 bit)
double a
Definition: hdecay.h:121
std::set< unsigned char > maskedChannels
list of channels to be masked
void GetChannels(xercesc::DOMNode *n, std::set< unsigned char > &channels)
Contains mappind data related to a VFAT.
void TotemDAQMappingESSourceXML::ParseXML ( ParseType  pType,
const string &  file,
const std::shared_ptr< TotemDAQMapping > &  mapping,
const std::shared_ptr< TotemAnalysisMask > &  mask 
)
private

parses XML file

Definition at line 321 of file TotemDAQMappingESSourceXML.cc.

References Exception, nTop, createfilelist::parser, ParseTreeDiamond(), and ParseTreeRP().

Referenced by produce().

323 {
324  unique_ptr<XercesDOMParser> parser(new XercesDOMParser());
325  parser->parse(file.c_str());
326 
327  DOMDocument* domDoc = parser->getDocument();
328 
329  if (!domDoc)
330  throw cms::Exception("TotemDAQMappingESSourceXML::ParseXML") << "Cannot parse file `" << file
331  << "' (domDoc = NULL)." << endl;
332 
333  DOMElement* elementRoot = domDoc->getDocumentElement();
334 
335  if (!elementRoot)
336  throw cms::Exception("TotemDAQMappingESSourceXML::ParseXML") << "File `" <<
337  file << "' is empty." << endl;
338 
339  ParseTreeRP(pType, elementRoot, nTop, 0, mapping, mask);
340 
341  ParseTreeDiamond(pType, elementRoot, nTop, 0, mapping, mask);
342 }
void ParseTreeRP(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
void ParseTreeDiamond(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
recursive method to extract RP-related information from the DOM tree
edm::ESProducts< std::shared_ptr< TotemDAQMapping >, std::shared_ptr< TotemAnalysisMask > > TotemDAQMappingESSourceXML::produce ( const TotemReadoutRcd )

Definition at line 287 of file TotemDAQMappingESSourceXML.cc.

References CompleteFileName(), configuration, currentBlock, currentBlockValid, Exception, HPSPFTaus_cff::mapping, mappingFileNames, RecoTauDiscriminantConfiguration::mask, ParseXML(), pMapping, pMask, edm::es::products(), and cms::xerces::toString().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

288 {
289  assert(currentBlockValid);
290 
291  auto mapping = std::make_shared<TotemDAQMapping>();
292  auto mask = std::make_shared<TotemAnalysisMask>();
293 
294  // initialize Xerces
295  try
296  {
297  XMLPlatformUtils::Initialize();
298  }
299  catch (const XMLException& toCatch)
300  {
301  throw cms::Exception("TotemDAQMappingESSourceXML") << "An XMLException caught with message: " << cms::xerces::toString(toCatch.getMessage()) << ".\n";
302  }
303 
304  // load mapping files
305  for (const auto &fn : configuration[currentBlock].mappingFileNames)
307 
308  // load mask files
309  for (const auto &fn : configuration[currentBlock].maskFileNames)
310  ParseXML(pMask, CompleteFileName(fn), mapping, mask);
311 
312  // release Xerces
313  XMLPlatformUtils::Terminate();
314 
315  // commit the products
316  return edm::es::products(mapping, mask);
317 }
bool currentBlockValid
flag whether the &#39;currentBlock&#39; index is valid
void ParseXML(ParseType, const string &file, const std::shared_ptr< TotemDAQMapping > &, const std::shared_ptr< TotemAnalysisMask > &)
parses XML file
std::vector< std::string > mappingFileNames
the mapping files
std::string toString(XMLCh const *toTranscode)
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:191
unsigned int currentBlock
index of the current block in &#39;configuration&#39; array
string CompleteFileName(const string &fn)
adds the path prefix, if needed
bool TotemDAQMappingESSourceXML::RPNode ( NodeType  type)
inlineprivate
void TotemDAQMappingESSourceXML::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey key,
const edm::IOVSyncValue iosv,
edm::ValidityInterval oValidity 
)
overrideprotectedvirtual

sets infinite validity of this data

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 224 of file TotemDAQMappingESSourceXML.cc.

References begin, configuration, edm::contains(), currentBlock, currentBlockValid, end, edm::EventRange::endEventID(), edm::EventID::event(), edm::IOVSyncValue::eventID(), Exception, training_settings::idx, edm::EventID::luminosityBlock(), edm::eventsetup::EventSetupRecordKey::name(), edm::EventID::run(), and edm::EventRange::startEventID().

226 {
227  LogVerbatim("TotemDAQMappingESSourceXML")
228  << ">> TotemDAQMappingESSourceXML::setIntervalFor(" << key.name() << ")";
229 
230  LogVerbatim("TotemDAQMappingESSourceXML")
231  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
232 
233  currentBlockValid = false;
234  for (unsigned int idx = 0; idx < configuration.size(); ++idx)
235  {
236  const auto &bl = configuration[idx];
237 
238  edm::EventRange range = bl.validityRange;
239 
240  // If "<run>:min" is specified in python config, it is translated into event <run>:0:1.
241  // However, the truly minimal event id often found in data is <run>:0:0. Therefore the
242  // adjustment below is needed.
243  if (range.startEventID().luminosityBlock() == 0 && range.startEventID().event() == 1)
244  range = edm::EventRange(edm::EventID(range.startEventID().run(), 0, 0), range.endEventID());
245 
246  if (edm::contains(range, iosv.eventID()))
247  {
248  currentBlockValid = true;
249  currentBlock = idx;
250 
251  const IOVSyncValue begin(range.startEventID());
252  const IOVSyncValue end(range.endEventID());
253  oValidity = edm::ValidityInterval(begin, end);
254 
255  LogVerbatim("TotemDAQMappingESSourceXML")
256  << " block found: index=" << currentBlock
257  << ", interval=(" << range.startEventID() << " - " << range.endEventID() << ")";
258 
259  return;
260  }
261  }
262 
263  if (!currentBlockValid)
264  {
265  throw cms::Exception("TotemDAQMappingESSourceXML::setIntervalFor") <<
266  "No configuration for event " << iosv.eventID();
267  }
268 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
const EventID & eventID() const
Definition: IOVSyncValue.h:42
bool currentBlockValid
flag whether the &#39;currentBlock&#39; index is valid
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
EventID startEventID() const
Definition: EventRange.h:44
EventID endEventID() const
Definition: EventRange.h:45
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
unsigned int currentBlock
index of the current block in &#39;configuration&#39; array
bool TotemDAQMappingESSourceXML::Test ( xercesc::DOMNode *  node,
const std::string &  name 
)
inlineprivate

returns true iff the node is of the given name

Definition at line 130 of file TotemDAQMappingESSourceXML.cc.

References cms::xerces::toString().

Referenced by GetChannels(), and GetNodeType().

131  {
132  return !(name.compare(cms::xerces::toString(node->getNodeName())));
133  }
std::string toString(XMLCh const *toTranscode)

Member Data Documentation

vector<ConfigBlock> TotemDAQMappingESSourceXML::configuration
private
unsigned int TotemDAQMappingESSourceXML::currentBlock
private

index of the current block in 'configuration' array

Definition at line 103 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce(), and setIntervalFor().

bool TotemDAQMappingESSourceXML::currentBlockValid
private

flag whether the 'currentBlock' index is valid

Definition at line 106 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce(), and setIntervalFor().

std::vector<std::string> TotemDAQMappingESSourceXML::mappingFileNames
private

the mapping files

Definition at line 86 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce().

string TotemDAQMappingESSourceXML::subSystemName
private

label of the CTPPS sub-system

Definition at line 82 of file TotemDAQMappingESSourceXML.cc.

Referenced by TotemDAQMappingESSourceXML().

const string TotemDAQMappingESSourceXML::tagAnalysisMask ="analysisMask"
static

Definition at line 55 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

const string TotemDAQMappingESSourceXML::tagArm = "arm"
static

Common position tags.

Definition at line 58 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagChannel ="channel"
static

Definition at line 54 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

const string TotemDAQMappingESSourceXML::tagChip1 = "vfat"
static

COMMON Chip XML tags.

Definition at line 66 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagChip2 = "test_vfat"
static

Definition at line 67 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondCh = "diamond_channel"
static

Definition at line 71 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondPlane = "rp_plane_diamond"
static

diamond specific tags

Definition at line 70 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPlane = "rp_plane"
static

Definition at line 63 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPot = "rp_detector_set"
static

Definition at line 62 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPStation = "station"
static

RP XML tags.

Definition at line 61 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagVFAT ="vfat"
static

Definition at line 53 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

unsigned int TotemDAQMappingESSourceXML::verbosity
private

Definition at line 79 of file TotemDAQMappingESSourceXML.cc.