CMS 3D CMS Logo

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>
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::DOMNode
XERCES_CPP_NAMESPACE::DOMNode DOMNode
Definition: AlgorithmCalibration.h:42
AlgorithmCalibration::updateCalibration
void updateCalibration(const typename T::Input &calibrationInput)
AlgorithmCalibration::readObject
CO * readObject(DOMNode *)
Definition: AlgorithmCalibration.h:124
AlgorithmCalibration::m_xml
CalibrationXML * m_xml
Definition: AlgorithmCalibration.h:84
contentValuesFiles.dom
dom
Definition: contentValuesFiles.py:50
AlgorithmCalibration::m_filename
std::string m_filename
Definition: AlgorithmCalibration.h:83
AlgorithmCalibration::saveCalibration
void saveCalibration(const std::string &fileName)
eostools.cat
def cat(path)
Definition: eostools.py:401
AlgorithmCalibration
Definition: AlgorithmCalibration.h:38
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
CalibrationXML
Definition: CalibrationXML.h:13
CalibrationXML::calibrationDOM
DOMElement * calibrationDOM()
Definition: CalibrationXML.h:46
cms::cuda::co
T *__restrict__ co
Definition: prefixScan.h:46
CalibrationXML.h
AlgorithmCalibration::dom
DOMElement * dom()
Definition: AlgorithmCalibration.h:74
Input
#define Input(cl)
Definition: vmac.h:190
AlgorithmCalibration::DOMElement
XERCES_CPP_NAMESPACE::DOMElement DOMElement
Definition: AlgorithmCalibration.h:41
AlgorithmCalibration::readCategories
bool readCategories()
Definition: AlgorithmCalibration.h:102
XERCES_CPP_NAMESPACE
Definition: XmlConfigParser.h:12
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CalibrationXML::openFile
void openFile(const std::string &xmlFileName)
Definition: CalibrationXML.cc:32
T
long double T
Definition: Basic3DVectorLD.h:48
AlgorithmCalibration::~AlgorithmCalibration
~AlgorithmCalibration()
Definition: AlgorithmCalibration.h:96
CalibrationXML::closeFile
void closeFile()
Definition: CalibrationXML.h:36
CalibrationInterface.h
CalibrationInterface
Definition: CalibrationInterface.h:12
AlgorithmCalibration::startCalibration
void startCalibration()
AlgorithmCalibration::AlgorithmCalibration
AlgorithmCalibration(const std::string &fileName)
Definition: AlgorithmCalibration.h:88