CalibDataSvc Class Reference

#include <CalibDataSvc.h>

List of all members.

Public Member Functions

virtual StatusCode initialize ()
virtual StatusCode finalize ()
 Finalize the service.
virtual StatusCode clearStore ()
 Remove all data objects in the data store.
virtual StatusCode updateObject (DataObject *toUpdate)
 Update object.
virtual StatusCode loadObject (IConversionSvc *pLoader, IRegistry *pRegistry)
virtual StatusCode retrieveObject (const std::string &fullPath, DataObject *&pObject)
virtual StatusCode registerObject (const std::string &parentPath, const std::string &objPath, DataObject *pObject)
 CalibDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~CalibDataSvc ()
 Standard Destructor.
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 Query the interface of the service.
virtual void handle (const Incident &)
 Inform that a new incident has occured.

Private Member Functions

StatusCode updateRun (int &runfrm, int &runto, std::string &fullPath)
 For use of CalibMySQLCnvSvc, to set "use event time mode".
StatusCode makeFlavorNodes (IAddressCreator *calibCreator, MsgStream *log)
 Private utility, called from initialize().

Private Attributes

int m_calibType [12]
 Calibration Data Persistency Storage type.
std::string m_calibRootName
 Name of the root node of the calib store.
StringArrayProperty m_calibList
 calibration types
std::vector< std::stringm_flavorList
IDataProviderSvc * m_eventSvc
 Dumping place for various time-fetching methods to save the timestamp.

Friends

class SvcFactory< CalibDataSvc >


Detailed Description

A DataSvc specialized for calibration data. This Service borrows heavily from DetDataSvc. In particular it implements the IDetDataSvc interface. The only significant difference is in initialize() and in the elimination of members concerned with detector (geometry) description.

Maybe will also need to implement another abstract service which gets (and sets?) instrument.

Author:
J. Bogart
Date:
15 Oct. 2002

Definition at line 36 of file CalibDataSvc.h.


Constructor & Destructor Documentation

CalibDataSvc::CalibDataSvc ( const std::string name,
ISvcLocator *  svc 
)

Standard Constructor.

Definition at line 45 of file CalibDataSvc.cxx.

References CALIBROOT_StorageType, m_calibList, m_calibRootName, m_calibType, and m_flavorList.

00045                                                                  :
00046   DataSvc(name,svc)
00047  {
00048      
00049   // declare a property which is a list of known calibrations.
00050   // Have default list in one of the standard options files.  
00051   // User can add others.
00052   declareProperty("CalibNameList", m_calibList);
00053   declareProperty("CalibFlavorList", m_flavorList);
00054   declareProperty("CalibRootName",   m_calibRootName  = "Calib" ); 
00055   declareProperty("Mdc_CalibStorageType",
00056                      m_calibType[0] = CALIBROOT_StorageType );
00057   declareProperty("Tof_CalibStorageType",
00058                      m_calibType[1] = CALIBROOT_StorageType );
00059   declareProperty("Dedx_CalibStorageType",
00060                      m_calibType[2] = CALIBROOT_StorageType );
00061   declareProperty("EMC_CalibStorageType",
00062                      m_calibType[3] = CALIBROOT_StorageType ); 
00063   declareProperty("MUC_CalibStorageType",
00064                      m_calibType[4] = CALIBROOT_StorageType );
00065   declareProperty("EsTime_CalibStorageType",
00066                      m_calibType[5] = CALIBROOT_StorageType );
00067   declareProperty("EstTof_CalibStorageType",
00068                      m_calibType[6] = CALIBROOT_StorageType );
00069   declareProperty("TofQElec_CalibStorageType",
00070                      m_calibType[8] = CALIBROOT_StorageType );
00071   declareProperty("TofSim_CalibStorageType",
00072                      m_calibType[9] = CALIBROOT_StorageType );
00073   declareProperty("DedxSim_CalibStorageType",
00074                      m_calibType[10] = CALIBROOT_StorageType );
00075 
00076   //MdcAlign
00077   m_calibType[7]=14;
00078   //MdcDataConst
00079   m_calibType[11]=14;
00080 
00081   // m_rootName and m_rootCLID are declared in base class DataSvc
00082   m_rootName = "/" + m_calibRootName;
00083   m_rootCLID = CLID_DataObject;  
00084 
00085  
00086 
00087 }

CalibDataSvc::~CalibDataSvc (  )  [virtual]

Standard Destructor.

Definition at line 90 of file CalibDataSvc.cxx.

