1#include "GaudiKernel/Kernel.h"
2#include "GaudiKernel/IInterface.h"
3#include "GaudiKernel/PropertyMgr.h"
4#include "GaudiKernel/StatusCode.h"
6#include "GaudiKernel/IIncidentSvc.h"
8#include "GaudiKernel/SvcFactory.h"
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/SmartDataPtr.h"
12#include "EventModel/EventModel.h"
13#include "EventModel/Event.h"
14#include "EventModel/EventHeader.h"
16#include "HltConfig/HltConfigSvc.h"
17#include "GaudiKernel/IJobOptionsSvc.h"
31 m_propMgr.declareProperty(
"FromDB", m_fromDatabase =
true);
32 m_propMgr.declareProperty(
"seqListFile", m_seqListFile =
"myseqlist.xml");
33 m_propMgr.declareProperty(
"sigListFile", m_sigListFile =
"mysiglist.xml");
35 IJobOptionsSvc* jobSvc;
36 Gaudi::svcLocator()->service(
"JobOptionsSvc", jobSvc);
37 jobSvc->setMyProperties(
"HltConfigSvc", &m_propMgr);
48 if ( IID_IHltConfigSvc.versionMatch(riid) ) {
52 return Service::queryInterface(riid, ppvIF) ;
54 return StatusCode::SUCCESS;
59 MsgStream log( messageService(), name() );
60 log << MSG::INFO <<
"handle: " << inc.type() << endreq;
62 if ( inc.type() ==
"NewRun" ){
64 log << MSG::DEBUG <<
"start read from database" << endreq;
66 if (sc .isFailure() ) {
67 log << MSG::ERROR <<
"Unable to read config from DatabaseSvc " << endreq;
71 log << MSG::INFO <<
"sequenceListFileLocation= " << m_seqListFile << endreq;
72 log << MSG::INFO <<
"signatureListFileLocation= " << m_sigListFile << endreq;
82 MsgStream log(messageService(), name());
83 log << MSG::INFO << name() <<
": Start of initialisation" << endreq;
86 StatusCode sc = service(
"IncidentSvc", incsvc);
89 incsvc -> addListener(
this,
"NewRun", priority);
92 log << MSG::FATAL <<
"Cannot find IncidentSvc" << endreq;
97 sc = serviceLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
98 if (sc .isFailure() ) {
99 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endreq;
104 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
105 if (sc .isFailure() ) {
106 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
111 log << MSG::INFO <<
"MyFrame::instance() == 0" << endreq;
113 log << MSG::ALWAYS <<
"Read config from files" << endreq;
118 return StatusCode::SUCCESS;
131 MsgStream log(messageService(), name());
133 log << MSG::INFO << name() <<
" finalized successfully" << endreq;
134 return StatusCode::SUCCESS;
138 MsgStream log(messageService(), name());
140 log << MSG::FATAL <<
" m_dbsvc=0" << endreq;
141 return StatusCode::FAILURE;
144 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
145 int run = eventHeader->runNumber();
147 log << MSG::INFO <<
"run=" << run << endreq;
150 sprintf(stmt1,
"select efconfig_id from RunParams where run_number = %d",
abs(run));
153 int row_no = m_dbsvc->
query(
"RunInfo",stmt1,res);
155 log << MSG::ERROR<<
"search errror"<<endreq;
156 return StatusCode::FAILURE;
158 long int efId=atoi((*res[0])[
"efconfig_id"]);
161 sprintf(stmt2,
"select Seqlist_dtd,Siglist_dtd,Seqlist_xml,Siglist_xml from EFConfInfo where EFConfId = %ld", efId);
164 row_no = m_dbsvc->
query(
"configdb",stmt2,res);
166 log << MSG::ERROR<<
"search errror"<<endreq;
167 return StatusCode::FAILURE;
170 long int seq_dtd,sig_dtd,seq_xml,sig_xml;
171 seq_dtd=atoi((*res[0])[
"Seqlist_dtd"]);
173 sig_dtd=atoi((*res[0])[
"Siglist_dtd"]);
175 seq_xml=atoi((*res[0])[
"Seqlist_xml"]);
176 sig_xml=atoi((*res[0])[
"Siglist_xml"]);
181 sprintf(stmt3,
"select FileName,FileText from EFfile where EFfileId = %ld", seq_dtd);
183 row_no = m_dbsvc->
query(
"configdb",stmt3,res);
185 log << MSG::ERROR<<
"search errror"<<endreq;
186 return StatusCode::FAILURE;
188 outfile.open((*res[0])[
"FileName"],ios_base::out);
189 outfile << (*res[0])[
"FileText"];
193 sprintf(stmt4,
"select FileName,FileText from EFfile where EFfileId = %ld", sig_dtd);
195 row_no = m_dbsvc->
query(
"configdb",stmt4,res);
197 log << MSG::ERROR<<
"search errror"<<endreq;
198 return StatusCode::FAILURE;
200 outfile.open((*res[0])[
"FileName"],ios_base::out);
201 outfile << (*res[0])[
"FileText"];
205 sprintf(stmt5,
"select FileName,FileText from EFfile where EFfileId = %ld", seq_xml);
207 row_no = m_dbsvc->
query(
"configdb",stmt5,res);
209 log << MSG::ERROR<<
"search errror"<<endreq;
210 return StatusCode::FAILURE;
212 outfile.open((*res[0])[
"FileName"],ios_base::out);
213 outfile << (*res[0])[
"FileText"];
215 m_seqListFile = string((*res[0])[
"FileName"]);
218 sprintf(stmt6,
"select FileName,FileText from EFfile where EFfileId = %ld", sig_xml);
220 row_no = m_dbsvc->
query(
"configdb",stmt6,res);
222 log << MSG::ERROR<<
"search errror"<<endreq;
223 return StatusCode::FAILURE;
225 outfile.open((*res[0])[
"FileName"],ios_base::out);
226 outfile << (*res[0])[
"FileText"];
228 m_sigListFile = string((*res[0])[
"FileName"]);
230 return StatusCode::SUCCESS;
const std::vector< std::pair< Signature *, Sequence * > > & retrieve()
virtual StatusCode finalize()
StatusCode GenFileFromDatabase()
virtual void handle(const Incident &)
HltConfigSvc(const std::string &name, ISvcLocator *sl)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIF)
virtual StatusCode initialize()
static MyFrame * instance()
const std::vector< std::pair< Signature *, Sequence * > > & getTablesVector() const
void init(const std::string, const std::string)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)