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< boost::shared_ptr< TotemDAQMapping >, boost::shared_ptr< TotemAnalysisMask > > produce (const TotemReadoutRcd &)
 
 TotemDAQMappingESSourceXML (const edm::ParameterSet &)
 
 ~TotemDAQMappingESSourceXML ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- 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

virtual void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
 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())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 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 boost::shared_ptr< TotemDAQMapping > &, const boost::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 boost::shared_ptr< TotemDAQMapping > &, const boost::shared_ptr< TotemAnalysisMask > &)
 recursive method to extract RP-related information from the DOM tree More...
 
void ParseXML (ParseType, const string &file, const boost::shared_ptr< TotemDAQMapping > &, const boost::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 48 of file TotemDAQMappingESSourceXML.cc.

Member Enumeration Documentation

whether to parse a mapping of a mask XML

Enumerator
pMapping 
pMask 

Definition at line 110 of file TotemDAQMappingESSourceXML.cc.

Constructor & Destructor Documentation

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

Definition at line 201 of file TotemDAQMappingESSourceXML.cc.

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

201  :
202  verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
203  subSystemName(conf.getUntrackedParameter<string>("subSystem")),
204  currentBlock(0),
205  currentBlockValid(false)
206 {
207  for (const auto it : conf.getParameter<vector<ParameterSet>>("configuration"))
208  {
209  ConfigBlock b;
210  b.validityRange = it.getParameter<EventRange>("validityRange");
211  b.mappingFileNames = it.getParameter< vector<string> >("mappingFileNames");
212  b.maskFileNames = it.getParameter< vector<string> >("maskFileNames");
213  configuration.push_back(b);
214  }
215 
217  findingRecord<TotemReadoutRcd>();
218 }
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 ( )

Definition at line 267 of file TotemDAQMappingESSourceXML.cc.

268 {
269 }

Member Function Documentation

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

extracts VFAT's DAQ channel from XML attributes

Definition at line 604 of file TotemDAQMappingESSourceXML.cc.

References a, TotemFramePosition::checkXMLAttributeFlag(), Exception, j, and TotemFramePosition::setXMLAttribute().

Referenced by ParseTreeDiamond(), and ParseTreeRP().

605 {
607  unsigned char attributeFlag = 0;
608 
609  DOMNamedNodeMap* attr = chipnode->getAttributes();
610  for (unsigned int j = 0; j < attr->getLength(); j++)
611  {
612  DOMNode *a = attr->item(j);
613  if (fp.setXMLAttribute(XMLString::transcode(a->getNodeName()), XMLString::transcode(a->getNodeValue()), attributeFlag) > 1)
614  {
615  throw cms::Exception("TotemDAQMappingESSourceXML") <<
616  "Unrecognized tag `" << XMLString::transcode(a->getNodeName()) <<
617  "' or incompatible value `" << XMLString::transcode(a->getNodeValue()) <<
618  "'." << endl;
619  }
620  }
621 
622  if (!fp.checkXMLAttributeFlag(attributeFlag))
623  {
624  throw cms::Exception("TotemDAQMappingESSourceXML") <<
625  "Wrong/incomplete DAQ channel specification (attributeFlag = " << attributeFlag << ")." << endl;
626  }
627 
628  return fp;
629 }
int j
Definition: DBlmapReader.cc:9
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 273 of file TotemDAQMappingESSourceXML.cc.

References edm::FileInPath::fullPath().

Referenced by produce().

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

Definition at line 658 of file TotemDAQMappingESSourceXML.cc.

References a, class-composition::children, DEFINE_FWK_EVENTSETUP_SOURCE, Exception, i, j, and Test().

Referenced by ParseTreeRP().

659 {
660  DOMNodeList *children = n->getChildNodes();
661  for (unsigned int i = 0; i < children->getLength(); i++)
662  {
663  DOMNode *n = children->item(i);
664  if (n->getNodeType() != DOMNode::ELEMENT_NODE || !Test(n, "channel"))
665  continue;
666 
667  DOMNamedNodeMap* attr = n->getAttributes();
668  bool idSet = false;
669  for (unsigned int j = 0; j < attr->getLength(); j++)
670  {
671  DOMNode *a = attr->item(j);
672 
673  if (!strcmp(XMLString::transcode(a->getNodeName()), "id"))
674  {
675  unsigned int id = 0;
676  sscanf(XMLString::transcode(a->getNodeValue()), "%u", &id);
677  channels.insert(id);
678  idSet = true;
679  break;
680  }
681  }
682 
683  if (!idSet)
684  {
685  throw cms::Exception("TotemDAQMappingESSourceXML::GetChannels") <<
686  "Channel tags must have an `id' attribute.";
687  }
688  }
689 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
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 137 of file TotemDAQMappingESSourceXML.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

138  {
139  return string(xercesc::XMLString::transcode(parent->getTextContent()));
140  }
TotemDAQMappingESSourceXML::NodeType TotemDAQMappingESSourceXML::GetNodeType ( xercesc::DOMNode *  n)
private

determines node type

Definition at line 633 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseTreeDiamond(), and ParseTreeRP().

634 {
635  // common node types
636  if (Test(n, tagArm)) return nArm;
637  if (Test(n, tagChip1)) return nChip;
638  if (Test(n, tagChip2)) return nChip;
639 
640  // RP node types
641  if (Test(n, tagRPStation)) return nRPStation;
642  if (Test(n, tagRPPot)) return nRPPot;
643  if (Test(n, tagRPPlane)) return nRPPlane;
644 
645  //diamond specifics
646  if (Test(n, tagDiamondCh)) return nDiamondCh;
647  if (Test(n, tagDiamondPlane)) return nDiamondPlane;
648 
649  // for backward compatibility
650  if (Test(n, "trigger_vfat")) return nSkip;
651 
652  throw cms::Exception("TotemDAQMappingESSourceXML::GetNodeType") << "Unknown tag `"
653  << XMLString::transcode(n->getNodeName()) << "'.\n";
654 }
static const std::string tagDiamondPlane
diamond specific tags
static const std::string tagChip1
COMMON Chip XML tags.
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 143 of file TotemDAQMappingESSourceXML.cc.

References gen::n, and AlCaHLTBitMon_QueryRunRegistry::string.

144  {
145  return string(xercesc::XMLString::transcode(node->getNodeValue()));
146  }
void TotemDAQMappingESSourceXML::ParseTreeDiamond ( ParseType  pType,
xercesc::DOMNode *  parent,
NodeType  parentType,
unsigned int  parentID,
const boost::shared_ptr< TotemDAQMapping > &  mapping,
const boost::shared_ptr< TotemAnalysisMask > &  mask 
)
private

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

Definition at line 477 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseXML().

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

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

Definition at line 343 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseXML().

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

parses XML file

Definition at line 318 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by produce().

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

Definition at line 282 of file TotemDAQMappingESSourceXML.cc.

References CompleteFileName(), configuration, currentBlock, currentBlockValid, Exception, HPSPFTaus_cff::mapping, mappingFileNames, RecoTauDiscriminantConfiguration::mask, python.rootplot.argparse::message, ParseXML(), pMapping, pMask, edm::es::products(), and fetchall_from_DQM_v2::release.

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

283 {
284  assert(currentBlockValid);
285 
286  boost::shared_ptr<TotemDAQMapping> mapping(new TotemDAQMapping());
287  boost::shared_ptr<TotemAnalysisMask> mask(new TotemAnalysisMask());
288 
289  // initialize Xerces
290  try
291  {
292  XMLPlatformUtils::Initialize();
293  }
294  catch (const XMLException& toCatch)
295  {
296  char* message = XMLString::transcode(toCatch.getMessage());
297  throw cms::Exception("TotemDAQMappingESSourceXML") << "An XMLException caught with message: " << message << ".\n";
298  XMLString::release(&message);
299  }
300 
301  // load mapping files
302  for (const auto &fn : configuration[currentBlock].mappingFileNames)
304 
305  // load mask files
306  for (const auto &fn : configuration[currentBlock].maskFileNames)
308 
309  // release Xerces
310  XMLPlatformUtils::Terminate();
311 
312  // commit the products
313  return edm::es::products(mapping, mask);
314 }
Channel-mask mapping.
bool currentBlockValid
flag whether the &#39;currentBlock&#39; index is valid
void ParseXML(ParseType, const string &file, const boost::shared_ptr< TotemDAQMapping > &, const boost::shared_ptr< TotemAnalysisMask > &)
parses XML file
std::vector< std::string > mappingFileNames
the mapping files
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
The mapping between FramePosition and VFATInfo.
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 
)
protectedvirtual

sets infinite validity of this data

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 222 of file TotemDAQMappingESSourceXML.cc.

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

224 {
225  LogVerbatim("TotemDAQMappingESSourceXML")
226  << ">> TotemDAQMappingESSourceXML::setIntervalFor(" << key.name() << ")";
227 
228  LogVerbatim("TotemDAQMappingESSourceXML")
229  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
230 
231  currentBlockValid = false;
232  for (unsigned int idx = 0; idx < configuration.size(); ++idx)
233  {
234  const auto &bl = configuration[idx];
235 
236  // event id "1:min" has a special meaning and is translated to a truly minimal event id (1:0:0)
237  EventID startEventID = bl.validityRange.startEventID();
238  if (startEventID == EventID(1, 0, 1))
239  startEventID = EventID(1, 0, 0);
240 
241  if (startEventID <= iosv.eventID() && iosv.eventID() <= bl.validityRange.endEventID())
242  {
243  currentBlockValid = true;
244  currentBlock = idx;
245 
246  const IOVSyncValue begin(startEventID);
247  const IOVSyncValue end(bl.validityRange.endEventID());
248  oValidity = ValidityInterval(begin, end);
249 
250  LogVerbatim("TotemDAQMappingESSourceXML")
251  << " block found: index=" << currentBlock
252  << ", interval=(" << startEventID << " - " << bl.validityRange.endEventID() << ")";
253 
254  return;
255  }
256  }
257 
258  if (!currentBlockValid)
259  {
260  throw cms::Exception("TotemDAQMappingESSourceXML::setIntervalFor") <<
261  "No configuration for event " << iosv.eventID();
262  }
263 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
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
#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 128 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetChannels(), and GetNodeType().

129  {
130  return !(name.compare(xercesc::XMLString::transcode(node->getNodeName())));
131  }

Member Data Documentation

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

index of the current block in 'configuration' array

Definition at line 101 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce(), and setIntervalFor().

bool TotemDAQMappingESSourceXML::currentBlockValid
private

flag whether the 'currentBlock' index is valid

Definition at line 104 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce(), and setIntervalFor().

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

the mapping files

Definition at line 84 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce().

string TotemDAQMappingESSourceXML::subSystemName
private

label of the CTPPS sub-system

Definition at line 80 of file TotemDAQMappingESSourceXML.cc.

Referenced by TotemDAQMappingESSourceXML().

const string TotemDAQMappingESSourceXML::tagAnalysisMask ="analysisMask"
static

Definition at line 53 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

const string TotemDAQMappingESSourceXML::tagArm = "arm"
static

Common position tags.

Definition at line 56 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagChannel ="channel"
static

Definition at line 52 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

const string TotemDAQMappingESSourceXML::tagChip1 = "vfat"
static

COMMON Chip XML tags.

Definition at line 64 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagChip2 = "test_vfat"
static

Definition at line 65 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondCh = "diamond_channel"
static

Definition at line 69 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondPlane = "rp_plane_diamond"
static

diamond specific tags

Definition at line 68 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPlane = "rp_plane"
static

Definition at line 61 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPot = "rp_detector_set"
static

Definition at line 60 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPStation = "station"
static

RP XML tags.

Definition at line 59 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagVFAT ="vfat"
static

Definition at line 51 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

unsigned int TotemDAQMappingESSourceXML::verbosity
private

Definition at line 77 of file TotemDAQMappingESSourceXML.cc.