Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CalibDataSvc Class Reference

#include <CalibDataSvc.h>

List of all members.

Public Member Functions

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

Protected Member Functions

 CalibDataSvc (const std::string &name, ISvcLocator *svc)
 CalibDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~CalibDataSvc ()
virtual ~CalibDataSvc ()
 Standard Destructor.

Private Member Functions

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

Private Attributes

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

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


Constructor & Destructor Documentation

CalibDataSvc::CalibDataSvc const std::string &  name,
ISvcLocator *  svc
[protected]
 

Standard Constructor.

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   m_calibType[7]=14;
00077   // m_rootName and m_rootCLID are declared in base class DataSvc
00078   m_rootName = "/" + m_calibRootName;
00079   m_rootCLID = CLID_DataObject;  
00080 
00081  
00082 
00083 }

CalibDataSvc::~CalibDataSvc  )  [protected, virtual]
 

Standard Destructor.

00086                              {
00087   setDataLoader(0);
00088   clearStore();
00089 }

CalibDataSvc::CalibDataSvc const std::string &  name,
ISvcLocator *  svc
[protected]
 

virtual CalibDataSvc::~CalibDataSvc  )  [protected, virtual]
 


Member Function Documentation

virtual StatusCode CalibDataSvc::clearStore  )  [virtual]
 

Remove all data objects in the data store.

StatusCode CalibDataSvc::clearStore  )  [virtual]
 

Remove all data objects in the data store.

00281                                       {
00282   DataSvc::clearStore();
00283   return StatusCode::SUCCESS;
00284 }

virtual StatusCode CalibDataSvc::finalize  )  [virtual]
 

StatusCode CalibDataSvc::finalize  )  [virtual]
 

Finalize the service.

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

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

Inform that a new incident has occured.

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

Inform that a new incident has occured.

00287                                                 {
00288    MsgStream log( msgSvc(), name() );
00289      return; 
00290   }

virtual StatusCode CalibDataSvc::initialize  )  [virtual]
 

StatusCode CalibDataSvc::initialize  )  [virtual]
 

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

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

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

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

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

00325                                                           {
00326   return DataSvc::loadObject(pLoader, pRegistry);
00327 
00328 }

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::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.

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

Query the interface of the service.

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

Query the interface of the service.

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

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

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

00404                                                            {
00405   DataObject* pO = 0;
00406   StatusCode status =DataSvc::retrieveObject(parentPath, pO);
00407   if ( !status.isSuccess() && m_forceLeaves )   {
00408     pO = createDefaultObject();
00409     status =DataSvc::registerObject(parentPath, pO);
00410     if ( !status.isSuccess() )   {
00411       pO->release();
00412     }//end of if
00413   }//end of if( !status.isSuccess() && m_forceLeaves )
00414   if ( status.isSuccess() )   {
00415     status =DataSvc::registerObject(pO, objPath, pObject);
00416   }
00417   if(status.isSuccess() ){
00418   return status;
00419 }
00420 }

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

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

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

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

Update object.

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

Update object.

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

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

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

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

SvcFactory<CalibDataSvc> [friend]
 


Member Data Documentation

StringArrayProperty CalibDataSvc::m_calibList [private]
 

calibration types

std::string CalibDataSvc::m_calibRootName [private]
 

Name of the root node of the calib store.

int CalibDataSvc::m_calibType [private]
 

Calibration Data Persistency Storage type.

IDataProviderSvc* CalibDataSvc::m_eventSvc [private]
 

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

IDataProviderSvc* CalibDataSvc::m_eventSvc [private]
 

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

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

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


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 15:55:47 2011 for BOSS6.5.5 by  doxygen 1.3.9.1