CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- 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 ()
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder ()
 

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::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_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 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
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 
- 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 49 of file TotemDAQMappingESSourceXML.cc.

Member Enumeration Documentation

whether to parse a mapping of a mask XML

Enumerator
pMapping 
pMask 

Definition at line 111 of file TotemDAQMappingESSourceXML.cc.

Constructor & Destructor Documentation

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

Definition at line 202 of file TotemDAQMappingESSourceXML.cc.

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

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

272 {
273 }

Member Function Documentation

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

extracts VFAT's DAQ channel from XML attributes

Definition at line 608 of file TotemDAQMappingESSourceXML.cc.

References a, TotemFramePosition::checkXMLAttributeFlag(), Exception, personalPlayback::fp, j, TotemFramePosition::setXMLAttribute(), and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by ParseTreeDiamond(), and ParseTreeRP().

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

References edm::FileInPath::fullPath().

Referenced by produce().

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

Definition at line 662 of file TotemDAQMappingESSourceXML.cc.

References a, Exception, i, j, Test(), and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by ParseTreeRP().

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

References AlCaHLTBitMon_QueryRunRegistry::string, and XERCES_CPP_NAMESPACE_USE::transcode().

139  {
140  return string(xercesc::XMLString::transcode(parent->getTextContent()));
141  }
XMLCh * transcode(const T &fInput)
TotemDAQMappingESSourceXML::NodeType TotemDAQMappingESSourceXML::GetNodeType ( xercesc::DOMNode *  n)
private

determines node type

Definition at line 637 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseTreeDiamond(), and ParseTreeRP().

638 {
639  // common node types
640  if (Test(n, tagArm)) return nArm;
641  if (Test(n, tagChip1)) return nChip;
642  if (Test(n, tagChip2)) return nChip;
643 
644  // RP node types
645  if (Test(n, tagRPStation)) return nRPStation;
646  if (Test(n, tagRPPot)) return nRPPot;
647  if (Test(n, tagRPPlane)) return nRPPlane;
648 
649  //diamond specifics
650  if (Test(n, tagDiamondCh)) return nDiamondCh;
651  if (Test(n, tagDiamondPlane)) return nDiamondPlane;
652 
653  // for backward compatibility
654  if (Test(n, "trigger_vfat")) return nSkip;
655 
656  throw cms::Exception("TotemDAQMappingESSourceXML::GetNodeType") << "Unknown tag `"
657  << XMLString::transcode(n->getNodeName()) << "'.\n";
658 }
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.
XMLCh * transcode(const T &fInput)
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 144 of file TotemDAQMappingESSourceXML.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and XERCES_CPP_NAMESPACE_USE::transcode().

145  {
146  return string(xercesc::XMLString::transcode(node->getNodeValue()));
147  }
XMLCh * transcode(const T &fInput)
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 481 of file TotemDAQMappingESSourceXML.cc.

References a, ChipFramePosition(), DiamondNode(), Exception, GetNodeType(), TotemVFATInfo::hwID, i, j, gen::n, nArm, nDiamondCh, nDiamondPlane, nRPPot, nRPStation, nTop, nUnknown, pMapping, TotemSymbID::symbolicID, TotemVFATInfo::symbolicID, and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by ParseXML().

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

References a, 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, TotemVFATInfo::symbolicID, and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by ParseXML().

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

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

Referenced by produce().

324 {
325  unique_ptr<XercesDOMParser> parser(new XercesDOMParser());
326  parser->parse(file.c_str());
327 
328  DOMDocument* domDoc = parser->getDocument();
329 
330  if (!domDoc)
331  throw cms::Exception("TotemDAQMappingESSourceXML::ParseXML") << "Cannot parse file `" << file
332  << "' (domDoc = NULL)." << endl;
333 
334  DOMElement* elementRoot = domDoc->getDocumentElement();
335 
336  if (!elementRoot)
337  throw cms::Exception("TotemDAQMappingESSourceXML::ParseXML") << "File `" <<
338  file << "' is empty." << endl;
339 
340  ParseTreeRP(pType, elementRoot, nTop, 0, mapping, mask);
341 
342  ParseTreeDiamond(pType, elementRoot, nTop, 0, mapping, mask);
343 }
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 286 of file TotemDAQMappingESSourceXML.cc.

References assert(), CompleteFileName(), configuration, currentBlock, currentBlockValid, Exception, personalPlayback::fn, mappingFileNames, python.rootplot.argparse::message, ParseXML(), pMapping, pMask, edm::es::products(), fetchall_from_DQM_v2::release, and XERCES_CPP_NAMESPACE_USE::transcode().

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

