CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 { class DOMNode; }
20 
21 
22 
23 //template <class T,class CO> class CalibrationInterface;
37 template <class T,class CO> class AlgorithmCalibration : public CalibrationInterface<T,CO>
38 {
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> void updateCalibration(const typename T::Input & calibrationInputForCategory,const CI & inputForCalibration);
62 
66  void saveCalibration(const std::string & fileName);
67 
68  protected:
69 
70  CO* readObject(DOMNode *);
71  bool readCategories();
72 
73  protected:
74 
76  {
77  if(m_xml == 0)
78  {
79  m_xml=new CalibrationXML();
81 
82  }
83  return m_xml->calibrationDOM();
84  }
85 
86  private:
89 };
90 
91 
92 template <class T,class CO>
94 {
96  if(m_xml) {
97  m_xml->closeFile();
98  }
99 }
100 
101 template <class T,class CO>
103 {
104  if(m_xml) delete m_xml;
105 }
106 
107 template <class T,class CO>
109 {
110  if(dom()==0) return false;
111 
112  DOMNode* n1 = dom()->getFirstChild();
113  while(n1)
114  {
115  if (n1->getNodeType() == DOMNode::ELEMENT_NODE )
116  {
117  T *cat = new T();
118  cat->readFromDOM((DOMElement *)n1);
119  CO * obj =readObject(n1->getFirstChild());
120  if(obj)
121  {
122  this->addEntry(*cat,*obj);
123  delete obj;
124  }
125  delete cat;
126  }
127  n1 = n1->getNextSibling();
128  }
129 
130  return true;
131 }
132 template <class T,class CO>
134 {
135  DOMNode* n1 = dom;
136  while(n1)
137  {
138  if (n1->getNodeType() == DOMNode::ELEMENT_NODE )
139  break;
140  n1 = n1->getNextSibling();
141  }
142 
143  if(n1==0) return 0; //Cannot find any calibrated objects
144 
145  CO * co = new CO();
146  co->read((DOMElement *)n1);
147  return co;
148 }
149 
150 #endif
#define Input(cl)
Definition: vmac.h:188
AlgorithmCalibration(const std::string &fileName)
void updateCalibration(const typename T::Input &calibrationInput)
XERCES_CPP_NAMESPACE::DOMNode DOMNode
DOMElement * calibrationDOM()
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