#include <TreeMucCalibDataCnv.h>
Inheritance diagram for TreeMucCalibDataCnv:
Public Types | |
typedef Ty2 | destination |
typedef Ty2 | destination |
typedef Ty1 | source |
typedef Ty1 | source |
Public Member Functions | |
virtual StatusCode | createObj (IOpaqueAddress *addr, DataObject *&refpObject) |
virtual StatusCode | createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj) |
virtual StatusCode | finalize () |
ICalibTreeSvc * | getCalibTreeSvc () |
virtual StatusCode | initialize () |
const CLID & | objType () const |
destination * | operator (const source &) const |
destination * | operator (const source &) const |
virtual long | repSvcType () const |
TreeMucCalibDataCnv (ISvcLocator *svc) | |
virtual | ~TreeMucCalibDataCnv () |
Static Public Member Functions | |
const CLID & | classID () |
const unsigned char | storageType () |
Protected Member Functions | |
virtual destination * | convert (const source &) const =0 |
virtual destination * | convert (const source &) const =0 |
virtual StatusCode | fillRoot (CalibData::CalibBase *pTDSObj, TObject *pRootObj) |
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 | internalCreateObj (DataObject *&refpObject, IOpaqueAddress *address) |
void | setBaseInfo (CalibData::CalibBase1 *pObj) |
Another utility for derived classes to use. | |
Protected Attributes | |
TFile * | m_inFile |
IInstrumentName * | m_instrSvc |
ICalibMetaCnvSvc * | m_metaSvc |
TFile * | m_outFile |
int | m_runfrm |
int | m_runto |
TDirectory * | m_saveDir |
int | m_serNo |
ICalibTreeSvc * | m_treeSvc |
TTree * | m_ttree |
Private Attributes | |
CalibData::MucIdTransform * | m_ptrIdTr |
Friends | |
class | CnvFactory<TreeMucCalibDataCnv> |
|
|
|
|
|
|
|
|
|
00033 : 00034 TreeCalBaseCnv(svc, CLID_Calib_MucCal) { 00035 m_ptrIdTr = new MucIdTransform(); 00036 }
|
|
00031 {};
|
|
00043 {
00044 return CLID_Calib_MucCal;
00045 }
|
|
|
|
|
|
Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters. 00108 { 00109 // StatusCode ret; 00110 00111 // first do the things we always need: 00112 // First string parameter of opaque address is file ident 00113 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00114 log << MSG::DEBUG<<"TreeCalBaseCnv::createObj( starting ...."<<endreq; 00115 // const std::string* par = addr->par(); 00116 00117 // std::string par0 = par[0]; 00118 00119 // return internalCreateObj(par0, refpObject, addr); 00120 return internalCreateObj(refpObject, addr); 00121 00122 }
|
|
Create ROOT file corresponding to TDS object input. Default implementation is to return an error. Must be separately implemented for each calibration type.
00086 { 00087 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00088 log << MSG::ERROR 00089 << "createRoot method not implemented for this calibration type" 00090 << endreq; 00091 return StatusCode::FAILURE; 00092 }
|
|
Given a pointer to a TDS object which can be cast to "our" type, fill in corresponding information in the corresponding root class
00097 { 00098 00099 // Get instrument name from InstrumentName service Now handled by 00100 // TreeCalBaseCnv 00101 // TString instr = TString((m_instrSvc->getInstrumentName()).c_str()); 00102 // pRootObj->setInstrument(instr); 00103 return StatusCode::SUCCESS; 00104 }
|
|
00078 {
00079 return Converter::finalize();
00080 }
|
|
00057 {
00058 return m_treeSvc;
00059 }
|
|
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.
Reimplemented from TreeCalBaseCnv. 00048 { 00049 00050 MsgStream log(msgSvc(), "TreeMucCalibDataCnv"); 00051 log<<MSG::DEBUG<<"SetProperty"<<endreq; 00052 CalibData::MucCalibData *tmpObject = new CalibData::MucCalibData ; 00053 TreeAddress* add = dynamic_cast<TreeAddress*>(addr); 00054 DatabaseRecord *records=add->pp(); 00055 00056 TBuffer *buf1 = new TBuffer(TBuffer::kRead); 00057 TBuffer *buf2 = new TBuffer(TBuffer::kRead); 00058 TBuffer *buf3 = new TBuffer(TBuffer::kRead); 00059 buf1->SetBuffer((*records)["LayTree"],512000,kFALSE); 00060 buf2->SetBuffer((*records)["BoxTree"],512000,kFALSE); 00061 buf3->SetBuffer((*records)["StrTree"],512000,kFALSE); 00062 std::cout<<" CalVerSft is "<<(*records)["CalParVer"]; 00063 std::cout<<" File name is "<<(*records)["FileName"]<<std::endl; 00064 00065 00066 TTree* laytree = new TTree(); 00067 laytree->Streamer(*buf1); 00068 log<<MSG::DEBUG<< "laytree name:\t" << laytree->GetName() << endreq; 00069 TTree* boxtree = new TTree(); 00070 boxtree->Streamer(*buf2); 00071 log<<MSG::DEBUG<< "boxtree name:\t" << boxtree->GetName() << endreq; 00072 TTree* strtree= new TTree(); 00073 strtree->Streamer(*buf3); 00074 log<<MSG::DEBUG<< "strtree name:\t" << strtree->GetName() << endreq; 00075 00076 // Read in the object 00077 //read layerConst----------------------------- 00078 Double_t lay_eff,box_eff,str_eff; 00079 Double_t lay_cnt, box_cnt, str_cnt; 00080 Double_t lay_nos, box_nos, str_nos; 00081 Double_t lay_nos_ratio, box_nos_ratio, str_nos_ratio; 00082 lay_eff = box_eff = str_eff = 0.0; 00083 lay_cnt = box_cnt = str_cnt = 0.0; 00084 lay_nos = box_nos = str_nos = 0.0; 00085 lay_nos_ratio = box_nos_ratio = str_nos_ratio = 0.0; 00086 00087 char name[60]; 00088 laytree->SetBranchAddress("layer_eff", &lay_eff); 00089 laytree->SetBranchAddress("layer_cnt", &lay_cnt); 00090 laytree->SetBranchAddress("layer_noise", &lay_nos); 00091 laytree->SetBranchAddress("layer_nosratio",&lay_nos_ratio); 00092 00093 boxtree->SetBranchAddress("box_eff", &box_eff); 00094 boxtree->SetBranchAddress("box_cnt", &box_cnt); 00095 boxtree->SetBranchAddress("box_noise", &box_nos); 00096 boxtree->SetBranchAddress("box_nosratio", &box_nos_ratio); 00097 00098 strtree->SetBranchAddress("strip_eff", &str_eff); 00099 strtree->SetBranchAddress("strip_cnt", &str_cnt); 00100 strtree->SetBranchAddress("strip_noise", &str_nos); 00101 strtree->SetBranchAddress("strip_nosratio", &str_nos_ratio); 00102 00103 int part, segment, layer, strip; 00104 part = segment = layer = strip = 0; 00105 for(int i=0; i<LAYER_MAX; i++) 00106 { 00107 laytree->GetEntry(i); 00108 tmpObject->setLayerEff(lay_eff,i); 00109 tmpObject->setLayerCnt(lay_cnt, i); 00110 tmpObject->setLayerNos(lay_nos, i); 00111 tmpObject->setLayerNosRatio(lay_nos_ratio, i); 00112 sprintf(name,"LayClstPro"); 00113 for(int j=0; j<CLST_MAX; j++) { 00114 // if( ht_Pro[0] != NULL ) tmpObject->setLayerClstPro(ht_Pro[0]->GetBinContent(j),i,j); 00115 // else tmpObject->setLayerClstPro(DEFAULT_CLST_PRO[j],i,j); 00116 tmpObject->setLayerClstPro(DEFAULT_CLST_PRO[j],i,j); 00117 } 00118 log<<MSG::DEBUG<<"layer: " << i << "\t" << lay_eff <<endreq; 00119 } 00120 00121 for(int i=0; i<BOX_MAX; i++) 00122 { 00123 m_ptrIdTr->SetBoxPos( i, &part, &segment, &layer ); 00124 boxtree->GetEntry(i); 00125 tmpObject->setBoxEff(box_eff, part, segment, layer); 00126 tmpObject->setBoxCnt(box_cnt, part, segment, layer); 00127 tmpObject->setBoxNos(box_nos, part, segment, layer); 00128 tmpObject->setBoxNosRatio(box_nos_ratio, part, segment, layer); 00129 00130 sprintf(name,"BoxClstPro_B%d",i); 00131 for(int j=0; j<CLST_MAX; j++) { 00132 // if( ht_Pro[1] != NULL ) tmpObject->setBoxClstPro(ht_Pro[1]->GetBinContent(j),part,segment,layer,j); 00133 // else 00134 tmpObject->setBoxClstPro(DEFAULT_CLST_PRO[j],part,segment,layer,j); 00135 } 00136 log<<MSG::DEBUG<<"box: " << i << "\t" << box_eff <<endreq; 00137 } 00138 00139 log<<MSG::DEBUG<<"strtree entries:\t" << strtree->GetEntries() << endreq; 00140 for(int i=0; i<STRIP_MAX; i++) 00141 { 00142 m_ptrIdTr->SetStripPos( i, &part, &segment, &layer, &strip ); 00143 strtree->GetEntry(i); 00144 tmpObject->setStripEff(str_eff, part, segment, layer, strip); 00145 tmpObject->setStripCnt(str_cnt, part, segment, layer, strip); 00146 tmpObject->setStripNos(str_nos, part, segment, layer, strip); 00147 tmpObject->setStripNosRatio(str_nos_ratio, part, segment, layer, strip); 00148 log<<MSG::DEBUG<<"strip: " << i << "\t" << str_eff <<endreq; 00149 00150 } 00151 00152 refpObject=tmpObject; 00153 delete laytree; 00154 delete boxtree; 00155 delete strtree; 00156 return StatusCode::SUCCESS; 00157 00158 00159 }
|
|
In case there is additional work to do on the created object.
00184 {
00185 return StatusCode::SUCCESS;
00186 }
|
|
00045 { 00046 StatusCode status = Converter::initialize(); 00047 00048 IDataProviderSvc* dp; 00049 00050 // I guess the service names are assigned in jobOptions? 00051 00052 serviceLocator()->getService ("CalibDataSvc", 00053 IID_IDataProviderSvc, 00054 (IInterface*&)dp); 00055 setDataProvider(dp); 00056 00057 // Locate the Root Conversion Service 00058 serviceLocator()->getService ("CalibTreeCnvSvc", 00059 IID_ICalibTreeSvc, 00060 (IInterface*&) m_treeSvc); 00061 00062 // Locate meta conversion service 00063 // Will anything need to be changed here to accommodate possibility 00064 // of two concrete implementations of ICalibMetaCnvSvc? Would 00065 // have different storage types. Could specify type desired 00066 // as job option. Ditto for name of class? 00067 serviceLocator()->getService("CalibMySQLCnvSvc", 00068 IID_ICalibMetaCnvSvc, 00069 (IInterface*&)m_metaSvc); 00070 00071 serviceLocator()->getService ("CalibDataSvc", 00072 IID_IInstrumentName, 00073 (IInterface*&)m_instrSvc); 00074 00075 return status; 00076 }
|
|
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.
00128 { 00129 00130 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00131 log << MSG::DEBUG<<"TreeCalBaseCnv::internalCreateObj( starting ..... "<<endreq; 00132 TreeCalBaseCnv* converter = this; 00133 CLID classId = address->clID(); 00134 00135 IConverter* conv = this->conversionSvc()->converter(classId); 00136 if (0 == conv) { 00137 log << MSG::WARNING 00138 << "No proper converter found for classID " << classId 00139 << ", the default converter" 00140 << " will be used. " << endreq; 00141 } else { 00142 converter = dynamic_cast <TreeCalBaseCnv*> (conv); 00143 if (0 == converter) { 00144 log << MSG::ERROR 00145 << "The converter found for classID " << classId 00146 << " was not a descendent of TreeCalBaseCnv as it should be " 00147 << "( was of type " << typeid (*converter).name() << "). " 00148 << "The default converter will be used" << endreq; 00149 converter = this; 00150 } 00151 } 00152 00153 m_runfrm =*( address->ipar()); 00154 m_runto =*( address->ipar()+1); 00155 // m_runfrm = 100; 00156 // m_runto =1000; 00157 // creates an object for the node found 00158 StatusCode sc = converter->i_createObj(address, refpObject); 00159 if (sc.isFailure()) { 00160 return sc; 00161 } 00162 CalibData::CalibBase1* tmpObject = dynamic_cast <CalibData::CalibBase1*> (refpObject); 00163 setBaseInfo(tmpObject); 00164 // ends up the object construction 00165 sc = converter->i_processObj(refpObject, address); 00166 if (sc.isSuccess()) { 00167 log << MSG::DEBUG << "Successfully created calib. object " << endreq; 00168 } 00169 // closeRead(); 00170 return sc; 00171 }
|
|
00039 {
00040 return CLID_Calib_MucCal;
00041 }
|
|
|
|
|
|
00036 {
00037 return CALIBTREE_StorageType;
00038 }
|
|
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. 00189 { 00190 MsgStream log(msgSvc(), "TreeCalBaseCnv"); 00191 log << MSG::DEBUG<<"set the runfrm and runto Numbers in the converter"<<endreq; 00192 pObj->setrunfrm(m_runfrm); 00193 pObj->setrunto(m_runto); 00194 }
|
|
00061 {return CALIBTREE_StorageType;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|