TofEnergyCalibSvc Class Reference

#include <TofEnergyCalibSvc.h>

Inheritance diagram for TofEnergyCalibSvc:

ITofEnergyCalibSvc List of all members.

Public Member Functions

 TofEnergyCalibSvc (const std::string &name, ISvcLocator *svcloc)
 ~TofEnergyCalibSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void handle (const Incident &)
void SetIsData (const std::string &_IsData)
std::string GetIsData () const
void SetBossRelease (const std::string &_bossrelease)
std::string GetBossRelease () const
double getCalibConst () const
double getPara1 () const
double getPara2 () const
double getPara3 () const
double getPara4 () const
double getPara5 () const
void setCalibConst (double _CalibConst)
void setPara1 (double _Para1)
void setPara2 (double _Para2)
void setPara3 (double _Para3)
void setPara4 (double _Para4)
void setPara5 (double _Para5)
bool getTofEnergyCalibSvcInfo ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Public Attributes

IDatabaseSvcm_dbsvc

Private Attributes

double m_CalibConst
double m_Para1
double m_Para2
double m_Para3
double m_Para4
double m_Para5
std::string dbName
std::string m_bossRelease
std::string m_IsData
std::string host
std::string table
std::string userName
std::string password
unsigned int serialNo
IDataProviderSvc * m_eventSvc

Detailed Description

Definition at line 24 of file TofEnergyCalibSvc.h.


Constructor & Destructor Documentation

TofEnergyCalibSvc::TofEnergyCalibSvc ( const std::string name,
ISvcLocator *  svcloc 
)

TofEnergyCalibSvc::~TofEnergyCalibSvc (  ) 

Definition at line 55 of file TofEnergyCalibSvc.cxx.

00055                                      {
00056 }


Member Function Documentation

StatusCode TofEnergyCalibSvc::finalize (  )  [virtual]

Definition at line 97 of file TofEnergyCalibSvc.cxx.

References Bes_Common::INFO.

00097                                       {
00098         MsgStream log(messageService(), name());
00099         log << MSG::INFO << "TofEnergyCalibSvc::finalize()" << endreq;
00100         //  if(m_connect_offline) delete m_connect_offline;
00101         return StatusCode::SUCCESS;
00102 }

