CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
MiscalibReaderFromXML Class Referenceabstract

#include <MiscalibReaderFromXML.h>

Inheritance diagram for MiscalibReaderFromXML:
MiscalibReaderFromXMLEcalBarrel MiscalibReaderFromXMLEcalEndcap MiscalibReaderFromXMLHcal

Public Member Functions

double getFloatAttribute (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute, const std::string &attribute_name)
 
int getIntAttribute (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute, const std::string &attribute_name)
 
double getScalingFactor (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)
 
 MiscalibReaderFromXML (CaloMiscalibMap &)
 
virtual DetId parseCellEntry (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)=0
 
bool parseXMLMiscalibFile (std::string configFile)
 
virtual ~MiscalibReaderFromXML ()
 

Private Attributes

CaloMiscalibMapcaloMap_
 

Static Private Attributes

static int s_numberOfInstances = 0
 

Detailed Description

Definition at line 26 of file MiscalibReaderFromXML.h.

Constructor & Destructor Documentation

◆ MiscalibReaderFromXML()

MiscalibReaderFromXML::MiscalibReaderFromXML ( CaloMiscalibMap caloMap)

Definition at line 24 of file MiscalibReaderXML.cc.

References _toString(), gather_cfg::cout, MillePedeFileConverter_cfg::e, s_numberOfInstances, and cms::concurrency::xercesInitialize().

24  : caloMap_(caloMap) {
25  try {
26  //std::cout << "Xerces-c initialization Number "
27  //<< s_numberOfInstances<<std::endl;
28  if (s_numberOfInstances == 0)
30  } catch (const XMLException& e) {
31  std::cout << "Xerces-c error in initialization \n"
32  << "Exception message is: \n"
33  << _toString(e.getMessage()) << std::endl;
34  // throw an exception here
35  }
36 
38 }
std::string _toString(const XMLCh *toTranscode)
CaloMiscalibMap & caloMap_
void xercesInitialize()
Definition: Xerces.cc:18

◆ ~MiscalibReaderFromXML()

virtual MiscalibReaderFromXML::~MiscalibReaderFromXML ( )
inlinevirtual

Definition at line 29 of file MiscalibReaderFromXML.h.

29 {}

Member Function Documentation

◆ getFloatAttribute()

double MiscalibReaderFromXML::getFloatAttribute ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute,
const std::string &  attribute_name 
)

Definition at line 58 of file MiscalibReaderXML.cc.

References gather_cfg::cout, and MiscalibReaderFromXMLDomUtils::getFloatAttribute().

Referenced by getScalingFactor().

58  {
59  bool well_formed_string;
60  double retval = MiscalibReaderFromXMLDomUtils::getFloatAttribute(attribute, attribute_name, well_formed_string);
61  if (!well_formed_string)
62  std::cout << "MiscalibReaderFromXML::getFloatAttribute PROBLEMS ...!!!" << std::endl;
63 
64  return retval;
65 }
static double getFloatAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes, std::string attr_name, bool &well_formed_string)

◆ getIntAttribute()

int MiscalibReaderFromXML::getIntAttribute ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute,
const std::string &  attribute_name 
)

Definition at line 41 of file MiscalibReaderXML.cc.

References gather_cfg::cout, and MiscalibReaderFromXMLDomUtils::getIntAttribute().

Referenced by MiscalibReaderFromXMLEcalBarrel::parseCellEntry(), MiscalibReaderFromXMLHcal::parseCellEntry(), and MiscalibReaderFromXMLEcalEndcap::parseCellEntry().

41  {
42  bool well_formed_string;
43  int retval = MiscalibReaderFromXMLDomUtils::getIntAttribute(attribute, attribute_name, well_formed_string);
44  if (!well_formed_string)
45  std::cout << "MiscalibReaderFromXML::getIntAttribute PROBLEMS ...!!!" << std::endl;
46 
47  return retval;
48 }
static int getIntAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes, std::string attr_name, bool &well_formed_string)

◆ getScalingFactor()

double MiscalibReaderFromXML::getScalingFactor ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute)

Definition at line 52 of file MiscalibReaderXML.cc.

References getFloatAttribute().

Referenced by parseXMLMiscalibFile().

52  {
53  return MiscalibReaderFromXML::getFloatAttribute(attribute, "scale_factor");
54 }
double getFloatAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute, const std::string &attribute_name)

◆ parseCellEntry()

virtual DetId MiscalibReaderFromXML::parseCellEntry ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute)
pure virtual

◆ parseXMLMiscalibFile()

bool MiscalibReaderFromXML::parseXMLMiscalibFile ( std::string  configFile)

Get ME name

Definition at line 69 of file MiscalibReaderXML.cc.

References _toDOMS(), CaloMiscalibMap::addCell(), cms::cuda::assert(), caloMap_, GCPpyPlots::configFile, gather_cfg::cout, hcalRecHitTable_cff::doc, getScalingFactor(), mps_fire::i, parseCellEntry(), and writedatasetfile::parser.

Referenced by HcalRecHitRecalib::beginRun(), InvRingCalib::duringLoop(), ZeeCalibration::duringLoop(), CaloMiscalibTools::produce(), and CaloMiscalibToolsMC::produce().

69  {
70  XercesDOMParser* parser = new XercesDOMParser;
71  parser->setValidationScheme(XercesDOMParser::Val_Auto);
72  parser->setDoNamespaces(false);
73  parser->parse(configFile.c_str());
74  DOMDocument* doc = parser->getDocument();
75  assert(doc);
76 
77  unsigned int linkTagsNum = doc->getElementsByTagName(_toDOMS("Cell"))->getLength();
78  // The following should be on LogInfo
79  //std::cout << "Read number of Cells = " << linkTagsNum << std::endl;
80 
81  if (linkTagsNum == 0)
82  std::cout << "Number of Cells in file is 0 - probably bad file format" << std::endl;
83 
84  for (unsigned int i = 0; i < linkTagsNum; i++) {
85  DOMNode* linkNode = doc->getElementsByTagName(_toDOMS("Cell"))->item(i);
87  if (!linkNode) {
88  std::cout << "Node LINK does not exist, i=" << i << std::endl;
89  return true;
90  }
91  DOMElement* linkElement = static_cast<DOMElement*>(linkNode);
92  if (!linkElement) {
93  std::cout << "Element LINK does not exist, i=" << i << std::endl;
94  return true;
95  }
96 
97  DOMNamedNodeMap* attributes = linkNode->getAttributes();
98  double scalingfactor = getScalingFactor(attributes);
99 
100  DetId cell = parseCellEntry(attributes);
101 
102  if (cell != DetId(0)) {
103  caloMap_.addCell(cell, scalingfactor);
104  } else {
105  // std::cout << "Null received" << std::endl;
106  }
107  }
108 
109  // The following should be on LogInfo
110  // std::cout << "Number of good Cells = " << count << std::endl;
111  return false;
112 }
CaloMiscalibMap & caloMap_
assert(be >=bs)
virtual void addCell(const DetId &cell, float scaling_factor)=0
double getScalingFactor(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)
Definition: DetId.h:17
XMLCh * _toDOMS(std::string temp)
virtual DetId parseCellEntry(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)=0

Member Data Documentation

◆ caloMap_

CaloMiscalibMap& MiscalibReaderFromXML::caloMap_
private

Definition at line 40 of file MiscalibReaderFromXML.h.

Referenced by parseXMLMiscalibFile().

◆ s_numberOfInstances

int MiscalibReaderFromXML::s_numberOfInstances = 0
staticprivate

Definition at line 39 of file MiscalibReaderFromXML.h.

Referenced by MiscalibReaderFromXML().