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 ()
 
- 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 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 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 269 of file TotemDAQMappingESSourceXML.cc.

270 {
271 }

Member Function Documentation

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

extracts VFAT's DAQ channel from XML attributes

Definition at line 606 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseTreeDiamond(), and ParseTreeRP().

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

References edm::FileInPath::fullPath().

Referenced by produce().

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

Definition at line 660 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseTreeRP().

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

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

determines node type

Definition at line 635 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().

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

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

145  {
146  return string(xercesc::XMLString::transcode(node->getNodeValue()));
147  }
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 479 of file TotemDAQMappingESSourceXML.cc.

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

Referenced by ParseXML().

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

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

Referenced by ParseXML().

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

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

Referenced by produce().

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

285 {
286  assert(currentBlockValid);
287 
288  auto mapping = std::make_shared<TotemDAQMapping>();
289  auto mask = std::make_shared<TotemAnalysisMask>();
290 
291  // initialize Xerces
292  try
293  {
294  XMLPlatformUtils::Initialize();
295  }
296  catch (const XMLException& toCatch)
297  {
298  char* message = XMLString::transcode(toCatch.getMessage());
299  throw cms::Exception("TotemDAQMappingESSourceXML") << "An XMLException caught with message: " << message << ".\n";
300  XMLString::release(&message);
301  }
302 
303  // load mapping files
304  for (const auto &fn : configuration[currentBlock].mappingFileNames)
306 
307  // load mask files
308  for (const auto &fn : configuration[currentBlock].maskFileNames)
309  ParseXML(pMask, CompleteFileName(fn), mapping, mask);
310 
311  // release Xerces
312  XMLPlatformUtils::Terminate();
313 
314  // commit the products
315  return edm::es::products(mapping, mask);
316 }
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: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 
)
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, training_settings::idx, 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  // event id "1:min" has a special meaning and is translated to a truly minimal event id (1:0:0)
240  if (range.startEventID()==edm::EventID(1, 0, 1))
241  range = edm::EventRange(edm::EventID(1, 0, 0), range.endEventID());
242 
243  if (edm::contains(range, iosv.eventID()))
244  {
245  currentBlockValid = true;
246  currentBlock = idx;
247 
248  const IOVSyncValue begin(range.startEventID());
249  const IOVSyncValue end(range.endEventID());
250  oValidity = edm::ValidityInterval(begin, end);
251 
252  LogVerbatim("TotemDAQMappingESSourceXML")
253  << " block found: index=" << currentBlock
254  << ", interval=(" << range.startEventID() << " - " << range.endEventID() << ")";
255 
256  return;
257  }
258  }
259 
260  if (!currentBlockValid)
261  {
262  throw cms::Exception("TotemDAQMappingESSourceXML::setIntervalFor") <<
263  "No configuration for event " << iosv.eventID();
264  }
265 }
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
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 129 of file TotemDAQMappingESSourceXML.cc.

Referenced by GetChannels(), and GetNodeType().

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

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.

Referenced by CommonNode().

const string TotemDAQMappingESSourceXML::tagArm = "arm"
static

Common position tags.

Definition at line 57 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagChannel ="channel"
static

Definition at line 53 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

const string TotemDAQMappingESSourceXML::tagChip1 = "vfat"
static

COMMON Chip XML tags.

Definition at line 65 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagChip2 = "test_vfat"
static

Definition at line 66 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondCh = "diamond_channel"
static

Definition at line 70 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagDiamondPlane = "rp_plane_diamond"
static

diamond specific tags

Definition at line 69 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPlane = "rp_plane"
static

Definition at line 62 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPPot = "rp_detector_set"
static

Definition at line 61 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagRPStation = "station"
static

RP XML tags.

Definition at line 60 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode(), and GetNodeType().

const string TotemDAQMappingESSourceXML::tagVFAT ="vfat"
static

Definition at line 52 of file TotemDAQMappingESSourceXML.cc.

Referenced by CommonNode().

unsigned int TotemDAQMappingESSourceXML::verbosity
private

Definition at line 78 of file TotemDAQMappingESSourceXML.cc.