BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
HltConfigSvc Class Reference

#include <HltConfigSvc.h>

+ Inheritance diagram for HltConfigSvc:

Public Member Functions

 HltConfigSvc (const std::string &name, ISvcLocator *sl)
 
 ~HltConfigSvc ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvIF)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual void handle (const Incident &)
 
StatusCode GenFileFromDatabase ()
 
const std::vector< std::pair< Signature *, Sequence * > > & retrieve ()
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Detailed Description

Definition at line 25 of file HltConfigSvc.h.

Constructor & Destructor Documentation

◆ HltConfigSvc()

HltConfigSvc::HltConfigSvc ( const std::string &  name,
ISvcLocator *  sl 
)

Definition at line 27 of file HltConfigSvc.cxx.

27 :
28 Service(name, sl),
29 m_dbsvc(0)
30{
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");
34
35 IJobOptionsSvc* jobSvc;
36 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
37 jobSvc->setMyProperties("HltConfigSvc", &m_propMgr);
38 jobSvc->release();
39}

◆ ~HltConfigSvc()

HltConfigSvc::~HltConfigSvc ( )

Definition at line 42 of file HltConfigSvc.cxx.

42 {
43
44}

Member Function Documentation

◆ finalize()

StatusCode HltConfigSvc::finalize ( )
virtual

Definition at line 129 of file HltConfigSvc.cxx.

130{
131 MsgStream log(messageService(), name());
132 //MyFrame::destruct();
133 log << MSG::INFO << name() << " finalized successfully" << endreq;
134 return StatusCode::SUCCESS;
135}

◆ GenFileFromDatabase()

StatusCode HltConfigSvc::GenFileFromDatabase ( )

Definition at line 137 of file HltConfigSvc.cxx.

137 {
138 MsgStream log(messageService(), name());
139 if(!m_dbsvc){
140 log << MSG::FATAL << " m_dbsvc=0" << endreq;
141 return StatusCode::FAILURE;
142 }
143
144 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
145 int run = eventHeader->runNumber();
146
147 log << MSG::INFO << "run=" << run << endreq;
148
149 char stmt1[200];
150 sprintf(stmt1,"select efconfig_id from RunParams where run_number = %d",abs(run));
151
153 int row_no = m_dbsvc->query("RunInfo",stmt1,res);
154 if(!row_no){
155 log << MSG::ERROR<<"search errror"<<endreq;
156 return StatusCode::FAILURE;
157 }
158 long int efId=atoi((*res[0])["efconfig_id"]);
159
160 char stmt2[200];
161 sprintf(stmt2,"select Seqlist_dtd,Siglist_dtd,Seqlist_xml,Siglist_xml from EFConfInfo where EFConfId = %ld", efId);
162
163 res.clear();
164 row_no = m_dbsvc->query("configdb",stmt2,res);
165 if(!row_no){
166 log << MSG::ERROR<<"search errror"<<endreq;
167 return StatusCode::FAILURE;
168 }
169
170 long int seq_dtd,sig_dtd,seq_xml,sig_xml;
171 seq_dtd=atoi((*res[0])["Seqlist_dtd"]);
172 seq_dtd=18;
173 sig_dtd=atoi((*res[0])["Siglist_dtd"]);
174 sig_dtd=15;
175 seq_xml=atoi((*res[0])["Seqlist_xml"]);
176 sig_xml=atoi((*res[0])["Siglist_xml"]);
177
178 ofstream outfile;
179
180 char stmt3[200];
181 sprintf(stmt3,"select FileName,FileText from EFfile where EFfileId = %ld", seq_dtd);
182 res.clear();
183 row_no = m_dbsvc->query("configdb",stmt3,res);
184 if(!row_no){
185 log << MSG::ERROR<<"search errror"<<endreq;
186 return StatusCode::FAILURE;
187 }
188 outfile.open((*res[0])["FileName"],ios_base::out);
189 outfile << (*res[0])["FileText"];
190 outfile.close();
191
192 char stmt4[200];
193 sprintf(stmt4,"select FileName,FileText from EFfile where EFfileId = %ld", sig_dtd);
194 res.clear();
195 row_no = m_dbsvc->query("configdb",stmt4,res);
196 if(!row_no){
197 log << MSG::ERROR<<"search errror"<<endreq;
198 return StatusCode::FAILURE;
199 }
200 outfile.open((*res[0])["FileName"],ios_base::out);
201 outfile << (*res[0])["FileText"];
202 outfile.close();
203
204 char stmt5[200];
205 sprintf(stmt5,"select FileName,FileText from EFfile where EFfileId = %ld", seq_xml);
206 res.clear();
207 row_no = m_dbsvc->query("configdb",stmt5,res);
208 if(!row_no){
209 log << MSG::ERROR<<"search errror"<<endreq;
210 return StatusCode::FAILURE;
211 }
212 outfile.open((*res[0])["FileName"],ios_base::out);
213 outfile << (*res[0])["FileText"];
214 outfile.close();
215 m_seqListFile = string((*res[0])["FileName"]);
216
217 char stmt6[200];
218 sprintf(stmt6,"select FileName,FileText from EFfile where EFfileId = %ld", sig_xml);
219 res.clear();
220 row_no = m_dbsvc->query("configdb",stmt6,res);
221 if(!row_no){
222 log << MSG::ERROR<<"search errror"<<endreq;
223 return StatusCode::FAILURE;
224 }
225 outfile.open((*res[0])["FileName"],ios_base::out);
226 outfile << (*res[0])["FileText"];
227 outfile.close();
228 m_sigListFile = string((*res[0])["FileName"]);
229
230 return StatusCode::SUCCESS;
231}
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)
std::ofstream ofstream
Definition: bpkt_streams.h:42

