CalibRootCnvSvc Class Reference

--------------------------------------------------------------------------- More...

#include <CalibRootCnvSvc.h>

Inheritance diagram for CalibRootCnvSvc:

ICalibRootSvc List of all members.

Public Member Functions

virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
virtual StatusCode writeToRoot (const std::string &outputFile, const std::string &tdsPath)
virtual StatusCode writeToRoot (const std::string &outputFile, CalibData::CalibBase1 *calib)
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
std::string getrootfile ()
StatusCode decodeDescription (const std::string &oldpath, std::string &realpath)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

 CalibRootCnvSvc (const std::string &name, ISvcLocator *svc)
virtual ~CalibRootCnvSvc ()

Private Attributes

IConversionSvc * m_detPersSvc
 Handle to the IConversionSvc interface of the DetectorPersistencySvc.
IDataProviderSvc * m_detDataSvc
 Handle to IDataProviderSvc interface of CalibDataSvc.
std::string m_rootfile [10]

Friends

class SvcFactory< CalibRootCnvSvc >
 Only factories can access protected constructors.

Detailed Description

---------------------------------------------------------------------------

A conversion service for GLAST calibration bulk data in ROOT format.

Author:
J. Bogart
Date:
July 2004

Definition at line 42 of file CalibRootCnvSvc.h.


Constructor & Destructor Documentation

CalibRootCnvSvc::CalibRootCnvSvc ( const std::string name,
ISvcLocator *  svc 
) [protected]

Definition at line 23 of file CalibRootCnvSvc.cxx.

References m_rootfile, and deljobs::string.

00024                                                  :
00025   ConversionSvc(name, svc, CALIBROOT_StorageType),
00026   m_detPersSvc(0), m_detDataSvc(0)   {
00027   //huangb add
00028   declareProperty("Mdcrootfile",m_rootfile[0]= std::string("no rootfile"));
00029   declareProperty("Tofrootfile",m_rootfile[1]= std::string("no rootfile"));
00030   declareProperty("Dedxrootfile",m_rootfile[2]= std::string("no rootfile"));
00031   declareProperty("Emcrootfile",m_rootfile[3]= std::string("no rootfile"));
00032   declareProperty("Mucrootfile",m_rootfile[4]= std::string("no rootfile"));
00033   declareProperty("EsTimerootfile",m_rootfile[5]= std::string("no rootfile"));
00034   declareProperty("EstTofrootfile",m_rootfile[6]= std::string("no rootfile"));
00035   declareProperty("TofQElecrootfile",m_rootfile[7]= std::string("no rootfile"));
00036   declareProperty("TofSimrootfile",m_rootfile[8]= std::string("no rootfile"));
00037   declareProperty("DedxSimrootfile",m_rootfile[9]= std::string("no rootfile"));
00038   // Some day might have a property to declare having to do with path to
00039   // xml files.
00040 }

virtual CalibRootCnvSvc::~CalibRootCnvSvc (  )  [inline, protected, virtual]

Definition at line 50 of file CalibRootCnvSvc.h.

00050 {}


Member Function Documentation

StatusCode CalibRootCnvSvc::createAddress ( long  svc_type,
const CLID &  clid,
const std::string par,
const unsigned long *  ip,
IOpaqueAddress *&  refpAddress 
) [virtual]

Create a ROOT address using explicit arguments to identify a single object

Parameters:
svc_type the service type
CLID the CLID of the ROOT Element for which an address is created
par an array of three strings containing the format version, calibration type name and the flavor, in this order
ip has a single element, the serial number of the MySQL row which corresponds to this element
refpAddress the new address created
Returns:
a StatusCode giving the status of the address creation

Definition at line 141 of file CalibRootCnvSvc.cxx.

References CALIBROOT_StorageType, CLID_Calib_DedxCal, CLID_Calib_EmcCal, CLID_Calib_EsTimeCal, CLID_Calib_EstTofCal, CLID_Calib_MdcCal, CLID_Calib_MucCal, CLID_Calib_TofCal, CLID_Calib_TofSim, CLID_Dedx_Sim, CLID_TofQ_Elec, Bes_Common::DEBUG, decodeDescription(), calibUtil::ERROR, Bes_Common::INFO, m_rootfile, msgSvc(), deljobs::string, and Bes_Common::WARNING.