std::string TofEnergyCalibSvc::GetBossRelease (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 52 of file TofEnergyCalibSvc.h.

References m_bossRelease.

00052 {return m_bossRelease;}

double TofEnergyCalibSvc::getCalibConst (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 53 of file TofEnergyCalibSvc.h.

References m_CalibConst.

00053 { return m_CalibConst;}

std::string TofEnergyCalibSvc::GetIsData (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 50 of file TofEnergyCalibSvc.h.

References m_IsData.

00050 {return m_IsData;}

double TofEnergyCalibSvc::getPara1 (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 54 of file TofEnergyCalibSvc.h.

References m_Para1.

00054 { return m_Para1;}

double TofEnergyCalibSvc::getPara2 (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 55 of file TofEnergyCalibSvc.h.

References m_Para2.

00055 { return m_Para2;}

double TofEnergyCalibSvc::getPara3 (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 56 of file TofEnergyCalibSvc.h.

References m_Para3.

00056 { return m_Para3;}

double TofEnergyCalibSvc::getPara4 (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 57 of file TofEnergyCalibSvc.h.

References m_Para4.

00057 { return m_Para4;}

double TofEnergyCalibSvc::getPara5 (  )  const [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 58 of file TofEnergyCalibSvc.h.

References m_Para5.

00058 { return m_Para5;}

bool TofEnergyCalibSvc::getTofEnergyCalibSvcInfo (  )  [virtual]

Implements ITofEnergyCalibSvc.

Definition at line 117 of file TofEnergyCalibSvc.cxx.

References DatabaseRecord::GetDouble(), m_bossRelease, m_CalibConst, m_dbsvc, m_eventSvc, m_IsData, m_Para1, m_Para2, m_Para3, m_Para4, m_Para5, and IDatabaseSvc::query().

Referenced by handle().

00117                                                 {
00118         MsgStream log(messageService(), name());
00119         SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
00120         int  run = eventHeader->runNumber();
00121   cout<<"Run in getTofEnergyCalibSvcInfo() is: "<<run<<endl;
00122 
00123         char stmt1[400];
00124         if(run<0) {
00125                 cout << "This data is the MC sample with the Run Number: " << run << endl;
00126                 run = -run;
00127         }
00128         
00129         if(m_bossRelease=="default") m_bossRelease = getenv("BES_RELEASE");
00130         sprintf(stmt1, "select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergyCalib where BossVer = '%s' and RunFrom <= %d and RunTo >= %d and IsData = '%s'", m_bossRelease.c_str(), run, run, m_IsData.c_str());
00131         cout<<"stmt is:"<<stmt1<<endl;
00132         DatabaseRecordVector res;
00133         int row_no = m_dbsvc->query("offlinedb",stmt1,res);
00134         if( row_no > 0 ) {
00135                 DatabaseRecord& dbrec = *res[row_no-1];
00136                 m_CalibConst = dbrec.GetDouble("CalibConst");
00137                 m_Para1 = dbrec.GetDouble("Para1");
00138                 m_Para2 = dbrec.GetDouble("Para2");
00139                 m_Para3 = dbrec.GetDouble("Para3");
00140                 m_Para4 = dbrec.GetDouble("Para4");
00141                 m_Para5 = dbrec.GetDouble("Para5");
00142                 cout<<"m_CalibConst is:"<<m_CalibConst<<endl;
00143                 cout << "Successfully fetch TofEnergyCalibSvc information for run: "
00144                         << run << endl;
00145                 return true;
00146         } else if( row_no<=0 ) {
00147                 cout << " TofEnergyCalibSvc:: can not found TofEnergyCalibSvc information of run:"
00148                         << run << ", boss version " << m_bossRelease << endl;
00149                 exit(1);
00150                 return false;
00151         }
00152         return true;
00153 }

void TofEnergyCalibSvc::handle ( const Incident &   ) 

Definition at line 104 of file TofEnergyCalibSvc.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, and getTofEnergyCalibSvcInfo().

00104                                                  {
00105         MsgStream log( messageService(), name() );
00106         log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00107 
00108         if ( inc.type() == "NewRun" ){
00109                 log << MSG::DEBUG << "NewRun" << endreq;
00110                 if(!getTofEnergyCalibSvcInfo()){
00111                         log << MSG::ERROR << "can not initilize Tof energy Calib Constants" << endreq;
00112                 }
00113         } 
00114 }

StatusCode TofEnergyCalibSvc::initialize (  )  [virtual]

Definition at line 67 of file TofEnergyCalibSvc.cxx.

References calibUtil::ERROR, Bes_Common::INFO, m_dbsvc, and m_eventSvc.

00067                                         {
00068         MsgStream log(messageService(), name());
00069         log << MSG::INFO << "TofEnergyCalibSvc::initialize()" << endreq;
00070 
00071         StatusCode sc = Service::initialize();
00072         if( sc.isFailure() ) return sc;
00073 
00074 
00075         IIncidentSvc* incsvc;
00076         sc = service("IncidentSvc", incsvc);
00077         int priority = 100;
00078         if( sc.isSuccess() ){
00079                 incsvc -> addListener(this, "NewRun", priority);
00080         }
00081 
00082         sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
00083         if (sc .isFailure() ) {
00084                 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
00085                 return sc;
00086         }
00087 
00088         sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
00089         if (sc .isFailure() ) {
00090                 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
00091                 return sc;
00092         }
00093 
00094         return StatusCode::SUCCESS;
00095 }

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

Definition at line 15 of file ITofEnergyCalibSvc.h.

References IID_ITofEnergyCalibSvc().

00015 { return IID_ITofEnergyCalibSvc; }

StatusCode TofEnergyCalibSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
) [virtual]

Definition at line 58 of file TofEnergyCalibSvc.cxx.

References IID_ITofEnergyCalibSvc().

00058                                                                                         {
00059         if( IID_ITofEnergyCalibSvc.versionMatch(riid) ){
00060                 *ppvInterface = static_cast<ITofEnergyCalibSvc*> (this);
00061         } else{
00062                 return Service::queryInterface(riid, ppvInterface);
00063         }
00064         return StatusCode::SUCCESS;
00065 }

void TofEnergyCalibSvc::SetBossRelease ( const std::string _bossrelease  )  [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 51 of file TofEnergyCalibSvc.h.

References m_bossRelease.

00051 {m_bossRelease = _bossrelease;}

void TofEnergyCalibSvc::setCalibConst ( double  _CalibConst  )  [inline]

Definition at line 59 of file TofEnergyCalibSvc.h.

References m_CalibConst.

00059 {m_CalibConst=_CalibConst;}

void TofEnergyCalibSvc::SetIsData ( const std::string _IsData  )  [inline, virtual]

Implements ITofEnergyCalibSvc.

Definition at line 49 of file TofEnergyCalibSvc.h.

References m_IsData.

00049 {m_IsData = _IsData;}

void TofEnergyCalibSvc::setPara1 ( double  _Para1  )  [inline]

Definition at line 60 of file TofEnergyCalibSvc.h.

References m_Para1.

00060 {m_Para1=_Para1;}

void TofEnergyCalibSvc::setPara2 ( double  _Para2  )  [inline]

Definition at line 61 of file TofEnergyCalibSvc.h.

References m_Para2.

00061 {m_Para2=_Para2;}

void TofEnergyCalibSvc::setPara3 ( double  _Para3  )  [inline]

Definition at line 62 of file TofEnergyCalibSvc.h.

References m_Para3.

00062 {m_Para3=_Para3;}

void TofEnergyCalibSvc::setPara4 ( double  _Para4  )  [inline]

Definition at line 63 of file TofEnergyCalibSvc.h.

References m_Para4.

00063 {m_Para4=_Para4;}

void TofEnergyCalibSvc::setPara5 ( double  _Para5  )  [inline]

Definition at line 64 of file TofEnergyCalibSvc.h.

References m_Para5.

00064 {m_Para5=_Para5;}


Member Data Documentation

std::string TofEnergyCalibSvc::dbName [private]

Definition at line 76 of file TofEnergyCalibSvc.h.

std::string TofEnergyCalibSvc::host [private]

Definition at line 80 of file TofEnergyCalibSvc.h.

std::string TofEnergyCalibSvc::m_bossRelease [private]

Definition at line 77 of file TofEnergyCalibSvc.h.

Referenced by GetBossRelease(), getTofEnergyCalibSvcInfo(), and SetBossRelease().

double TofEnergyCalibSvc::m_CalibConst [private]

Definition at line 70 of file TofEnergyCalibSvc.h.

Referenced by getCalibConst(), getTofEnergyCalibSvcInfo(), and setCalibConst().

IDatabaseSvc* TofEnergyCalibSvc::m_dbsvc

Definition at line 41 of file TofEnergyCalibSvc.h.

Referenced by getTofEnergyCalibSvcInfo(), and initialize().

IDataProviderSvc* TofEnergyCalibSvc::m_eventSvc [private]

Definition at line 87 of file TofEnergyCalibSvc.h.

Referenced by getTofEnergyCalibSvcInfo(), and initialize().

std::string TofEnergyCalibSvc::m_IsData [private]

Definition at line 78 of file TofEnergyCalibSvc.h.

Referenced by GetIsData(), getTofEnergyCalibSvcInfo(), and SetIsData().

double TofEnergyCalibSvc::m_Para1 [private]

Definition at line 71 of file TofEnergyCalibSvc.h.

Referenced by getPara1(), getTofEnergyCalibSvcInfo(), and setPara1().

double TofEnergyCalibSvc::m_Para2 [private]

Definition at line 72 of file TofEnergyCalibSvc.h.

Referenced by getPara2(), getTofEnergyCalibSvcInfo(), and setPara2().

double TofEnergyCalibSvc::m_Para3 [private]

Definition at line 73 of file TofEnergyCalibSvc.h.

Referenced by getPara3(), getTofEnergyCalibSvcInfo(), and setPara3().

double TofEnergyCalibSvc::m_Para4 [private]

Definition at line 74 of file TofEnergyCalibSvc.h.

Referenced by getPara4(), getTofEnergyCalibSvcInfo(), and setPara4().

double TofEnergyCalibSvc::m_Para5 [private]

Definition at line 75 of file TofEnergyCalibSvc.h.

Referenced by getPara5(), getTofEnergyCalibSvcInfo(), and setPara5().

std::string TofEnergyCalibSvc::password [private]

Definition at line 83 of file TofEnergyCalibSvc.h.

unsigned int TofEnergyCalibSvc::serialNo [private]

Definition at line 84 of file TofEnergyCalibSvc.h.

std::string TofEnergyCalibSvc::table [private]

Definition at line 81 of file TofEnergyCalibSvc.h.

std::string TofEnergyCalibSvc::userName [private]

Definition at line 82 of file TofEnergyCalibSvc.h.


Generated on Tue Nov 29 23:36:05 2016 for BOSS_7.0.2 by  doxygen 1.4.7