CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlgorithmCalibration.h
Go to the documentation of this file.
1 #ifndef ALGORITHM_CALIBRATION_H
2 #define ALGORITHM_CALIBRATION_H
3 
4 #include <map>
5 #include <string>
6 #include <vector>
7 #include <xercesc/dom/DOM.hpp>
8 #include <xercesc/dom/DOMElement.hpp>
9 #include <xercesc/util/XMLString.hpp>
10 #include <string>
11 #include <list>
12 #include <iostream>
13 
14 #include "CalibrationXML.h"
15 //#include "CondFormats/BTagObjects/interface/CalibrationInterface.h"
16 //#include "RecoBTag/TrackProbability/interface/CalibrationInterface.h"
18 
19 namespace XERCES_CPP_NAMESPACE {
20  class DOMNode;
21 }
22 
23 //template <class T,class CO> class CalibrationInterface;
37 template <class T, class CO>
39  // friend class CalibrationInterface<T,CO>;
40 public:
41  typedef XERCES_CPP_NAMESPACE::DOMElement DOMElement;
42  typedef XERCES_CPP_NAMESPACE::DOMNode DOMNode;
43 
49 
51 
55  void startCalibration();
56 
60  void updateCalibration(const typename T::Input &calibrationInput);
61  template <class CI>
62  void updateCalibration(const typename T::Input &calibrationInputForCategory, const CI &inputForCalibration);
63 
68 
69 protected:
70  CO *readObject(DOMNode *);
71  bool readCategories();
72 
73 protected:
75  if (m_xml == nullptr) {
76  m_xml = new CalibrationXML();
78  }
79  return m_xml->calibrationDOM();
80  }
81 
82 private:
85 };
86 
87 template <class T, class CO>
88 AlgorithmCalibration<T, CO>::AlgorithmCalibration(const std::string &filename) : m_filename(filename), m_xml(nullptr) {
90  if (m_xml) {
91  m_xml->closeFile();
92  }
93 }
94 
95 template <class T, class CO>
97  if (m_xml)
98  delete m_xml;
99 }
100 
101 template <class T, class CO>
103  if (dom() == nullptr)
104  return false;
105 
106  DOMNode *n1 = dom()->getFirstChild();
107  while (n1) {
108  if (n1->getNodeType() == DOMNode::ELEMENT_NODE) {
109  T *cat = new T();
110  cat->readFromDOM((DOMElement *)n1);
111  CO *obj = readObject(n1->getFirstChild());
112  if (obj) {
113  this->addEntry(*cat, *obj);
114  delete obj;
115  }
116  delete cat;
117  }
118  n1 = n1->getNextSibling();
119  }
120 
121  return true;
122 }
123 template <class T, class CO>
125  DOMNode *n1 = dom;
126  while (n1) {
127  if (n1->getNodeType() == DOMNode::ELEMENT_NODE)
128  break;
129  n1 = n1->getNextSibling();
130  }
131 
132  if (n1 == nullptr)
133  return nullptr; //Cannot find any calibrated objects
134 
135  CO *co = new CO();
136  co->read((DOMElement *)n1);
137  return co;
138 }
139 
140 #endif
AlgorithmCalibration(const std::string &fileName)
__host__ __device__ VT * co
Definition: prefixScan.h:47
void updateCalibration(const typename T::Input &calibrationInput)
XERCES_CPP_NAMESPACE::DOMNode DOMNode
DOMElement * calibrationDOM()
def cat
Definition: eostools.py:401
XERCES_CPP_NAMESPACE::DOMElement DOMElement
void openFile(const std::string &xmlFileName)
void saveCalibration(const std::string &fileName)
tuple filename
Definition: lut2db_cfg.py:20
long double T