HltConfigSvc Class Reference

#include <HltConfigSvc.h>

List of all members.

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 ()

Private Attributes

IDatabaseSvcm_dbsvc
IDataProviderSvc * m_eventSvc
bool m_fromDatabase
std::string m_seqListFile
std::string m_sigListFile
PropertyMgr m_propMgr


Detailed Description

Definition at line 25 of file HltConfigSvc.h.


Constructor & Destructor Documentation

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

Definition at line 27 of file HltConfigSvc.cxx.

References m_fromDatabase, m_propMgr, m_seqListFile, and m_sigListFile.

00027                                                                    : 
00028   Service(name, sl),
00029   m_dbsvc(0)
00030 {   
00031   m_propMgr.declareProperty( "FromDB", m_fromDatabase = true);
00032   m_propMgr.declareProperty( "seqListFile", m_seqListFile = "myseqlist.xml");
00033   m_propMgr.declareProperty( "sigListFile", m_sigListFile = "mysiglist.xml");  
00034     
00035   IJobOptionsSvc* jobSvc;
00036   Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
00037   jobSvc->setMyProperties("HltConfigSvc", &m_propMgr);
00038   jobSvc->release();
00039 }

HltConfigSvc::~HltConfigSvc (  ) 

Definition at line 42 of file HltConfigSvc.cxx.

00042                             {
00043   
00044 }


Member Function Documentation

StatusCode HltConfigSvc::finalize (  )  [virtual]

Definition at line 129 of file HltConfigSvc.cxx.

References Bes_Common::INFO.

00130 {
00131   MsgStream log(messageService(), name());
00132   //MyFrame::destruct();
00133   log << MSG::INFO << name() << " finalized successfully" << endreq;
00134   return StatusCode::SUCCESS;
00135 }

StatusCode HltConfigSvc::GenFileFromDatabase (  ) 

Definition at line 137 of file HltConfigSvc.cxx.

References abs, DatabaseRecordVector::clear(), calibUtil::ERROR, Bes_Common::FATAL, Bes_Common::INFO, m_dbsvc, m_eventSvc, m_seqListFile, m_sigListFile, IDatabaseSvc::query(), and deljobs::string.

Referenced by handle().