00145                                                                           {
00146   MsgStream log( msgSvc(), name() );
00147    log << MSG::DEBUG<<"here is the createAddress in the CalibRootCnvSvc"<<endreq;
00148    if (svc_type != CALIBROOT_StorageType) {
00149     log << MSG::ERROR << "bad storage type" << (int)svc_type << endreq;
00150     return StatusCode::FAILURE;
00151   }
00152    std::cout<<"clid=="<<clid<<std::endl;
00153     std::string dataIdent;
00154     std::string fullpath;
00155     int index=-99;
00156     if(clid==6412) return StatusCode::SUCCESS;
00157     if(clid==CLID_Calib_MdcCal) 
00158       { index=0;}
00159     else if(clid==CLID_Calib_TofCal)
00160       {index =1;}
00161     else if(clid==CLID_Calib_DedxCal)
00162       {index =2;}
00163     else if(clid==CLID_Calib_EmcCal)
00164       {index =3;}
00165     else if(clid==CLID_Calib_MucCal)
00166       {index =4;}
00167     else if(clid==CLID_Calib_EsTimeCal)   
00168        {index =5;} 
00169     else if(clid==CLID_Calib_EstTofCal)
00170       {index =6;}
00171      else if(clid==CLID_TofQ_Elec)
00172       {index =7;}
00173      else if(clid==CLID_Calib_TofSim)
00174       {index =8;}
00175      else if(clid==CLID_Dedx_Sim)
00176       {index =9;}
00177 
00178     else{ 
00179       log << MSG::WARNING<<"Wrong CLID"<<endreq;
00180     }
00181     std::cout<<"index=="<<index<<std::endl;
00182   //see if svctype set in the CalibDataSvc is MYSQL_StorageType or  CALIBROOT_StorageType
00183  /* IInstrumentName* iInstrumentName;
00184   StatusCode sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
00185                                     (void**) &iInstrumentName);
00186 
00187   if ( !sc.isSuccess() ) {
00188     log << MSG::ERROR
00189         << "Cannot query IInstrumentName interface of CalibDataSvc"
00190         << endreq;
00191     return sc;
00192   } else {
00193     log << MSG::DEBUG
00194         << "Retrieved IInstrumentName interface of CalibDataSvc"
00195         << endreq;
00196   }
00197 
00198    int svctype = iInstrumentName->getsvctype();
00199     if(svctype== CALIBROOT_StorageType)
00200       {
00201 */ 
00202 //      dataIdent = m_rootfile[index];
00203 if(m_rootfile[index]=="no rootfile")
00204 {
00205 log << MSG::INFO<<"no sepcified calibration file path of type "<< index <<endreq;
00206 return StatusCode::FAILURE;
00207 }
00208         decodeDescription(m_rootfile[index],dataIdent);
00209         fullpath = par[0];
00210   /*    }
00211 
00212    if(svctype== MYSQL_StorageType)
00213       {   log << MSG::INFO<<"rootfile is not set in the jobOption,get it from MySQL"<<endreq;
00214       dataIdent = par[0];
00215       fullpath = par[1];
00216       }
00217 
00218    if ((svctype != CALIBROOT_StorageType)&&(svctype!= MYSQL_StorageType)) {
00219     log << MSG::ERROR << "bad storage type" << (int)svctype << endreq;
00220     return StatusCode::FAILURE;
00221   }
00222 */
00223 
00224    // std::string dataIdent(par[0]); // file identifier for PDS version of data
00225    log << MSG::INFO<<"dataIdent is:"<<dataIdent<<endreq;
00226    //std::string fullpath(par[1]);  // path within TCDS for the object
00227    log << MSG::INFO<<"fullpath is :"<<fullpath<<endreq;
00228  
00229  
00230    int runfrm = ip[0];
00231    int runto = ip[1];
00232   
00233    // for now have to ignore fmtVersion because of defective implementation
00234   // of GenericAddress. If we want it, should probably write new
00235   // opaque address implementation for this package to use.  All
00236   // dealings with (calibration) opaque addresses are confined to
00237   // the CalibSvc package.
00238   refpAddress = new GenericAddress(CALIBROOT_StorageType,
00239                                    clid,
00240                                    dataIdent,  
00241                                    fullpath,
00242                                    runfrm,
00243                                    runto);
00244                                    
00245   return StatusCode::SUCCESS; 
00246 
00247 }

StatusCode CalibRootCnvSvc::decodeDescription ( const std::string oldpath,
std::string realpath 
)

Definition at line 307 of file CalibRootCnvSvc.cxx.

References genRecEmupikp::i, msgSvc(), RealDBUtil::npos, and deljobs::string.

Referenced by createAddress().

