BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
InjSigTimeSvc.cxx
Go to the documentation of this file.
1#include "InjSigTimeSvc.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/InjSigTimeCal.h"
16#include "EventModel/EventHeader.h"
17
18#include <fstream>
19#include <iomanip>
20#include <iostream>
21
22using namespace std;
24InjSigTimeSvc::InjSigTimeSvc( const string& name, ISvcLocator* svcloc )
25 : base_class( name, svcloc ) {}
26
28
30 MsgStream log( msgSvc(), name() );
31 log << MSG::INFO << "InjSigTimeSvc::initialize()" << endmsg;
32
33 StatusCode sc = Service::initialize();
34 if ( sc.isFailure() ) return sc;
35
36 IIncidentSvc* incsvc;
37 sc = service( "IncidentSvc", incsvc );
38 int priority = 100;
39 if ( sc.isSuccess() ) { incsvc->addListener( this, "NewRun", priority ); }
40
41 sc = service( "CalibDataSvc", m_pCalDataSvc, true );
42 if ( sc == StatusCode::SUCCESS )
43 { log << MSG::INFO << "Retrieve IDataProviderSvc" << endmsg; }
44 else { log << MSG::FATAL << "can not get IDataProviderSvc" << endmsg; }
45
46 return StatusCode::SUCCESS;
47}
48
50 MsgStream log( msgSvc(), name() );
51 log << MSG::INFO << "InjSigTimeSvc::finalize()" << endmsg;
52
53 m_npar = 0;
54 m_IST.clear();
55 m_flag.clear();
56
57 return StatusCode::SUCCESS;
58}
59
60void InjSigTimeSvc::handle( const Incident& inc ) {
61 MsgStream log( msgSvc(), name() );
62 log << MSG::DEBUG << "handle: " << inc.type() << endmsg;
63
64 if ( inc.type() == "NewRun" )
65 {
66 log << MSG::DEBUG << "NewRun" << endmsg;
67
68 if ( !initCalibConst() )
69 { log << MSG::ERROR << "can not initilize InjSigTime Constants" << endmsg; }
70 }
71}
72
73bool InjSigTimeSvc::initCalibConst() {
74 MsgStream log( msgSvc(), name() );
75 log << MSG::INFO << "read calib const from TCDS" << endmsg;
76
77 IDataProviderSvc* eventSvc = NULL;
78 Gaudi::svcLocator()->service( "EventDataSvc", eventSvc );
79 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc, "/Event/EventHeader" );
80 if ( !eventHeader )
81 {
82 log << MSG::FATAL << "Could not find Event Header" << endmsg;
83 return false;
84 }
85
86 // clear calibration constants vectors
87 m_npar = 0;
88 m_IST.clear();
89 m_flag.clear();
90
91 string fullPath = "/Calib/InjSigTime";
92 SmartDataPtr<CalibData::InjSigTimeCal> calConst( m_pCalDataSvc, fullPath );
93 if ( !calConst )
94 {
95 log << MSG::ERROR << "can not get InjSigTime via SmartPtr" << endmsg;
96 return false;
97 }
98
99 m_npar = calConst->getNpar();
100 for ( int i = 0; i < m_npar; i++ )
101 {
102 m_IST.push_back( calConst->getIST( i ) );
103 m_flag.push_back( calConst->getFlag( i ) );
104 }
105
106 return true;
107}
DECLARE_COMPONENT(BesBdkRc)
IMessageSvc * msgSvc()
virtual StatusCode finalize()
InjSigTimeSvc(const std::string &name, ISvcLocator *svcloc)
void handle(const Incident &)
virtual StatusCode initialize()