CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 30 of file MiscalibReaderFromXML.h.

Constructor & Destructor Documentation

MiscalibReaderFromXML::MiscalibReaderFromXML ( CaloMiscalibMap caloMap)

Definition at line 25 of file MiscalibReaderXML.cc.

References _toString(), gather_cfg::cout, alignCSCRings::e, and s_numberOfInstances.

25  :caloMap_(caloMap){
26 
27 
28  try {
29  //std::cout << "Xerces-c initialization Number "
30  //<< s_numberOfInstances<<std::endl;
31  if (s_numberOfInstances==0)
32  XMLPlatformUtils::Initialize();
33  }
34  catch (const XMLException& e) {
35  std::cout << "Xerces-c error in initialization \n"
36  << "Exception message is: \n"
37  << _toString(e.getMessage()) <<std::endl;
38  // throw an exception here
39  }
40 
42 
43 
44 
45 
46 }
std::string _toString(const XMLCh *toTranscode)
CaloMiscalibMap & caloMap_
tuple cout
Definition: gather_cfg.py:121
virtual MiscalibReaderFromXML::~MiscalibReaderFromXML ( )
inlinevirtual

Definition at line 34 of file MiscalibReaderFromXML.h.

34 {}

Member Function Documentation

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

Definition at line 68 of file MiscalibReaderXML.cc.

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

Referenced by getScalingFactor().

69 {
70 bool well_formed_string;
71 double retval = MiscalibReaderFromXMLDomUtils::getFloatAttribute(attribute,attribute_name,well_formed_string);
72 if(!well_formed_string) std::cout << "MiscalibReaderFromXML::getFloatAttribute PROBLEMS ...!!!" << std::endl;
73 
74  return retval;
75 }
static double getFloatAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes, std::string attr_name, bool &well_formed_string)
tuple cout
Definition: gather_cfg.py:121
int MiscalibReaderFromXML::getIntAttribute ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute,
const std::string &  attribute_name 
)

Definition at line 50 of file MiscalibReaderXML.cc.

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

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

51 {
52 bool well_formed_string;
53 int retval = MiscalibReaderFromXMLDomUtils::getIntAttribute(attribute,attribute_name,well_formed_string);
54 if(!well_formed_string) std::cout << "MiscalibReaderFromXML::getIntAttribute PROBLEMS ...!!!" << std::endl;
55 
56  return retval;
57 }
static int getIntAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes, std::string attr_name, bool &well_formed_string)
tuple cout
Definition: gather_cfg.py:121
double MiscalibReaderFromXML::getScalingFactor ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute)

Definition at line 61 of file MiscalibReaderXML.cc.

References getFloatAttribute().

Referenced by parseXMLMiscalibFile().

62 {
63 return MiscalibReaderFromXML::getFloatAttribute(attribute,"scale_factor");
64 }
double getFloatAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute, const std::string &attribute_name)
virtual DetId MiscalibReaderFromXML::parseCellEntry ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute)
pure virtual
bool MiscalibReaderFromXML::parseXMLMiscalibFile ( std::string  configFile)

Get ME name

Definition at line 79 of file MiscalibReaderXML.cc.

References _toDOMS(), CaloMiscalibMap::addCell(), asciidump::attributes, caloMap_, prof2calltree::count, gather_cfg::cout, asciidump::doc, getScalingFactor(), i, parseCellEntry(), and geometryXMLtoCSV::parser.

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

79  {
80 
81  XercesDOMParser* parser = new XercesDOMParser;
82  parser->setValidationScheme(XercesDOMParser::Val_Auto);
83  parser->setDoNamespaces(false);
84  parser->parse(configFile.c_str());
85  DOMDocument* doc = parser->getDocument();
86  assert(doc);
87 
88  unsigned int linkTagsNum = doc->getElementsByTagName(_toDOMS("Cell"))->getLength();
89  // The following should be on LogInfo
90  //std::cout << "Read number of Cells = " << linkTagsNum << std::endl;
91 
92  if(linkTagsNum==0) std::cout <<"Number of Cells in file is 0 - probably bad file format"<<std::endl;
93 
94  int count=0;
95  for (unsigned int i=0; i<linkTagsNum; i++){
96 
97 
98  DOMNode* linkNode = doc->getElementsByTagName(_toDOMS("Cell"))->item(i);
100  if (! linkNode){
101  std::cout<<"Node LINK does not exist, i="<<i<<std::endl;
102  return true;
103  }
104  DOMElement* linkElement = static_cast<DOMElement *>(linkNode);
105  if (! linkElement){
106  std::cout<<"Element LINK does not exist, i="<<i<<std::endl;
107  return true;
108  }
109 
110 
111  DOMNamedNodeMap *attributes = linkNode->getAttributes();
112  double scalingfactor= getScalingFactor(attributes);
113 
114 
115 
116  DetId cell = parseCellEntry(attributes);
117 
118  if(cell!= DetId(0))
119  {
120  count++;
121  caloMap_.addCell(cell,scalingfactor);
122  } else
123  {
124  // std::cout << "Null received" << std::endl;
125  }
126 
127  }
128 
129  // The following should be on LogInfo
130  // std::cout << "Number of good Cells = " << count << std::endl;
131  return false;
132 
133 }
int i
Definition: DBlmapReader.cc:9
CaloMiscalibMap & caloMap_
virtual void addCell(const DetId &cell, float scaling_factor)=0
double getScalingFactor(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)
list attributes
Definition: asciidump.py:415
tuple doc
Definition: asciidump.py:381
Definition: DetId.h:20
XMLCh * _toDOMS(std::string temp)
tuple cout
Definition: gather_cfg.py:121
virtual DetId parseCellEntry(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)=0

Member Data Documentation

CaloMiscalibMap& MiscalibReaderFromXML::caloMap_
private

Definition at line 45 of file MiscalibReaderFromXML.h.

Referenced by parseXMLMiscalibFile().

int MiscalibReaderFromXML::s_numberOfInstances = 0
staticprivate

Definition at line 44 of file MiscalibReaderFromXML.h.

Referenced by MiscalibReaderFromXML().