CMS 3D CMS Logo

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
 
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
 
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

◆ DOMElement

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

Definition at line 41 of file AlgorithmCalibration.h.

◆ DOMNode

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

◆ AlgorithmCalibration()

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.

88  : m_filename(filename), m_xml(nullptr) {
90  if (m_xml) {
91  m_xml->closeFile();
92  }
93 }

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

◆ ~AlgorithmCalibration()

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

◆ dom()

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

◆ readCategories()

template<class T , class CO >
bool AlgorithmCalibration< T, CO >::readCategories ( )
protected

Definition at line 102 of file AlgorithmCalibration.h.

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 }

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

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

◆ readObject()

template<class T , class CO >
CO * AlgorithmCalibration< T, CO >::readObject ( DOMNode dom)
protected

Definition at line 124 of file AlgorithmCalibration.h.

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 }

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

◆ saveCalibration()

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

Finalize and save the calibration run to fileName

◆ startCalibration()

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

Prepare for a new calibration run

◆ updateCalibration() [1/2]

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

Accumulate information to calibrate.

◆ updateCalibration() [2/2]

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

Member Data Documentation

◆ m_filename

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().

◆ m_xml

template<class T , class CO >
CalibrationXML* AlgorithmCalibration< T, CO >::m_xml
private
AlgorithmCalibration::DOMNode
XERCES_CPP_NAMESPACE::DOMNode DOMNode
Definition: AlgorithmCalibration.h:42
AlgorithmCalibration::readObject
CO * readObject(DOMNode *)
Definition: AlgorithmCalibration.h:124
AlgorithmCalibration::m_xml
CalibrationXML * m_xml
Definition: AlgorithmCalibration.h:84
AlgorithmCalibration::m_filename
std::string m_filename
Definition: AlgorithmCalibration.h:83
eostools.cat
def cat(path)
Definition: eostools.py:401
CalibrationXML
Definition: CalibrationXML.h:13
CalibrationXML::calibrationDOM
DOMElement * calibrationDOM()
Definition: CalibrationXML.h:46
cms::cuda::co
T *__restrict__ co
Definition: prefixScan.h:46
AlgorithmCalibration::dom
DOMElement * dom()
Definition: AlgorithmCalibration.h:74
AlgorithmCalibration::DOMElement
XERCES_CPP_NAMESPACE::DOMElement DOMElement
Definition: AlgorithmCalibration.h:41
AlgorithmCalibration::readCategories
bool readCategories()
Definition: AlgorithmCalibration.h:102
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
CalibrationInterface< T, CO >::addEntry
int addEntry(const T &categoryDefinition, const CO &data)
Definition: CalibrationInterface.h:93
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
CalibrationXML::openFile
void openFile(const std::string &xmlFileName)
Definition: CalibrationXML.cc:32
T
long double T
Definition: Basic3DVectorLD.h:48
CalibrationXML::closeFile
void closeFile()
Definition: CalibrationXML.h:36