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 28 of file MiscalibReaderFromXML.h.

Constructor & Destructor Documentation

MiscalibReaderFromXML::MiscalibReaderFromXML ( CaloMiscalibMap caloMap)

Definition at line 26 of file MiscalibReaderXML.cc.

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

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

Definition at line 32 of file MiscalibReaderFromXML.h.

32 {}

Member Function Documentation

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

Definition at line 69 of file MiscalibReaderXML.cc.

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

Referenced by getScalingFactor().

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

Definition at line 51 of file MiscalibReaderXML.cc.

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

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

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

Definition at line 62 of file MiscalibReaderXML.cc.

References getFloatAttribute().

Referenced by parseXMLMiscalibFile().

63 {
64 return MiscalibReaderFromXML::getFloatAttribute(attribute,"scale_factor");
65 }
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 80 of file MiscalibReaderXML.cc.

References _toDOMS(), CaloMiscalibMap::addCell(), assert(), caloMap_, KineDebug3::count(), gather_cfg::cout, getScalingFactor(), i, parseCellEntry(), and createfilelist::parser.

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

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

Member Data Documentation

CaloMiscalibMap& MiscalibReaderFromXML::caloMap_
private

Definition at line 43 of file MiscalibReaderFromXML.h.

Referenced by parseXMLMiscalibFile().

int MiscalibReaderFromXML::s_numberOfInstances = 0
staticprivate

Definition at line 42 of file MiscalibReaderFromXML.h.

Referenced by MiscalibReaderFromXML().