/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #include "SimReadoutController.h" 00002 00003 #include "GaudiKernel/IAlgManager.h" 00004 #include "SimSequencer.h" 00005 00006 SimReadoutController::SimReadoutController(const std::string& name, 00007 ISvcLocator* pSvcLocator) 00008 : GaudiAlgorithm(name,pSvcLocator) 00009 { 00010 declareProperty 00011 ( "algSeq" , 00012 m_algSeqName="SimSequencer" , 00013 "Sequence algorithm to be turned on or off") ; 00014 00015 m_algSeqName.declareUpdateHandler(& SimReadoutController::membershipHandler 00016 , this ); 00017 } 00018 00019 SimReadoutController::~SimReadoutController() 00020 { 00021 } 00022 00023 StatusCode SimReadoutController::initialize() 00024 { 00025 debug() << "Initializing: " << this->name() << endreq; 00026 00027 m_bufferSvc = svc<IReadoutBufferSvc>("ReadoutBufferSvc",true); 00028 00029 return this->GaudiAlgorithm::initialize(); 00030 } 00031 00032 StatusCode SimReadoutController::execute() 00033 { 00034 debug() << "executing: " << this->name() << endreq; 00035 00036 // If the buffer has readouts waiting in it don't produce more 00037 // i.e. dont run the simulation sequence, skip right to readout stage. 00038 00039 if( m_bufferSvc->hasMoreReadouts() ) 00040 { 00041 verbose() << "Buffer Service has readout in buffer " 00042 << " so simulation subSequence will NOT execute" << endreq; 00043 if(m_algSeq) m_algSeq->setExecuteThisEvent(false); 00044 }else{ 00045 verbose() << "Buffer Service has empty buffer " 00046 << " so simulation subSequence WILL execute" << endreq; 00047 } 00048 00049 return StatusCode::SUCCESS; 00050 } 00051 00052 StatusCode SimReadoutController::finalize() 00053 { 00054 debug() << "Finalizing: " << this->name() << endreq; 00055 return this->GaudiAlgorithm::finalize();; 00056 } 00057 00058 //========================================================================= 00059 // Decode the input names and fills the m_algs vector. 00060 //========================================================================= 00061 StatusCode SimReadoutController::decodeName( ) { 00062 00063 //= Get the Application manager, to see if algorithm exist 00064 IAlgManager* appMgr = svc<IAlgManager>("ApplicationMgr"); 00065 00066 00067 std::string theName( m_algSeqName.value() ); 00068 std::string theType( m_algSeqName.value() ); 00069 std::string::size_type slash = m_algSeqName.value().find_first_of( '/' ); 00070 if ( slash != std::string::npos ) { 00071 theType = m_algSeqName.value().substr( 0, slash ); 00072 theName = m_algSeqName.value().substr( slash+1 ); 00073 } 00074 00075 //== Check wether the specified algorithm already exists. 00076 00077 IAlgorithm* myIAlg; 00078 StatusCode result = appMgr->getAlgorithm( theName, myIAlg ); 00079 00080 if ( result.isSuccess() ) 00081 { 00082 m_algSeq = dynamic_cast<SimSequencer*>( myIAlg ); 00083 00084 if (m_algSeq != 0) 00085 { 00086 m_algSeq->addRef(); 00087 debug () << "Watching algorithm " << theName << endreq; 00088 } 00089 else 00090 { 00091 fatal() << theName << " is not a SimSeq - failed dynamic_cast" << endreq; 00092 result = StatusCode::FAILURE; 00093 } 00094 } 00095 else 00096 { 00097 fatal() << theName << " does not exist" << endreq; 00098 } 00099 00100 release(appMgr).ignore(); 00101 00102 return result; 00103 00104 } 00105 00106 //========================================================================= 00107 // Interface for the Property manager 00108 //========================================================================= 00109 void SimReadoutController::membershipHandler ( Property& ) { 00110 decodeName().ignore(); 00111 } 00112 //============================================================================= 00113