#include <RootDedxCalibDataCnv.h>
Inheritance diagram for RootDedxCalibDataCnv:
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 () |
ICalibRootSvc * | getCalibRootSvc () |
virtual StatusCode | initialize () |
const CLID & | objType () const |
destination * | operator (const source &) const |
destination * | operator (const source &) const |
virtual StatusCode | readRootObj (TTree *tree, const std::string &branch, TObject *&pCalib, unsigned index=0) |
virtual StatusCode | readRootObj (const std::string &treename, const std::string &branch, TObject *&pCalib, unsigned index=0) |
virtual long | repSvcType () const |
RootDedxCalibDataCnv (ISvcLocator *svc) | |
virtual | ~RootDedxCalibDataCnv () |
Static Public Member Functions | |
const CLID & | classID () |
const unsigned char | storageType () |
Protected Member Functions | |
StatusCode | closeRead () |
StatusCode | closeWrite () |
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 (const std::string &fname, 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 (const std::string &fname, DataObject *&refpObject, IOpaqueAddress *address) |
StatusCode | openRead (const std::string &fname) |
virtual StatusCode | openWrite (const std::string &fname) |
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 |
ICalibRootSvc * | m_rootSvc |
int | m_runfrm |
int | m_runto |
TDirectory * | m_saveDir |
int | m_serNo |
TTree * | m_ttree |
ITime * | m_vend |
ITime * | m_vstart |
Friends | |
class | CnvFactory<RootDedxCalibDataCnv> |
|
|
|
|
|
|
|
|
|
00035 : 00036 RootCalBaseCnv(svc, CLID_Calib_DedxCal) { 00037 }
|
|
00029 {};
|
|
00044 {
00045 return CLID_Calib_DedxCal;
00046 }
|
|
Clean up when we've finished reading in 00132 { 00133 m_inFile->Close(); 00134 00135 delete m_inFile; 00136 m_inFile = 0; 00137 00138 if (m_saveDir) { 00139 m_saveDir->cd(); 00140 m_saveDir = 0; 00141 } 00142 return StatusCode::SUCCESS; 00143 }
|
|
Finish up writing file opened with openWrite: fill the tree write the file close the file Delete TFile (causes associated Tree to be deleted) 00179 { 00180 00181 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00182 00183 StatusCode ret = StatusCode::SUCCESS; 00184 00185 m_outFile->cd(); 00186 m_outFile->Close(); 00187 delete m_outFile; 00188 m_outFile = 0; 00189 if (m_saveDir) m_saveDir->cd(); 00190 m_saveDir = 0; 00191 return ret; 00192 }
|
|
|
|
|
|
Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters. 00250 { 00251 // StatusCode ret; 00252 00253 // first do the things we always need: 00254 // First string parameter of opaque address is file ident 00255 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00256 log << MSG::DEBUG<<"RootCalBaseCnv::createObj( starting ...."<<endreq; 00257 const std::string* par = addr->par(); 00258 00259 std::string par0 = par[0]; 00260 00261 return internalCreateObj(par0, refpObject, addr); 00262 00263 }
|
|
Create ROOT file corresponding to TDS object input. Default implementation is to return an error. Must be separately implemented for each calibration type.
Reimplemented from RootCalBaseCnv. 00291 { 00292 00293 MsgStream log(msgSvc(), "RootDedxCalibDataCnv"); 00294 00295 // Open the file, create the branch 00296 StatusCode sc = openWrite(fname); 00297 if(!sc) 00298 { log<<MSG::ERROR<<"unable to open files"<<endreq; 00299 } 00300 // write the Data in the TCDS to RootFile 00301 int i; 00302 CalibData::DedxCalibData* tmpObject = dynamic_cast<CalibData::DedxCalibData*>(pTDSObj); 00303 // write rungcalib ------------------------------------------------------------ 00304 double rungain; 00305 double runmean; 00306 double runno; 00307 double runresol; 00308 TTree *rungcalibtree = new TTree("rungcalib", "rungCalib"); 00309 rungcalibtree -> Branch("rungain", &rungain, "S/D"); 00310 rungcalibtree -> Branch("runmean", &runmean, "S/D"); 00311 rungcalibtree -> Branch("runno", &runno, "S/D"); 00312 rungcalibtree -> Branch("runresol", &runresol, "S/D"); 00313 int N = tmpObject->getrunNO(); 00314 for(i=0; i<N; i++){ 00315 rungain = tmpObject->getrung(0,i); 00316 runmean = tmpObject->getrung(1,i); 00317 runno = tmpObject->getrung(2,i); 00318 runresol = tmpObject->getrung(3,i); 00319 rungcalibtree -> Fill(); 00320 } 00321 00322 00323 00324 // write ddgcalib---------------------------------------------------------------- 00325 double ddg0; 00326 double ddg1; 00327 double ddg2; 00328 double ddg3; 00329 TTree *ddgcalibtree = new TTree("ddgcalib", "ddgCalib"); 00330 ddgcalibtree -> Branch("ddg0", &ddg0, "S/D"); 00331 ddgcalibtree -> Branch("ddg1", &ddg1, "S/D"); 00332 ddgcalibtree -> Branch("ddg2", &ddg2, "S/D"); 00333 ddgcalibtree -> Branch("ddg3", &ddg3, "S/D"); 00334 for(i=0; i<43; i++){ 00335 ddg0 = tmpObject->getddg(0,i); 00336 ddg1 = tmpObject->getddg(1,i); 00337 ddg2 = tmpObject->getddg(2,i); 00338 ddg3 = tmpObject->getddg(3,i); 00339 ddgcalibtree -> Fill(); 00340 } 00341 00342 // write ggscalib---------------------------------------------------------------- 00343 double ggs0; 00344 double ggs1; 00345 double ggs2; 00346 double ggs3; 00347 TTree *ggscalibtree = new TTree("ggscalib", "ggsCalib"); 00348 ggscalibtree -> Branch("ggs0", &ggs0, "S/D"); 00349 ggscalibtree -> Branch("ggs1", &ggs1, "S/D"); 00350 ggscalibtree -> Branch("ggs2", &ggs2, "S/D"); 00351 ggscalibtree -> Branch("ggs3", &ggs3, "S/D"); 00352 for(i=0; i<43; i++){ 00353 ggs0 = tmpObject->getggs(0,i); 00354 ggs1 = tmpObject->getggs(1,i); 00355 ggs2 = tmpObject->getggs(2,i); 00356 ggs3 = tmpObject->getggs(3,i); 00357 ggscalibtree -> Fill(); 00358 } 00359 00360 // write zdepcalib---------------------------------------------------------------- 00361 double zdep0; 00362 double zdep1; 00363 double zdep2; 00364 double zdep3; 00365 TTree *zdepcalibtree = new TTree("zdepcalib", "zdepCalib"); 00366 zdepcalibtree -> Branch("zdep0", &zdep0, "S/D"); 00367 zdepcalibtree -> Branch("zdep1", &zdep1, "S/D"); 00368 zdepcalibtree -> Branch("zdep2", &zdep2, "S/D"); 00369 zdepcalibtree -> Branch("zdep3", &zdep3, "S/D"); 00370 for(i=0; i<43; i++){ 00371 zdep0 = tmpObject->getzdep(0,i); 00372 zdep1 = tmpObject->getzdep(1,i); 00373 zdep2 = tmpObject->getzdep(2,i); 00374 zdep3 = tmpObject->getzdep(3,i); 00375 zdepcalibtree -> Fill(); 00376 } 00377 00378 // write entacalib---------------------------------------------------------------- 00379 double enta0; 00380 double enta1; 00381 double enta2; 00382 double enta3; 00383 TTree *entacalibtree = new TTree("entacalib", "entaCalib"); 00384 entacalibtree -> Branch("enta0", &enta0, "S/D"); 00385 entacalibtree -> Branch("enta1", &enta1, "S/D"); 00386 entacalibtree -> Branch("enta2", &enta2, "S/D"); 00387 entacalibtree -> Branch("enta3", &enta3, "S/D"); 00388 for(i=0; i<43; i++){ 00389 enta0 = tmpObject->getenta(0,i); 00390 enta1 = tmpObject->getenta(1,i); 00391 enta2 = tmpObject->getenta(2,i); 00392 enta3 = tmpObject->getenta(3,i); 00393 entacalibtree -> Fill(); 00394 } 00395 00396 00397 00398 // write gain--------------------------------------------------------------------- 00399 double gain; 00400 TTree *gaintree = new TTree("gaincalib", "gainCalib"); 00401 gaintree -> Branch("gain", &gain, "S/D"); 00402 gain = tmpObject->getgain(); 00403 gaintree -> Fill(); 00404 00405 // write resol--------------------------------------------------------------------- 00406 double resol; 00407 TTree *resoltree = new TTree("resolcalib", "resolCalib"); 00408 resoltree -> Branch("resol", &resol, "S/D"); 00409 resol = tmpObject->getresol(); 00410 resoltree -> Fill(); 00411 00412 00413 // write wiregcalib---------------------------------------------------------------- 00414 double wireg; 00415 TTree *wiregcalibtree = new TTree("wiregcalib", "wiregCalib"); 00416 wiregcalibtree -> Branch("wireg", &wireg, "S/D"); 00417 for(i=0; i<6796; i++){ 00418 wireg = tmpObject->getwireg(i); 00419 wiregcalibtree -> Fill(); 00420 } 00421 00422 // write layergcalib---------------------------------------------------------------- 00423 double layerg; 00424 TTree *layergcalibtree = new TTree("layergcalib", "layergCalib"); 00425 layergcalibtree -> Branch("layerg", &layerg, "S/D"); 00426 for(i=0; i<43; i++){ 00427 layerg = tmpObject->getlayerg(i); 00428 layergcalibtree -> Fill(); 00429 } 00430 00431 // write all the trees 00432 rungcalibtree -> Write(); 00433 ddgcalibtree -> Write(); 00434 ggscalibtree -> Write(); 00435 zdepcalibtree -> Write(); 00436 entacalibtree -> Write(); 00437 gaintree -> Write(); 00438 resoltree -> Write(); 00439 wiregcalibtree -> Write(); 00440 layergcalibtree -> Write(); 00441 00442 delete rungcalibtree; 00443 delete ddgcalibtree; 00444 delete ggscalibtree; 00445 delete zdepcalibtree; 00446 delete entacalibtree; 00447 delete gaintree; 00448 delete resoltree; 00449 delete wiregcalibtree; 00450 delete layergcalibtree; 00451 closeWrite(); 00452 log<<MSG::INFO<<"successfully create RootFile"<<endreq; 00453 return sc; 00454 00455 }
|
|
Given a pointer to a TDS object which can be cast to "our" type, fill in corresponding information in the corresponding root class
00239 { 00240 00241 // Get instrument name from InstrumentName service Now handled by 00242 // RootCalBaseCnv 00243 // TString instr = TString((m_instrSvc->getInstrumentName()).c_str()); 00244 // pRootObj->setInstrument(instr); 00245 return StatusCode::SUCCESS; 00246 }
|
|
00079 {
00080 return Converter::finalize();
00081 }
|
|
00058 {
00059 return m_rootSvc;
00060 }
|
|
Read in object from specified branch. Don't need tree name; it's always Calib Reimplemented from RootCalBaseCnv. 00049 { 00050 00051 MsgStream log(msgSvc(), "RootDedxCalibDataCnv"); 00052 log<<MSG::DEBUG<<"SetProperty"<<endreq; 00053 StatusCode sc = openRead(fname); 00054 if(!sc) 00055 { log<<MSG::ERROR<<"unable to open files"<<endreq; 00056 } 00057 00058 CalibData::DedxCalibData *tmpObject = new CalibData::DedxCalibData; 00059 // Read in our object 00060 int i; 00061 // read rungcalib ------------------------------------------------------------ 00062 double rungain; 00063 double runmean; 00064 int runno; 00065 double runresol; 00066 TTree *rungtree = (TTree*)m_inFile -> Get("runcalib"); 00067 rungtree -> SetBranchAddress("rungain", &rungain); 00068 rungtree -> SetBranchAddress("runmean", &runmean); 00069 rungtree -> SetBranchAddress("runno", &runno); 00070 rungtree -> SetBranchAddress("runresol", &runresol); 00071 int N = rungtree -> GetEntries(); 00072 tmpObject -> setrunNO(N); 00073 //std::cout<<"N = "<<N<<std::endl; 00074 for(i=0; i<N; i++){ 00075 rungtree -> GetEntry(i); 00076 //std::cout<<rungain<<" "<<runmean<<" "<<runno<<" "<<runresol<<std::endl; 00077 tmpObject -> setrung(rungain,0,i); 00078 tmpObject -> setrung(runmean,1,i); 00079 tmpObject -> setrung(runno,2,i); 00080 tmpObject -> setrung(runresol,3,i); 00081 } 00082 00083 00084 00085 // read ddgcalib ------------------------------------------------------------ 00086 double ddg0[43]; 00087 double ddg1[43]; 00088 double ddg2[43]; 00089 double ddg3[43]; 00090 double id_doca[1600]; 00091 double iner_chi[1600]; 00092 double iner_gain[1600]; 00093 double iner_hits[1600]; 00094 double ip_eangle[1600]; 00095 double out_chi[1600]; 00096 double out_gain[1600]; 00097 double out_hits[1600]; 00098 00099 TTree *ddgtree = (TTree*)m_inFile -> Get("ddgcalib"); 00100 ddgtree -> SetBranchAddress("ddg0", ddg0); 00101 ddgtree -> SetBranchAddress("ddg1", ddg1); 00102 ddgtree -> SetBranchAddress("ddg2", ddg2); 00103 ddgtree -> SetBranchAddress("ddg3", ddg3); 00104 TBranch *bbb = ddgtree->FindBranch("Id_doca"); 00105 if(bbb){ 00106 ddgtree -> SetBranchAddress("Id_doca", id_doca); 00107 ddgtree -> SetBranchAddress("Iner_chi", iner_chi); 00108 ddgtree -> SetBranchAddress("Iner_gain", iner_gain); 00109 ddgtree -> SetBranchAddress("Iner_hits", iner_hits); 00110 ddgtree -> SetBranchAddress("Ip_eangle", ip_eangle); 00111 ddgtree -> SetBranchAddress("Out_chi", out_chi); 00112 ddgtree -> SetBranchAddress("Out_gain", out_gain); 00113 ddgtree -> SetBranchAddress("Out_hits", out_hits); 00114 } 00115 ddgtree -> GetEntry(0); 00116 for(i=0; i<43; i++){ 00117 tmpObject -> setddg(ddg0[i],0,i); 00118 tmpObject -> setddg(ddg1[i],1,i); 00119 tmpObject -> setddg(ddg2[i],2,i); 00120 tmpObject -> setddg(ddg3[i],3,i); 00121 } 00122 00123 for(i=0; i<1600; i++){ 00124 if(!bbb){ 00125 id_doca[i]=0; 00126 iner_chi[i]=0; 00127 iner_gain[i]=0; 00128 iner_hits[i]=0; 00129 ip_eangle[i]=0; 00130 out_chi[i]=0; 00131 out_gain[i]=0; 00132 out_hits[i]=0; 00133 } 00134 tmpObject -> set_id_doca(id_doca[i],i); 00135 tmpObject -> set_iner_chi(iner_chi[i],i); 00136 tmpObject -> set_iner_gain(iner_gain[i],i); 00137 tmpObject -> set_iner_hits(iner_hits[i],i); 00138 tmpObject -> set_ip_eangle(ip_eangle[i],i); 00139 tmpObject -> set_out_chi(out_chi[i],i); 00140 tmpObject -> set_out_gain(out_gain[i],i); 00141 tmpObject -> set_out_hits(out_hits[i],i); 00142 } 00143 00144 // read entratree--------------------------------------------- 00145 double entra0[43]; 00146 double entra1[43]; 00147 double entra2[43]; 00148 double entra3[43]; 00149 double engle[100]; 00150 int engle_no; 00151 TTree *entratree = (TTree*)m_inFile -> Get("entracalib"); 00152 entratree -> SetBranchAddress("entra0", entra0); 00153 entratree -> SetBranchAddress("entra1", entra1); 00154 entratree -> SetBranchAddress("entra2", entra2); 00155 entratree -> SetBranchAddress("entra3", entra3); 00156 entratree -> SetBranchAddress("1denangle", engle); 00157 entratree -> SetBranchAddress("1denangle_entry", &engle_no); 00158 entratree -> GetEntry(0); 00159 for(i=0; i<43; i++){ 00160 tmpObject -> setenta(entra0[i],0,i); 00161 tmpObject -> setenta(entra1[i],1,i); 00162 tmpObject -> setenta(entra2[i],2,i); 00163 tmpObject -> setenta(entra3[i],3,i); 00164 } 00165 tmpObject -> set_enanglesize(engle_no); 00166 for(i=0; i<engle_no; i++){ 00167 tmpObject -> set_enangle(engle[i],i); 00168 } 00169 00170 00171 00172 // read ggscalib ------------------------------------------------------------ 00173 double ggs0[43]; 00174 double ggs1[43]; 00175 double ggs2[43]; 00176 double ggs3[43]; 00177 double gcostheta[80]; 00178 int hadron_entry; 00179 double hadron[20]; 00180 TTree *ggstree = (TTree*)m_inFile -> Get("ggscalib"); 00181 ggstree -> SetBranchAddress("ggs0", ggs0); 00182 ggstree -> SetBranchAddress("ggs1", ggs1); 00183 ggstree -> SetBranchAddress("ggs2", ggs2); 00184 ggstree -> SetBranchAddress("ggs3", ggs3); 00185 ggstree -> SetBranchAddress("hadron", hadron); 00186 ggstree -> SetBranchAddress("hadronNo", &hadron_entry); 00187 if(bbb){ 00188 ggstree -> SetBranchAddress("costheta", gcostheta); 00189 } 00190 ggstree -> GetEntry(0); 00191 for(i=0; i<43;i++){ 00192 tmpObject -> setggs(ggs0[i],0,i); 00193 tmpObject -> setggs(ggs1[i],1,i); 00194 tmpObject -> setggs(ggs2[i],2,i); 00195 tmpObject -> setggs(ggs3[i],3,i); 00196 } 00197 00198 for(i=0; i<80;i++){ 00199 if(!bbb) gcostheta[i]=0; 00200 tmpObject ->set_costheta(gcostheta[i],i); 00201 } 00202 00203 if(hadron_entry>20){ 00204 log<<MSG::FATAL<<"hadron entry is larger than 20, larger than designed"<<endreq; 00205 return StatusCode::FAILURE; 00206 } 00207 00208 tmpObject->set_hadronNo(hadron_entry); 00209 00210 for(i=0;i<hadron_entry;i++){ 00211 tmpObject->set_hadron(hadron[i],i); 00212 } 00213 00214 00215 // read zdepcalib ------------------------------------------------------------ 00216 double zdep0[43]; 00217 double zdep1[43]; 00218 double zdep2[43]; 00219 double zdep3[43]; 00220 TTree *zdeptree = (TTree*)m_inFile -> Get("zdepcalib"); 00221 zdeptree -> SetBranchAddress("zdep0", zdep0); 00222 zdeptree -> SetBranchAddress("zdep1", zdep1); 00223 zdeptree -> SetBranchAddress("zdep2", zdep2); 00224 zdeptree -> SetBranchAddress("zdep3", zdep3); 00225 zdeptree -> GetEntry(0); 00226 00227 for(i=0; i<43;i++){ 00228 tmpObject -> setzdep(zdep0[i],0,i); 00229 tmpObject -> setzdep(zdep1[i],1,i); 00230 tmpObject -> setzdep(zdep2[i],2,i); 00231 tmpObject -> setzdep(zdep3[i],3,i); 00232 } 00233 00234 // read gain ------------------------------------------------------------ 00235 double gain; 00236 double gt0[35],gdedx[35]; 00237 TTree *gaintree = (TTree*)m_inFile -> Get("gaincalib"); 00238 gaintree -> SetBranchAddress("gain", &gain); 00239 if(bbb){ 00240 gaintree -> SetBranchAddress("t0", gt0); 00241 gaintree -> SetBranchAddress("dedx", gdedx); 00242 } 00243 gaintree -> GetEntry(0); 00244 tmpObject -> setgain(gain); 00245 for(i=0; i<35;i++){ 00246 if(!bbb){ 00247 gt0[i]=0; 00248 gdedx[i]=0; 00249 } 00250 tmpObject->set_t0(gt0[i],i); 00251 tmpObject->set_dedx(gdedx[i],i); 00252 } 00253 00254 // read resol---------------------------------------------------------------- 00255 double resol; 00256 TTree *resoltree = (TTree*)m_inFile -> Get("resolcalib"); 00257 resoltree -> SetBranchAddress("resol", &resol); 00258 resoltree -> GetEntry(0); 00259 tmpObject -> setresol(resol); 00260 00261 // read wireg---------------------------------------------------------------- 00262 double wireg[6796]; 00263 TTree *wiregtree = (TTree*)m_inFile -> Get("wiregcalib"); 00264 wiregtree -> SetBranchAddress("wireg",wireg); 00265 wiregtree -> GetEntry(0); 00266 for(i=0;i<6796;i++){ 00267 tmpObject -> setwireg(wireg[i],i); 00268 } 00269 00270 // read layerg---------------------------------------------------------------- 00271 double layerg[43]; 00272 TTree *layergtree = (TTree*)m_inFile -> Get("layergcalib"); 00273 layergtree -> SetBranchAddress("layerg",layerg); 00274 layergtree -> GetEntry(0); 00275 00276 for(i=0;i<43;i++){ 00277 tmpObject -> setlayerg(layerg[i],i); 00278 } 00279 00280 refpObject=tmpObject; 00281 // delete pObj; 00282 // std::cout<<"pObj.m_t0[Cell]="<<*(pObj->gett0()+Cell-1); 00283 // dynamic_cast<CalibData::Mdct0& >(refpObject); 00284 //refpObject = pObj; 00285 // std::cout<<"refObject.m_t0[Cell]="<<*(refpObject->gett0()+Cell-1); 00286 // refpObject = new Mdct0(&t0_tmp[0]); 00287 return StatusCode::SUCCESS; 00288 }
|
|
In case there is additional work to do on the created object.
00320 {
00321 return StatusCode::SUCCESS;
00322 }
|
|
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 setDataProvider(dp); 00057 00058 // Locate the Root Conversion Service 00059 serviceLocator()->getService ("CalibRootCnvSvc", 00060 IID_ICalibRootSvc, 00061 (IInterface*&) m_rootSvc); 00062 00063 // Locate meta conversion service 00064 // Will anything need to be changed here to accommodate possibility 00065 // of two concrete implementations of ICalibMetaCnvSvc? Would 00066 // have different storage types. Could specify type desired 00067 // as job option. Ditto for name of class? 00068 serviceLocator()->getService("CalibMySQLCnvSvc", 00069 IID_ICalibMetaCnvSvc, 00070 (IInterface*&)m_metaSvc); 00071 00072 serviceLocator()->getService ("CalibDataSvc", 00073 IID_IInstrumentName, 00074 (IInterface*&)m_instrSvc); 00075 00076 return status; 00077 }
|
|
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.
00267 { 00268 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00269 log << MSG::DEBUG<<"RootCalBaseCnv::internalCreateObj( starting ..... "<<endreq; 00270 RootCalBaseCnv* converter = this; 00271 CLID classId = address->clID(); 00272 00273 IConverter* conv = this->conversionSvc()->converter(classId); 00274 if (0 == conv) { 00275 log << MSG::WARNING 00276 << "No proper converter found for classID " << classId 00277 << ", the default converter" 00278 << " will be used. " << endreq; 00279 } else { 00280 converter = dynamic_cast <RootCalBaseCnv*> (conv); 00281 if (0 == converter) { 00282 log << MSG::ERROR 00283 << "The converter found for classID " << classId 00284 << " was not a descendent of RootCalBaseCnv as it should be " 00285 << "( was of type " << typeid (*converter).name() << "). " 00286 << "The default converter will be used" << endreq; 00287 converter = this; 00288 } 00289 } 00290 00291 m_runfrm =*( address->ipar()); 00292 m_runto =*( address->ipar()+1); 00293 // creates an object for the node found 00294 StatusCode sc = converter->i_createObj(fname, refpObject); 00295 if (sc.isFailure()) { 00296 return sc; 00297 } 00298 CalibData::CalibBase1* tmpObject = dynamic_cast <CalibData::CalibBase1*> (refpObject); 00299 setBaseInfo(tmpObject); 00300 // ends up the object construction 00301 sc = converter->i_processObj(refpObject, address); 00302 if (sc.isSuccess()) { 00303 log << MSG::DEBUG << "Successfully created calib. object " << endreq; 00304 } 00305 closeRead(); 00306 return sc; 00307 }
|
|
00040 {
00041 return CLID_Calib_DedxCal;
00042 }
|
|
Utility for "leaf" converters to call
00095 { 00096 00097 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00098 00099 // Check fname isn't empty 00100 if (fname == std::string("")) return StatusCode::FAILURE; 00101 00102 if (doClean() ) { 00103 log << MSG::WARNING << "Previous operation didn't clean up! " << endreq; 00104 } 00105 m_saveDir = gDirectory; 00106 00107 std::string ourName(fname); 00108 facilities::Util::expandEnvVar(&ourName); 00109 00110 m_inFile = new TFile(ourName.c_str()); 00111 00112 if (!m_inFile->IsOpen() ) { 00113 log << MSG::ERROR << "ROOT file " << ourName 00114 << "could not be opened for reading " << endreq; 00115 delete m_inFile; 00116 m_inFile = 0; 00117 return StatusCode::FAILURE; 00118 } 00119 else { 00120 log << MSG::INFO 00121 << "Successfully opened ROOT file " << fname << " aka " << ourName 00122 << " for reading " << endreq; 00123 } 00124 00125 00126 m_inFile->cd(); // Maybe will need this 00127 00128 00129 return StatusCode::SUCCESS; 00130 }
|
|
Utility used by derived converters to start writing a ROOT file (open TFile, make a TTree, give it a branch)
00145 { 00146 00147 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00148 00149 // Check fname isn't empty 00150 if (fname == std::string("")) return StatusCode::FAILURE; 00151 00152 std::string ourName(fname); 00153 facilities::Util::expandEnvVar(&ourName); 00154 00155 if (doClean() ) { 00156 log << MSG::WARNING << "Previous operation didn't clean up! " << endreq; 00157 } 00158 00159 m_saveDir = gDirectory; 00160 00161 00162 m_outFile = new TFile(ourName.c_str(), "RECREATE"); 00163 if (!m_outFile->IsOpen()) { 00164 log << MSG::ERROR << "ROOT file " << fname << " aka " << ourName 00165 << " could not be opened for writing" << endreq; 00166 delete m_outFile; 00167 m_outFile = 0; 00168 return StatusCode::FAILURE; 00169 } 00170 else { 00171 log << MSG::INFO 00172 << "Successfully opened ROOT file " << fname << " aka " << ourName 00173 << " for writing " << endreq; 00174 } 00175 m_outFile->cd(); 00176 return StatusCode::SUCCESS; 00177 }
|
|
|
|
|
|
00205 { 00206 TBranch* pBranch=pTree->GetBranch(branch.c_str()); 00207 pBranch->SetAddress(&pObj); 00208 int nBytes = pBranch->GetEntry(ix); 00209 return (nBytes > 0) ? StatusCode::SUCCESS : StatusCode::FAILURE; 00210 }
|
|
Read in object (by default the first) from specified branch. 00197 { 00198 TTree* pTree = (TTree*)m_inFile->Get(treename.c_str()); 00199 00200 return readRootObj(pTree, branch, pObj, ix); 00201 }
|
|
00034 {
00035 return CALIBROOT_StorageType;
00036 }
|
|
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. 00325 { 00326 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00327 log << MSG::DEBUG<<"set the runfrm and runto Numbers in the converter"<<endreq; 00328 pObj->setrunfrm(m_runfrm); 00329 pObj->setrunto(m_runto); 00330 }
|
|
00062 {return CALIBROOT_StorageType;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|