3#include "ESController/SC.h"
4#include "ESController/error.h"
5#include "EFServices/IEFEventLoopMgr.h"
6#include "HltTools/PathResolver.h"
20#include "GaudiKernel/SmartIF.h"
21#include "GaudiKernel/Bootstrap.h"
22#include "GaudiKernel/IAppMgrUI.h"
23#include "GaudiKernel/ISvcLocator.h"
24#include "GaudiKernel/IProperty.h"
25#include "GaudiKernel/Property.h"
26#include "GaudiKernel/IService.h"
27#include "GaudiKernel/IMessageSvc.h"
28#include "GaudiKernel/IClassManager.h"
40 m_nameEventLoopMgr(
"EFEventLoopMgr")
42 ::setenv(
"SCOutputLevel",
"3",1);
43 char* ss=::getenv(
"SCOutputLevel");
56 m_pesaAppMgr->release() ;
61 static bool first_call_configure =
true;
62 if(first_call_configure){
63 first_call_configure =
false;
75 if(m_outLev<=3) std::cout<<
"efpsc::SC::configure "<<
"SC configuration started."<<std::endl;
81 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"---> Create Pesa Application Manager:"
82 <<m_isCreated<<std::endl;
84 if ((m_config->dllName().size() != 0) && (m_config->factoryName().size() != 0)) {
85 m_pesaAppMgr = Gaudi::createApplicationMgr(m_config->dllName(),m_config->factoryName());
86 if(m_outLev<=3)std::cout<<
"Gaudi::createApplicationMgr(m_config->dllName(),m_config->factoryName())"
89 m_pesaAppMgr = Gaudi::createApplicationMgr();
90 if(m_outLev<=3)std::cout<<
"Gaudi::createApplicationMgr()"<<std::endl;
97 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"---> Configure Pesa Property Manager"<<std::endl;
99 SmartIF<IProperty> propMgr ( m_pesaAppMgr );
100 SmartIF<IAppMgrUI> appMgr ( m_pesaAppMgr );
101 if( !appMgr.isValid() || !propMgr.isValid() ) {
104 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"While creating the ApplicationMgr"<<std::endl;
109 std::string opts =
"jobOptions.txt";
110 ::setenv(
"efJobPath",
"",1);
111 if (m_config->jobOptionsPath().size() != 0) {
112 opts = m_config->jobOptionsPath() ;
113 if (opts.rfind(
"/") < opts.size()) {
114 ::setenv(
"efJobPath",opts.substr(0,opts.rfind(
"/")).c_str(),1);
119 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"---> Pesa JobOptions file is = " << opts<<std::endl
120 <<
" "<<
"---> Pesa JobOptions path = "
121 << ::getenv(
"efJobPath")<<std::endl;
122 propMgr->setProperty(
"JobOptionsPath", opts );
124 propMgr->setProperty(
"EventLoop",m_nameEventLoopMgr );
129 if (m_config->messageSvcType().size() != 0) {
130 propMgr->setProperty(
"MessageSvcType", m_config->messageSvcType());
134 if (m_config->evtSel().size() != 0) {
135 propMgr->setProperty(
"EvtSel", m_config->evtSel());
137 propMgr->setProperty(
"EvtSel",
"NONE" );
142 if(m_outLev<=3) std::cout<<
"efpsc::SC::configure "<<
"finish property set--->start configure"<<std::endl;
143 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Configuring ApplicationMgr: "
144 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
146 if( opts.substr( opts.length() - 3, 3 ) ==
".py" ) {
150 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "
151 <<
"Error: Don't support python config files"<<std::endl;
196 sc = appMgr->configure();
197 if( sc.isFailure() ) {
200 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"While configuring the ApplicationMgr"<<std::endl;
206 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Configuring ApplicationMgr: "
207 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
209 sc = appMgr->initialize();
213 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Initialize ApplicationMgr : "
214 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
215 if( sc.isFailure() ) {
216 EFPSC_ERROR(
"efpsc::SC::configure",
"While intializing the ApplicationMgr");
223 sc = propMgr->getProperty(
"EventLoop", value );
225 if( sc.isFailure() ) {
227 if(m_outLev<=4) std::cout<<
"efpsc::SC::configure "<<
"While retrieving Property EventLoop "<<std::endl;
229 m_nameEventLoopMgr.assign(value, value.find_first_of(
"\"")+1,
230 value.find_last_of(
"\"")-value.find_first_of(
"\"")-1) ;
233 SmartIF<ISvcLocator> svcLoc( m_pesaAppMgr );
234 if (svcLoc.isValid()) {
236 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Name for EventLoopManager:"
237 <<m_nameEventLoopMgr<<std::endl;
239 IEventProcessor* processingMgr = 0 ;
241 sc = svcLoc->service( m_nameEventLoopMgr , processingMgr);
242 m_eventLoopMgr=processingMgr;
244 if( !sc.isSuccess() ) {
246 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"Error Retrieving Processing manager!"<<std::endl;
252 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"Error Retrieving Service Locator!"<<std::endl;
258 if(m_outLev<=3) std::cout<<
"efpsc::SC::configure "<<
"SC configuration finished."<<std::endl;
267 if(m_outLev<=3) std::cout<<
"efpsc::SC::unconfigure "<<
"SC UNconfiguration started."<<std::endl;
269 SmartIF<IAppMgrUI> appMgr ( m_pesaAppMgr );
270 if( !appMgr.isValid() ) {
273 if(m_outLev<=5) std::cout<<
"efpsc::SC::unconfigure "
274 <<
"While unconfiguring the ApplicationMgr, no valid interface"<<std::endl;
277 SmartIF<ISvcLocator> svcLoc( m_pesaAppMgr );
285 sc = appMgr->finalize();
289 if(m_outLev<=2) std::cout<<
"efpsc::SC::unconfigure "<<
"Finalize ApplicationMgr: "
290 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
291 if( sc.isFailure() ) {
294 if(m_outLev<=5) std::cout<<
"efpsc::SC::unconfigure "<<
"While finalizing the ApplicationMgr"<<std::endl;
299 sc = appMgr->terminate();
302 if(m_outLev<=2) std::cout<<
"efpsc::SC::unconfigure "<<
"Terminate ApplicationMgr : "
303 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
304 if( sc.isFailure() ) {
306 if(m_outLev<=5) std::cout<<
"efpsc::SC::unconfigure "<<
"While terminating the ApplicationMgr"<<std::endl;
333 if(m_outLev<=3) std::cout<<
"efpsc::SC::unconfigure "<<
"SC UNconfiguration finished."<<std::endl;
341 SmartIF<IEFEventLoopMgr> processor_psc( m_eventLoopMgr);
342 StatusCode sc = processor_psc->prepareForRun(run_number);
343 std::cout <<
"=================" << m_eventLoopMgr << std::endl;
344 if(sc.isSuccess())
return true;
349bool efpsc::SC::process(
const uint32_t *&feStore,
const uint32_t *&sdStore,std::string &efDecision_s,std::vector<uint32_t> &efBitPattern)
355 if(m_outLev<=3)std::cout<<
"efpsc::SC::process"<<
" **************** NEW EVENT ****************"<<std::endl;
367 if ( 0 != m_eventLoopMgr ) {
368 SmartIF<IEventProcessor> processor( m_eventLoopMgr);
370 if ( processor.isValid() ) {
371 SmartIF<IService> processor_s( m_eventLoopMgr);
375 sc = processor->executeEvent((
void*)feStore);
380 if(m_outLev<=2)std::cout<<
"efpsc::SC::process "<<
"after executeEvent(fe)"<<std::endl;
381 if( sc.isFailure() ) {
383 if(m_outLev<=4)std::cout<<
"efpsc::SC::process "<<
"Error for executeEvent in the ApplicationMgr "
384 << processor_s->name()<<std::endl;
387 SmartIF<IEFEventLoopMgr> processor_psc( m_eventLoopMgr);
392 efDecision_s = processor_psc->EF_Decision();
396 if(m_outLev<=3)std::cout<<
"efpsc::SC::process "<<
"after EF_Decision. EFdecision is: "
397 <<efDecision_s<<std::endl;
398 sdStore=(uint32_t*)processor_psc->EF_Fragment_Address();
402 if(m_outLev<=2)std::cout<<
"efpsc::SC::process "
403 <<
"EF_Fragment_Address() returns NULL pointer"<<std::endl;
424 efBitPattern.resize(4, 0);
425 if(efDecision_s==
"Junk") efBitPattern[0]=1<<0;
427 else if(efDecision_s==
"GJunk") efBitPattern[0]=(1<<1);
428 else if(efDecision_s==
"Beamgas") efBitPattern[0]=1<<2;
430 else if(efDecision_s==
"GBeamgas") efBitPattern[0]=(1<<3);
431 else if(efDecision_s==
"Cosmic") efBitPattern[0]=1<<4;
433 else if(efDecision_s==
"GCosmic") efBitPattern[0]=(1<<5);
434 else if(efDecision_s==
"EBhabha") efBitPattern[0]=1<<6;
436 else if(efDecision_s==
"GEBhabha") efBitPattern[0]=(1<<7);
437 else if(efDecision_s==
"BBhabha") efBitPattern[0]=1<<8;
439 else if(efDecision_s==
"GBBhabha") efBitPattern[0]=(1<<9);
440 else if(efDecision_s==
"Dimuon") efBitPattern[0]=1<<10;
442 else if(efDecision_s==
"GDimuon") efBitPattern[0]=(1<<11);
443 else if(efDecision_s==
"Diphoton") efBitPattern[0]=1<<12;
445 else if(efDecision_s==
"GDiphoton") efBitPattern[0]=(1<<13);
446 else if(efDecision_s==
"Hadron") efBitPattern[0]=1<<14;
448 else if(efDecision_s==
"GHadron") efBitPattern[0]=(1<<15);
449 else if(efDecision_s==
"Twophoton") efBitPattern[0]=1<<16;
451 else if(efDecision_s==
"GTwophoton") efBitPattern[0]=(17);
452 else if(efDecision_s==
"RandomTrg") efBitPattern[0]=1<<31;
453 else if(efDecision_s==
"Error") efBitPattern[0]=1<<30;
454 else if(efDecision_s==
"Other") efBitPattern[0]=1<<29;
455 else efBitPattern[0]=1<<28;
456 efBitPattern[1]=processor_psc->EF_Algorithm_Tag();
457 efBitPattern[2]=processor_psc->EF_Version();
458 efBitPattern[3]=processor_psc->EF_Total_Energy();
460 if(m_outLev<=2)std::cout<<
"efpsc::SC::process "
461 <<
"**************end of psc process!**************"<<std::endl;
466 if(m_outLev<=5)std::cout<<
"efpsc::SC::process "
467 <<
"executeEvent ApplicationMgr : no valid event processor "<<std::endl;
#define EFPSC_ERROR(p, m)
virtual bool prepareForRun(int run_number)
virtual bool unconfigure(void)
virtual bool configure(const std::string &config)
virtual bool process(const uint32_t *&feStore, const uint32_t *&sdStore, std::string &efDecision_s, std::vector< uint32_t > &efBitPattern)