BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
InjSigIntervalSvc.cxx
Go to the documentation of this file.
1#include "InjSigIntervalSvc.h"
2
3#include "GaudiKernel/Bootstrap.h"
4#include "GaudiKernel/DataSvc.h"
5#include "GaudiKernel/IIncidentSvc.h"
6#include "GaudiKernel/IInterface.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/Incident.h"
9#include "GaudiKernel/Kernel.h"
10#include "GaudiKernel/MsgStream.h"
11#include "GaudiKernel/SmartDataPtr.h"
12#include "GaudiKernel/StatusCode.h"
13
14#include "CalibData/CalibModel.h"
15#include "CalibData/Ets/InjSigIntervalCal.h"
16#include "EventModel/EventHeader.h"
17
18#include <fstream>
19#include <iomanip>
20#include <iostream>
21
22using namespace std;
23
25InjSigIntervalSvc::InjSigIntervalSvc( const string& name, ISvcLocator* svcloc )
26 : base_class( name, svcloc ) {}
27
29
30/*StatusCode InjSigIntervalSvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
31 if( IID_IInjSigIntervalSvc.versionMatch(riid) ){
32 *ppvInterface = static_cast<IInjSigIntervalSvc*> (this);
33 } else{
34 return Service::queryInterface(riid, ppvInterface);
35 }
36 return StatusCode::SUCCESS;
37}
38*/
40 MsgStream log( msgSvc(), name() );
41 log << MSG::INFO << "InjSigIntervalSvc::initialize()" << endmsg;
42
43 StatusCode sc = Service::initialize();
44 if ( sc.isFailure() ) return sc;
45
46 IIncidentSvc* incsvc;
47 sc = service( "IncidentSvc", incsvc );
48 int priority = 100;
49 if ( sc.isSuccess() ) { incsvc->addListener( this, "NewRun", priority ); }
50
51 sc = service( "CalibDataSvc", m_pCalDataSvc, true );
52 if ( sc == StatusCode::SUCCESS )
53 { log << MSG::INFO << "Retrieve IDataProviderSvc" << endmsg; }
54 else { log << MSG::FATAL << "can not get IDataProviderSvc" << endmsg; }
55
56 return StatusCode::SUCCESS;
57}
58
60 MsgStream log( msgSvc(), name() );
61 log << MSG::INFO << "InjSigIntervalSvc::finalize()" << endmsg;
62
63 return StatusCode::SUCCESS;
64}
65
66void InjSigIntervalSvc::handle( const Incident& inc ) {
67 MsgStream log( msgSvc(), name() );
68 log << MSG::DEBUG << "handle: " << inc.type() << endmsg;
69
70 if ( inc.type() == "NewRun" )
71 {
72 log << MSG::DEBUG << "NewRun" << endmsg;
73
74 if ( !initCalibConst() )
75 { log << MSG::ERROR << "can not initilize InjSigInterval Constants" << endmsg; }
76 }
77}
78
79bool InjSigIntervalSvc::initCalibConst() {
80 MsgStream log( msgSvc(), name() );
81 log << MSG::INFO << "read calib const from TCDS" << endmsg;
82
83 IDataProviderSvc* eventSvc = NULL;
84 Gaudi::svcLocator()->service( "EventDataSvc", eventSvc );
85 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc, "/Event/EventHeader" );
86 if ( !eventHeader )
87 {
88 log << MSG::FATAL << "Could not find Event Header" << endmsg;
89 return false;
90 ;
91 }
92
93 string fullPath = "/Calib/InjSigInterval";
94 SmartDataPtr<CalibData::InjSigIntervalCal> calConst( m_pCalDataSvc, fullPath );
95 if ( !calConst )
96 {
97 log << MSG::ERROR << "can not get InjSigInterval via SmartPtr" << endmsg;
98 return false;
99 }
100
101 m_tInterval = calConst->getTInterval();
102
103 return true;
104}
DECLARE_COMPONENT(BesBdkRc)
IMessageSvc * msgSvc()
InjSigIntervalSvc(const std::string &name, ISvcLocator *svcloc)
void handle(const Incident &)
virtual StatusCode finalize()
virtual StatusCode initialize()