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() ;
68 if(m_outLev<=3) std::cout<<
"efpsc::SC::configure "<<
"SC configuration started."<<std::endl;
74 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"---> Create Pesa Application Manager:"
75 <<m_isCreated<<std::endl;
77 if ((m_config->dllName().size() != 0) && (m_config->factoryName().size() != 0)) {
78 m_pesaAppMgr = Gaudi::createApplicationMgr(m_config->dllName(),m_config->factoryName());
79 if(m_outLev<=3)std::cout<<
"Gaudi::createApplicationMgr(m_config->dllName(),m_config->factoryName())"
82 m_pesaAppMgr = Gaudi::createApplicationMgr();
83 if(m_outLev<=3)std::cout<<
"Gaudi::createApplicationMgr()"<<std::endl;
90 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"---> Configure Pesa Property Manager"<<std::endl;
92 SmartIF<IProperty> propMgr ( m_pesaAppMgr );
93 SmartIF<IAppMgrUI> appMgr ( m_pesaAppMgr );
94 if( !appMgr.isValid() || !propMgr.isValid() ) {
97 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"While creating the ApplicationMgr"<<std::endl;
102 std::string opts =
"jobOptions.txt";
103 ::setenv(
"efJobPath",
"",1);
104 if (m_config->jobOptionsPath().size() != 0) {
105 opts = m_config->jobOptionsPath() ;
106 if (opts.rfind(
"/") < opts.size()) {
107 ::setenv(
"efJobPath",opts.substr(0,opts.rfind(
"/")).c_str(),1);
112 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"---> Pesa JobOptions file is = " << opts<<std::endl
113 <<
" "<<
"---> Pesa JobOptions path = "
114 << ::getenv(
"efJobPath")<<std::endl;
115 propMgr->setProperty(
"JobOptionsPath", opts );
117 propMgr->setProperty(
"EventLoop",m_nameEventLoopMgr );
122 if (m_config->messageSvcType().size() != 0) {
123 propMgr->setProperty(
"MessageSvcType", m_config->messageSvcType());
127 if (m_config->evtSel().size() != 0) {
128 propMgr->setProperty(
"EvtSel", m_config->evtSel());
130 propMgr->setProperty(
"EvtSel",
"NONE" );
135 if(m_outLev<=3) std::cout<<
"efpsc::SC::configure "<<
"finish property set--->start configure"<<std::endl;
136 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Configuring ApplicationMgr: "
137 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
139 if( opts.substr( opts.length() - 3, 3 ) ==
".py" ) {
143 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "
144 <<
"Error: Don't support python config files"<<std::endl;
189 sc = appMgr->configure();
190 if( sc.isFailure() ) {
193 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"While configuring the ApplicationMgr"<<std::endl;
199 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Configuring ApplicationMgr: "
200 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
202 sc = appMgr->initialize();
206 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Initialize ApplicationMgr : "
207 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
208 if( sc.isFailure() ) {
209 EFPSC_ERROR(
"efpsc::SC::configure",
"While intializing the ApplicationMgr");
216 sc = propMgr->getProperty(
"EventLoop", value );
218 if( sc.isFailure() ) {
220 if(m_outLev<=4) std::cout<<
"efpsc::SC::configure "<<
"While retrieving Property EventLoop "<<std::endl;
222 m_nameEventLoopMgr.assign(value, value.find_first_of(
"\"")+1,
223 value.find_last_of(
"\"")-value.find_first_of(
"\"")-1) ;
226 SmartIF<ISvcLocator> svcLoc( m_pesaAppMgr );
227 if (svcLoc.isValid()) {
229 if(m_outLev<=2) std::cout<<
"efpsc::SC::configure "<<
"Name for EventLoopManager:"
230 <<m_nameEventLoopMgr<<std::endl;
232 IEventProcessor* processingMgr = 0 ;
234 sc = svcLoc->service( m_nameEventLoopMgr , processingMgr);
235 m_eventLoopMgr=processingMgr;
237 if( !sc.isSuccess() ) {
239 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"Error Retrieving Processing manager!"<<std::endl;
245 if(m_outLev<=5) std::cout<<
"efpsc::SC::configure "<<
"Error Retrieving Service Locator!"<<std::endl;
251 if(m_outLev<=3) std::cout<<
"efpsc::SC::configure "<<
"SC configuration finished."<<std::endl;
259 if(m_outLev<=3) std::cout<<
"efpsc::SC::unconfigure "<<
"SC UNconfiguration started."<<std::endl;
261 SmartIF<IAppMgrUI> appMgr ( m_pesaAppMgr );
262 if( !appMgr.isValid() ) {
265 if(m_outLev<=5) std::cout<<
"efpsc::SC::unconfigure "
266 <<
"While unconfiguring the ApplicationMgr, no valid interface"<<std::endl;
269 SmartIF<ISvcLocator> svcLoc( m_pesaAppMgr );
277 sc = appMgr->finalize();
281 if(m_outLev<=2) std::cout<<
"efpsc::SC::unconfigure "<<
"Finalize ApplicationMgr: "
282 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
283 if( sc.isFailure() ) {
286 if(m_outLev<=5) std::cout<<
"efpsc::SC::unconfigure "<<
"While finalizing the ApplicationMgr"<<std::endl;
291 sc = appMgr->terminate();
294 if(m_outLev<=2) std::cout<<
"efpsc::SC::unconfigure "<<
"Terminate ApplicationMgr : "
295 << appMgr->FSMState() <<
" Status : " << sc.getCode()<<std::endl;
296 if( sc.isFailure() ) {
298 if(m_outLev<=5) std::cout<<
"efpsc::SC::unconfigure "<<
"While terminating the ApplicationMgr"<<std::endl;
325 if(m_outLev<=3) std::cout<<
"efpsc::SC::unconfigure "<<
"SC UNconfiguration finished."<<std::endl;
333 SmartIF<IEFEventLoopMgr> processor_psc( m_eventLoopMgr);
334 StatusCode sc = processor_psc->prepareForRun(run_number);
335 if(sc.isSuccess())
return true;
340bool efpsc::SC::process(
const uint32_t *&feStore,
const uint32_t *&sdStore,std::string &efDecision_s,std::vector<uint32_t> &efBitPattern)
346 if(m_outLev<=3)std::cout<<
"efpsc::SC::process"<<
" **************** NEW EVENT ****************"<<std::endl;
358 if ( 0 != m_eventLoopMgr ) {
359 SmartIF<IEventProcessor> processor( m_eventLoopMgr);
361 if ( processor.isValid() ) {
362 SmartIF<IService> processor_s( m_eventLoopMgr);
366 sc = processor->executeEvent((
void*)feStore);
371 if(m_outLev<=2)std::cout<<
"efpsc::SC::process "<<
"after executeEvent(fe)"<<std::endl;
372 if( sc.isFailure() ) {
374 if(m_outLev<=4)std::cout<<
"efpsc::SC::process "<<
"Error for executeEvent in the ApplicationMgr "
375 << processor_s->name()<<std::endl;
378 SmartIF<IEFEventLoopMgr> processor_psc( m_eventLoopMgr);
383 efDecision_s = processor_psc->EF_Decision();
387 if(m_outLev<=3)std::cout<<
"efpsc::SC::process "<<
"after EF_Decision. EFdecision is: "
388 <<efDecision_s<<std::endl;
389 sdStore=(uint32_t*)processor_psc->EF_Fragment_Address();
393 if(m_outLev<=2)std::cout<<
"efpsc::SC::process "
394 <<
"EF_Fragment_Address() returns NULL pointer"<<std::endl;
415 efBitPattern.resize(4, 0);
416 if(efDecision_s==
"Junk") efBitPattern[0]=1<<0;
418 else if(efDecision_s==
"GJunk") efBitPattern[0]=(1<<1);
419 else if(efDecision_s==
"Beamgas") efBitPattern[0]=1<<2;
421 else if(efDecision_s==
"GBeamgas") efBitPattern[0]=(1<<3);
422 else if(efDecision_s==
"Cosmic") efBitPattern[0]=1<<4;
424 else if(efDecision_s==
"GCosmic") efBitPattern[0]=(1<<5);
425 else if(efDecision_s==
"EBhabha") efBitPattern[0]=1<<6;
427 else if(efDecision_s==
"GEBhabha") efBitPattern[0]=(1<<7);
428 else if(efDecision_s==
"BBhabha") efBitPattern[0]=1<<8;
430 else if(efDecision_s==
"GBBhabha") efBitPattern[0]=(1<<9);
431 else if(efDecision_s==
"Dimuon") efBitPattern[0]=1<<10;
433 else if(efDecision_s==
"GDimuon") efBitPattern[0]=(1<<11);
434 else if(efDecision_s==
"Diphoton") efBitPattern[0]=1<<12;
436 else if(efDecision_s==
"GDiphoton") efBitPattern[0]=(1<<13);
437 else if(efDecision_s==
"Hadron") efBitPattern[0]=1<<14;
439 else if(efDecision_s==
"GHadron") efBitPattern[0]=(1<<15);
440 else if(efDecision_s==
"Twophoton") efBitPattern[0]=1<<16;
442 else if(efDecision_s==
"GTwophoton") efBitPattern[0]=(17);
443 else if(efDecision_s==
"RandomTrg") efBitPattern[0]=1<<31;
444 else if(efDecision_s==
"Error") efBitPattern[0]=1<<30;
445 else if(efDecision_s==
"Other") efBitPattern[0]=1<<29;
446 else efBitPattern[0]=1<<28;
447 efBitPattern[1]=processor_psc->EF_Algorithm_Tag();
448 efBitPattern[2]=processor_psc->EF_Version();
449 efBitPattern[3]=processor_psc->EF_Total_Energy();
451 if(m_outLev<=2)std::cout<<
"efpsc::SC::process "
452 <<
"**************end of psc process!**************"<<std::endl;
457 if(m_outLev<=5)std::cout<<
"efpsc::SC::process "
458 <<
"executeEvent ApplicationMgr : no valid event processor "<<std::endl;
Defines the error and reporting policies.
#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)