00137                                             {
00138   MsgStream log(messageService(), name());
00139   if(!m_dbsvc){
00140     log << MSG::FATAL << " m_dbsvc=0" << endreq;
00141     return StatusCode::FAILURE;
00142   } 
00143   
00144   SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
00145   int  run = eventHeader->runNumber();
00146   
00147   log << MSG::INFO << "run=" << run << endreq;
00148 
00149   char stmt1[200];
00150   sprintf(stmt1,"select efconfig_id from RunParams where run_number = %d",abs(run));
00151  
00152   DatabaseRecordVector res;
00153   int row_no = m_dbsvc->query("RunInfo",stmt1,res);
00154   if(!row_no){
00155     log << MSG::ERROR<<"search errror"<<endreq;
00156     return StatusCode::FAILURE;
00157   }
00158   long int efId=atoi((*res[0])["efconfig_id"]);
00159 
00160   char stmt2[200];
00161   sprintf(stmt2,"select Seqlist_dtd,Siglist_dtd,Seqlist_xml,Siglist_xml from EFConfInfo where EFConfId = %ld", efId);
00162 
00163   res.clear();
00164   row_no = m_dbsvc->query("configdb",stmt2,res);
00165   if(!row_no){
00166     log << MSG::ERROR<<"search errror"<<endreq;
00167     return StatusCode::FAILURE;
00168   }
00169   
00170   long int seq_dtd,sig_dtd,seq_xml,sig_xml;
00171   seq_dtd=atoi((*res[0])["Seqlist_dtd"]);
00172   seq_dtd=18;
00173   sig_dtd=atoi((*res[0])["Siglist_dtd"]);
00174   sig_dtd=15;
00175   seq_xml=atoi((*res[0])["Seqlist_xml"]);
00176   sig_xml=atoi((*res[0])["Siglist_xml"]);
00177 
00178   ofstream outfile;
00179 
00180   char stmt3[200];
00181   sprintf(stmt3,"select FileName,FileText from EFfile where EFfileId = %ld", seq_dtd);
00182   res.clear();
00183   row_no = m_dbsvc->query("configdb",stmt3,res);
00184   if(!row_no){
00185     log << MSG::ERROR<<"search errror"<<endreq;
00186     return StatusCode::FAILURE;
00187   }
00188   outfile.open((*res[0])["FileName"],ios_base::out);
00189   outfile << (*res[0])["FileText"];
00190   outfile.close();
00191 
00192   char stmt4[200];
00193   sprintf(stmt4,"select FileName,FileText from EFfile where EFfileId = %ld", sig_dtd);
00194   res.clear();
00195   row_no = m_dbsvc->query("configdb",stmt4,res);
00196   if(!row_no){
00197     log << MSG::ERROR<<"search errror"<<endreq;
00198     return StatusCode::FAILURE;
00199   }
00200   outfile.open((*res[0])["FileName"],ios_base::out);
00201   outfile << (*res[0])["FileText"];
00202   outfile.close();
00203 
00204   char stmt5[200];
00205   sprintf(stmt5,"select FileName,FileText from EFfile where EFfileId = %ld", seq_xml);
00206   res.clear();
00207   row_no = m_dbsvc->query("configdb",stmt5,res);
00208   if(!row_no){
00209     log << MSG::ERROR<<"search errror"<<endreq;
00210     return StatusCode::FAILURE;
00211   }
00212   outfile.open((*res[0])["FileName"],ios_base::out);
00213   outfile << (*res[0])["FileText"];
00214   outfile.close();
00215   m_seqListFile = string((*res[0])["FileName"]);
00216   
00217   char stmt6[200];
00218   sprintf(stmt6,"select FileName,FileText from EFfile where EFfileId = %ld", sig_xml);
00219   res.clear();
00220   row_no = m_dbsvc->query("configdb",stmt6,res);
00221   if(!row_no){
00222     log << MSG::ERROR<<"search errror"<<endreq;
00223     return StatusCode::FAILURE;
00224   }
00225   outfile.open((*res[0])["FileName"],ios_base::out);
00226   outfile << (*res[0])["FileText"];
00227   outfile.close();
00228   m_sigListFile = string((*res[0])["FileName"]);
00229 
00230   return StatusCode::SUCCESS;  
00231 }

void HltConfigSvc::handle ( const Incident &   )  [virtual]

Definition at line 58 of file HltConfigSvc.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, GenFileFromDatabase(), Bes_Common::INFO, m_fromDatabase, m_seqListFile, and m_sigListFile.

00058                                             {
00059   MsgStream log( messageService(), name() );
00060   log << MSG::INFO << "handle: " << inc.type() << endreq;
00061 
00062   if ( inc.type() == "NewRun" ){
00063     if(m_fromDatabase){
00064       log << MSG::DEBUG << "start read from database" << endreq;
00065       StatusCode sc = GenFileFromDatabase();
00066       if (sc .isFailure() ) {
00067         log << MSG::ERROR << "Unable to read config from DatabaseSvc " << endreq;
00068         return;
00069       }
00070       //if(MyFrame::instance()) MyFrame::destruct();
00071       log << MSG::INFO << "sequenceListFileLocation= " << m_seqListFile << endreq;
00072       log << MSG::INFO << "signatureListFileLocation= " << m_sigListFile << endreq;
00073       MyFrame::instance()->init(m_seqListFile, m_sigListFile);
00074       MyFrame::instance()->final();
00075     }
00076   }
00077 }

StatusCode HltConfigSvc::initialize (  )  [virtual]

Definition at line 79 of file HltConfigSvc.cxx.

