CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
AlgorithmCalibration< T, CO > Class Template Reference

#include <AlgorithmCalibration.h>

Inheritance diagram for AlgorithmCalibration< T, CO >:
CalibrationInterface< T, CO >

Public Types

typedef
XERCES_CPP_NAMESPACE::DOMElement 
DOMElement
 
typedef
XERCES_CPP_NAMESPACE::DOMNode 
DOMNode
 

Public Member Functions

 AlgorithmCalibration (const std::string &fileName)
 
void saveCalibration (const std::string &fileName)
 
void startCalibration ()
 
void updateCalibration (const typename T::Input &calibrationInput)
 
template<class CI >
void updateCalibration (const typename T::Input &calibrationInputForCategory, const CI &inputForCalibration)
 
 ~AlgorithmCalibration ()
 
- Public Member Functions inherited from CalibrationInterface< T, CO >
int addCategoryDefinition (const T &categoryDefinition)
 
int addEntry (const T &categoryDefinition, const CO &data)
 
 CalibrationInterface ()
 
const std::vector< std::pair
< T, CO > > & 
categoriesWithData () const
 
const CO * getCalibData (const typename T::Input &calibrationInput) const
 
CO * getCalibData (const typename T::Input &calibrationInput)
 
const CO * getCalibData (int index) const
 
CO * getCalibData (int index)
 
const TgetCategoryDefinition (int index) const
 
int getIndex (const typename T::Input &calibrationInput) const
 
void setCalibData (int index, const CO &data)
 
int size () const
 
 ~CalibrationInterface ()
 

Protected Member Functions

DOMElementdom ()
 
bool readCategories ()
 
CO * readObject (DOMNode *)
 

Private Attributes

std::string m_filename
 
CalibrationXMLm_xml
 

Detailed Description

template<class T, class CO>
class AlgorithmCalibration< T, CO >

The AlgorithmCalibration class is the interface between user code and calibration framework developed for BReco subsytem. Both the analysis programs and the calibration programs should only access calibration information via that class.

An algorithm is supposed to keep a single instance of that class to avoid the reload of XML for every event (during analysis) and because you want to accumulate over all events the data to perform a new calibration in the calibration program.

The class is templated on the Category T and on the CalibratedObject CO

Definition at line 38 of file AlgorithmCalibration.h.

Member Typedef Documentation

template<class T , class CO >
typedef XERCES_CPP_NAMESPACE::DOMElement AlgorithmCalibration< T, CO >::DOMElement

Definition at line 41 of file AlgorithmCalibration.h.

template<class T , class CO >
typedef XERCES_CPP_NAMESPACE::DOMNode AlgorithmCalibration< T, CO >::DOMNode

Definition at line 42 of file AlgorithmCalibration.h.

Constructor & Destructor Documentation

template<class T , class CO >
AlgorithmCalibration< T, CO >::AlgorithmCalibration ( const std::string &  fileName)

Create an AlgorithmCalibration class and load from fileName the cateogries and their objects.

Definition at line 88 of file AlgorithmCalibration.h.

References CalibrationXML::closeFile(), AlgorithmCalibration< T, CO >::m_xml, and AlgorithmCalibration< T, CO >::readCategories().

88  : m_filename(filename), m_xml(nullptr) {
90  if (m_xml) {
91  m_xml->closeFile();
92  }
93 }
tuple filename
Definition: lut2db_cfg.py:20
template<class T , class CO >
AlgorithmCalibration< T, CO >::~AlgorithmCalibration ( )

Definition at line 96 of file AlgorithmCalibration.h.

96  {
97  if (m_xml)
98  delete m_xml;
99 }

Member Function Documentation

template<class T , class CO >
DOMElement* AlgorithmCalibration< T, CO >::dom ( )
inlineprotected

Definition at line 74 of file AlgorithmCalibration.h.

References CalibrationXML::calibrationDOM(), AlgorithmCalibration< T, CO >::m_filename, AlgorithmCalibration< T, CO >::m_xml, and CalibrationXML::openFile().

74  {
75  if (m_xml == nullptr) {
76  m_xml = new CalibrationXML();
78  }
79  return m_xml->calibrationDOM();
80  }
DOMElement * calibrationDOM()
void openFile(const std::string &xmlFileName)
template<class T , class CO >
bool AlgorithmCalibration< T, CO >::readCategories ( )
protected

Definition at line 102 of file AlgorithmCalibration.h.

References eostools::cat(), contentValuesFiles::dom, and getGTfromDQMFile::obj.

Referenced by AlgorithmCalibration< T, CO >::AlgorithmCalibration().

102  {
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 }
XERCES_CPP_NAMESPACE::DOMNode DOMNode
def cat
Definition: eostools.py:401
XERCES_CPP_NAMESPACE::DOMElement DOMElement
int addEntry(const T &categoryDefinition, const CO &data)
long double T
template<class T , class CO >
CO * AlgorithmCalibration< T, CO >::readObject ( DOMNode dom)
protected

Definition at line 124 of file AlgorithmCalibration.h.

References cms::cuda::co, and contentValuesFiles::dom.

124  {
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 }
__host__ __device__ VT * co
Definition: prefixScan.h:47
XERCES_CPP_NAMESPACE::DOMNode DOMNode
XERCES_CPP_NAMESPACE::DOMElement DOMElement
template<class T , class CO >
void AlgorithmCalibration< T, CO >::saveCalibration ( const std::string &  fileName)

Finalize and save the calibration run to fileName

template<class T , class CO >
void AlgorithmCalibration< T, CO >::startCalibration ( )

Prepare for a new calibration run

template<class T , class CO >
void AlgorithmCalibration< T, CO >::updateCalibration ( const typename T::Input &  calibrationInput)

Accumulate information to calibrate.

template<class T , class CO >
template<class CI >
void AlgorithmCalibration< T, CO >::updateCalibration ( const typename T::Input &  calibrationInputForCategory,
const CI &  inputForCalibration 
)

Member Data Documentation

template<class T , class CO >
std::string AlgorithmCalibration< T, CO >::m_filename
private

Definition at line 83 of file AlgorithmCalibration.h.

Referenced by AlgorithmCalibration< T, CO >::dom().

template<class T , class CO >
CalibrationXML* AlgorithmCalibration< T, CO >::m_xml
private