CMS 3D CMS Logo

AlgorithmCalibration< T, CO > Class Template Reference

The AlgorithmCalibration class is the interface between user code and calibration framework developed for BReco subsytem. More...

#include <RecoBTag/XMLCalibration/interface/AlgorithmCalibration.h>

Inheritance diagram for AlgorithmCalibration< T, CO >:

CalibrationInterface< T, CO >

List of all members.

Public Member Functions

 AlgorithmCalibration (const std::string &fileName)
 Create an AlgorithmCalibration class and load from fileName the cateogries and their objects.
void saveCalibration (const std::string &fileName)
 Finalize and save the calibration run to fileName.
void startCalibration ()
 Prepare for a new calibration run.
template<class CI>
void updateCalibration (const typename T::Input &calibrationInputForCategory, const CI &inputForCalibration)
void updateCalibration (const typename T::Input &calibrationInput)
 Accumulate information to calibrate.
 ~AlgorithmCalibration ()

Protected Member Functions

DOMElement * dom ()
bool readCategories ()
CO * readObject (DOMNode *)

Private Attributes

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

template<class T, class CO>
AlgorithmCalibration< T, CO >::~AlgorithmCalibration (  )  [inline]

Definition at line 102 of file AlgorithmCalibration.h.

References AlgorithmCalibration< T, CO >::m_xml.

00103 {
00104    if(m_xml) delete m_xml;
00105 }


Member Function Documentation

template<class T, class CO>
DOMElement* AlgorithmCalibration< T, CO >::dom (  )  [inline, protected]

Definition at line 75 of file AlgorithmCalibration.h.

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

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

00076     {
00077       if(m_xml == 0)
00078        {
00079         m_xml=new CalibrationXML();
00080         m_xml->openFile(m_filename);
00081         
00082        } 
00083     return m_xml->calibrationDOM();
00084     }

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

Definition at line 108 of file AlgorithmCalibration.h.

References CalibrationInterface< T, CO >::addEntry(), AlgorithmCalibration< T, CO >::dom(), VarParsing::obj, and AlgorithmCalibration< T, CO >::readObject().

00109 {
00110    if(dom()==0) return false;
00111    
00112    DOMNode* n1 = dom()->getFirstChild();
00113    while(n1)
00114     {
00115       if (n1->getNodeType() == DOMNode::ELEMENT_NODE   )
00116       {
00117           T *cat = new T();
00118           cat->readFromDOM((DOMElement *)n1);
00119           CO * obj =readObject(n1->getFirstChild());
00120           if(obj) 
00121            {
00122                 addEntry(*cat,*obj);  
00123                 delete obj;  
00124            }
00125           delete cat;
00126       }
00127       n1 = n1->getNextSibling();
00128     }
00129     
00130  return true;
00131 }

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

Definition at line 133 of file AlgorithmCalibration.h.

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

00134 {
00135   DOMNode* n1 = dom;
00136   while(n1)
00137     {
00138       if (n1->getNodeType() == DOMNode::ELEMENT_NODE   )
00139            break;
00140       n1 = n1->getNextSibling();
00141     }
00142      
00143   if(n1==0) return 0; //Cannot find any calibrated objects
00144   
00145   CO * co = new CO();
00146   co->read((DOMElement *)n1);
00147   return co;
00148 }

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>
template<class CI>
void AlgorithmCalibration< T, CO >::updateCalibration ( const typename T::Input &  calibrationInputForCategory,
const CI &  inputForCalibration 
) [inline]

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

Accumulate information to calibrate.


Member Data Documentation

template<class T, class CO>
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]

Definition at line 88 of file AlgorithmCalibration.h.

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


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:14:12 2009 for CMSSW by  doxygen 1.5.4