CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 37 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 93 of file AlgorithmCalibration.h.

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

94 {
96  if(m_xml) {
97  m_xml->closeFile();
98  }
99 }
tuple filename
Definition: lut2db_cfg.py:20
template<class T , class CO >
AlgorithmCalibration< T, CO >::~AlgorithmCalibration ( )

Definition at line 102 of file AlgorithmCalibration.h.

103 {
104  if(m_xml) delete m_xml;
105 }

Member Function Documentation

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

Definition at line 75 of file AlgorithmCalibration.h.

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

76  {
77  if(m_xml == 0)
78  {
79  m_xml=new CalibrationXML();
81 
82  }
83  return m_xml->calibrationDOM();
84  }
DOMElement * calibrationDOM()
void openFile(const std::string &xmlFileName)
template<class T , class CO >
bool AlgorithmCalibration< T, CO >::readCategories ( )
protected

Definition at line 108 of file AlgorithmCalibration.h.

References revisionDML::addEntry(), and getGTfromDQMFile::obj.

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

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 }
XERCES_CPP_NAMESPACE::DOMNode DOMNode
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 133 of file AlgorithmCalibration.h.

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 }
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 87 of file AlgorithmCalibration.h.

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

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