References clearStore().

00090                              {
00091   setDataLoader(0);
00092   clearStore();
00093 }


Member Function Documentation

StatusCode CalibDataSvc::clearStore (  )  [virtual]

Remove all data objects in the data store.

Definition at line 290 of file CalibDataSvc.cxx.

Referenced by ~CalibDataSvc().

00290                                       {
00291   DataSvc::clearStore();
00292   return StatusCode::SUCCESS;
00293 }

StatusCode CalibDataSvc::finalize (  )  [virtual]

Finalize the service.

Definition at line 256 of file CalibDataSvc.cxx.

References Bes_Common::DEBUG, and msgSvc().

00257 {
00258   MsgStream log(msgSvc(), name());
00259   log << MSG::DEBUG << "Finalizing" << endreq;
00260 
00261   //  return StatusCode::SUCCESS;
00262   // Finalize the base class
00263   //  huangb temply delete
00264    return DataSvc::finalize();
00265 }

void CalibDataSvc::handle ( const Incident &   )  [virtual]

Inform that a new incident has occured.

Definition at line 296 of file CalibDataSvc.cxx.

References msgSvc().

00296                                                 {
00297    MsgStream log( msgSvc(), name() );
00298      return; 
00299   }

StatusCode CalibDataSvc::initialize (  )  [virtual]

Definition at line 96 of file CalibDataSvc.cxx.

References calibUtil::ERROR, CalibData::CalibModelSvc::getPairs(), Bes_Common::INFO, m_calibType, m_eventSvc, msgSvc(), CalibData::pairs, and deljobs::string.