References calibUtil::ERROR, Bes_Common::FATAL, Bes_Common::INFO, m_dbsvc, m_eventSvc, m_fromDatabase, m_seqListFile, and m_sigListFile.

00080 {
00081 
00082   MsgStream log(messageService(), name());
00083   log << MSG::INFO << name() << ": Start of initialisation" << endreq;
00084 
00085   IIncidentSvc* incsvc;
00086   StatusCode sc = service("IncidentSvc", incsvc);
00087   int priority = 100;
00088   if( sc.isSuccess() ){
00089     incsvc -> addListener(this, "NewRun", priority);
00090   }
00091   else{
00092     log << MSG::FATAL << "Cannot find IncidentSvc" << endreq;
00093     return sc;
00094   }
00095 
00096   if(m_fromDatabase){
00097     sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
00098     if (sc .isFailure() ) {
00099       log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
00100       return sc;
00101     }
00102   }
00103 
00104   sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
00105   if (sc .isFailure() ) {
00106     log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
00107     return sc;
00108   }
00109 
00110   if (MyFrame::instance() == 0)
00111     log << MSG::INFO << "MyFrame::instance() == 0" << endreq;
00112   if(!m_fromDatabase){
00113     log << MSG::ALWAYS << "Read config from files" << endreq;
00114     MyFrame::instance()->init(m_seqListFile, m_sigListFile);
00115     // Finalize Frame. New version with singleton
00116     MyFrame::instance()->final();
00117   }
00118   return StatusCode::SUCCESS;
00119 }

static const InterfaceID& HltConfigSvc::interfaceID (  )  [inline, static]

Definition at line 54 of file HltConfigSvc.h.

References IID_IHltConfigSvc().

00054 { return IID_IHltConfigSvc; }

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

Definition at line 46 of file HltConfigSvc.cxx.

References IID_IHltConfigSvc().

00047 {
00048   if ( IID_IHltConfigSvc.versionMatch(riid) ) { 
00049 //    *ppvIF = static_cast<IHltConfigSvc*> (this); 
00050     *ppvIF = (HltConfigSvc*)this; 
00051   } else { 
00052     return Service::queryInterface(riid, ppvIF) ; 
00053   }
00054   return StatusCode::SUCCESS;
00055 }

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

Definition at line 122 of file HltConfigSvc.cxx.

Referenced by StepHandler::beginRun().

00123 {
00124 // Get the final vector object and play around with it.     
00125 //std::vector<std::pair<Signature*,Sequence*> > m_Vector = MyFrame::instance()->getTablesVector();
00126   return MyFrame::instance()->getTablesVector();
00127 }


Member Data Documentation

IDatabaseSvc* HltConfigSvc::m_dbsvc [private]

Definition at line 43 of file HltConfigSvc.h.

Referenced by GenFileFromDatabase(), and initialize().

IDataProviderSvc* HltConfigSvc::m_eventSvc [private]

Definition at line 44 of file HltConfigSvc.h.

Referenced by GenFileFromDatabase(), and initialize().

bool HltConfigSvc::m_fromDatabase [private]

Definition at line 46 of file HltConfigSvc.h.

Referenced by handle(), HltConfigSvc(), and initialize().

PropertyMgr HltConfigSvc::m_propMgr [private]

Definition at line 50 of file HltConfigSvc.h.

Referenced by HltConfigSvc().

std::string HltConfigSvc::m_seqListFile [private]

Definition at line 47 of file HltConfigSvc.h.

Referenced by GenFileFromDatabase(), handle(), HltConfigSvc(), and initialize().

std::string HltConfigSvc::m_sigListFile [private]

Definition at line 48 of file HltConfigSvc.h.

Referenced by GenFileFromDatabase(), handle(), HltConfigSvc(), and initialize().


Generated on Tue Nov 29 23:19:40 2016 for BOSS_7.0.2 by  doxygen 1.4.7