BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
VertexDbSvc Class Reference

#include <VertexDbSvc.h>

+ Inheritance diagram for VertexDbSvc:

Public Member Functions

 VertexDbSvc (const std::string &name, ISvcLocator *svcloc)
 
 ~VertexDbSvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
double * PrimaryVertex ()
 
double * SigmaPrimaryVertex ()
 
bool isVertexValid ()
 

Detailed Description

Definition at line 29 of file VertexDbSvc.h.

Constructor & Destructor Documentation

◆ VertexDbSvc()

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

Definition at line 49 of file VertexDbSvc.cxx.

49 :
50 base_class(name, svcloc){
51 // declare properties
52 declareProperty("Host" , host = std::string("bes3db2.ihep.ac.cn"));
53 declareProperty("DbName" , dbName = std::string("offlinedb"));
54 declareProperty("UserName" , userName = std::string("guest"));
55 declareProperty("Password" , password = std::string("guestpass"));
56 declareProperty("BossVer" , m_bossver = std::string("default"));
57 declareProperty("VerPar" , m_verpar = std::string("default"));
58 declareProperty("BossRelease",m_bossRelease = std::string("default"));
59 declareProperty("ReadOneTime",m_readOneTime=false);
60 declareProperty("RunFrom", m_runFrom=8093);
61 declareProperty("RunTo",m_runTo=9025);
62 declareProperty("RunIdList",m_runIdList);
63}

◆ ~VertexDbSvc()

VertexDbSvc::~VertexDbSvc ( )

Definition at line 65 of file VertexDbSvc.cxx.

65 {
66}

Member Function Documentation

◆ finalize()

StatusCode VertexDbSvc::finalize ( )
virtual

Definition at line 126 of file VertexDbSvc.cxx.

126 {
127 MsgStream log(messageService(), name());
128 log << MSG::INFO << "VertexDbSvc::finalize()" << endreq;
129 // if(m_connect_offline) delete m_connect_offline;
130 return StatusCode::SUCCESS;
131}

◆ handle()

void VertexDbSvc::handle ( const Incident & inc)

Definition at line 133 of file VertexDbSvc.cxx.

133 {
134 MsgStream log( messageService(), name() );
135 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
136
137 if ( inc.type() == "NewRun" ){
138 log << MSG::DEBUG << "NewRun" << endreq;
139 if(!m_readOneTime) {
140 getVertexTableInfo();
141 } else {
142 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
143 int run = eventHeader->runNumber();
144 //cout << endl << "New Run: " << run << " VertexDB vertex= ";
145 if(run<0) run=-run;
146 if((m_mapPrimaryVertex[run]).size()>0) {
147 m_isRunNumberValid = true;
148 m_primaryVertex[0] = (m_mapPrimaryVertex[run])[0];
149 m_primaryVertex[1] = (m_mapPrimaryVertex[run])[1];
150 m_primaryVertex[2] = (m_mapPrimaryVertex[run])[2];
151 m_sigmaPrimaryVertex[0] = (m_mapPrimaryVertex[run])[3];
152 m_sigmaPrimaryVertex[1] = (m_mapPrimaryVertex[run])[4];
153 m_sigmaPrimaryVertex[2] = (m_mapPrimaryVertex[run])[5];
154 //cout << m_primaryVertex[0] << "," << m_primaryVertex[1] << "," << m_primaryVertex[2] << " sigma= " << m_sigmaPrimaryVertex[0] << "," << m_sigmaPrimaryVertex[1] << "," << m_sigmaPrimaryVertex[2] << endl;
155 } else {
156 std::cout<<"VertexDbSvc, could not get vertex infor in handle new run"<<std::endl;
157 }
158 }
159 }
160}

◆ initialize()

StatusCode VertexDbSvc::initialize ( )
virtual

Definition at line 77 of file VertexDbSvc.cxx.

77 {
78 MsgStream log(messageService(), name());
79 log << MSG::INFO << "VertexDbSvc::initialize()" << endreq;
80
81 StatusCode sc = Service::initialize();
82 if( sc.isFailure() ) return sc;
83
84
85 IIncidentSvc* incsvc;
86 sc = service("IncidentSvc", incsvc);
87 int priority = 100;
88 if( sc.isSuccess() ){
89 incsvc -> addListener(this, "NewRun", priority);
90 }
91
92 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
93 if (sc .isFailure() ) {
94 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
95 return sc;
96 }
97
98 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
99 if (sc .isFailure() ) {
100 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
101 return sc;
102 }
103 /*if(m_readOneTime){
104 if(m_runFrom>=8093){
105 getReadBunchInfo(m_runFrom, m_runTo);
106 }
107 else
108 std::cout<<"VertexDbSvc, invalid RunFrom, RunFrom should be >=8093"<<std::endl;
109 }*/
110 for(unsigned int i = 0; i < m_runIdList.size(); i++) {
111 m_runFrom=m_runIdList[i];
112 i=i+2;
113 m_runTo=m_runIdList[i];
114 if(m_readOneTime){
115 if(m_runFrom>=8093){
116 getReadBunchInfo(m_runFrom, m_runTo);
117 }
118 else
119 std::cout<<"VertexDbSvc, invalid RunFrom, RunFrom should be >=8093"<<std::endl;
120 }
121 }
122
123 return StatusCode::SUCCESS;
124}

◆ isVertexValid()

bool VertexDbSvc::isVertexValid ( )
inline

Definition at line 75 of file VertexDbSvc.h.

75{return m_isRunNumberValid;}

◆ PrimaryVertex()

double * VertexDbSvc::PrimaryVertex ( )

Definition at line 196 of file VertexDbSvc.cxx.

197{
198 if( !m_isRunNumberValid ) {
199 cerr << "WARNING in VertexDbSvc: runNo is invalid!\n";
200 memset(m_primaryVertex,0,sizeof(m_primaryVertex));
201 }
202 return m_primaryVertex;
203}

◆ SigmaPrimaryVertex()

double * VertexDbSvc::SigmaPrimaryVertex ( )

Definition at line 205 of file VertexDbSvc.cxx.

206{
207 if( !m_isRunNumberValid ) {
208 cerr << "WARNING in VertexDbSvc: runNo is invalid!\n";
209 memset(m_sigmaPrimaryVertex,0,sizeof(m_sigmaPrimaryVertex));
210 }
211 return m_sigmaPrimaryVertex;
212}

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