/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/CalibSvc/CalibTreeCnv/CalibTreeCnv-00-01-18/src/CalibTreeCnvSvc.cxx

Go to the documentation of this file.
00001 
00002 #include "GaudiKernel/IDetDataSvc.h"
00003 #include "GaudiKernel/IConversionSvc.h"
00004 #include "GaudiKernel/IConverter.h"
00005 
00006 #include "GaudiKernel/MsgStream.h"
00007 #include "GaudiKernel/SvcFactory.h"
00008 #include "GaudiKernel/CnvFactory.h"
00009 #include "GaudiKernel/ISvcLocator.h"
00010 #include "GaudiKernel/IDataProviderSvc.h"
00011 #include "GaudiKernel/GenericAddress.h"
00012 #include "CalibTreeCnv/CalibTreeCnvSvc.h"
00013 #include "CalibData/CalibBase.h"
00014 #include "cnv/TreeCalBaseCnv.h"
00015 #include "CalibData/CalibBase1.h"
00016 #include "CalibDataSvc/IInstrumentName.h"
00017 // Make instances only via static factory class
00018 //static SvcFactory<CalibTreeCnvSvc> calibRootCnvSvc_factory;
00019 //const ISvcFactory& CalibTreeCnvSvcFactory = calibRootCnvSvc_factory;
00020 
00021 CalibTreeCnvSvc::CalibTreeCnvSvc(const std::string& name, 
00022                                ISvcLocator* svc) :
00023   ConversionSvc(name, svc, CALIBTREE_StorageType),
00024   m_detPersSvc(0), m_detDataSvc(0)   {
00025   //huangb add
00026 }
00027 
00028 StatusCode CalibTreeCnvSvc::queryInterface(const InterfaceID& riid,
00029                                           void** ppvInterface) {
00030   /* Uncomment if choose to derive from abstract root conv. interface */
00031   if (IID_ICalibTreeSvc.versionMatch(riid))  {
00032     *ppvInterface = (ICalibTreeSvc*)this;
00033   }
00034   else {
00035     // Interface is not directly availible: try out a base class
00036     return ConversionSvc::queryInterface(riid, ppvInterface);
00037     /*  }  */
00038   addRef();
00039   }
00040   return StatusCode::SUCCESS;
00041 }
00042 
00043 StatusCode CalibTreeCnvSvc::initialize() {
00044   StatusCode sc = ConversionSvc::initialize();
00045 
00046   MsgStream log(msgSvc(), "CalibTreeCnvSvc");
00047 
00048   if (!sc.isSuccess()) return sc;
00049 
00050   // Locate the Calib Data Service.  Since it inherits from DataSvc
00051   // it has to implement IDataProviderSvc
00052   m_detDataSvc = 0;
00053   /*sc = serviceLocator()->getService 
00054     ("CalibDataSvc",  IID_IDataProviderSvc,(IInterface*&) m_detDataSvc);*/
00055   sc = serviceLocator()->getService 
00056     ("CalibDataSvc",  IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
00057   if ( !sc.isSuccess() ) {
00058     log << MSG::ERROR << "Could not locate CalibDataSvc" << endreq;
00059     return sc;
00060   }
00061 
00062  /*  IInstrumentName* iInstrumentName;
00063   sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
00064                                     (void**) &iInstrumentName);
00065 */
00066   // Set the CalibDataSvc as data provider service
00067   sc = setDataProvider(m_detDataSvc);
00068   if ( !sc.isSuccess() ) {
00069     log << MSG::ERROR << "Could not set data provider" << endreq;
00070     return sc;
00071   }
00072   //huangb add 
00073  sc = setProperties();
00074 
00075   // Locate IConversionSvc interface of the DetectorPersistencySvc
00076   sc = serviceLocator()->service 
00077     ("DetectorPersistencySvc", m_detPersSvc, true);
00078   if ( !sc.isSuccess() ) {
00079     log << MSG::ERROR 
00080         << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
00081         << endreq;
00082     return sc;
00083   } else {
00084     log << MSG::DEBUG 
00085         << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
00086         << endreq;
00087   }
00088   
00089   // Query the IAddressCreator interface of the detector persistency service
00090   IAddressCreator* iAddrCreator;
00091   /*sc = m_detPersSvc->queryInterface(IID_IAddressCreator, 
00092                                     (void**) &iAddrCreator);*/
00093   sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(), 
00094                                     (void**) &iAddrCreator);
00095   if ( !sc.isSuccess() ) {
00096     log << MSG::ERROR 
00097         << "Cannot query IAddressCreator interface of DetectorPersistencySvc" 
00098         << endreq;
00099     return sc;
00100   } else {
00101     log << MSG::DEBUG 
00102         << "Retrieved IAddressCreator interface of DetectorPersistencySvc" 
00103         << endreq;
00104   }
00105   log << MSG::DEBUG 
00106       << "Set it as the address creator of the CalibTreeCnvSvc" << endreq;
00107   sc = setAddressCreator(iAddrCreator);
00108   if ( !sc.isSuccess() ) {
00109     log << MSG::ERROR   << "Cannot set the address creator" << endreq;
00110     return sc;
00111   }
00112 
00113   // set properties if there are any??
00114 
00115   return sc;
00116 }
00117 
00118 StatusCode CalibTreeCnvSvc::finalize() {
00119   // If anything was allocated, get rid of it.  So far, nothing was.
00120 
00121   return ConversionSvc::finalize();
00122 }
00123 
00124   StatusCode CalibTreeCnvSvc::createAddress(long svc_type,
00125                                             const CLID& clid,
00126                                             const std::string* par, 
00127                                             const unsigned long* ip,
00128                                             IOpaqueAddress*& refpAddress) {
00129  //createAddress of   CalibTreeCnvSvc
00130     MsgStream log( msgSvc(), name() );
00131     if (svc_type != CALIBTREE_StorageType) {
00132     log << MSG::ERROR << "bad storage type" << (int)svc_type << endreq;
00133     return StatusCode::FAILURE;
00134   }
00135     std::string dataIdent;
00136     std::string fullpath;
00137     int index ;
00138     if(clid==CLID_Calib_MdcCal) 
00139       { index=0;}
00140     else if(clid==CLID_Calib_TofCal)
00141       {index =1;}
00142     else if(clid==CLID_Calib_DedxCal)
00143       {index =2;}
00144     else if(clid==CLID_Calib_EmcCal)
00145       {index =3;}
00146     else{ 
00147       log << MSG::WARNING<<"Wrong CLID"<<endreq;
00148     }
00149     
00150   //see if svctype set in the CalibDataSvc is MYSQL_StorageType or  CALIBROOT_StorageType
00151 /*  IInstrumentName* iInstrumentName;
00152   StatusCode sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
00153                                     (void**) &iInstrumentName);
00154 
00155   if ( !sc.isSuccess() ) {
00156     log << MSG::ERROR
00157         << "Cannot query IInstrumentName interface of CalibDataSvc"
00158         << endreq;
00159     return sc;
00160   } else {
00161     log << MSG::DEBUG
00162         << "Retrieved IInstrumentName interface of CalibDataSvc"
00163         << endreq;
00164   }
00165 
00166    int svctype = iInstrumentName->getsvctype();
00167     if(svctype== CALIBROOT_StorageType)
00168       {
00169         dataIdent = m_rootfile[index];
00170         fullpath = par[0];
00171       }
00172 
00173    if(svctype== MYSQL_StorageType)
00174       {   log << MSG::INFO<<"rootfile is not set in the jobOption,get it from MySQL"<<endreq;
00175       dataIdent = par[0];
00176       fullpath = par[1];
00177       }
00178 
00179    if ((svctype != CALIBROOT_StorageType)&&(svctype!= MYSQL_StorageType)) {
00180     log << MSG::ERROR << "bad storage type" << (int)svctype << endreq;
00181     return StatusCode::FAILURE;
00182   }
00183 */
00184    // std::string dataIdent(par[0]); // file identifier for PDS version of data
00185   // log << MSG::INFO<<"dataIdent is:"<<dataIdent<<endreq;
00186    //std::string fullpath(par[1]);  // path within TCDS for the object
00187  //  log << MSG::INFO<<"fullpath is :"<<fullpath<<endreq;
00188  
00189  
00190    int runfrm = ip[0];
00191    int runto = ip[1];
00192    dataIdent = par[0];
00193    fullpath = par[1];
00194 
00195    // for now have to ignore fmtVersion because of defective implementation
00196   // of GenericAddress. If we want it, should probably write new
00197   // opaque address implementation for this package to use.  All
00198   // dealings with (calibration) opaque addresses are confined to
00199   // the CalibSvc package.
00200   refpAddress = new GenericAddress(CALIBTREE_StorageType,
00201                                    clid,
00202                                    dataIdent,  
00203                                    fullpath,
00204                                    runfrm,
00205                                    runto);
00206                                    
00207                                
00208   return StatusCode::SUCCESS; 
00209 
00210 }
00211 
00212 
00213 StatusCode CalibTreeCnvSvc::updateObj(IOpaqueAddress* pAddress, 
00214                                        DataObject*     pObject  ) {
00215 
00216   //  using facilities::Timestamp;
00217 
00218    MsgStream log(msgSvc(), "CalibTreeCnvSvc" );
00219    
00220    // Don't update when we're using enter time
00221    log << MSG::DEBUG << "CalibTreeCnvSvc::updateObj starting ...."<<endreq;
00222 }

Generated on Tue Nov 29 22:57:52 2016 for BOSS_7.0.2 by  doxygen 1.4.7