287 {
289 
290  auto mapping = std::make_shared<TotemDAQMapping>();
291  auto mask = std::make_shared<TotemAnalysisMask>();
292 
293  // initialize Xerces
294  try
295  {
296  XMLPlatformUtils::Initialize();
297  }
298  catch (const XMLException& toCatch)
299  {
300  char* message = XMLString::transcode(toCatch.getMessage());
301  throw cms::Exception("TotemDAQMappingESSourceXML") << "An XMLException caught with message: " << message << ".\n";
302  XMLString::release(&message);
303  }
304 
305  // load mapping files
306  for (const auto &fn : configuration[currentBlock].mappingFileNames)
307  ParseXML(pMapping, CompleteFileName(fn), mapping, mask);
308 
309  // load mask files
310  for (const auto &fn : configuration[currentBlock].maskFileNames)
311  ParseXML(pMask, CompleteFileName(fn), mapping, mask);
312 
313  // release Xerces
314  XMLPlatformUtils::Terminate();
315 
316  // commit the products
317  return edm::es::products(mapping, mask);
318 }
assert(m_qm.get())
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
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
XMLCh * transcode(const T &fInput)
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 223 of file TotemDAQMappingESSourceXML.cc.

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

225 {
226  LogVerbatim("TotemDAQMappingESSourceXML")
227  << ">> TotemDAQMappingESSourceXML::setIntervalFor(" << key.name() << ")";
228 
229  LogVerbatim("TotemDAQMappingESSourceXML")
230  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
231 
232  currentBlockValid = false;
233  for (unsigned int idx = 0; idx < configuration.size(); ++idx)
234  {
235  const auto &bl = configuration[idx];
236 
237  edm::EventRange range = bl.validityRange;
238 
239  // If "<run>:min" is specified in python config, it is translated into event <run>:0:1.
240  // However, the truly minimal event id often found in data is <run>:0:0. Therefore the
241  // adjustment below is needed.
242  if (range.startEventID().luminosityBlock() == 0 && range.startEventID().event() == 1)
243  range = edm::EventRange(edm::EventID(range.startEventID().run(), 0, 0), range.endEventID());
244 
245  if (edm::contains(range, iosv.eventID()))
246  {
247  currentBlockValid = true;
248  currentBlock = idx;
249 
250  const IOVSyncValue begin(range.startEventID());
251  const IOVSyncValue end(range.endEventID());
252  oValidity = edm::ValidityInterval(begin, end);
253 
254  LogVerbatim("TotemDAQMappingESSourceXML")
255  << " block found: index=" << currentBlock
256  << ", interval=(" << range.startEventID() << " - " << range.endEventID() << ")";
257 
258  return;
259  }
260  }
261 
262  if (!currentBlockValid)
263  {
264  throw cms::Exception("TotemDAQMappingESSourceXML::setIntervalFor") <<
265  "No configuration for event " << iosv.eventID();
266  }
267 }
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
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
#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 129 of file TotemDAQMappingESSourceXML.cc.

References XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by GetChannels(), and GetNodeType().

130  {
131  return !(name.compare(xercesc::XMLString::transcode(node->getNodeName())));
132  }
XMLCh * transcode(const T &fInput)

Member Data Documentation

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

index of the current block in 'configuration' array

Definition at line 102 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce(), and setIntervalFor().

bool TotemDAQMappingESSourceXML::currentBlockValid
private

flag whether the 'currentBlock' index is valid

Definition at line 105 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce(), and setIntervalFor().

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

the mapping files

Definition at line 85 of file TotemDAQMappingESSourceXML.cc.

Referenced by produce().

string TotemDAQMappingESSourceXML::subSystemName
private

label of the CTPPS sub-system

Definition at line 81 of file TotemDAQMappingESSourceXML.cc.

Referenced by TotemDAQMappingESSourceXML().

const string TotemDAQMappingESSourceXML::tagAnalysisMask ="analysisMask"
static

Definition at line 54 of file TotemDAQMappingESSourceXML.cc.

const string TotemDAQMappingESSourceXML::tagArm = "arm"
static

Common position tags.

Definition at line 57 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagChannel ="channel"
static

Definition at line 53 of file TotemDAQMappingESSourceXML.cc.

const string TotemDAQMappingESSourceXML::tagChip1 = "vfat"
static

COMMON Chip XML tags.

Definition at line 65 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagChip2 = "test_vfat"
static

Definition at line 66 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondCh = "diamond_channel"
static

Definition at line 70 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondPlane = "rp_plane_diamond"
static

diamond specific tags

Definition at line 69 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPlane = "rp_plane"
static

Definition at line 62 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPot = "rp_detector_set"
static

Definition at line 61 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPStation = "station"
static

RP XML tags.

Definition at line 60 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetNodeType().

const string TotemDAQMappingESSourceXML::tagVFAT ="vfat"
static

Definition at line 52 of file TotemDAQMappingESSourceXML.cc.

unsigned int TotemDAQMappingESSourceXML::verbosity
private

Definition at line 78 of file TotemDAQMappingESSourceXML.cc.