Referenced by handle().

◆ handle()

void HltConfigSvc::handle ( const Incident &  inc)
virtual

Definition at line 58 of file HltConfigSvc.cxx.

58 {
59 MsgStream log( messageService(), name() );
60 log << MSG::INFO << "handle: " << inc.type() << endreq;
61
62 if ( inc.type() == "NewRun" ){
63 if(m_fromDatabase){
64 log << MSG::DEBUG << "start read from database" << endreq;
65 StatusCode sc = GenFileFromDatabase();
66 if (sc .isFailure() ) {
67 log << MSG::ERROR << "Unable to read config from DatabaseSvc " << endreq;
68 return;
69 }
70 //if(MyFrame::instance()) MyFrame::destruct();
71 log << MSG::INFO << "sequenceListFileLocation= " << m_seqListFile << endreq;
72 log << MSG::INFO << "signatureListFileLocation= " << m_sigListFile << endreq;
73 MyFrame::instance()->init(m_seqListFile, m_sigListFile);
75 }
76 }
77}
StatusCode GenFileFromDatabase()
static MyFrame * instance()
Definition: MyFrame.cxx:22
void init(const std::string, const std::string)
Definition: MyFrame.cxx:58

◆ initialize()

StatusCode HltConfigSvc::initialize ( )
virtual

Definition at line 79 of file HltConfigSvc.cxx.

80{
81
82 MsgStream log(messageService(), name());
83 log << MSG::INFO << name() << ": Start of initialisation" << endreq;
84
85 IIncidentSvc* incsvc;
86 StatusCode sc = service("IncidentSvc", incsvc);
87 int priority = 100;
88 if( sc.isSuccess() ){
89 incsvc -> addListener(this, "NewRun", priority);
90 }
91 else{
92 log << MSG::FATAL << "Cannot find IncidentSvc" << endreq;
93 return sc;
94 }
95
96 if(m_fromDatabase){
97 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
98 if (sc .isFailure() ) {
99 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
100 return sc;
101 }
102 }
103
104 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
105 if (sc .isFailure() ) {
106 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
107 return sc;
108 }
109
110 if (MyFrame::instance() == 0)
111 log << MSG::INFO << "MyFrame::instance() == 0" << endreq;
112 if(!m_fromDatabase){
113 log << MSG::ALWAYS << "Read config from files" << endreq;
114 MyFrame::instance()->init(m_seqListFile, m_sigListFile);
115 // Finalize Frame. New version with singleton
117 }
118 return StatusCode::SUCCESS;
119}

◆ interfaceID()

static const InterfaceID & HltConfigSvc::interfaceID ( )
inlinestatic

Definition at line 54 of file HltConfigSvc.h.

54{ return IID_IHltConfigSvc; }

◆ queryInterface()

StatusCode HltConfigSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvIF 
)
virtual

Definition at line 46 of file HltConfigSvc.cxx.

47{
48 if ( IID_IHltConfigSvc.versionMatch(riid) ) {
49// *ppvIF = static_cast<IHltConfigSvc*> (this);
50 *ppvIF = (HltConfigSvc*)this;
51 } else {
52 return Service::queryInterface(riid, ppvIF) ;
53 }
54 return StatusCode::SUCCESS;
55}

◆ retrieve()

const std::vector< std::pair< Signature *, Sequence * > > & HltConfigSvc::retrieve ( )

Definition at line 122 of file HltConfigSvc.cxx.

123{
124// Get the final vector object and play around with it.
125//std::vector<std::pair<Signature*,Sequence*> > m_Vector = MyFrame::instance()->getTablesVector();
127}
const std::vector< std::pair< Signature *, Sequence * > > & getTablesVector() const
Definition: MyFrame.cxx:390

Referenced by StepHandler::beginRun().


The documentation for this class was generated from the following files: