BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
TofEnergyCalibSvc Class Reference

#include <TofEnergyCalibSvc.h>

+ Inheritance diagram for TofEnergyCalibSvc:

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 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)
 
StatusCode getSftParVer (std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
 
bool getTofEnergyCalibSvcInfo ()
 
 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 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)
 
StatusCode getSftParVer (std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
 
bool getTofEnergyCalibSvcInfo ()
 
virtual void SetBossRelease (const std::string &_bossrelease)=0
 
virtual std::string GetBossRelease () const =0
 
virtual bool getTofEnergyCalibSvcInfo ()=0
 
virtual double getCalibConst () const =0
 
virtual double getPara1 () const =0
 
virtual double getPara2 () const =0
 
virtual double getPara3 () const =0
 
virtual double getPara4 () const =0
 
virtual double getPara5 () const =0
 
virtual void SetBossRelease (const std::string &_bossrelease)=0
 
virtual std::string GetBossRelease () const =0
 
virtual bool getTofEnergyCalibSvcInfo ()=0
 
virtual double getCalibConst () const =0
 
virtual double getPara1 () const =0
 
virtual double getPara2 () const =0
 
virtual double getPara3 () const =0
 
virtual double getPara4 () const =0
 
virtual double getPara5 () const =0
 

Public Attributes

IDatabaseSvcm_dbsvc
 

Additional Inherited Members

- Static Public Member Functions inherited from ITofEnergyCalibSvc
static const InterfaceID & interfaceID ()
 
static const InterfaceID & interfaceID ()
 

Detailed Description

Constructor & Destructor Documentation

◆ TofEnergyCalibSvc() [1/2]

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

◆ ~TofEnergyCalibSvc() [1/2]

TofEnergyCalibSvc::~TofEnergyCalibSvc ( )

Definition at line 57 of file TofEnergyCalibSvc.cxx.

57 {
58}

◆ TofEnergyCalibSvc() [2/2]

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

◆ ~TofEnergyCalibSvc() [2/2]

TofEnergyCalibSvc::~TofEnergyCalibSvc ( )

Member Function Documentation

◆ finalize() [1/2]

StatusCode TofEnergyCalibSvc::finalize ( )
virtual

Definition at line 99 of file TofEnergyCalibSvc.cxx.

99 {
100 MsgStream log(messageService(), name());
101 log << MSG::INFO << "TofEnergyCalibSvc::finalize()" << endreq;
102 // if(m_connect_offline) delete m_connect_offline;
103 return StatusCode::SUCCESS;
104}

◆ finalize() [2/2]

virtual StatusCode TofEnergyCalibSvc::finalize ( )
virtual

◆ GetBossRelease() [1/2]

std::string TofEnergyCalibSvc::GetBossRelease ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 52 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

52{return m_bossRelease;}

◆ GetBossRelease() [2/2]

std::string TofEnergyCalibSvc::GetBossRelease ( ) const
inlinevirtual

◆ getCalibConst() [1/2]

double TofEnergyCalibSvc::getCalibConst ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 53 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

53{ return m_CalibConst;}

◆ getCalibConst() [2/2]

double TofEnergyCalibSvc::getCalibConst ( ) const
inlinevirtual

◆ getPara1() [1/2]

double TofEnergyCalibSvc::getPara1 ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 54 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

54{ return m_Para1;}

◆ getPara1() [2/2]

double TofEnergyCalibSvc::getPara1 ( ) const
inlinevirtual

◆ getPara2() [1/2]

double TofEnergyCalibSvc::getPara2 ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 55 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

55{ return m_Para2;}

◆ getPara2() [2/2]

double TofEnergyCalibSvc::getPara2 ( ) const
inlinevirtual

◆ getPara3() [1/2]

double TofEnergyCalibSvc::getPara3 ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 56 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

56{ return m_Para3;}

◆ getPara3() [2/2]

double TofEnergyCalibSvc::getPara3 ( ) const
inlinevirtual

◆ getPara4() [1/2]

double TofEnergyCalibSvc::getPara4 ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 57 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

57{ return m_Para4;}

◆ getPara4() [2/2]

double TofEnergyCalibSvc::getPara4 ( ) const
inlinevirtual

◆ getPara5() [1/2]

double TofEnergyCalibSvc::getPara5 ( ) const
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 58 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

58{ return m_Para5;}

◆ getPara5() [2/2]

double TofEnergyCalibSvc::getPara5 ( ) const
inlinevirtual

◆ getSftParVer() [1/2]

StatusCode TofEnergyCalibSvc::getSftParVer ( std::string &  SftVer,
std::string &  CalParVer,
int &  runfrm,
int &  runto,
int  RunNo,
std::string  BossRelease,
std::string  DataType 
)

Definition at line 119 of file TofEnergyCalibSvc.cxx.

127{
128 MsgStream log(msgSvc(), "TofEnergyCalibSvc" );
129 char stmt[300];
130 int run_No =RunNo;
131 MYSQL_RES *res_set;
134 StatusCode sc=serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
135 if (sc .isFailure() ) {
136 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
137 return sc;
138 }
139
140 const char* bossRelease = BossRelease.c_str();
141 const char* dataType = DataType.c_str();
142
143 sprintf(stmt,"select RunFrom,RunTo,SftVer,ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType='%s' ",bossRelease,run_No,run_No,dataType);
144
145 int row_no = m_dbsvc->query("offlinedb",stmt,res);
146 if(row_no<1){
147 std::cout<<"ERROR:error searching with:"<<stmt<<std::endl;
148 exit(1);
149 }
150 if(row_no=1){
151 DatabaseRecord* records1 = res[0];
152 runfrm=records1->GetInt("RunFrom");
153 runto=records1->GetInt("RunTo");
154 cout<<dataType<<" runfrm,runto in getSftParVer is:"<<runfrm<<"::::"<<runto<<endl;
155 SftVer=records1->GetString("SftVer");
156 CalParVer=records1->GetString("ParVer");
157 }
158 if(row_no>1){
159 cout<<"ERROR: "<<dataType<<" set overlapped run number in the table CalVtxLumVer"<<endl;
160 exit(1);
161 }
162 return StatusCode::SUCCESS;
163 }
char * SftVer
Definition: DQA_TO_DB.cxx:18
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)