00309 {
00310   MsgStream log(msgSvc(), "CalibMySQLCnvSvc");
00311  
00312    if(oldpath[0]!='$'){
00313      realpath=oldpath;
00314    }
00315   if(oldpath[0]=='$'){
00316     std::string::size_type idx =oldpath.find("/");
00317      if( std::string::npos != idx )
00318    {  std::string relpath;
00319       for(int i=1;i<idx-1;i++){
00320         relpath[i-1] = oldpath[i];
00321       }
00322       std::string otherpath;
00323       for(int i=idx-1;i<oldpath.size();i++){
00324         otherpath[i-idx+1]=oldpath[i];
00325       }
00326     realpath =  std::string(getenv(relpath.c_str()))+otherpath;
00327     }
00328    if( std::string::npos == idx ){
00329      std::string relpath;
00330       for(int i=1;i<oldpath.size();i++){
00331         relpath[i-1] = oldpath[i];
00332       }
00333      realpath = std::string(getenv(relpath.c_str()));
00334    }
00335    }
00336 
00337   return StatusCode::SUCCESS;
00338 }

StatusCode CalibRootCnvSvc::finalize (  )  [virtual]

Definition at line 134 of file CalibRootCnvSvc.cxx.

00134                                      {
00135   // If anything was allocated, get rid of it.  So far, nothing was.
00136 
00137   return ConversionSvc::finalize();
00138 }

std::string CalibRootCnvSvc::getrootfile (  )  [inline, virtual]

Implements ICalibRootSvc.

Definition at line 91 of file CalibRootCnvSvc.h.

References m_rootfile.

00092         { return m_rootfile[0];}

StatusCode CalibRootCnvSvc::initialize (  )  [virtual]

Definition at line 57 of file CalibRootCnvSvc.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, m_detDataSvc, m_detPersSvc, and msgSvc().

00057                                        {
00058   StatusCode sc = ConversionSvc::initialize();
00059 
00060   MsgStream log(msgSvc(), "CalibRootCnvSvc");
00061 
00062   if (!sc.isSuccess()) return sc;
00063 
00064   // Locate the Calib Data Service.  Since it inherits from DataSvc
00065   // it has to implement IDataProviderSvc
00066   m_detDataSvc = 0;
00067   /*sc = serviceLocator()->getService 
00068     ("CalibDataSvc",  IID_IDataProviderSvc,(IInterface*&) m_detDataSvc);*/
00069   sc = serviceLocator()->getService 
00070     ("CalibDataSvc",  IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
00071   if ( !sc.isSuccess() ) {
00072     log << MSG::ERROR << "Could not locate CalibDataSvc" << endreq;
00073     return sc;
00074   }
00075 
00076  /*  IInstrumentName* iInstrumentName;
00077   sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
00078                                     (void**) &iInstrumentName);
00079 */
00080   // Set the CalibDataSvc as data provider service
00081   sc = setDataProvider(m_detDataSvc);
00082   if ( !sc.isSuccess() ) {
00083     log << MSG::ERROR << "Could not set data provider" << endreq;
00084     return sc;
00085   }
00086   //huangb add 
00087  sc = setProperties();
00088 
00089   // Locate IConversionSvc interface of the DetectorPersistencySvc
00090   sc = serviceLocator()->service 
00091     ("DetectorPersistencySvc", m_detPersSvc, true);
00092   if ( !sc.isSuccess() ) {
00093     log << MSG::ERROR 
00094         << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
00095         << endreq;
00096     return sc;
00097   } else {
00098     log << MSG::DEBUG 
00099         << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
00100         << endreq;
00101   }
00102   
00103   // Query the IAddressCreator interface of the detector persistency service
00104   IAddressCreator* iAddrCreator;
00105 /*  sc = m_detPersSvc->queryInterface(IID_IAddressCreator, 
00106 
00107                                     (void**) &iAddrCreator);*/
00108 
00109   sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(), 
00110                                     (void**) &iAddrCreator);
00111   if ( !sc.isSuccess() ) {
00112     log << MSG::ERROR 
00113         << "Cannot query IAddressCreator interface of DetectorPersistencySvc" 
00114         << endreq;
00115     return sc;
00116   } else {
00117     log << MSG::DEBUG 
00118         << "Retrieved IAddressCreator interface of DetectorPersistencySvc" 
00119         << endreq;
00120   }
00121   log << MSG::DEBUG 
00122       << "Set it as the address creator of the CalibRootCnvSvc" << endreq;
00123   sc = setAddressCreator(iAddrCreator);
00124   if ( !sc.isSuccess() ) {
00125     log << MSG::ERROR   << "Cannot set the address creator" << endreq;
00126     return sc;
00127   }
00128 
00129   // set properties if there are any??
00130 
00131   return sc;
00132 }

static const InterfaceID& ICalibRootSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 36 of file ICalibRootSvc.h.

References IID_ICalibRootSvc().

00036 { return IID_ICalibRootSvc; }

StatusCode CalibRootCnvSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

