CGEM BOSS 6.6.5.i
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
 

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
 

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
 

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 39 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
38}

◆ 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 42 of file TreeCalBaseCnv.cxx.

42 :
unsigned const char CALIBTREE_StorageType
TDirectory * m_saveDir
ICalibMetaCnvSvc * m_metaSvc
IInstrumentName * m_instrSvc
ICalibTreeSvc * m_treeSvc

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.

112 {
113 // StatusCode ret;
114
115 // first do the things we always need:
116 // First string parameter of opaque address is file ident
117 MsgStream log(msgSvc(), "TreeCalBaseCnv");
118 log << MSG::DEBUG<<"TreeCalBaseCnv::createObj( starting ...."<<endreq;
119 // const std::string* par = addr->par();
120
121 // std::string par0 = par[0];
122
123// return internalCreateObj(par0, refpObject, addr);
124 return internalCreateObj(refpObject, addr);
125
126}
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 89 of file TreeCalBaseCnv.cxx.

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

◆ 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 82 of file TreeCalBaseCnv.cxx.

82 {
83 return Converter::finalize();
84}

◆ getCalibTreeSvc()

ICalibTreeSvc * TreeCalBaseCnv::getCalibTreeSvc ( )
inline

Definition at line 58 of file TreeCalBaseCnv.h.

58 {
59 return m_treeSvc;
60 }

◆ 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 TreeDedxCalibDataCnv, TreeDedxSimDataCnv, TreeEmcCalibDataCnv, TreeEsTimeCalibDataCnv, TreeEstTofCalibDataCnv, TreeMdcAlignDataCnv, TreeMdcCalibDataCnv, TreeMdcDataConstCnv, TreeMucCalibDataCnv, TreeTofCalibDataCnv, TreeTofElecDataCnv, and TreeTofSimDataCnv.

Definition at line 184 of file TreeCalBaseCnv.cxx.

185 {
186 return StatusCode::FAILURE; // shouldn't ever get here
187}

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 190 of file TreeCalBaseCnv.cxx.

191 {
192 return StatusCode::SUCCESS;
193}

Referenced by internalCreateObj().

◆ initialize()

StatusCode TreeCalBaseCnv::initialize ( )
virtual

Definition at line 46 of file TreeCalBaseCnv.cxx.

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

◆ 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 131 of file TreeCalBaseCnv.cxx.

132 {
133
134 MsgStream log(msgSvc(), "TreeCalBaseCnv");
135 log << MSG::DEBUG<<"TreeCalBaseCnv::internalCreateObj( starting ..... "<<endreq;
136 TreeCalBaseCnv* converter = this;
137 CLID classId = address->clID();
138
139 IConverter* conv = this->conversionSvc()->converter(classId);
140 if (0 == conv) {
141 log << MSG::WARNING
142 << "No proper converter found for classID " << classId
143 << ", the default converter"
144 << " will be used. " << endreq;
145 } else {
146 converter = dynamic_cast <TreeCalBaseCnv*> (conv);
147 if (0 == converter) {
148 log << MSG::ERROR
149 << "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" << endreq;
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()) {
167 return sc;
168 }
169 CalibData::CalibBase1* tmpObject = dynamic_cast <CalibData::CalibBase1*> (refpObject);
170 setBaseInfo(tmpObject);
171 // ends up the object construction
172 sc = converter->i_processObj(refpObject, address);
173 if (sc.isSuccess()) {
174 log << MSG::DEBUG << "Successfully created calib. object " << endreq;
175 }
176 // closeRead();
177 return sc;
178}
int getRunFrom()
get run from
int getRunTo()
get run to
virtual StatusCode i_processObj(DataObject *pObject, IOpaqueAddress *address)
In case there is additional work to do on the created object.
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 196 of file TreeCalBaseCnv.cxx.

196 {
197 MsgStream log(msgSvc(), "TreeCalBaseCnv");
198 log << MSG::DEBUG<<"set the runfrm and runto Numbers in the converter"<<endreq;
199 pObj->setrunfrm(m_runfrm);
200 pObj->setrunto(m_runto);
201}
void setrunto(int runto)
Definition CalibBase1.h:56
void setrunfrm(int runfrm)
Definition CalibBase1.h:55

Referenced by internalCreateObj().

◆ storageType()

static const unsigned char TreeCalBaseCnv::storageType ( )
inlinestatic

Definition at line 62 of file TreeCalBaseCnv.h.

Member Data Documentation

◆ m_inFile

TFile* TreeCalBaseCnv::m_inFile
protected

Definition at line 212 of file TreeCalBaseCnv.h.

◆ m_instrSvc

IInstrumentName* TreeCalBaseCnv::m_instrSvc
protected

Definition at line 202 of file TreeCalBaseCnv.h.

Referenced by initialize().

◆ m_metaSvc

ICalibMetaCnvSvc* TreeCalBaseCnv::m_metaSvc
protected

Definition at line 201 of file TreeCalBaseCnv.h.

Referenced by initialize().

◆ m_outFile

TFile* TreeCalBaseCnv::m_outFile
protected

Definition at line 209 of file TreeCalBaseCnv.h.

◆ m_runfrm

int TreeCalBaseCnv::m_runfrm
protected

Definition at line 205 of file TreeCalBaseCnv.h.

Referenced by internalCreateObj(), and setBaseInfo().

◆ m_runto

int TreeCalBaseCnv::m_runto
protected

Definition at line 206 of file TreeCalBaseCnv.h.

Referenced by internalCreateObj(), and setBaseInfo().

◆ m_saveDir

TDirectory* TreeCalBaseCnv::m_saveDir
protected

Definition at line 214 of file TreeCalBaseCnv.h.

◆ m_serNo

int TreeCalBaseCnv::m_serNo
protected

Definition at line 204 of file TreeCalBaseCnv.h.

◆ m_treeSvc

ICalibTreeSvc* TreeCalBaseCnv::m_treeSvc
protected

Definition at line 200 of file TreeCalBaseCnv.h.

Referenced by getCalibTreeSvc(), and initialize().

◆ m_ttree

TTree* TreeCalBaseCnv::m_ttree
protected

Definition at line 210 of file TreeCalBaseCnv.h.


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