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"
14#include "CalibData/CalibModel.h"
15#include "CalibData/Ets/OffEvtFilterCal.h"
16#include "EventModel/EventHeader.h"
26 : base_class( name, svcloc ) {}
31 MsgStream log(
msgSvc(), name() );
32 log << MSG::INFO <<
"OfflineEvtFilterSvc::initialize()" << endmsg;
34 StatusCode sc = Service::initialize();
35 if ( sc.isFailure() )
return sc;
38 sc = service(
"IncidentSvc", incsvc );
40 if ( sc.isSuccess() ) { incsvc->addListener(
this,
"NewRun", priority ); }
42 sc = service(
"CalibDataSvc", m_pCalDataSvc,
true );
43 if ( sc == StatusCode::SUCCESS )
44 { log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endmsg; }
45 else { log << MSG::FATAL <<
"can not get IDataProviderSvc" << endmsg; }
47 return StatusCode::SUCCESS;
51 MsgStream log(
msgSvc(), name() );
52 log << MSG::INFO <<
"OfflineEvtFilterSvc::finalize()" << endmsg;
59 return StatusCode::SUCCESS;
63 MsgStream log(
msgSvc(), name() );
64 log << MSG::DEBUG <<
"handle: " << inc.type() << endmsg;
66 if ( inc.type() ==
"NewRun" )
68 log << MSG::DEBUG <<
"NewRun" << endmsg;
70 if ( !initCalibConst() )
71 { log << MSG::ERROR <<
"can not initilize OffEvtFilter Constants" << endmsg; }
75bool OfflineEvtFilterSvc::initCalibConst() {
76 MsgStream log(
msgSvc(), name() );
77 log << MSG::INFO <<
"read calib const from TCDS" << endmsg;
79 IDataProviderSvc* eventSvc = NULL;
80 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc );
81 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc,
"/Event/EventHeader" );
84 log << MSG::FATAL <<
"Could not find Event Header" << endmsg;
94 string fullPath =
"/Calib/OffEvtFilter";
95 SmartDataPtr<CalibData::OffEvtFilterCal> calConst( m_pCalDataSvc, fullPath );
98 log << MSG::ERROR <<
"can not get OffEvtFilter via SmartPtr" << endmsg;
102 m_runFrom = calConst->getRunFrom();
103 m_runTo = calConst->getRunTo();
104 m_eventFrom = calConst->getEventFrom();
105 m_eventTo = calConst->getEventTo();
106 m_npar = calConst->getNpar();
108 std::vector<double> tBegin[2];
109 std::vector<double> tEnd[2];
111 for (
int i = 0; i < m_npar; i++ )
113 int flag = calConst->getFlag( i );
114 tBegin[
flag].push_back( calConst->getTBegin( i ) );
115 tEnd[
flag].push_back( calConst->getTEnd( i ) );
118 for (
int i = 0; i < 2; ++i )
120 std::vector<double>& _tBegin = tBegin[i];
121 std::vector<double>& _tEnd = tEnd[i];
122 int _nPar = _tBegin.size();
126 for (
int j = 0; j < _nPar - 1; ++j )
128 for (
int k = j + 1; k < _nPar; ++k )
130 if ( _tBegin[j] > _tBegin[k] )
132 double _ttmp = _tBegin[j];
133 _tBegin[j] = _tBegin[k];
143 for (
int j = 0; j < _nPar; ++j )
145 m_flag.push_back( i );
146 m_tBegin.push_back( _tBegin[j] );
147 m_tEnd.push_back( _tEnd[j] );
DECLARE_COMPONENT(BesBdkRc)
virtual StatusCode initialize()
OfflineEvtFilterSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode finalize()
void handle(const Incident &)