BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeCalBaseCnv Class Reference

#include <TreeCalBaseCnv.h>

Inheritance diagram for TreeCalBaseCnv:

Public Member Functions

virtual ~TreeCalBaseCnv ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&refpObject)
ICalibTreeSvcgetCalibTreeSvc ()
 TreeCalBaseCnv (ISvcLocator *svc, const CLID &clid)
virtual StatusCode createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj)
Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
destinationoperator (const source &) const
destinationoperator (const source &) const

Static Public Member Functions

static const unsigned char storageType ()

Protected Member Functions

virtual StatusCode internalCreateObj (DataObject *&refpObject, IOpaqueAddress *address)
virtual StatusCode i_createObj (IOpaqueAddress *address, DataObject *&refpObject)
virtual StatusCode i_processObj (DataObject *pObject, IOpaqueAddress *address)
 In case there is additional work to do on the created object.
virtual StatusCode fillRoot (CalibData::CalibBase *pTDSObj, TObject *pRootObj)
void setBaseInfo (CalibData::CalibBase1 *pObj)
 Another utility for derived classes to use.
Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0

Protected Attributes

ICalibTreeSvcm_treeSvc
ICalibMetaCnvSvcm_metaSvc
IInstrumentNamem_instrSvc
int m_serNo
int m_runfrm
int m_runto
TFile * m_outFile
TTree * m_ttree
TFile * m_inFile
TDirectory * m_saveDir

Additional Inherited Members

Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination

Detailed Description

Base class for calibration converters from Trees to TCDS. All such converters need to do certain things, which are handled here.

Author
HUANG Bin

Definition at line 38 of file TreeCalBaseCnv.h.

Constructor & Destructor Documentation

◆ ~TreeCalBaseCnv()

TreeCalBaseCnv::~TreeCalBaseCnv ( )
virtual
     @file  TreeCalBaseCnv.cxx

Implementation file for Root calibration converter base class

Definition at line 32 of file TreeCalBaseCnv.cxx.

32 {
33 // release TFile, TTree if they need releasing. With normal
34 // termination they should already have been released.
35
36 // doClean();
37}

◆ TreeCalBaseCnv()

TreeCalBaseCnv::TreeCalBaseCnv ( ISvcLocator * svc,
const CLID & clid )

Constructor for this converter

Parameters
svca ISvcLocator interface to find services
clidthe type of object the converter is able to convert

Definition at line 41 of file TreeCalBaseCnv.cxx.

42 : Converter( CALIBTREE_StorageType, clid, svc )
43 , m_treeSvc( 0 )
44 , m_metaSvc( 0 )
45 , m_instrSvc( 0 )
46 , m_outFile( 0 )
47 , m_ttree( 0 )
48 , m_inFile( 0 )
49 , m_saveDir( 0 ) {}
TDirectory * m_saveDir
ICalibMetaCnvSvc * m_metaSvc
IInstrumentName * m_instrSvc
ICalibTreeSvc * m_treeSvc

Referenced by internalCreateObj(), TreeCorrectedETSCnv::TreeCorrectedETSCnv(), TreeDedxCalibDataCnv::TreeDedxCalibDataCnv(), TreeDedxSimDataCnv::TreeDedxSimDataCnv(), TreeEmcCalibDataCnv::TreeEmcCalibDataCnv(), TreeEsTimeCalibDataCnv::TreeEsTimeCalibDataCnv(), TreeEstTofCalibDataCnv::TreeEstTofCalibDataCnv(), TreeInjSigIntervalCnv::TreeInjSigIntervalCnv(), TreeInjSigTimeCnv::TreeInjSigTimeCnv(), TreeMdcAlignDataCnv::TreeMdcAlignDataCnv(), TreeMdcCalibDataCnv::TreeMdcCalibDataCnv(), TreeMdcDataConstCnv::TreeMdcDataConstCnv(), TreeMucCalibDataCnv::TreeMucCalibDataCnv(), TreeOffEvtFilterCnv::TreeOffEvtFilterCnv(), TreeTofCalibDataCnv::TreeTofCalibDataCnv(), TreeTofElecDataCnv::TreeTofElecDataCnv(), and TreeTofSimDataCnv::TreeTofSimDataCnv().

Member Function Documentation

◆ createObj()

StatusCode TreeCalBaseCnv::createObj ( IOpaqueAddress * addr,
DataObject *& refpObject )
virtual

Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters.

Definition at line 111 of file TreeCalBaseCnv.cxx.

111 {
112 // StatusCode ret;
113
114 // first do the things we always need:
115 // First string parameter of opaque address is file ident
116 MsgStream log( msgSvc(), "TreeCalBaseCnv" );
117 log << MSG::DEBUG << "TreeCalBaseCnv::createObj( starting ...." << endmsg;
118 // const std::string* par = addr->par();
119
120 // std::string par0 = par[0];
121
122 // return internalCreateObj(par0, refpObject, addr);
123 return internalCreateObj( refpObject, addr );
124}
IMessageSvc * msgSvc()
virtual StatusCode internalCreateObj(DataObject *&refpObject, IOpaqueAddress *address)

◆ createRoot()

StatusCode TreeCalBaseCnv::createRoot ( const std::string & fname,
CalibData::CalibBase1 * pTDSObj )
virtual

Create ROOT file corresponding to TDS object input. Default implementation is to return an error. Must be separately implemented for each calibration type.

Parameters
fnameFilename for output file
pTDSObjPointer to tds object to be converted

Definition at line 92 of file TreeCalBaseCnv.cxx.

93 {
94 MsgStream log( msgSvc(), "TreeCalBaseCnv" );
95 log << MSG::ERROR << "createRoot method not implemented for this calibration type" << endmsg;
96 return StatusCode::FAILURE;
97}

◆ fillRoot()

StatusCode TreeCalBaseCnv::fillRoot ( CalibData::CalibBase * pTDSObj,
TObject * pRootObj )
protectedvirtual

Given a pointer to a TDS object which can be cast to "our" type, fill in corresponding information in the corresponding root class

Parameters
pTDSObjPointer to tds object to be converted
pRootObjPointer to destination root object

...maybe don't need pRootObj argument; keep this as the (protected) data member m_rootObj. Or else this routine could set the protected member to this passed-in value

Definition at line 100 of file TreeCalBaseCnv.cxx.

101 {
102
103 // Get instrument name from InstrumentName service Now handled by
104 // TreeCalBaseCnv
105 // TString instr = TString((m_instrSvc->getInstrumentName()).c_str());
106 // pRootObj->setInstrument(instr);
107 return StatusCode::SUCCESS;
108}

◆ finalize()

StatusCode TreeCalBaseCnv::finalize ( )
virtual

Definition at line 88 of file TreeCalBaseCnv.cxx.

88{ return Converter::finalize(); }

◆ getCalibTreeSvc()

ICalibTreeSvc * TreeCalBaseCnv::getCalibTreeSvc ( )
inline

Definition at line 54 of file TreeCalBaseCnv.h.

54{ return m_treeSvc; }

◆ i_createObj()

StatusCode TreeCalBaseCnv::i_createObj ( IOpaqueAddress * address,
DataObject *& refpObject )
protectedvirtual

This creates the transient representation of an object from the corresponding ROOT object. This actually does the "new" operation and deals with the attributes of the node. This base class implementation does nothing; it should not normally be called because it doesn't correspond to any TCDS class. Instead, i_createObj of some derived class will be called.

Parameters
fnameThe ROOT file to be read in to be used to builds the object
refpObjectthe object to be built
Returns
status depending on the completion of the call

Reimplemented in TreeCorrectedETSCnv, TreeDedxCalibDataCnv, TreeDedxSimDataCnv, TreeEmcCalibDataCnv, TreeEsTimeCalibDataCnv, TreeEstTofCalibDataCnv, TreeInjSigIntervalCnv, TreeInjSigTimeCnv, TreeMdcAlignDataCnv, TreeMdcCalibDataCnv, TreeMdcDataConstCnv, TreeMucCalibDataCnv, TreeOffEvtFilterCnv, TreeTofCalibDataCnv, TreeTofElecDataCnv, and TreeTofSimDataCnv.

Definition at line 181 of file TreeCalBaseCnv.cxx.

182 {
183 return StatusCode::FAILURE; // shouldn't ever get here
184}

Referenced by internalCreateObj().

◆ i_processObj()

StatusCode TreeCalBaseCnv::i_processObj ( DataObject * pObject,
IOpaqueAddress * address )
protectedvirtual

