BOSS 7.0.8
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
25InjSigIntervalSvc::InjSigIntervalSvc( const string& name, ISvcLocator* svcloc) :
26 Service (name, svcloc) {
27}
28
30}
31
32StatusCode InjSigIntervalSvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
33 if( IID_IInjSigIntervalSvc.versionMatch(riid) ){
34 *ppvInterface = static_cast<IInjSigIntervalSvc*> (this);
35 } else{
36 return Service::queryInterface(riid, ppvInterface);
37 }
38 return StatusCode::SUCCESS;
39}
40
42 MsgStream log(messageService(), name());
43 log << MSG::INFO << "InjSigIntervalSvc::initialize()" << endreq;
44
45 StatusCode sc = Service::initialize();
46 if( sc.isFailure() ) return sc;
47
48 IIncidentSvc* incsvc;
49 sc = service("IncidentSvc", incsvc);
50 int priority = 100;
51 if( sc.isSuccess() ){
52 incsvc -> addListener(this, "NewRun", priority);
53 }
54
55 sc = service("CalibDataSvc", m_pCalDataSvc, true);
56 if( sc == StatusCode::SUCCESS ){
57 log << MSG::INFO << "Retrieve IDataProviderSvc" << endreq;
58 }else{
59 log << MSG::FATAL << "can not get IDataProviderSvc" << endreq;
60 }
61
62 return StatusCode::SUCCESS;
63}
64
66 MsgStream log(messageService(), name());
67 log << MSG::INFO << "InjSigIntervalSvc::finalize()" << endreq;
68
69
70 return StatusCode::SUCCESS;
71}
72
73void InjSigIntervalSvc::handle(const Incident& inc){
74 MsgStream log( messageService(), name() );
75 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
76
77 if ( inc.type() == "NewRun" ){
78 log << MSG::DEBUG << "NewRun" << endreq;
79
80 if( ! initCalibConst() ){
81 log << MSG::ERROR
82 << "can not initilize InjSigInterval Constants" << endreq;
83 }
84 }
85}
86
87bool InjSigIntervalSvc::initCalibConst(){
88 MsgStream log(messageService(), name());
89 log << MSG::INFO << "read calib const from TCDS" << endreq;
90
91 IDataProviderSvc* eventSvc = NULL;
92 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
93 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
94 if (!eventHeader) {
95 log << MSG::FATAL << "Could not find Event Header" << endreq;
96 return( StatusCode::FAILURE);
97 }
98
99 string fullPath = "/Calib/InjSigInterval";
100 SmartDataPtr<CalibData::InjSigIntervalCal> calConst(m_pCalDataSvc, fullPath);
101 if( ! calConst ){
102 log << MSG::ERROR << "can not get InjSigInterval via SmartPtr"
103 << endreq;
104 return false;
105 }
106
107 m_tInterval = calConst->getTInterval();
108
109 return true;
110}
#define NULL
InjSigIntervalSvc(const std::string &name, ISvcLocator *svcloc)
void handle(const Incident &)
virtual StatusCode finalize()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize()