RootEstTofCalibDataCnv Class Reference

#include <RootEstTofCalibDataCnv.h>

Inheritance diagram for RootEstTofCalibDataCnv:

RootCalBaseCnv Converter< Ty1, Ty2 > List of all members.

Public Types

typedef Ty1 source
typedef Ty2 destination

Public Member Functions

const CLID & objType () const
 RootEstTofCalibDataCnv (ISvcLocator *svc)
virtual ~RootEstTofCalibDataCnv ()
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)
ICalibRootSvcgetCalibRootSvc ()
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)
destinationoperator (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 destinationconvert (const source &) const =0

Protected Attributes

ICalibRootSvcm_rootSvc
ICalibMetaCnvSvcm_metaSvc
IInstrumentNamem_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< RootEstTofCalibDataCnv >

Detailed Description

Definition at line 20 of file RootEstTofCalibDataCnv.h.


Member Typedef Documentation

template<class Ty1, class Ty2>
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited]

Definition at line 19 of file Converter.h.

template<class Ty1, class Ty2>
typedef Ty1 Converter< Ty1, Ty2 >::source [inherited]

Definition at line 18 of file Converter.h.


Constructor & Destructor Documentation

RootEstTofCalibDataCnv::RootEstTofCalibDataCnv ( ISvcLocator *  svc  ) 

Definition at line 38 of file RootEstTofCalibDataCnv.cxx.

00038                                                                 :
00039   RootCalBaseCnv(svc, CLID_Calib_EstTofCal) { 
00040  }

virtual RootEstTofCalibDataCnv::~RootEstTofCalibDataCnv (  )  [inline, virtual]

Definition at line 29 of file RootEstTofCalibDataCnv.h.

00029 {};


Member Function Documentation

const CLID & RootEstTofCalibDataCnv::classID (  )  [static]

Definition at line 47 of file RootEstTofCalibDataCnv.cxx.

References CLID_Calib_EstTofCal.

00047                                             {
00048   return CLID_Calib_EstTofCal;
00049 }

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(), createRoot(), RootEmcCalibDataCnv::createRoot(), and RootDedxCalibDataCnv::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 }

template<class Ty1, class Ty2>
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 RootEstTofCalibDataCnv::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:
fname Filename for output file
pTDSObj Pointer to tds object to be converted

Reimplemented from RootCalBaseCnv.

Definition at line 218 of file RootEstTofCalibDataCnv.cxx.

References RootCalBaseCnv::closeWrite(), calibUtil::ERROR, CalibData::TofCalibData::getBTofPleft(), CalibData::TofCalibData::getBTofPright(), CalibData::TofCalibData::getEtfPcombine(), CalibData::TofCalibData::getEtfPleft(), CalibData::TofCalibData::getEtfPright(), CalibData::TofCalibData::getETofP(), genRecEmupikp::i, Bes_Common::INFO, ganga-rec::j, msgSvc(), nBarPar, nEndPar, nEtfPar, and RootCalBaseCnv::openWrite().