In case there is additional work to do on the created object.

Definition at line 187 of file TreeCalBaseCnv.cxx.

188 {
189 return StatusCode::SUCCESS;
190}

Referenced by internalCreateObj().

◆ initialize()

StatusCode TreeCalBaseCnv::initialize ( )
virtual

Definition at line 51 of file TreeCalBaseCnv.cxx.

51 {
52 StatusCode status = Converter::initialize();
53
54 IDataProviderSvc* dp;
55
56 // I guess the service names are assigned in jobOptions?
57
58 /* serviceLocator()->getService ("CalibDataSvc",
59 IID_IDataProviderSvc,
60 (IInterface*&)dp);*/
61 serviceLocator()->getService( "CalibDataSvc", IDataProviderSvc::interfaceID(),
62 (IInterface*&)dp );
63 setDataProvider( dp );
64
65 // Locate the Root Conversion Service
66 // serviceLocator()->getService ("CalibTreeCnvSvc",
67 // IID_ICalibTreeSvc,
68 // (IInterface*&) m_treeSvc);
69 IInterface* m_treeSvc = serviceLocator()->service( "CalibTreeCnvSvc" );
70 // Locate meta conversion service
71 // Will anything need to be changed here to accommodate possibility
72 // of two concrete implementations of ICalibMetaCnvSvc? Would
73 // have different storage types. Could specify type desired
74 // as job option. Ditto for name of class?
75 /*serviceLocator()->getService("CalibMySQLCnvSvc",
76 IID_ICalibMetaCnvSvc,
77 (IInterface*&)m_metaSvc);
78 */
79 IInterface* m_metaSvc = serviceLocator()->service( "CalibMySQLCnvSvc" );
80 /*serviceLocator()->getService ("CalibDataSvc",
81 IID_IInstrumentName,
82 (IInterface*&)m_instrSvc);*/
83 IInterface* m_instrSvc = serviceLocator()->service( "CalibDataSvc" );
84
85 return status;
86}

◆ internalCreateObj()

StatusCode TreeCalBaseCnv::internalCreateObj ( DataObject *& refpObject,
IOpaqueAddress * address )
protectedvirtual

Read in object (by default the first) from specified branch. This creates the transient representation of an object from the corresponding ROOT object it, then fills it and process it. This implementation actually only calls the i_* methods of the "right" converter to do the job; so the very first thing it does is get a pointer to the appropriate derived converter. Converters typically don't need to override this method but only to override/implement some of the i_* methods.

Parameters
pRootObjpointer to the ROOT object
refpObjectthe object to be built
addressthe opaque address for this object
Returns
status depending on the completion of the call

Definition at line 129 of file TreeCalBaseCnv.cxx.

130 {
131
132 MsgStream log( msgSvc(), "TreeCalBaseCnv" );
133 log << MSG::DEBUG << "TreeCalBaseCnv::internalCreateObj( starting ..... " << endmsg;
134 TreeCalBaseCnv* converter = this;
135 CLID classId = address->clID();
136
137 IConverter* conv = this->conversionSvc()->converter( classId );
138 if ( 0 == conv )
139 {
140 log << MSG::WARNING << "No proper converter found for classID " << classId
141 << ", the default converter"
142 << " will be used. " << endmsg;
143 }
144 else
145 {
146 converter = dynamic_cast<TreeCalBaseCnv*>( conv );
147 if ( 0 == converter )
148 {
149 log << MSG::ERROR << "The converter found for classID " << classId
150 << " was not a descendent of TreeCalBaseCnv as it should be "
151 << "( was of type " << typeid( *converter ).name() << "). "
152 << "The default converter will be used" << endmsg;
153 converter = this;
154 }
155 }
156
157 TreeAddress* treeAddress = dynamic_cast<TreeAddress*>( address );
158 m_runfrm = treeAddress->getRunFrom();
159 m_runto = treeAddress->getRunTo();
160 // m_runfrm =*( address->ipar());
161 // m_runto =*( address->ipar()+1);
162 // m_runfrm = 100;
163 // m_runto =1000;
164 // creates an object for the node found
165 StatusCode sc = converter->i_createObj( address, refpObject );
166 if ( sc.isFailure() ) { return sc; }
167 CalibData::CalibBase1* tmpObject = dynamic_cast<CalibData::CalibBase1*>( refpObject );
168 setBaseInfo( tmpObject );
169 // ends up the object construction
170 sc = converter->i_processObj( refpObject, address );
171 if ( sc.isSuccess() )
172 { log << MSG::DEBUG << "Successfully created calib. object " << endmsg; }
173 // closeRead();
174 return sc;
175}
virtual StatusCode i_processObj(DataObject *pObject, IOpaqueAddress *address)
In case there is additional work to do on the created object.
TreeCalBaseCnv(ISvcLocator *svc, const CLID &clid)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
void setBaseInfo(CalibData::CalibBase1 *pObj)
Another utility for derived classes to use.

