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