00219                                                                       {
00220   MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
00221 
00222   // Open the file, create the branch
00223   StatusCode sc = openWrite(fname);
00224   if(!sc)
00225     { log<<MSG::ERROR<<"unable to open files"<<endreq;
00226     }
00227   // write the Data in the TCDS to RootFile
00228   CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
00229 
00230   // write  btoftree----------------------------------------------------------------
00231   double cnvBarPar1[nBarPar];
00232   double cnvBarPar2[nBarPar];
00233 
00234   char brname[8], ibrname[8];
00235   TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
00236   for( unsigned int i=0; i<nBarPar; i++ ) {
00237     sprintf(  brname, "P%i",   i );
00238     sprintf( ibrname, "P%i/D", i );
00239     btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
00240   }
00241 
00242   for( int i=0; i<176; i++ ) {
00243     for( int j=0;j<static_cast<int>(nBarPar);j++){
00244       cnvBarPar1[j] = btof->getBTofPleft(i,j);
00245       cnvBarPar2[j] = btof->getBTofPright(i,j);
00246     }
00247     btoftree -> Fill();
00248   }
00249      
00250  //write  etoftree----------------------------------------------------------------
00251   double cnvEndPar[nEndPar];
00252 
00253   char ecname[8], iecname[8];
00254   TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
00255   for( unsigned int i=0; i<nEndPar; i++ ) {
00256     sprintf(  ecname, "P%i",   i );
00257     sprintf( iecname, "P%i/D", i );
00258     etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
00259   }
00260 
00261   for(int i=0; i<96; i++){
00262     for(int j=0;j<static_cast<int>(nEndPar);j++){
00263       cnvEndPar[j] = btof->getETofP(i,j);
00264     }
00265     etoftree->Fill();
00266   }
00267 
00268  //write  etftree----------------------------------------------------------------
00269   double cnvEtfPar[nEtfPar];
00270   double cnvEtfPar1[nEtfPar];
00271   double cnvEtfPar2[nEtfPar];
00272 
00273   char etfname[8], ietfname[8];
00274   TTree *etftree = new TTree("EtfTofPar", "EtfTofPar");
00275   for( unsigned int i=0; i<nEtfPar; i++ ) {
00276     sprintf(  etfname, "P%i",   i );
00277     sprintf( ietfname, "P%i/D", i );
00278     etftree -> Branch( etfname, &cnvEtfPar[i], ietfname );
00279   }
00280   for( unsigned int i=0; i<nEtfPar; i++ ) {
00281     sprintf(  etfname, "P%i",   i+nEtfPar );
00282     sprintf( ietfname, "P%i/D", i+nEtfPar );
00283     etftree -> Branch( etfname, &cnvEtfPar1[i], ietfname );
00284   }
00285   for( unsigned int i=0; i<nEtfPar; i++ ) {
00286     sprintf(  etfname, "P%i",   i+2*nEtfPar );
00287     sprintf( ietfname, "P%i/D", i+2*nEtfPar );
00288     etftree -> Branch( etfname, &cnvEtfPar2[i], ietfname );
00289   }
00290 
00291   for( int i=0; i<72; i++ ) {
00292     for( int k=0; k<12; k++ ) {
00293       for(int j=0;j<static_cast<int>(nEtfPar);j++){
00294         cnvEtfPar[j] = btof->getEtfPcombine(i,k,j);
00295         cnvEtfPar1[j] = btof->getEtfPleft(i,k,j);
00296         cnvEtfPar2[j] = btof->getEtfPright(i,k,j);
00297       }
00298       etftree -> Fill();
00299     }
00300   }
00301 
00302   //  write all the trees
00303   btoftree -> Write();
00304   etoftree -> Write();
00305   etftree -> Write();
00306   delete btoftree;
00307   delete etoftree;
00308   delete etftree;
00309   closeWrite();
00310   log<<MSG::INFO<<"successfully create RootFile"<<endreq;
00311   
00312   return sc;
00313 }

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

Parameters:
pTDSObj Pointer to tds object to be converted
pRootObj Pointer 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 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]

Definition at line 82 of file RootCalBaseCnv.cxx.

00082                                     {
00083   return Converter::finalize();
00084 }

ICalibRootSvc* RootCalBaseCnv::getCalibRootSvc (  )  [inline, inherited]

Definition at line 58 of file RootCalBaseCnv.h.

References RootCalBaseCnv::m_rootSvc.

00058                                    {
00059     return m_rootSvc;
00060   }

StatusCode RootEstTofCalibDataCnv::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 51 of file RootEstTofCalibDataCnv.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, genRecEmupikp::i, RootCalBaseCnv::m_inFile, msgSvc(), nBarOffset, nBarPar, nBarParOff, nEndPar, nEtfPar, RootCalBaseCnv::openRead(), CalibData::bTofCommonCalibBase::setOffset(), CalibData::etfCalibBase::setP(), CalibData::eTofCalibBase::setP(), CalibData::etfCalibBase::setP1(), CalibData::bTofCalibBase::setP1(), CalibData::etfCalibBase::setP2(), CalibData::bTofCalibBase::setP2(), CalibData::bTofCalibBase::setPoff1_bunch0(), CalibData::bTofCalibBase::setPoff1_bunch1(), CalibData::bTofCalibBase::setPoff1_bunch2(), CalibData::bTofCalibBase::setPoff1_bunch3(), CalibData::bTofCalibBase::setPoff2_bunch0(), CalibData::bTofCalibBase::setPoff2_bunch1(), CalibData::bTofCalibBase::setPoff2_bunch2(), and CalibData::bTofCalibBase::setPoff2_bunch3().

00052                                                                 {
00053 
00054   MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
00055   log<<MSG::DEBUG<<"SetProperty"<<endreq;
00056  
00057  // open the file
00058   StatusCode sc = openRead(fname);
00059   if(!sc)
00060     { log<<MSG::ERROR<<"unable to open files"<<endreq;
00061     }
00062  
00063   CalibData::bTofCalibBase bTof;
00064   CalibData::eTofCalibBase eTof;
00065   CalibData::etfCalibBase  etf;
00066   CalibData::bTofCommonCalibBase bTofCommon;
00067   CalibData::tofCalibInfoBase tofinfo;
00068 
00069   std::vector<CalibData::bTofCalibBase> tmpbTof;
00070   std::vector<CalibData::eTofCalibBase> tmpeTof;
00071   std::vector<CalibData::etfCalibBase>  tmpetf;
00072   std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
00073   std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
00074 
00075   // Read in the object
00076   int cnt;
00077   // read btoftree ------------------------------------------------------------
00078   double cnvBarPar1[nBarPar];
00079   double cnvBarPar2[nBarPar];
00080   double cnvBarParOff1_bunch0[nBarParOff];
00081   double cnvBarParOff2_bunch0[nBarParOff];
00082   double cnvBarParOff1_bunch1[nBarParOff];
00083   double cnvBarParOff2_bunch1[nBarParOff];
00084   double cnvBarParOff1_bunch2[nBarParOff];
00085   double cnvBarParOff2_bunch2[nBarParOff];
00086   double cnvBarParOff1_bunch3[nBarParOff];
00087   double cnvBarParOff2_bunch3[nBarParOff];
00088 
00089   TTree *btoftree = (TTree*)m_inFile -> Get("BarTofPar");
00090 
00091   char brname[10];
00092   for( unsigned int i=0; i<nBarPar; i++ ) {
00093     sprintf( brname, "P%i", i );
00094     btoftree -> SetBranchAddress( brname, &cnvBarPar1[i] );    
00095   }
00096   for( unsigned int i=0; i<nBarPar; i++ ) {
00097     sprintf( brname, "P%i", i+nBarPar );
00098     btoftree -> SetBranchAddress( brname, &cnvBarPar2[i] );    
00099   }
00100   for( unsigned int i=0; i<nBarParOff; i++ ) {
00101     sprintf( brname, "Bunch0_Poff%i", i );
00102     btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch0[i] );    
00103   }
00104   for( unsigned int i=0; i<nBarParOff; i++ ) {
00105     sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
00106     btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch0[i] );    
00107   }
00108   for( unsigned int i=0; i<nBarParOff; i++ ) {
00109     sprintf( brname, "Bunch1_Poff%i", i );
00110     btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch1[i] );
00111   }
00112   for( unsigned int i=0; i<nBarParOff; i++ ) {
00113     sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
00114     btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch1[i] );
00115   }
00116   for( unsigned int i=0; i<nBarParOff; i++ ) {
00117     sprintf( brname, "Bunch2_Poff%i", i );
00118     btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch2[i] );
00119   }
00120   for( unsigned int i=0; i<nBarParOff; i++ ) {
00121     sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
00122     btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch2[i] );
00123   }
00124   for( unsigned int i=0; i<nBarParOff; i++ ) {
00125     sprintf( brname, "Bunch3_Poff%i", i );
00126     btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch3[i] );
00127   }
00128   for( unsigned int i=0; i<nBarParOff; i++ ) {
00129     sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
00130     btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch3[i] );
00131   }
00132 
00133   for(cnt=0; cnt<176; cnt++){
00134     btoftree -> GetEntry(cnt);
00135     bTof.setP1( cnvBarPar1 );
00136     bTof.setP2( cnvBarPar2 );
00137     bTof.setPoff1_bunch0( cnvBarParOff1_bunch0 );
00138     bTof.setPoff2_bunch0( cnvBarParOff2_bunch0 );
00139     bTof.setPoff1_bunch1( cnvBarParOff1_bunch1 );
00140     bTof.setPoff2_bunch1( cnvBarParOff2_bunch1 );
00141     bTof.setPoff1_bunch2( cnvBarParOff1_bunch2 );
00142     bTof.setPoff2_bunch2( cnvBarParOff2_bunch2 );
00143     bTof.setPoff1_bunch3( cnvBarParOff1_bunch3 );
00144     bTof.setPoff2_bunch3( cnvBarParOff2_bunch3 );
00145     tmpbTof.push_back( bTof );
00146   }
00147 
00148   //read etoftree
00149   double cnvEndPar[nEndPar];
00150 
00151   TTree *etoftree = (TTree*)m_inFile -> Get("EndTofPar");
00152 
00153   char ecname[10];
00154   for( unsigned int i=0; i<nEndPar; i++ ) {
00155     sprintf( ecname, "P%i", i );
00156     etoftree -> SetBranchAddress( ecname, &cnvEndPar[i] );
00157   }
00158    
00159   for(cnt=0; cnt<96; cnt++){
00160     etoftree->GetEntry(cnt);
00161     eTof.setP( cnvEndPar );
00162     tmpeTof.push_back(eTof);
00163   }
00164 
00165   //read etftree
00166   double cnvEtfPar[nEtfPar];
00167   double cnvEtfPar1[nEtfPar];
00168   double cnvEtfPar2[nEtfPar];
00169 
00170   if( NULL!=m_inFile->Get("EtfTofPar") ) {
00171     TTree *etftree = (TTree*)m_inFile -> Get("EtfTofPar");
00172 
00173     char etfname[10];
00174     for( unsigned int i=0; i<nEtfPar; i++ ) {
00175       sprintf( etfname, "P%i", i );
00176       etftree -> SetBranchAddress( etfname, &cnvEtfPar[i] );    
00177     }
00178     for( unsigned int i=0; i<nEtfPar; i++ ) {
00179       sprintf( etfname, "P%i", i+nEtfPar );
00180       etftree -> SetBranchAddress( etfname, &cnvEtfPar1[i] );    
00181     }
00182     for( unsigned int i=0; i<nEtfPar; i++ ) {
00183       sprintf( etfname, "P%i", i+2*nEtfPar );
00184       etftree -> SetBranchAddress( etfname, &cnvEtfPar2[i] );    
00185     }
00186 
00187     for(cnt=0; cnt<(72*12); cnt++){
00188       etftree -> GetEntry(cnt);
00189       etf.setP( cnvEtfPar );
00190       etf.setP1( cnvEtfPar1 );
00191       etf.setP2( cnvEtfPar2 );
00192       tmpetf.push_back(etf);
00193     }
00194   }
00195 
00196   //read bTofCommonCalibBase
00197   double cnvBarOffset[nBarOffset];
00198   TTree *btofcommontree = (TTree*)m_inFile -> Get("BarTofParCommon");
00199   for( unsigned int i=0; i<nBarOffset; i++ ) {
00200     sprintf( brname, "t0offset%i", i );
00201     btofcommontree-> SetBranchAddress( brname, &cnvBarOffset[i]);
00202   }
00203 
00204   int entries = btofcommontree->GetEntries();
00205   for(cnt=0;cnt<entries;cnt++){
00206     btofcommontree->GetEntry(cnt);
00207     bTofCommon.setOffset( cnvBarOffset );
00208     tmpbTofCommon.push_back(bTofCommon);   
00209   }
00210 
00211   CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tmpetf,&tofinfoCol);
00212 
00213   refpObject=tmpObject;
00214 
00215   return StatusCode::SUCCESS;
00216 }

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().

00323                                                                       {
00324   return StatusCode::SUCCESS;
00325 }

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.

Parameters:
pRootObj pointer to the ROOT object
refpObject the object to be built
address the opaque address for this object
Returns:
status depending on the completion of the call

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 & RootEstTofCalibDataCnv::objType (  )  const

Definition at line 43 of file RootEstTofCalibDataCnv.cxx.

References CLID_Calib_EstTofCal.

00043                                                   {
00044   return CLID_Calib_EstTofCal;
00045 }

StatusCode RootCalBaseCnv::openRead ( const std::string fname  )  [protected, inherited]

Utility for "leaf" converters to call

Parameters:
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(), i_createObj(), RootEsTimeCalibDataCnv::i_createObj(), RootEmcCalibDataCnv::i_createObj(), RootDedxSimDataCnv::i_createObj(), and RootDedxCalibDataCnv::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)

Parameters:
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(), createRoot(), RootEsTimeCalibDataCnv::createRoot(), RootEmcCalibDataCnv::createRoot(), RootDedxSimDataCnv::createRoot(), and RootDedxCalibDataCnv::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 }

template<class Ty1, class Ty2>
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 RootEstTofCalibDataCnv::repSvcType (  )  const [inline, virtual]

Definition at line 34 of file RootEstTofCalibDataCnv.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;}


Friends And Related Function Documentation

friend class CnvFactory< RootEstTofCalibDataCnv > [friend]

Definition at line 22 of file RootEstTofCalibDataCnv.h.


Member Data Documentation

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(), i_createObj(), RootEsTimeCalibDataCnv::i_createObj(), RootEmcCalibDataCnv::i_createObj(), RootDedxSimDataCnv::i_createObj(), RootDedxCalibDataCnv::i_createObj(), RootCalBaseCnv::openRead(), and RootCalBaseCnv::readRootObj().

IInstrumentName* RootCalBaseCnv::m_instrSvc [protected, inherited]

Definition at line 195 of file RootCalBaseCnv.h.

Referenced by RootCalBaseCnv::initialize().

ICalibMetaCnvSvc* RootCalBaseCnv::m_metaSvc [protected, inherited]

Definition at line 194 of file RootCalBaseCnv.h.

Referenced by RootCalBaseCnv::initialize().

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]

Definition at line 205 of file RootCalBaseCnv.h.

Referenced by RootCalBaseCnv::doClean().

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.


Generated on Tue Nov 29 23:35:51 2016 for BOSS_7.0.2 by  doxygen 1.4.7