00096                                       {
00097 
00098   StatusCode sc;
00099 
00100   sc  = DataSvc::initialize();     // Call base class initialisation
00101   if (sc.isFailure() )  return sc;
00102 
00103   // Set up MsgSvc, Data Loader
00104   MsgStream log(msgSvc(), name());
00105   IConversionSvc* cnv_svc;
00106   sc = serviceLocator()->service("DetectorPersistencySvc", cnv_svc, true);
00107   if (sc .isFailure() ) {
00108     log << MSG::ERROR << "Unable to find DetectorPersistencySvc " << endreq;
00109     return sc;
00110   }
00111  
00112   IIncidentSvc* incsvc;
00113      sc = service("IncidentSvc", incsvc);
00114      int priority = 100;
00115      if( sc.isSuccess() ){
00116           incsvc -> addListener(this, "NewRun", priority);
00117      }
00118   
00119  sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
00120   if (sc .isFailure() ) {
00121     log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
00122     return sc;
00123   }
00124 
00125   sc = setDataLoader(cnv_svc);
00126   if (sc.isFailure() ) {
00127     log << MSG::ERROR << "Unable to set data loader " << endreq;
00128     return sc;
00129   }
00130   sc = setProperties();   
00131 
00132   // Initialize the calibration data transient store
00133   IAddressCreator*     calibCreator = 0;
00134 
00135   // Use Gaudi-supplied DetectorPersistencySvc; it's essentially
00136   // the same as base class PersistencySvc, which is all we need
00137   sc = serviceLocator()->service("DetectorPersistencySvc", calibCreator);
00138   
00139   if( sc.isFailure() ) {
00140     log << MSG::ERROR << "Unable to locate DetectorPersistencySvc." << endreq;
00141     return StatusCode::FAILURE; 
00142   }
00143   
00144   //   Make the root for the TDDS data
00145   DataObject* rootObj = new DataObject();
00146   sc = setRoot(m_rootName, rootObj);
00147   if (!sc.isSuccess() ) {
00148     log << MSG::ERROR << "Unable to set calib data store root." << endreq;
00149     delete rootObj;
00150     return sc;
00151   }
00152 
00153 // Create and register the next level of nodes.
00154 // Have one per calibration type. They are of a class trivially 
00155 // derived from DataObject, CalibCLIDNode.  Only additional 
00156 // information is CLID of child nodes.  List comes from CalibData 
00157 // namespace
00158 //StatusCode CalibDataSvc::makeFlavorNodes(IAddressCreator*  calibCreator,
00159 //                                         MsgStream* log) {
00160   typedef std::vector<CalibData::CalibModelSvc::CalibPair>::const_iterator 
00161     PairIt;
00162   PairIt  pairIt;
00163   CalibData::CalibModelSvc svc;
00164   const std::vector<CalibData::CalibModelSvc::CalibPair>& pairs = 
00165     svc.getPairs();
00166   int jj =0;
00167   for (pairIt = pairs.begin(); pairIt != pairs.end(); pairIt++,jj++) {
00168     
00169     CalibCLIDNode* node = new CalibCLIDNode(pairIt->second);
00170 
00171     std::string calibTypePath(pairIt->first);
00172     // sc =DataSvc::registerObject(calibTypePath, node);
00173 
00174     // Still have to figure out what to do about args, iargs
00175     unsigned long iargs[]={0,0};
00176     IOpaqueAddress* pAddress;
00177 
00178     // Set up nodes for each calibration type, default flavor
00179     // Create and register addresses suitable for the metadata
00180     // conversion service.  Ultimately, in order to find the "right"
00181     // set of constants,  it needs to know
00182     //    Calibration type, e.g. CAL Electronic gain
00183     //    Flavor            e.g. vanilla 
00184     //    Event time        validity period of constants must include this time
00185     //    Instrument        LAT, EM, etc.
00186     // We save the first two, or equivalent information, in the first
00187     // string parameter of a generic address
00188     // Consumers can use utilities in CalibData::CalibModelSvc to
00189     // extract fields they need
00190     // Event time and Instrument will be discovered by conversion service
00191     // when constants are requested by invoking our (CalibDataSvc) time
00192     // and instrument name services, resp.
00193 
00194     // Always do vanilla
00195     std::string fullpath = calibTypePath;
00196     std::string args[] = {fullpath};
00197   
00198 //    sc = calibCreator->createAddress(m_calibStorageType, 
00199 //                                   pairIt->second,   // class id
00200 //                                     args, iargs, pAddress);
00201     sc = calibCreator->createAddress(m_calibType[jj],
00202                                      pairIt->second,   // class id
00203                                      args, iargs, pAddress);
00204 
00205 
00206     if (!sc.isSuccess()) { 
00207       log<< MSG::INFO 
00208           << "Unable to create Calib address with path " << fullpath << endreq;
00209     }
00210  
00211     // A node unof a specific flavor is a child of the per-calibration type
00212     // node for which an object was registered above.
00213     sc = registerAddress(fullpath, pAddress);
00214     if (!sc.isSuccess()) {
00215       log<< MSG::ERROR << "Unable to register Calib address with path" 
00216          << fullpath << endreq;
00217     }
00218     // Now do the same for any requested flavors
00219     /*
00220     unsigned int ix;
00221     
00222     for (ix = 0; ix < m_flavorList.size(); ix++) { 
00223       log<<MSG::DEBUG<<"here is the flavor in the CalibDataSvc"<<endreq; 
00224       // Don't redo vanilla, if present in user list
00225       if (m_flavorList[ix] == std::string("vanilla")) continue;
00226 
00227       fullpath = calibTypePath + "/" + m_flavorList[ix];
00228       args[0] = fullpath;
00229 
00230       sc = calibCreator->createAddress(m_calibStorageType, 
00231                                        pairIt->second, args, iargs, pAddress); 
00232       if (!sc.isSuccess()) {
00233 
00234 
00235         log<< MSG::ERROR << "Unable to create Calib address with path " 
00236             << fullpath << endreq;
00237       }
00238       sc = DataSvc::registerAddress(fullpath, pAddress);
00239       if (!sc.isSuccess()) {
00240         log<< MSG::ERROR << "Unable to register Calib address with path " 
00241             << fullpath << endreq;
00242       }
00243     }   
00244  // end flavor loop 
00245  */
00246   } 
00247 // end calibType loop
00248 // initialize the parameters
00249                                      
00250   return StatusCode::SUCCESS;
00251 }

StatusCode CalibDataSvc::loadObject ( IConversionSvc *  pLoader,
IRegistry *  pRegistry 
) [virtual]

Load object. Override DataSvc implementation to get current event time first if necessary

Definition at line 333 of file CalibDataSvc.cxx.

00334                                                           {
00335   return DataSvc::loadObject(pLoader, pRegistry);
00336 
00337 }

StatusCode CalibDataSvc::makeFlavorNodes ( IAddressCreator *  calibCreator,
MsgStream *  log 
) [private]

Private utility, called from initialize().

Redundant job option to indicate whether or not to check for valid event time when fetching calibrations. There already is a similar thing for CalibMySQLCnvSvc, but no easy way for one service to tell the other about it.

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

Query the interface of the service.

Definition at line 267 of file CalibDataSvc.cxx.

References IInstrumentName::interfaceID().