Referenced by createObj().

◆ setBaseInfo()

void TreeCalBaseCnv::setBaseInfo ( CalibData::CalibBase1 * pObj)
protected

Another utility for derived classes to use.

Utility used by derived converters to start writing a ROOT file (open TFile, make a TTree, give it a branch)

Parameters
fnameName for new file
classNameName of class for object specified in next parameter; used to name branch as well)
pCalibpointer to object used to create the branch Finish up writing file opened with openWrite: fill the tree write the file close the file Delete TFile (causes associated Tree to be deleted)
 Utility for "leaf" converters to call
 @param    Root file to open for read
Nameof branch to be read in
ref.to pCalib pointer which will be set to address of read-in object Clean up when we've finished reading in Another convenience for derived classes: sets information belonging to the calibration base class, namely validity interval and serial number.

Definition at line 193 of file TreeCalBaseCnv.cxx.

193 {
194 MsgStream log( msgSvc(), "TreeCalBaseCnv" );
195 log << MSG::DEBUG << "set the runfrm and runto Numbers in the converter" << endmsg;
196 pObj->setrunfrm( m_runfrm );
197 pObj->setrunto( m_runto );
198}

Referenced by internalCreateObj().

◆ storageType()

const unsigned char TreeCalBaseCnv::storageType ( )
inlinestatic

Definition at line 56 of file TreeCalBaseCnv.h.

56{ return CALIBTREE_StorageType; }

Member Data Documentation

◆ m_inFile

TFile* TreeCalBaseCnv::m_inFile
protected

Definition at line 198 of file TreeCalBaseCnv.h.

Referenced by TreeCalBaseCnv().

◆ m_instrSvc

IInstrumentName* TreeCalBaseCnv::m_instrSvc
protected

Definition at line 188 of file TreeCalBaseCnv.h.

Referenced by initialize(), and TreeCalBaseCnv().

◆ m_metaSvc

ICalibMetaCnvSvc* TreeCalBaseCnv::m_metaSvc
protected

Definition at line 187 of file TreeCalBaseCnv.h.

Referenced by initialize(), and TreeCalBaseCnv().

◆ m_outFile

TFile* TreeCalBaseCnv::m_outFile
protected

Definition at line 195 of file TreeCalBaseCnv.h.

Referenced by TreeCalBaseCnv().

◆ m_runfrm

int TreeCalBaseCnv::m_runfrm
protected

Definition at line 191 of file TreeCalBaseCnv.h.

Referenced by internalCreateObj(), and setBaseInfo().

◆ m_runto

int TreeCalBaseCnv::m_runto
protected

Definition at line 192 of file TreeCalBaseCnv.h.

Referenced by internalCreateObj(), and setBaseInfo().

◆ m_saveDir

TDirectory* TreeCalBaseCnv::m_saveDir
protected

Definition at line 200 of file TreeCalBaseCnv.h.

Referenced by TreeCalBaseCnv().

◆ m_serNo

int TreeCalBaseCnv::m_serNo
protected

Definition at line 190 of file TreeCalBaseCnv.h.

◆ m_treeSvc

ICalibTreeSvc* TreeCalBaseCnv::m_treeSvc
protected

Definition at line 186 of file TreeCalBaseCnv.h.

Referenced by getCalibTreeSvc(), initialize(), and TreeCalBaseCnv().

◆ m_ttree

TTree* TreeCalBaseCnv::m_ttree
protected

Definition at line 196 of file TreeCalBaseCnv.h.

Referenced by TreeCalBaseCnv().


The documentation for this class was generated from the following files: