#include <TreeMdcCalibDataCnv.h>
Inheritance diagram for TreeMdcCalibDataCnv:
Public Types | |
typedef Ty1 | source |
typedef Ty2 | destination |
Public Member Functions | |
const CLID & | objType () const |
TreeMdcCalibDataCnv (ISvcLocator *svc) | |
virtual | ~TreeMdcCalibDataCnv () |
virtual long | repSvcType () const |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
virtual StatusCode | createObj (IOpaqueAddress *addr, DataObject *&refpObject) |
ICalibTreeSvc * | getCalibTreeSvc () |
virtual StatusCode | createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj) |
destination * | operator (const source &) const |
Static Public Member Functions | |
static const CLID & | classID () |
static const unsigned char | storageType () |
Protected Member Functions | |
virtual StatusCode | i_createObj (IOpaqueAddress *address, DataObject *&refpObject) |
virtual StatusCode | internalCreateObj (DataObject *&refpObject, IOpaqueAddress *address) |
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. | |
virtual destination * | convert (const source &) const =0 |
Protected Attributes | |
ICalibTreeSvc * | m_treeSvc |
ICalibMetaCnvSvc * | m_metaSvc |
IInstrumentName * | m_instrSvc |
int | m_serNo |
int | m_runfrm |
int | m_runto |
TFile * | m_outFile |
TTree * | m_ttree |
TFile * | m_inFile |
TDirectory * | m_saveDir |
Friends | |
class | CnvFactory< TreeMdcCalibDataCnv > |
Definition at line 20 of file TreeMdcCalibDataCnv.h.
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited] |
Definition at line 19 of file Converter.h.
Definition at line 18 of file Converter.h.
TreeMdcCalibDataCnv::TreeMdcCalibDataCnv | ( | ISvcLocator * | svc | ) |
Definition at line 32 of file TreeMdcCalibDataCnv.cxx.
00032 : 00033 TreeCalBaseCnv(svc, CLID_Calib_MdcCal) { 00034 00035 }
virtual TreeMdcCalibDataCnv::~TreeMdcCalibDataCnv | ( | ) | [inline, virtual] |
const CLID & TreeMdcCalibDataCnv::classID | ( | ) | [static] |
Definition at line 42 of file TreeMdcCalibDataCnv.cxx.
References CLID_Calib_MdcCal.
00042 { 00043 return CLID_Calib_MdcCal; 00044 }
virtual destination* Converter< Ty1, Ty2 >::convert | ( | const source & | ) | const [protected, pure virtual, inherited] |
StatusCode TreeCalBaseCnv::createObj | ( | IOpaqueAddress * | addr, | |
DataObject *& | refpObject | |||
) | [virtual, inherited] |
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.
References Bes_Common::DEBUG, TreeCalBaseCnv::internalCreateObj(), and msgSvc().
00112 { 00113 // StatusCode ret; 00114 00115 // first do the things we always need: 00116 // First string parameter of opaque address is file ident 00117 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00118 log << MSG::DEBUG<<"TreeCalBaseCnv::createObj( starting ...."<<endreq; 00119 // const std::string* par = addr->par(); 00120 00121 // std::string par0 = par[0]; 00122 00123 // return internalCreateObj(par0, refpObject, addr); 00124 return internalCreateObj(refpObject, addr); 00125 00126 }
StatusCode TreeCalBaseCnv::createRoot | ( | const std::string & | fname, | |
CalibData::CalibBase1 * | pTDSObj | |||
) | [virtual, inherited] |
Create ROOT file corresponding to TDS object input. Default implementation is to return an error. Must be separately implemented for each calibration type.
fname | Filename for output file | |
pTDSObj | Pointer to tds object to be converted |
Definition at line 89 of file TreeCalBaseCnv.cxx.
References calibUtil::ERROR, and msgSvc().
00090 { 00091 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00092 log << MSG::ERROR 00093 << "createRoot method not implemented for this calibration type" 00094 << endreq; 00095 return StatusCode::FAILURE; 00096 }
StatusCode TreeCalBaseCnv::fillRoot | ( | CalibData::CalibBase * | pTDSObj, | |
TObject * | pRootObj | |||
) | [protected, virtual, inherited] |
Given a pointer to a TDS object which can be cast to "our" type, fill in corresponding information in the corresponding root class
pTDSObj | Pointer to tds object to be converted | |
pRootObj | Pointer to destination root object |
Definition at line 100 of file TreeCalBaseCnv.cxx.
00101 { 00102 00103 // Get instrument name from InstrumentName service Now handled by 00104 // TreeCalBaseCnv 00105 // TString instr = TString((m_instrSvc->getInstrumentName()).c_str()); 00106 // pRootObj->setInstrument(instr); 00107 return StatusCode::SUCCESS; 00108 }
StatusCode TreeCalBaseCnv::finalize | ( | ) | [virtual, inherited] |
ICalibTreeSvc* TreeCalBaseCnv::getCalibTreeSvc | ( | ) | [inline, inherited] |
Definition at line 58 of file TreeCalBaseCnv.h.
References TreeCalBaseCnv::m_treeSvc.
00058 { 00059 return m_treeSvc; 00060 }
StatusCode TreeMdcCalibDataCnv::i_createObj | ( | IOpaqueAddress * | address, | |
DataObject *& | refpObject | |||
) | [protected, virtual] |
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.
fname | The ROOT file to be read in to be used to builds the object | |
refpObject | the object to be built |
Reimplemented from TreeCalBaseCnv.
Definition at line 46 of file TreeMdcCalibDataCnv.cxx.
References Bes_Common::DEBUG, genRecEmupikp::i, msgSvc(), TreeAddress::pp(), CalibData::MdcCalibData::setNewXtpar(), and CalibData::MdcCalibData::setR2tpar().
00047 { 00048 00049 MsgStream log(msgSvc(), "TreeMdcCalibDataCnv"); 00050 log<<MSG::DEBUG<<"SetProperty"<<endreq; 00051 CalibData::MdcCalibData *tmpObject = new CalibData::MdcCalibData ; 00052 TreeAddress* add = dynamic_cast<TreeAddress*>(addr); 00053 DatabaseRecord *records=add->pp(); 00054 00055 TBufferFile *buf1 = new TBufferFile(TBuffer::kRead); 00056 TBufferFile *buf2 = new TBufferFile(TBuffer::kRead); 00057 TBufferFile *buf3 = new TBufferFile(TBuffer::kRead); 00058 TBufferFile *buf4 = new TBufferFile(TBuffer::kRead); 00059 TBufferFile *buf5 = new TBufferFile(TBuffer::kRead); 00060 TBufferFile *buf6 = new TBufferFile(TBuffer::kRead); 00061 00062 buf1->SetBuffer((*records)["XtTree"],512000,kFALSE); 00063 buf2->SetBuffer((*records)["QtTree"],512000,kFALSE); 00064 buf3->SetBuffer((*records)["T0Tree"],512000,kFALSE); 00065 buf4->SetBuffer((*records)["SdTree"],512000,kFALSE); 00066 buf5->SetBuffer((*records)["NewXtTrees"],51200000,kFALSE); 00067 buf6->SetBuffer((*records)["R2tTrees"],25600000,kFALSE); 00068 00069 std::cout<<" SftVer is "<<(*records)["SftVer"]; 00070 std::cout<<"TreeMdcCalibDataCnv: CalVerSft is "<<(*records)["CalParVer"]<<std::endl; 00071 std::cout<<"TreeMdcCalibDataCnv: Calib file name is "<<(*records)["FileName"]<<std::endl; 00072 00073 TTree* xttree = new TTree(); 00074 xttree->Streamer(*buf1); 00075 00076 TTree* qttree = new TTree(); 00077 qttree->Streamer(*buf2); 00078 00079 TTree* t0tree= new TTree(); 00080 t0tree->Streamer(*buf3); 00081 00082 TTree* sdtree = new TTree(); 00083 sdtree->Streamer(*buf4); 00084 00085 TObjArray newxttrees; 00086 DatabaseRecord::iterator it = (*records).find("NewXtTrees"); 00087 if(it!=(*records).end()){ 00088 if((*it).second!=NULL) { 00089 newxttrees.Streamer(*buf5); 00090 } 00091 } 00092 00093 TObjArray r2ttrees; 00094 it = (*records).find("R2tTrees"); 00095 if(it!=(*records).end()){ 00096 if((*it).second!=NULL) { 00097 r2ttrees.Streamer(*buf6); 00098 } 00099 } 00100 00101 00102 // Read in the object 00103 int i; 00104 int nentries; 00105 00106 //read xttree----------------------------- 00107 double xtpar; 00108 int xtkey; 00109 xttree -> SetBranchAddress("xtpar", &xtpar); 00110 xttree -> SetBranchAddress("xtkey", &xtkey); 00111 nentries = xttree -> GetEntries(); 00112 for(i=0; i<nentries; i++){ 00113 xttree -> GetEntry(i); 00114 tmpObject -> setXtpar(xtkey,xtpar); 00115 } 00116 00117 //read newxttrees----------------------------- 00118 if((43*18*2)==newxttrees.GetEntries()){ 00119 tmpObject->setNewXtpar(&newxttrees); 00120 for(int i=0;i<43*18*2;i++){ 00121 TTree* tempTree = (TTree*) newxttrees.At(i); 00122 delete tempTree; 00123 } 00124 } 00125 //read r2ttrees----------------------------- 00126 if(43==r2ttrees.GetEntries()){ 00127 tmpObject->setR2tpar(&r2ttrees); 00128 for(int i=0;i<43;i++){ 00129 TTree* tempTree = (TTree*) r2ttrees.At(i); 00130 delete tempTree; 00131 } 00132 } 00133 00134 // read t0tree ------------------------------------------------------------ 00135 double t0; 00136 double delt0; 00137 t0tree -> SetBranchAddress("t0", &t0); 00138 t0tree -> SetBranchAddress("delt0", &delt0); 00139 nentries = t0tree -> GetEntries(); 00140 for(i=0; i<nentries; i++){ 00141 t0tree -> GetEntry(i); 00142 tmpObject -> setT0(t0); 00143 tmpObject -> setDelT0(delt0); 00144 } 00145 // read qttree ------------------------------------------------------------ 00146 double qtpar0; 00147 double qtpar1; 00148 qttree -> SetBranchAddress("qtpar0", &qtpar0); 00149 qttree -> SetBranchAddress("qtpar1", &qtpar1); 00150 nentries = qttree -> GetEntries(); 00151 for(i=0; i<nentries; i++){ 00152 qttree -> GetEntry(i); 00153 tmpObject -> setQtpar0(qtpar0); 00154 tmpObject -> setQtpar1(qtpar1); 00155 } 00156 00157 // read Sdtree --------------------------------------------------------- 00158 double sdpar; 00159 int sdkey; 00160 sdtree -> SetBranchAddress("sdpar", &sdpar); 00161 sdtree -> SetBranchAddress("sdkey", &sdkey); 00162 nentries = sdtree -> GetEntries(); 00163 00164 for(i=0; i<nentries; i++){ 00165 sdtree -> GetEntry(i); 00166 tmpObject -> setSdpar(sdkey,sdpar); 00167 } 00168 00169 refpObject=tmpObject; 00170 delete xttree; 00171 delete qttree; 00172 delete t0tree; 00173 delete sdtree; 00174 00175 delete buf1; 00176 delete buf2; 00177 delete buf3; 00178 delete buf4; 00179 delete buf5; 00180 delete buf6; 00181 00182 return StatusCode::SUCCESS; 00183 00184 00185 }
StatusCode TreeCalBaseCnv::i_processObj | ( | DataObject * | pObject, | |
IOpaqueAddress * | address | |||
) | [protected, virtual, inherited] |
In case there is additional work to do on the created object.
Definition at line 190 of file TreeCalBaseCnv.cxx.
Referenced by TreeCalBaseCnv::internalCreateObj().
StatusCode TreeCalBaseCnv::initialize | ( | ) | [virtual, inherited] |
Definition at line 46 of file TreeCalBaseCnv.cxx.
References IID_ICalibMetaCnvSvc(), IID_ICalibTreeSvc(), IID_IInstrumentName(), TreeCalBaseCnv::m_instrSvc, TreeCalBaseCnv::m_metaSvc, and TreeCalBaseCnv::m_treeSvc.
00046 { 00047 StatusCode status = Converter::initialize(); 00048 00049 IDataProviderSvc* dp; 00050 00051 // I guess the service names are assigned in jobOptions? 00052 00053 /* serviceLocator()->getService ("CalibDataSvc", 00054 IID_IDataProviderSvc, 00055 (IInterface*&)dp);*/ 00056 serviceLocator()->getService ("CalibDataSvc", 00057 IDataProviderSvc::interfaceID(), 00058 (IInterface*&)dp); 00059 setDataProvider(dp); 00060 00061 // Locate the Root Conversion Service 00062 serviceLocator()->getService ("CalibTreeCnvSvc", 00063 IID_ICalibTreeSvc, 00064 (IInterface*&) m_treeSvc); 00065 00066 // Locate meta conversion service 00067 // Will anything need to be changed here to accommodate possibility 00068 // of two concrete implementations of ICalibMetaCnvSvc? Would 00069 // have different storage types. Could specify type desired 00070 // as job option. Ditto for name of class? 00071 serviceLocator()->getService("CalibMySQLCnvSvc", 00072 IID_ICalibMetaCnvSvc, 00073 (IInterface*&)m_metaSvc); 00074 00075 serviceLocator()->getService ("CalibDataSvc", 00076 IID_IInstrumentName, 00077 (IInterface*&)m_instrSvc); 00078 00079 return status; 00080 }
StatusCode TreeCalBaseCnv::internalCreateObj | ( | DataObject *& | refpObject, | |
IOpaqueAddress * | address | |||
) | [protected, virtual, inherited] |
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.
pRootObj | pointer to the ROOT object | |
refpObject | the object to be built | |
address | the opaque address for this object |
Definition at line 131 of file TreeCalBaseCnv.cxx.
References Bes_Common::DEBUG, calibUtil::ERROR, TreeAddress::getRunFrom(), TreeAddress::getRunTo(), TreeCalBaseCnv::i_createObj(), TreeCalBaseCnv::i_processObj(), TreeCalBaseCnv::m_runfrm, TreeCalBaseCnv::m_runto, msgSvc(), TreeCalBaseCnv::setBaseInfo(), and Bes_Common::WARNING.
Referenced by TreeCalBaseCnv::createObj().
00132 { 00133 00134 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00135 log << MSG::DEBUG<<"TreeCalBaseCnv::internalCreateObj( starting ..... "<<endreq; 00136 TreeCalBaseCnv* converter = this; 00137 CLID classId = address->clID(); 00138 00139 IConverter* conv = this->conversionSvc()->converter(classId); 00140 if (0 == conv) { 00141 log << MSG::WARNING 00142 << "No proper converter found for classID " << classId 00143 << ", the default converter" 00144 << " will be used. " << endreq; 00145 } else { 00146 converter = dynamic_cast <TreeCalBaseCnv*> (conv); 00147 if (0 == converter) { 00148 log << MSG::ERROR 00149 << "The converter found for classID " << classId 00150 << " was not a descendent of TreeCalBaseCnv as it should be " 00151 << "( was of type " << typeid (*converter).name() << "). " 00152 << "The default converter will be used" << endreq; 00153 converter = this; 00154 } 00155 } 00156 00157 TreeAddress* treeAddress = dynamic_cast <TreeAddress*> (address); 00158 m_runfrm = treeAddress->getRunFrom(); 00159 m_runto = treeAddress->getRunTo(); 00160 //m_runfrm =*( address->ipar()); 00161 //m_runto =*( address->ipar()+1); 00162 // m_runfrm = 100; 00163 // m_runto =1000; 00164 // creates an object for the node found 00165 StatusCode sc = converter->i_createObj(address, refpObject); 00166 if (sc.isFailure()) { 00167 return sc; 00168 } 00169 CalibData::CalibBase1* tmpObject = dynamic_cast <CalibData::CalibBase1*> (refpObject); 00170 setBaseInfo(tmpObject); 00171 // ends up the object construction 00172 sc = converter->i_processObj(refpObject, address); 00173 if (sc.isSuccess()) { 00174 log << MSG::DEBUG << "Successfully created calib. object " << endreq; 00175 } 00176 // closeRead(); 00177 return sc; 00178 }
const CLID & TreeMdcCalibDataCnv::objType | ( | ) | const |
Definition at line 38 of file TreeMdcCalibDataCnv.cxx.
References CLID_Calib_MdcCal.
00038 { 00039 return CLID_Calib_MdcCal; 00040 }
destination* Converter< Ty1, Ty2 >::operator | ( | const source & | ) | const [inline, inherited] |
virtual long TreeMdcCalibDataCnv::repSvcType | ( | ) | const [inline, virtual] |
Definition at line 34 of file TreeMdcCalibDataCnv.h.
References CALIBTREE_StorageType.
00034 { 00035 return CALIBTREE_StorageType; 00036 }
void TreeCalBaseCnv::setBaseInfo | ( | CalibData::CalibBase1 * | pObj | ) | [protected, inherited] |
Another utility for derived classes to use.
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.
References Bes_Common::DEBUG, TreeCalBaseCnv::m_runfrm, TreeCalBaseCnv::m_runto, msgSvc(), CalibData::CalibBase1::setrunfrm(), and CalibData::CalibBase1::setrunto().
Referenced by TreeCalBaseCnv::internalCreateObj().
00196 { 00197 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00198 log << MSG::DEBUG<<"set the runfrm and runto Numbers in the converter"<<endreq; 00199 pObj->setrunfrm(m_runfrm); 00200 pObj->setrunto(m_runto); 00201 }
static const unsigned char TreeCalBaseCnv::storageType | ( | ) | [inline, static, inherited] |
Definition at line 62 of file TreeCalBaseCnv.h.
References CALIBTREE_StorageType.
00062 {return CALIBTREE_StorageType;}
friend class CnvFactory< TreeMdcCalibDataCnv > [friend] |
Definition at line 22 of file TreeMdcCalibDataCnv.h.
TFile* TreeCalBaseCnv::m_inFile [protected, inherited] |
Definition at line 212 of file TreeCalBaseCnv.h.
IInstrumentName* TreeCalBaseCnv::m_instrSvc [protected, inherited] |
ICalibMetaCnvSvc* TreeCalBaseCnv::m_metaSvc [protected, inherited] |
TFile* TreeCalBaseCnv::m_outFile [protected, inherited] |
Definition at line 209 of file TreeCalBaseCnv.h.
int TreeCalBaseCnv::m_runfrm [protected, inherited] |
Definition at line 205 of file TreeCalBaseCnv.h.
Referenced by TreeCalBaseCnv::internalCreateObj(), and TreeCalBaseCnv::setBaseInfo().
int TreeCalBaseCnv::m_runto [protected, inherited] |
Definition at line 206 of file TreeCalBaseCnv.h.
Referenced by TreeCalBaseCnv::internalCreateObj(), and TreeCalBaseCnv::setBaseInfo().
TDirectory* TreeCalBaseCnv::m_saveDir [protected, inherited] |
Definition at line 214 of file TreeCalBaseCnv.h.
int TreeCalBaseCnv::m_serNo [protected, inherited] |
Definition at line 204 of file TreeCalBaseCnv.h.
ICalibTreeSvc* TreeCalBaseCnv::m_treeSvc [protected, inherited] |
Definition at line 200 of file TreeCalBaseCnv.h.
Referenced by TreeCalBaseCnv::getCalibTreeSvc(), and TreeCalBaseCnv::initialize().
TTree* TreeCalBaseCnv::m_ttree [protected, inherited] |
Definition at line 210 of file TreeCalBaseCnv.h.