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"
27 base_class (name, svcloc) {
43 MsgStream log(messageService(), name());
44 log << MSG::INFO <<
"OfflineEvtFilterSvc::initialize()" << endreq;
46 StatusCode sc = Service::initialize();
47 if( sc.isFailure() )
return sc;
50 sc = service(
"IncidentSvc", incsvc);
53 incsvc -> addListener(
this,
"NewRun", priority);
56 sc = service(
"CalibDataSvc", m_pCalDataSvc,
true);
57 if( sc == StatusCode::SUCCESS ){
58 log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endreq;
60 log << MSG::FATAL <<
"can not get IDataProviderSvc" << endreq;
63 return StatusCode::SUCCESS;
67 MsgStream log(messageService(), name());
68 log << MSG::INFO <<
"OfflineEvtFilterSvc::finalize()" << endreq;
75 return StatusCode::SUCCESS;
79 MsgStream log( messageService(), name() );
80 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
82 if ( inc.type() ==
"NewRun" ){
83 log << MSG::DEBUG <<
"NewRun" << endreq;
85 if( ! initCalibConst() ){
87 <<
"can not initilize OffEvtFilter Constants" << endreq;
93bool OfflineEvtFilterSvc::initCalibConst(){
94 MsgStream log(messageService(), name());
95 log << MSG::INFO <<
"read calib const from TCDS" << endreq;
97 IDataProviderSvc* eventSvc =
NULL;
98 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
99 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
101 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
111 string fullPath =
"/Calib/OffEvtFilter";
112 SmartDataPtr<CalibData::OffEvtFilterCal> calConst(m_pCalDataSvc, fullPath);
114 log << MSG::ERROR <<
"can not get OffEvtFilter via SmartPtr"
119 m_runFrom = calConst->getRunFrom();
120 m_runTo = calConst->getRunTo();
121 m_eventFrom = calConst->getEventFrom();
122 m_eventTo = calConst->getEventTo();
123 m_npar = calConst->getNpar();
125 std::vector<double> tBegin[2];
126 std::vector<double> tEnd[2];
128 for(
int i=0; i<m_npar; i++) {
129 int flag = calConst->getFlag(i);
130 tBegin[
flag].push_back(calConst->getTBegin(i));
131 tEnd[
flag].push_back(calConst->getTEnd(i));
134 for (
int i = 0; i < 2; ++i ) {
135 std::vector<double>& _tBegin = tBegin[i];
136 std::vector<double>& _tEnd = tEnd[i];
137 int _nPar = _tBegin.size();
140 for (
int j = 0; j < _nPar-1; ++j ) {
141 for (
int k = j+1; k < _nPar; ++k ) {
142 if ( _tBegin[j] > _tBegin[k] ) {
143 double _ttmp = _tBegin[j];
144 _tBegin[j] = _tBegin[k];
154 for (
int j = 0; j < _nPar; ++j ) {
156 m_tBegin.push_back(_tBegin[j]);
157 m_tEnd.push_back(_tEnd[j]);
virtual StatusCode initialize()
virtual StatusCode finalize()
void handle(const Incident &)