Referenced by getTofEnergyCalibSvcInfo().

◆ getSftParVer() [2/2]

StatusCode TofEnergyCalibSvc::getSftParVer ( std::string &  SftVer,
std::string &  CalParVer,
int &  runfrm,
int &  runto,
int  RunNo,
std::string  BossRelease,
std::string  DataType 
)

◆ getTofEnergyCalibSvcInfo() [1/2]

bool TofEnergyCalibSvc::getTofEnergyCalibSvcInfo ( )
virtual

Implements ITofEnergyCalibSvc.

Definition at line 164 of file TofEnergyCalibSvc.cxx.

164 {
165 MsgStream log(messageService(), name());
166 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
167 int run = eventHeader->runNumber();
168 //cout<<"Run in getTofEnergyCalibSvcInfo() is: "<<run<<endl;
169
170 char stmt1[400];
171 StatusCode st1;
172 //runfrm,runto are the value from the table ***CalConst;runfrm1,runto1 are the value from the table CalVtxLumVer
173 int runfrm,runfrm1;
174 int runto,runto1;
175 std:string cType;
176
177 if(run<0) {
178 cout << "This data is the MC sample with the Run Number: " << run << endl;
179 run = -run;
180 }
181
182 if(m_bossRelease=="default") m_bossRelease = getenv("BES_RELEASE");
183 if(m_isData=="default")
184 {
185 cout<<"Please set the type of TofEnergy"<<endl;
186 exit(1);
187 }
188 if(m_isData=="Data") cType="TofEnergyData";
189 if(m_isData=="MC") cType="TofEnergyMC";
190 st1=getSftParVer(m_bossVer,m_calPar,runfrm1,runto1,run,m_bossRelease,cType);
191 sprintf(stmt1, "select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergyCalib where BossVer = '%s' and RunFrom <= %d and RunTo >= %d and isData = '%s'", m_bossVer.c_str(), run, run, m_isData.c_str());
192 //cout<<"stmt is:"<<stmt1<<endl;
194 int row_no = m_dbsvc->query("offlinedb",stmt1,res);
195 if( row_no > 0 ) {
196 DatabaseRecord& dbrec = *res[row_no-1];
197 m_CalibConst = dbrec.GetDouble("CalibConst");
198 m_Para1 = dbrec.GetDouble("Para1");
199 m_Para2 = dbrec.GetDouble("Para2");
200 m_Para3 = dbrec.GetDouble("Para3");
201 m_Para4 = dbrec.GetDouble("Para4");
202 m_Para5 = dbrec.GetDouble("Para5");
203 cout<<stmt1<<endl;
204 cout<<"BossReleaseVer="<<m_bossRelease.c_str()<<"\t"<<"TofEnergyBossVer="<<m_bossVer.c_str()<<endl;
205 cout<<"m_CalibConst is:"<<m_CalibConst<<endl;
206 cout<<"Para1="<<m_Para1<<"\t"
207 <<"Para2="<<m_Para2<<"\t"
208 <<"Para3="<<m_Para3<<"\t"
209 <<"Para4="<<m_Para4<<"\t"
210 <<"Para5="<<m_Para5<<endl;
211 cout << "Successfully fetch TofEnergyCalibSvc information for run: "
212 << run << endl;
213 return true;
214 } else if( row_no<=0 ) {
215 cout << " TofEnergyCalibSvc:: can not found TofEnergyCalibSvc information of run:"
216 << run << ", boss version " << m_bossRelease << endl;
217 exit(1);
218 return false;
219 }
220 return true;
221}
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)

