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"
26 Service (name, svcloc) {
33 if( IID_IOfflineEvtFilterSvc.versionMatch(riid) ){
36 return Service::queryInterface(riid, ppvInterface);
38 return StatusCode::SUCCESS;
42 MsgStream log(messageService(), name());
43 log << MSG::INFO <<
"OfflineEvtFilterSvc::initialize()" << endreq;
45 StatusCode sc = Service::initialize();
46 if( sc.isFailure() )
return sc;
49 sc = service(
"IncidentSvc", incsvc);
52 incsvc -> addListener(
this,
"NewRun", priority);
55 sc = service(
"CalibDataSvc", m_pCalDataSvc,
true);
56 if( sc == StatusCode::SUCCESS ){
57 log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endreq;
59 log << MSG::FATAL <<
"can not get IDataProviderSvc" << endreq;
62 return StatusCode::SUCCESS;
66 MsgStream log(messageService(), name());
67 log << MSG::INFO <<
"OfflineEvtFilterSvc::finalize()" << endreq;
74 return StatusCode::SUCCESS;
78 MsgStream log( messageService(), name() );
79 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
81 if ( inc.type() ==
"NewRun" ){
82 log << MSG::DEBUG <<
"NewRun" << endreq;
84 if( ! initCalibConst() ){
86 <<
"can not initilize OffEvtFilter Constants" << endreq;
92bool OfflineEvtFilterSvc::initCalibConst(){
93 MsgStream log(messageService(), name());
94 log << MSG::INFO <<
"read calib const from TCDS" << endreq;
96 IDataProviderSvc* eventSvc =
NULL;
97 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
98 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
100 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
110 string fullPath =
"/Calib/OffEvtFilter";
111 SmartDataPtr<CalibData::OffEvtFilterCal> calConst(m_pCalDataSvc, fullPath);
113 log << MSG::ERROR <<
"can not get OffEvtFilter via SmartPtr"
118 m_runFrom = calConst->getRunFrom();
119 m_runTo = calConst->getRunTo();
120 m_eventFrom = calConst->getEventFrom();
121 m_eventTo = calConst->getEventTo();
122 m_npar = calConst->getNpar();
124 std::vector<double> tBegin[2];
125 std::vector<double> tEnd[2];
127 for(
int i=0; i<m_npar; i++) {
128 int flag = calConst->getFlag(i);
129 tBegin[
flag].push_back(calConst->getTBegin(i));
130 tEnd[
flag].push_back(calConst->getTEnd(i));
133 for (
int i = 0; i < 2; ++i ) {
134 std::vector<double>& _tBegin = tBegin[i];
135 std::vector<double>& _tEnd = tEnd[i];
136 int _nPar = _tBegin.size();
139 for (
int j = 0; j < _nPar-1; ++j ) {
140 for (
int k = j+1; k < _nPar; ++k ) {
141 if ( _tBegin[j] > _tBegin[k] ) {
142 double _ttmp = _tBegin[j];
143 _tBegin[j] = _tBegin[k];
153 for (
int j = 0; j < _nPar; ++j ) {
155 m_tBegin.push_back(_tBegin[j]);
156 m_tEnd.push_back(_tEnd[j]);
virtual StatusCode initialize()
OfflineEvtFilterSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode finalize()
void handle(const Incident &)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)