Definition at line 42 of file CalibRootCnvSvc.cxx.

References IID_ICalibRootSvc().

00043                                                                {
00044   /* Uncomment if choose to derive from abstract root conv. interface */
00045   if (IID_ICalibRootSvc.versionMatch(riid))  {
00046     *ppvInterface = (ICalibRootSvc*)this;
00047   }
00048   else {
00049     // Interface is not directly availible: try out a base class
00050     return ConversionSvc::queryInterface(riid, ppvInterface);
00051     /*  }  */
00052   addRef();
00053   }
00054   return StatusCode::SUCCESS;
00055 }

StatusCode CalibRootCnvSvc::updateObj ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
) [virtual]

Definition at line 290 of file CalibRootCnvSvc.cxx.

References Bes_Common::DEBUG, and msgSvc().

00291                                                                   {
00292 
00293   //  using facilities::Timestamp;
00294 
00295    MsgStream log(msgSvc(), "CalibRootCnvSvc" );
00296    
00297    // Don't update when we're using enter time
00298    log << MSG::DEBUG << "CalibRootCnvSvc::updateObj starting ...."<<endreq;
00299    /*
00300    if (!m_useEventTime) 
00301      {  log << MSG::DEBUG << "Method updateObj needn't update" << endreq;
00302         return StatusCode::SUCCESS;
00303      }
00304    */
00305 }

StatusCode CalibRootCnvSvc::writeToRoot ( const std::string outputFile,
CalibData::CalibBase1 calib 
) [virtual]

Implements ICalibRootSvc.

Definition at line 270 of file CalibRootCnvSvc.cxx.

References RootCalBaseCnv::createRoot(), and msgSvc().

00271                                                                      {
00272   MsgStream log(msgSvc(), name() );
00273  // Find converter corresponding to this object
00274   IConverter* converter = ConversionSvc::converter(pCalib->clID());
00275   if (!converter) {
00276     log << "No converter found for object with CLID  " << pCalib->clID()
00277         << endreq;
00278     return StatusCode::FAILURE;
00279   }
00280   RootCalBaseCnv* pCnv = dynamic_cast<RootCalBaseCnv*>(converter);
00281   if (!pCnv) {
00282     log << "Converter for CLID " << pCalib->clID() <<  " not of proper type" 
00283         << endreq;
00284     return StatusCode::FAILURE;
00285   }
00286   // Call its createRoot method
00287   return pCnv->createRoot(outfile, pCalib);
00288 }

StatusCode CalibRootCnvSvc::writeToRoot ( const std::string outputFile,
const std::string tdsPath 
) [virtual]

Method to write a ROOT file corresponding to TDS object

Parameters:
fileName the name of the file to be written
Returns:
the document issued from the parsing

Implements ICalibRootSvc.

Definition at line 249 of file CalibRootCnvSvc.cxx.

References m_detDataSvc, and msgSvc().

00250                                                                   {
00251   MsgStream log( msgSvc(), name() );
00252 
00253   // Find corresponding object
00254   DataObject* pObj;
00255   m_detDataSvc->findObject(tdsPath, pObj);
00256   if (!pObj) {
00257     log << "No object in TDS with path " << tdsPath << endreq;
00258     return StatusCode::FAILURE;
00259   }
00260 
00261   CalibData::CalibBase1* pCalib = 
00262     dynamic_cast<CalibData::CalibBase1*> (pObj);
00263 
00264   if (!pCalib) {
00265     log << "Object with path " << tdsPath << " not of proper type" << endreq;
00266     return StatusCode::FAILURE;
00267   }
00268   return writeToRoot(outfile, pCalib);
00269 }


Friends And Related Function Documentation

friend class SvcFactory< CalibRootCnvSvc > [friend]

Only factories can access protected constructors.

Definition at line 45 of file CalibRootCnvSvc.h.


Member Data Documentation

IDataProviderSvc* CalibRootCnvSvc::m_detDataSvc [private]

Handle to IDataProviderSvc interface of CalibDataSvc.

Definition at line 113 of file CalibRootCnvSvc.h.

Referenced by initialize(), and writeToRoot().

IConversionSvc* CalibRootCnvSvc::m_detPersSvc [private]

Handle to the IConversionSvc interface of the DetectorPersistencySvc.

Definition at line 110 of file CalibRootCnvSvc.h.

Referenced by initialize().

std::string CalibRootCnvSvc::m_rootfile[10] [private]

Definition at line 114 of file CalibRootCnvSvc.h.

Referenced by CalibRootCnvSvc(), createAddress(), and getrootfile().


Generated on Tue Nov 29 23:18:01 2016 for BOSS_7.0.2 by  doxygen 1.4.7