BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
InjSigTimeSvc.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;
24DECLARE_COMPONENT(InjSigTimeSvc)
25InjSigTimeSvc::InjSigTimeSvc( const string& name, ISvcLocator* svcloc) :
26 base_class (name, svcloc) {
27}
28
31
32/*StatusCode InjSigTimeSvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
33 if( IID_IInjSigTimeSvc.versionMatch(riid) ){
34 *ppvInterface = static_cast<IInjSigTimeSvc*> (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 << "InjSigTimeSvc::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 << "InjSigTimeSvc::finalize()" << endreq;
68
69 m_npar = 0;
70 m_IST.clear();
71 m_flag.clear();
72
73 return StatusCode::SUCCESS;
74}
75
76void InjSigTimeSvc::handle(const Incident& inc){
77 MsgStream log( messageService(), name() );
78 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
79
80 if ( inc.type() == "NewRun" ){
81 log << MSG::DEBUG << "NewRun" << endreq;
82
83 if( ! initCalibConst() ){
84 log << MSG::ERROR
85 << "can not initilize InjSigTime Constants" << endreq;
86 }
87 }
88}
89
90
91bool InjSigTimeSvc::initCalibConst(){
92 MsgStream log(messageService(), name());
93 log << MSG::INFO << "read calib const from TCDS" << endreq;
94
95 IDataProviderSvc* eventSvc = NULL;
96 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
97 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
98 if (!eventHeader) {
99 log << MSG::FATAL << "Could not find Event Header" << endreq;
100 return( StatusCode::FAILURE);
101 }
102
103 //clear calibration constants vectors
104 m_npar = 0;
105 m_IST.clear();
106 m_flag.clear();
107
108 string fullPath = "/Calib/InjSigTime";
109 SmartDataPtr<CalibData::InjSigTimeCal> calConst(m_pCalDataSvc, fullPath);
110 if( ! calConst ){
111 log << MSG::ERROR << "can not get InjSigTime via SmartPtr"
112 << endreq;
113 return false;
114 }
115
116 m_npar = calConst->getNpar();
117 for(int i=0; i<m_npar; i++){
118 m_IST.push_back(calConst->getIST(i));
119 m_flag.push_back(calConst->getFlag(i));
120 }
121
122 return true;
123}
#define NULL
virtual StatusCode finalize()
void handle(const Incident &)
virtual StatusCode initialize()