00268 {
00269   // With the highest priority return the specific interfaces
00270   // If interfaces are not directly available, try out a base class
00271   if (IDetDataSvc::interfaceID().versionMatch(riid) ) {
00272     *ppvInterface = (IDetDataSvc*)this;
00273   } else if (IInstrumentName::interfaceID().versionMatch(riid) ) {
00274     *ppvInterface = (IInstrumentName*) this;
00275 //  } else if ( IID_IIncidentListener.versionMatch(riid) ) {
00276 //    *ppvInterface = (IIncidentListener*)this; 
00277   } else {
00278     return DataSvc::queryInterface(riid, ppvInterface);
00279   }
00280   addRef();
00281   return StatusCode::SUCCESS;
00282 }

StatusCode CalibDataSvc::registerObject ( const std::string parentPath,
const std::string objPath,
DataObject *  pObject 
) [virtual]

Definition at line 413 of file CalibDataSvc.cxx.

00415                                                            {
00416   DataObject* pO = 0;
00417   StatusCode status =DataSvc::retrieveObject(parentPath, pO);
00418   if ( !status.isSuccess() && m_forceLeaves )   {
00419     pO = createDefaultObject();
00420     status =DataSvc::registerObject(parentPath, pO);
00421     if ( !status.isSuccess() )   {
00422       pO->release();
00423     }//end of if
00424   }//end of if( !status.isSuccess() && m_forceLeaves )
00425   if ( status.isSuccess() )   {
00426     status =DataSvc::registerObject(pO, objPath, pObject);
00427   }
00428   if(status.isSuccess() ){
00429   return status;
00430 }
00431 }

StatusCode CalibDataSvc::retrieveObject ( const std::string fullPath,
DataObject *&  pObject 
) [virtual]

Definition at line 339 of file CalibDataSvc.cxx.

References CALIBROOT_StorageType, Bes_Common::DEBUG, calibUtil::ERROR, CalibData::CalibBase1::getrunfrm(), CalibData::CalibBase1::getrunto(), Bes_Common::INFO, m_calibType, m_eventSvc, msgSvc(), runNo, and Bes_Common::WARNING.

00340 {  
00341    MsgStream log( msgSvc(), name() );
00342   
00343  int runNo;
00344  //maqm SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event");
00345  SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event/EventHeader");
00346  if( evt ){
00347    runNo = evt -> runNumber();
00348    log << MSG::DEBUG <<"The runNumber of current event is  "<<runNo<<endreq;
00349  }
00350 
00351  else{
00352    log << MSG::WARNING << "WARNING accessing Event" <<endreq;
00353 //   return StatusCode::FAILURE;
00354  }
00355 
00356    
00357 StatusCode  sc =DataSvc::retrieveObject(fullPath,pObject);
00358  if (!sc.isSuccess()) {
00359         log<< MSG::ERROR << "Unable to get the retrieveObject" 
00360             << endreq;
00361         return sc;
00362   }
00363 // if(fullPath=="/Calib/MdcAlign"&&m_calibType[0]==CALIBROOT_StorageType) 
00364 //   { return StatusCode::SUCCESS;}
00365 if(fullPath=="/Calib/MdcCal"&&m_calibType[0]==CALIBROOT_StorageType){
00366     return StatusCode::SUCCESS;}
00367 if(fullPath=="/Calib/DedxCal"&&m_calibType[2]==CALIBROOT_StorageType){
00368     return StatusCode::SUCCESS;}
00369 if(fullPath=="/Calib/TofCal"&&m_calibType[1]==CALIBROOT_StorageType){
00370     return StatusCode::SUCCESS;}
00371 if(fullPath=="/Calib/EmcCal"&&m_calibType[3]==CALIBROOT_StorageType){
00372     return StatusCode::SUCCESS;}
00373 if(fullPath=="/Calib/MucCal"&&m_calibType[4]==CALIBROOT_StorageType){
00374     return StatusCode::SUCCESS;}
00375 if(fullPath=="/Calib/EsTimeCal"&&m_calibType[5]==CALIBROOT_StorageType){
00376     return StatusCode::SUCCESS;}
00377 if(fullPath=="/Calib/EstTofCal"&&m_calibType[6]==CALIBROOT_StorageType){
00378     return StatusCode::SUCCESS;}
00379 if(fullPath=="/Calib/TofQElec"&&m_calibType[8]==CALIBROOT_StorageType){
00380     return StatusCode::SUCCESS;}
00381 if(fullPath=="/Calib/TofSim"&&m_calibType[9]==CALIBROOT_StorageType){
00382     return StatusCode::SUCCESS;}
00383 if(fullPath=="/Calib/DedxSim"&&m_calibType[10]==CALIBROOT_StorageType){
00384     return StatusCode::SUCCESS;}
00385  
00386 
00387 CalibData::CalibBase1* tmpObject = dynamic_cast<CalibData::CalibBase1*>(pObject);
00388 if(fullPath=="/Calib/TofCal"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
00389 { return StatusCode::SUCCESS;}
00390 if(fullPath=="/Calib/EstTofCal"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
00391 { return StatusCode::SUCCESS;}
00392 if(fullPath=="/Calib/TofSim"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
00393 { return StatusCode::SUCCESS;}
00394 if(fullPath=="/Calib/DedxSim"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
00395 { return StatusCode::SUCCESS;}
00396 
00397 
00398 
00399 if( fabs(runNo) >= tmpObject->getrunfrm() && fabs(runNo)<=tmpObject->getrunto())
00400 {
00401         log << MSG::DEBUG <<__LINE__<< " runfrm @CalibDataSvc is:"<<tmpObject->getrunfrm()<<" runto min is:"<<tmpObject->getrunto()<<endreq;
00402         return StatusCode::SUCCESS;}
00403 else
00404 { 
00405         log<< MSG::INFO <<"@CalibDataSvc runfrm="<< tmpObject->getrunfrm()<<"runto="<<tmpObject->getrunto()<<"runNo="<<runNo<<endreq;
00406         log<< MSG::DEBUG << "update the Object" 
00407                 << endreq;
00408         sc =DataSvc:: updateObject(pObject);
00409         return sc;    
00410 }//end of else
00411 }//end of if

StatusCode CalibDataSvc::updateObject ( DataObject *  toUpdate  )  [virtual]

Update object.

Definition at line 306 of file CalibDataSvc.cxx.

References calibUtil::ERROR, Bes_Common::INFO, and msgSvc().

00306                                                             {
00307 
00308    
00309   MsgStream log( msgSvc(), name() );
00310    log << MSG::INFO<<"begin of CalibDataSvc::updateObject"<<endreq;
00311   // Check that object to update exists
00312   if ( 0 == toUpdate ) { 
00313     log << MSG::ERROR
00314         << "There is no DataObject to update" << endreq;
00315     return INVALID_OBJECT; 
00316   }
00317 
00318    log << MSG::INFO<<"begin of CalibDataSvc::updateObject"<<endreq;
00319   // Now delegate update to the conversion service by calling the base class
00320   StatusCode status = DataSvc::updateObject(toUpdate);
00321   if ( !status.isSuccess() ) {
00322     log << MSG::ERROR 
00323         << "Could not update DataObject" << endreq; 
00324     if ( status == NO_DATA_LOADER )
00325       log << MSG::ERROR << "There is no data loader" << endreq; 
00326     return status;
00327   } 
00328    log << MSG::INFO<<"begin of CalibDataSvc::updateObject successfully updated"<<endreq;
00329   // DataObject was successfully updated
00330   return StatusCode::SUCCESS;
00331 }

StatusCode CalibDataSvc::updateRun ( int &  runfrm,
int &  runto,
std::string fullPath 
) [private]

For use of CalibMySQLCnvSvc, to set "use event time mode".


Friends And Related Function Documentation

friend class SvcFactory< CalibDataSvc > [friend]

Definition at line 42 of file CalibDataSvc.h.


Member Data Documentation

StringArrayProperty CalibDataSvc::m_calibList [private]

calibration types

Definition at line 108 of file CalibDataSvc.h.

Referenced by CalibDataSvc().

std::string CalibDataSvc::m_calibRootName [private]

Name of the root node of the calib store.

Definition at line 105 of file CalibDataSvc.h.

Referenced by CalibDataSvc().

int CalibDataSvc::m_calibType[12] [private]

Calibration Data Persistency Storage type.

Definition at line 102 of file CalibDataSvc.h.

Referenced by CalibDataSvc(), initialize(), and retrieveObject().

IDataProviderSvc* CalibDataSvc::m_eventSvc [private]

Dumping place for various time-fetching methods to save the timestamp.

Definition at line 120 of file CalibDataSvc.h.

Referenced by initialize(), and retrieveObject().

std::vector<std::string> CalibDataSvc::m_flavorList [private]

Definition at line 111 of file CalibDataSvc.h.

Referenced by CalibDataSvc().


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