Referenced by handle().

◆ getTofEnergyCalibSvcInfo() [2/2]

bool TofEnergyCalibSvc::getTofEnergyCalibSvcInfo ( )
virtual

Implements ITofEnergyCalibSvc.

◆ handle() [1/2]

void TofEnergyCalibSvc::handle ( const Incident &  inc)

Definition at line 106 of file TofEnergyCalibSvc.cxx.

106 {
107 MsgStream log( messageService(), name() );
108 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
109
110 if ( inc.type() == "NewRun" ){
111 log << MSG::DEBUG << "NewRun" << endreq;
113 log << MSG::ERROR << "can not initilize Tof energy Calib Constants" << endreq;
114 }
115 }
116}

◆ handle() [2/2]

void TofEnergyCalibSvc::handle ( const Incident &  )

◆ initialize() [1/2]

StatusCode TofEnergyCalibSvc::initialize ( )
virtual

Definition at line 69 of file TofEnergyCalibSvc.cxx.

69 {
70 MsgStream log(messageService(), name());
71 log << MSG::INFO << "TofEnergyCalibSvc::initialize()" << endreq;
72
73 StatusCode sc = Service::initialize();
74 if( sc.isFailure() ) return sc;
75
76
77 IIncidentSvc* incsvc;
78 sc = service("IncidentSvc", incsvc);
79 int priority = 100;
80 if( sc.isSuccess() ){
81 incsvc -> addListener(this, "NewRun", priority);
82 }
83
84 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
85 if (sc .isFailure() ) {
86 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
87 return sc;
88 }
89
90 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
91 if (sc .isFailure() ) {
92 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
93 return sc;
94 }
95
96 return StatusCode::SUCCESS;
97}

◆ initialize() [2/2]

virtual StatusCode TofEnergyCalibSvc::initialize ( )
virtual

◆ queryInterface() [1/2]

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

Definition at line 60 of file TofEnergyCalibSvc.cxx.

60 {
61 if( IID_ITofEnergyCalibSvc.versionMatch(riid) ){
62 *ppvInterface = static_cast<ITofEnergyCalibSvc*> (this);
63 } else{
64 return Service::queryInterface(riid, ppvInterface);
65 }
66 return StatusCode::SUCCESS;
67}

◆ queryInterface() [2/2]

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

◆ SetBossRelease() [1/2]

void TofEnergyCalibSvc::SetBossRelease ( const std::string &  _bossrelease)
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 51 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

51{m_bossRelease = _bossrelease;}

◆ SetBossRelease() [2/2]

void TofEnergyCalibSvc::SetBossRelease ( const std::string &  _bossrelease)
inlinevirtual

Implements ITofEnergyCalibSvc.

Definition at line 51 of file Tof/TofEnergyCalibSvc/TofEnergyCalibSvc-00-00-03/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

51{m_bossRelease = _bossrelease;}

◆ setCalibConst() [1/2]

void TofEnergyCalibSvc::setCalibConst ( double  _CalibConst)
inline

Definition at line 59 of file InstallArea/include/TofEnergyCalibSvc/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

59{m_CalibConst=_CalibConst;}

◆ setCalibConst() [2/2]

void TofEnergyCalibSvc::setCalibConst ( double  _CalibConst)
inline

Definition at line 59 of file Tof/TofEnergyCalibSvc/TofEnergyCalibSvc-00-00-03/TofEnergyCalibSvc/TofEnergyCalibSvc.h.

59{m_CalibConst=_CalibConst;}

◆ setPara1() [1/2]

void TofEnergyCalibSvc::setPara1 ( double  _Para1)
inline

◆ setPara1() [2/2]

void TofEnergyCalibSvc::setPara1 ( double  _Para1)
inline

◆ setPara2() [1/2]

void TofEnergyCalibSvc::setPara2 ( double  _Para2)
inline

◆ setPara2() [2/2]

void TofEnergyCalibSvc::setPara2 ( double  _Para2)
inline

◆ setPara3() [1/2]

void TofEnergyCalibSvc::setPara3 ( double  _Para3)
inline

◆ setPara3() [2/2]

void TofEnergyCalibSvc::setPara3 ( double  _Para3)
inline

◆ setPara4() [1/2]

void TofEnergyCalibSvc::setPara4 ( double  _Para4)
inline

◆ setPara4() [2/2]

void TofEnergyCalibSvc::setPara4 ( double  _Para4)
inline

◆ setPara5() [1/2]

void TofEnergyCalibSvc::setPara5 ( double  _Para5)
inline

◆ setPara5() [2/2]

void TofEnergyCalibSvc::setPara5 ( double  _Para5)
inline

Member Data Documentation

◆ m_dbsvc


The documentation for this class was generated from the following files: