#include <RootDedxCalibDataCnv.h>
Inheritance diagram for RootDedxCalibDataCnv:
Public Types | |
typedef Ty1 | source |
typedef Ty2 | destination |
Public Member Functions | |
const CLID & | objType () const |
RootDedxCalibDataCnv (ISvcLocator *svc) | |
virtual | ~RootDedxCalibDataCnv () |
virtual StatusCode | createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj) |
virtual long | repSvcType () const |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
virtual StatusCode | createObj (IOpaqueAddress *addr, DataObject *&refpObject) |
ICalibRootSvc * | getCalibRootSvc () |
virtual StatusCode | readRootObj (const std::string &treename, const std::string &branch, TObject *&pCalib, unsigned index=0) |
virtual StatusCode | readRootObj (TTree *tree, const std::string &branch, TObject *&pCalib, unsigned index=0) |
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 (const std::string &fname, DataObject *&refpObject) |
virtual StatusCode | internalCreateObj (const std::string &fname, 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) |
virtual StatusCode | openWrite (const std::string &fname) |
StatusCode | closeWrite () |
StatusCode | openRead (const std::string &fname) |
StatusCode | closeRead () |
void | setBaseInfo (CalibData::CalibBase1 *pObj) |
Another utility for derived classes to use. | |
virtual destination * | convert (const source &) const =0 |
Protected Attributes | |
ICalibRootSvc * | m_rootSvc |
ICalibMetaCnvSvc * | m_metaSvc |
IInstrumentName * | m_instrSvc |
int | m_serNo |
ITime * | m_vstart |
ITime * | m_vend |
int | m_runfrm |
int | m_runto |
TFile * | m_outFile |
TTree * | m_ttree |
TFile * | m_inFile |
TDirectory * | m_saveDir |
Friends | |
class | CnvFactory< RootDedxCalibDataCnv > |
Definition at line 20 of file RootDedxCalibDataCnv.h.
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited] |
Definition at line 19 of file Converter.h.
Definition at line 18 of file Converter.h.
RootDedxCalibDataCnv::RootDedxCalibDataCnv | ( | ISvcLocator * | svc | ) |
Definition at line 35 of file RootDedxCalibDataCnv.cxx.
00035 : 00036 RootCalBaseCnv(svc, CLID_Calib_DedxCal) { 00037 }
virtual RootDedxCalibDataCnv::~RootDedxCalibDataCnv | ( | ) | [inline, virtual] |
const CLID & RootDedxCalibDataCnv::classID | ( | ) | [static] |
Definition at line 44 of file RootDedxCalibDataCnv.cxx.
References CLID_Calib_DedxCal.
00044 { 00045 return CLID_Calib_DedxCal; 00046 }
StatusCode RootCalBaseCnv::closeRead | ( | ) | [protected, inherited] |
Clean up when we've finished reading in
Definition at line 135 of file RootCalBaseCnv.cxx.
References RootCalBaseCnv::m_inFile, and RootCalBaseCnv::m_saveDir.
Referenced by RootCalBaseCnv::internalCreateObj().
00135 { 00136 m_inFile->Close(); 00137 00138 delete m_inFile; 00139 m_inFile = 0; 00140 00141 if (m_saveDir) { 00142 m_saveDir->cd(); 00143 m_saveDir = 0; 00144 } 00145 return StatusCode::SUCCESS; 00146 }
StatusCode RootCalBaseCnv::closeWrite | ( | ) | [protected, inherited] |
Finish up writing file opened with openWrite: fill the tree write the file close the file Delete TFile (causes associated Tree to be deleted)
Definition at line 182 of file RootCalBaseCnv.cxx.
References RootCalBaseCnv::m_outFile, RootCalBaseCnv::m_saveDir, and msgSvc().
Referenced by RootTofCalibDataCnv::createRoot(), RootMdcCalibDataCnv::createRoot(), RootEstTofCalibDataCnv::createRoot(), RootEmcCalibDataCnv::createRoot(), and createRoot().
00182 { 00183 00184 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00185 00186 StatusCode ret = StatusCode::SUCCESS; 00187 00188 m_outFile->cd(); 00189 m_outFile->Close(); 00190 delete m_outFile; 00191 m_outFile = 0; 00192 if (m_saveDir) m_saveDir->cd(); 00193 m_saveDir = 0; 00194 return ret; 00195 }
virtual destination* Converter< Ty1, Ty2 >::convert | ( | const source & | ) | const [protected, pure virtual, inherited] |
StatusCode RootCalBaseCnv::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 252 of file RootCalBaseCnv.cxx.
References Bes_Common::DEBUG, RootCalBaseCnv::internalCreateObj(), msgSvc(), and deljobs::string.
00253 { 00254 // StatusCode ret; 00255 00256 // first do the things we always need: 00257 // First string parameter of opaque address is file ident 00258 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00259 log << MSG::DEBUG<<"RootCalBaseCnv::createObj( starting ...."<<endreq; 00260 const std::string* par = addr->par(); 00261 00262 std::string par0 = par[0]; 00263 00264 return internalCreateObj(par0, refpObject, addr); 00265 00266 }
StatusCode RootDedxCalibDataCnv::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.
fname | Filename for output file | |
pTDSObj | Pointer to tds object to be converted |
Reimplemented from RootCalBaseCnv.
Definition at line 290 of file RootDedxCalibDataCnv.cxx.
References RootCalBaseCnv::closeWrite(), calibUtil::ERROR, CalibData::DedxCalibData::getddg(), CalibData::DedxCalibData::getenta(), CalibData::DedxCalibData::getgain(), CalibData::DedxCalibData::getggs(), CalibData::DedxCalibData::getlayerg(), CalibData::DedxCalibData::getresol(), CalibData::DedxCalibData::getrung(), CalibData::DedxCalibData::getrunNO(), CalibData::DedxCalibData::getwireg(), CalibData::DedxCalibData::getzdep(), genRecEmupikp::i, Bes_Common::INFO, msgSvc(), TrigConf::N, RootCalBaseCnv::openWrite(), and check_raw_filter::runno.
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 }
StatusCode RootCalBaseCnv::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 241 of file RootCalBaseCnv.cxx.
00242 { 00243 00244 // Get instrument name from InstrumentName service Now handled by 00245 // RootCalBaseCnv 00246 // TString instr = TString((m_instrSvc->getInstrumentName()).c_str()); 00247 // pRootObj->setInstrument(instr); 00248 return StatusCode::SUCCESS; 00249 }
StatusCode RootCalBaseCnv::finalize | ( | ) | [virtual, inherited] |
ICalibRootSvc* RootCalBaseCnv::getCalibRootSvc | ( | ) | [inline, inherited] |
Definition at line 58 of file RootCalBaseCnv.h.
References RootCalBaseCnv::m_rootSvc.
00058 { 00059 return m_rootSvc; 00060 }
StatusCode RootDedxCalibDataCnv::i_createObj | ( | const std::string & | fname, | |
DataObject *& | refpObject | |||
) | [protected, virtual] |
Read in object from specified branch. Don't need tree name; it's always Calib
Reimplemented from RootCalBaseCnv.
Definition at line 48 of file RootDedxCalibDataCnv.cxx.
References Bes_Common::DEBUG, calibUtil::ERROR, Bes_Common::FATAL, genRecEmupikp::i, RootCalBaseCnv::m_inFile, msgSvc(), TrigConf::N, RootCalBaseCnv::openRead(), check_raw_filter::runno, CalibData::DedxCalibData::set_costheta(), CalibData::DedxCalibData::set_dedx(), CalibData::DedxCalibData::set_hadron(), CalibData::DedxCalibData::set_hadronNo(), and CalibData::DedxCalibData::set_t0().
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 }
StatusCode RootCalBaseCnv::i_processObj | ( | DataObject * | pObject, | |
IOpaqueAddress * | address | |||
) | [protected, virtual, inherited] |
In case there is additional work to do on the created object.
Definition at line 322 of file RootCalBaseCnv.cxx.
Referenced by RootCalBaseCnv::internalCreateObj().
StatusCode RootCalBaseCnv::initialize | ( | ) | [virtual, inherited] |
Definition at line 46 of file RootCalBaseCnv.cxx.
References IID_ICalibMetaCnvSvc(), IID_ICalibRootSvc(), IID_IInstrumentName(), RootCalBaseCnv::m_instrSvc, RootCalBaseCnv::m_metaSvc, and RootCalBaseCnv::m_rootSvc.
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 ("CalibRootCnvSvc", 00063 IID_ICalibRootSvc, 00064 (IInterface*&) m_rootSvc); 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 RootCalBaseCnv::internalCreateObj | ( | const std::string & | fname, | |
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 268 of file RootCalBaseCnv.cxx.
References RootCalBaseCnv::closeRead(), Bes_Common::DEBUG, calibUtil::ERROR, RootCalBaseCnv::i_createObj(), RootCalBaseCnv::i_processObj(), RootCalBaseCnv::m_runfrm, RootCalBaseCnv::m_runto, msgSvc(), RootCalBaseCnv::setBaseInfo(), and Bes_Common::WARNING.
Referenced by RootCalBaseCnv::createObj().
00270 { 00271 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00272 log << MSG::DEBUG<<"RootCalBaseCnv::internalCreateObj( starting ..... "<<endreq; 00273 RootCalBaseCnv* converter = this; 00274 CLID classId = address->clID(); 00275 00276 IConverter* conv = this->conversionSvc()->converter(classId); 00277 if (0 == conv) { 00278 log << MSG::WARNING 00279 << "No proper converter found for classID " << classId 00280 << ", the default converter" 00281 << " will be used. " << endreq; 00282 } else { 00283 converter = dynamic_cast <RootCalBaseCnv*> (conv); 00284 if (0 == converter) { 00285 log << MSG::ERROR 00286 << "The converter found for classID " << classId 00287 << " was not a descendent of RootCalBaseCnv as it should be " 00288 << "( was of type " << typeid (*converter).name() << "). " 00289 << "The default converter will be used" << endreq; 00290 converter = this; 00291 } 00292 } 00293 00294 m_runfrm =*( address->ipar()); 00295 m_runto =*( address->ipar()+1); 00296 // creates an object for the node found 00297 StatusCode sc = converter->i_createObj(fname, refpObject); 00298 if (sc.isFailure()) { 00299 return sc; 00300 } 00301 CalibData::CalibBase1* tmpObject = dynamic_cast <CalibData::CalibBase1*> (refpObject); 00302 setBaseInfo(tmpObject); 00303 // ends up the object construction 00304 sc = converter->i_processObj(refpObject, address); 00305 if (sc.isSuccess()) { 00306 log << MSG::DEBUG << "Successfully created calib. object " << endreq; 00307 } 00308 closeRead(); 00309 return sc; 00310 }
const CLID & RootDedxCalibDataCnv::objType | ( | ) | const |
Definition at line 40 of file RootDedxCalibDataCnv.cxx.
References CLID_Calib_DedxCal.
00040 { 00041 return CLID_Calib_DedxCal; 00042 }
StatusCode RootCalBaseCnv::openRead | ( | const std::string & | fname | ) | [protected, inherited] |
Utility for "leaf" converters to call
Root | file to open for read | |
Name | of branch to be read in | |
ref. | to pCalib pointer which will be set to address of read-in object |
Definition at line 98 of file RootCalBaseCnv.cxx.
References RootCalBaseCnv::doClean(), calibUtil::ERROR, Bes_Common::INFO, RootCalBaseCnv::m_inFile, RootCalBaseCnv::m_saveDir, msgSvc(), deljobs::string, and Bes_Common::WARNING.
Referenced by RootTofSimDataCnv::i_createObj(), RootTofElecDataCnv::i_createObj(), RootTofCalibDataCnv::i_createObj(), RootMucCalibDataCnv::i_createObj(), RootMdcCalibDataCnv::i_createObj(), RootEstTofCalibDataCnv::i_createObj(), RootEsTimeCalibDataCnv::i_createObj(), RootEmcCalibDataCnv::i_createObj(), RootDedxSimDataCnv::i_createObj(), and i_createObj().
00098 { 00099 00100 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00101 00102 // Check fname isn't empty 00103 if (fname == std::string("")) return StatusCode::FAILURE; 00104 00105 if (doClean() ) { 00106 log << MSG::WARNING << "Previous operation didn't clean up! " << endreq; 00107 } 00108 m_saveDir = gDirectory; 00109 00110 std::string ourName(fname); 00111 facilities::Util::expandEnvVar(&ourName); 00112 00113 m_inFile = new TFile(ourName.c_str()); 00114 00115 if (!m_inFile->IsOpen() ) { 00116 log << MSG::ERROR << "ROOT file " << ourName 00117 << "could not be opened for reading " << endreq; 00118 delete m_inFile; 00119 m_inFile = 0; 00120 return StatusCode::FAILURE; 00121 } 00122 else { 00123 log << MSG::INFO 00124 << "Successfully opened ROOT file " << fname << " aka " << ourName 00125 << " for reading " << endreq; 00126 } 00127 00128 00129 m_inFile->cd(); // Maybe will need this 00130 00131 00132 return StatusCode::SUCCESS; 00133 }
StatusCode RootCalBaseCnv::openWrite | ( | const std::string & | fname | ) | [protected, virtual, inherited] |
Utility used by derived converters to start writing a ROOT file (open TFile, make a TTree, give it a branch)
fname | Name for new file | |
className | Name of class for object specified in next parameter; used to name branch as well) | |
pCalib | pointer to object used to create the branch |
Definition at line 148 of file RootCalBaseCnv.cxx.
References RootCalBaseCnv::doClean(), calibUtil::ERROR, Bes_Common::INFO, RootCalBaseCnv::m_outFile, RootCalBaseCnv::m_saveDir, msgSvc(), deljobs::string, and Bes_Common::WARNING.
Referenced by RootTofSimDataCnv::createRoot(), RootTofCalibDataCnv::createRoot(), RootMdcCalibDataCnv::createRoot(), RootEstTofCalibDataCnv::createRoot(), RootEsTimeCalibDataCnv::createRoot(), RootEmcCalibDataCnv::createRoot(), RootDedxSimDataCnv::createRoot(), and createRoot().
00148 { 00149 00150 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00151 00152 // Check fname isn't empty 00153 if (fname == std::string("")) return StatusCode::FAILURE; 00154 00155 std::string ourName(fname); 00156 facilities::Util::expandEnvVar(&ourName); 00157 00158 if (doClean() ) { 00159 log << MSG::WARNING << "Previous operation didn't clean up! " << endreq; 00160 } 00161 00162 m_saveDir = gDirectory; 00163 00164 00165 m_outFile = new TFile(ourName.c_str(), "RECREATE"); 00166 if (!m_outFile->IsOpen()) { 00167 log << MSG::ERROR << "ROOT file " << fname << " aka " << ourName 00168 << " could not be opened for writing" << endreq; 00169 delete m_outFile; 00170 m_outFile = 0; 00171 return StatusCode::FAILURE; 00172 } 00173 else { 00174 log << MSG::INFO 00175 << "Successfully opened ROOT file " << fname << " aka " << ourName 00176 << " for writing " << endreq; 00177 } 00178 m_outFile->cd(); 00179 return StatusCode::SUCCESS; 00180 }
destination* Converter< Ty1, Ty2 >::operator | ( | const source & | ) | const [inline, inherited] |
StatusCode RootCalBaseCnv::readRootObj | ( | TTree * | tree, | |
const std::string & | branch, | |||
TObject *& | pCalib, | |||
unsigned | index = 0 | |||
) | [virtual, inherited] |
Definition at line 206 of file RootCalBaseCnv.cxx.
00208 { 00209 TBranch* pBranch=pTree->GetBranch(branch.c_str()); 00210 pBranch->SetAddress(&pObj); 00211 int nBytes = pBranch->GetEntry(ix); 00212 return (nBytes > 0) ? StatusCode::SUCCESS : StatusCode::FAILURE; 00213 }
StatusCode RootCalBaseCnv::readRootObj | ( | const std::string & | treename, | |
const std::string & | branch, | |||
TObject *& | pCalib, | |||
unsigned | index = 0 | |||
) | [virtual, inherited] |
Read in object (by default the first) from specified branch.
Definition at line 198 of file RootCalBaseCnv.cxx.
References RootCalBaseCnv::m_inFile.
00200 { 00201 TTree* pTree = (TTree*)m_inFile->Get(treename.c_str()); 00202 00203 return readRootObj(pTree, branch, pObj, ix); 00204 }
virtual long RootDedxCalibDataCnv::repSvcType | ( | ) | const [inline, virtual] |
Definition at line 34 of file RootDedxCalibDataCnv.h.
References CALIBROOT_StorageType.
00034 { 00035 return CALIBROOT_StorageType; 00036 }
void RootCalBaseCnv::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 328 of file RootCalBaseCnv.cxx.
References Bes_Common::DEBUG, RootCalBaseCnv::m_runfrm, RootCalBaseCnv::m_runto, msgSvc(), CalibData::CalibBase1::setrunfrm(), and CalibData::CalibBase1::setrunto().
Referenced by RootCalBaseCnv::internalCreateObj().
00328 { 00329 MsgStream log(msgSvc(), "RootCalBaseCnv"); 00330 log << MSG::DEBUG<<"set the runfrm and runto Numbers in the converter"<<endreq; 00331 pObj->setrunfrm(m_runfrm); 00332 pObj->setrunto(m_runto); 00333 }
static const unsigned char RootCalBaseCnv::storageType | ( | ) | [inline, static, inherited] |
Definition at line 62 of file RootCalBaseCnv.h.
References CALIBROOT_StorageType.
00062 {return CALIBROOT_StorageType;}
friend class CnvFactory< RootDedxCalibDataCnv > [friend] |
Definition at line 22 of file RootDedxCalibDataCnv.h.
TFile* RootCalBaseCnv::m_inFile [protected, inherited] |
Definition at line 207 of file RootCalBaseCnv.h.
Referenced by RootCalBaseCnv::closeRead(), RootCalBaseCnv::doClean(), RootTofSimDataCnv::i_createObj(), RootTofElecDataCnv::i_createObj(), RootTofCalibDataCnv::i_createObj(), RootMucCalibDataCnv::i_createObj(), RootMdcCalibDataCnv::i_createObj(), RootEstTofCalibDataCnv::i_createObj(), RootEsTimeCalibDataCnv::i_createObj(), RootEmcCalibDataCnv::i_createObj(), RootDedxSimDataCnv::i_createObj(), i_createObj(), RootCalBaseCnv::openRead(), and RootCalBaseCnv::readRootObj().
IInstrumentName* RootCalBaseCnv::m_instrSvc [protected, inherited] |
ICalibMetaCnvSvc* RootCalBaseCnv::m_metaSvc [protected, inherited] |
TFile* RootCalBaseCnv::m_outFile [protected, inherited] |
Definition at line 204 of file RootCalBaseCnv.h.
Referenced by RootCalBaseCnv::closeWrite(), RootCalBaseCnv::doClean(), and RootCalBaseCnv::openWrite().
ICalibRootSvc* RootCalBaseCnv::m_rootSvc [protected, inherited] |
Definition at line 193 of file RootCalBaseCnv.h.
Referenced by RootCalBaseCnv::getCalibRootSvc(), and RootCalBaseCnv::initialize().
int RootCalBaseCnv::m_runfrm [protected, inherited] |
Definition at line 200 of file RootCalBaseCnv.h.
Referenced by RootCalBaseCnv::internalCreateObj(), and RootCalBaseCnv::setBaseInfo().
int RootCalBaseCnv::m_runto [protected, inherited] |
Definition at line 201 of file RootCalBaseCnv.h.
Referenced by RootCalBaseCnv::internalCreateObj(), and RootCalBaseCnv::setBaseInfo().
TDirectory* RootCalBaseCnv::m_saveDir [protected, inherited] |
Definition at line 209 of file RootCalBaseCnv.h.
Referenced by RootCalBaseCnv::closeRead(), RootCalBaseCnv::closeWrite(), RootCalBaseCnv::doClean(), RootCalBaseCnv::openRead(), and RootCalBaseCnv::openWrite().
int RootCalBaseCnv::m_serNo [protected, inherited] |
Definition at line 197 of file RootCalBaseCnv.h.
TTree* RootCalBaseCnv::m_ttree [protected, inherited] |
ITime* RootCalBaseCnv::m_vend [protected, inherited] |
Definition at line 199 of file RootCalBaseCnv.h.
ITime* RootCalBaseCnv::m_vstart [protected, inherited] |
Definition at line 198 of file RootCalBaseCnv.h.