BOSS 8.0.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 45 of file VertexDbSvc.cxx.

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

Referenced by VertexDbSvc().

◆ ~VertexDbSvc()

VertexDbSvc::~VertexDbSvc ( )

Definition at line 61 of file VertexDbSvc.cxx.

61{}

Member Function Documentation

◆ finalize()

StatusCode VertexDbSvc::finalize ( )
virtual

Definition at line 119 of file VertexDbSvc.cxx.

119 {
120 MsgStream log( msgSvc(), name() );
121 log << MSG::INFO << "VertexDbSvc::finalize()" << endmsg;
122 // if(m_connect_offline) delete m_connect_offline;
123 return StatusCode::SUCCESS;
124}
IMessageSvc * msgSvc()

◆ handle()

void VertexDbSvc::handle ( const Incident & inc)

Definition at line 126 of file VertexDbSvc.cxx.

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

◆ initialize()

StatusCode VertexDbSvc::initialize ( )
virtual

Definition at line 72 of file VertexDbSvc.cxx.

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

◆ isVertexValid()

bool VertexDbSvc::isVertexValid ( )
inline

Definition at line 68 of file VertexDbSvc.h.

68{ return m_isRunNumberValid; }

◆ PrimaryVertex()

double * VertexDbSvc::PrimaryVertex ( )

Definition at line 195 of file VertexDbSvc.cxx.

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

◆ SigmaPrimaryVertex()

double * VertexDbSvc::SigmaPrimaryVertex ( )

Definition at line 204 of file VertexDbSvc.cxx.

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

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