BOSS 7.1.0
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}

◆ ~VertexDbSvc()

VertexDbSvc::~VertexDbSvc ( )

Definition at line 64 of file VertexDbSvc.cxx.

64 {
65}

Member Function Documentation

◆ finalize()

StatusCode VertexDbSvc::finalize ( )
virtual

Definition at line 112 of file VertexDbSvc.cxx.

112 {
113 MsgStream log(messageService(), name());
114 log << MSG::INFO << "VertexDbSvc::finalize()" << endreq;
115 // if(m_connect_offline) delete m_connect_offline;
116 return StatusCode::SUCCESS;
117}

◆ handle()

void VertexDbSvc::handle ( const Incident &  inc)

Definition at line 119 of file VertexDbSvc.cxx.

119 {
120 MsgStream log( messageService(), name() );
121 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
122
123 if ( inc.type() == "NewRun" ){
124 log << MSG::DEBUG << "NewRun" << endreq;
125 if(!m_readOneTime) {
126 getVertexTableInfo();
127 } else {
128 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
129 int run = eventHeader->runNumber();
130 //cout << endl << "New Run: " << run << " VertexDB vertex= ";
131 if(run<0) run=-run;
132 if((m_mapPrimaryVertex[run]).size()>0) {
133 m_isRunNumberValid = true;
134 m_primaryVertex[0] = (m_mapPrimaryVertex[run])[0];
135 m_primaryVertex[1] = (m_mapPrimaryVertex[run])[1];
136 m_primaryVertex[2] = (m_mapPrimaryVertex[run])[2];
137 m_sigmaPrimaryVertex[0] = (m_mapPrimaryVertex[run])[3];
138 m_sigmaPrimaryVertex[1] = (m_mapPrimaryVertex[run])[4];
139 m_sigmaPrimaryVertex[2] = (m_mapPrimaryVertex[run])[5];
140 //cout << m_primaryVertex[0] << "," << m_primaryVertex[1] << "," << m_primaryVertex[2] << " sigma= " << m_sigmaPrimaryVertex[0] << "," << m_sigmaPrimaryVertex[1] << "," << m_sigmaPrimaryVertex[2] << endl;
141 } else {
142 std::cout<<"VertexDbSvc, could not get vertex infor in handle new run"<<std::endl;
143 }
144 }
145 }
146}

◆ initialize()

StatusCode VertexDbSvc::initialize ( )
virtual

Definition at line 76 of file VertexDbSvc.cxx.

76 {
77 MsgStream log(messageService(), name());
78 log << MSG::INFO << "VertexDbSvc::initialize()" << endreq;
79
80 StatusCode sc = Service::initialize();
81 if( sc.isFailure() ) return sc;
82
83
84 IIncidentSvc* incsvc;
85 sc = service("IncidentSvc", incsvc);
86 int priority = 100;
87 if( sc.isSuccess() ){
88 incsvc -> addListener(this, "NewRun", priority);
89 }
90
91 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
92 if (sc .isFailure() ) {
93 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
94 return sc;
95 }
96
97 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
98 if (sc .isFailure() ) {
99 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
100 return sc;
101 }
102 if(m_readOneTime){
103 if(m_runFrom>=8093){
104 getReadBunchInfo(m_runFrom, m_runTo);
105 }
106 else
107 std::cout<<"VertexDbSvc, invalid RunFrom, RunFrom should be >=8093"<<std::endl;
108 }
109 return StatusCode::SUCCESS;
110}

◆ isVertexValid()

bool VertexDbSvc::isVertexValid ( )
inline

Definition at line 75 of file VertexDbSvc.h.

75{return m_isRunNumberValid;}

◆ PrimaryVertex()

double * VertexDbSvc::PrimaryVertex ( )

Definition at line 182 of file VertexDbSvc.cxx.

183{
184 if( !m_isRunNumberValid ) {
185 cerr << "WARNING in VertexDbSvc: runNo is invalid!\n";
186 memset(m_primaryVertex,0,sizeof(m_primaryVertex));
187 }
188 return m_primaryVertex;
189}

◆ SigmaPrimaryVertex()

double * VertexDbSvc::SigmaPrimaryVertex ( )

Definition at line 191 of file VertexDbSvc.cxx.

192{
193 if( !m_isRunNumberValid ) {
194 cerr << "WARNING in VertexDbSvc: runNo is invalid!\n";
195 memset(m_sigmaPrimaryVertex,0,sizeof(m_sigmaPrimaryVertex));
196 }
197 return m_sigmaPrimaryVertex;
198}

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