#include <StepSequencer.h>
Public Member Functions | |
StepSequencer (const std::string &name, ISvcLocator *pSvcLocator) | |
~StepSequencer () | |
virtual bool | isEnabled () const |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
void | reset () |
StatusCode | initSequencer (HltProcessor::Sequence *) |
bool | execSequencer (const std::string &seqID) |
std::vector< Algorithm * > | searchAlgForEachTE_o (HltProcessor::Sequence *) |
bool | doesExistAlready (std::string) |
Algorithm * | existingAlg (std::string) |
Private Attributes | |
Algorithm * | matchAlg |
std::vector< Algorithm * > | vMatchAlg |
std::map< std::string, std::vector< Algorithm * > > | m_AlgMap |
bool | m_isEnabled |
Definition at line 14 of file StepSequencer.h.
StepSequencer::StepSequencer | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 32 of file StepSequencer.cxx.
References m_isEnabled.
00032 : 00033 Algorithm(name, pSvcLocator) { 00034 m_isEnabled = false; 00035 }
StepSequencer::~StepSequencer | ( | ) |
Definition at line 38 of file StepSequencer.cxx.
00038 { 00039 /* 00040 std::vector<Algorithm*>* subAlgms = subAlgorithms(); 00041 std::vector<Algorithm *>::iterator it; 00042 for (it = subAlgms->begin(); it != subAlgms->end(); it++) { 00043 std::cout << *it << (*it)->name() << std::endl; 00044 (*it)->release(); 00045 } 00046 */ 00047 }
bool StepSequencer::doesExistAlready | ( | std::string | ) |
Definition at line 139 of file StepSequencer.cxx.
References Bes_Common::WARNING.
Referenced by initSequencer().
00140 { 00141 MsgStream log( messageService(), name() ); 00142 bool doesExist=false; 00143 std::vector<Algorithm*>* subAlgms = subAlgorithms(); 00144 00145 if(subAlgms->size()==0) { 00146 doesExist=false; 00147 return doesExist; 00148 } 00149 else { 00150 std::vector<Algorithm*>::iterator it = subAlgms->begin(); 00151 for ( ; it != subAlgms->end(); it++) { 00152 if(aName==(*it)->name()) { 00153 log << MSG::WARNING << aName <<" sub-algorithm already created" << endreq; 00154 doesExist=true; 00155 break; 00156 } 00157 } 00158 } 00159 return doesExist; 00160 }
bool StepSequencer::execSequencer | ( | const std::string & | seqID | ) |
Definition at line 164 of file StepSequencer.cxx.
References Bes_Common::DEBUG, calibUtil::ERROR, and m_AlgMap.
Referenced by StepHandler::execute().
00165 { 00166 MsgStream log( messageService(), name() ); 00167 const std::vector<Algorithm*>& algVec = m_AlgMap[seqID]; 00168 /*log << MSG::DEBUG << " Execute Sequencer on a step with " 00169 << algVec.size() << " algorithms." << endreq;*/ 00170 00171 log << MSG::DEBUG << "=============================" << endreq; 00172 00173 std::vector<Algorithm*>::const_iterator it = algVec.begin(); 00174 for(; it != algVec.end(); it++) { 00175 StatusCode sc = (*it)->execute(); 00176 if (sc.isFailure()) { 00177 log << MSG::ERROR << (*it)->name() << " execute failed" << endreq; 00178 return false; 00179 } 00180 } 00181 00182 return true; 00183 }
StatusCode StepSequencer::execute | ( | ) | [inline] |
Algorithm * StepSequencer::existingAlg | ( | std::string | ) |
Definition at line 123 of file StepSequencer.cxx.
References boss::Algorithm.
Referenced by initSequencer().
00124 { 00125 MsgStream log( messageService(), name() ); 00126 Algorithm* exAlg; 00127 std::vector<Algorithm*>* subAlgms = subAlgorithms(); 00128 std::vector<Algorithm*>::iterator it = subAlgms->begin(); 00129 for ( ; it != subAlgms->end(); it++) { 00130 if(subAlgName==(*it)->name()) { 00131 log << subAlgName<<" already created, return pointer to it "<< endreq; 00132 return *it; 00133 } 00134 } 00135 return exAlg; 00136 }
StatusCode StepSequencer::finalize | ( | ) | [inline] |
StatusCode StepSequencer::initialize | ( | ) | [inline] |
StatusCode StepSequencer::initSequencer | ( | HltProcessor::Sequence * | ) |
Definition at line 69 of file StepSequencer.cxx.
References HltProcessor::Sequence::algoNum(), boss::Algorithm, HltProcessor::Sequence::algoVector(), Bes_Common::DEBUG, doesExistAlready(), existingAlg(), Bes_Common::FATAL, findAlgTypeName(), findParamSet(), HltProcessor::Sequence::getSeqID(), Bes_Common::INFO, m_AlgMap, and deljobs::string.
Referenced by StepHandler::beginRun().
00069 { 00070 MsgStream log( messageService(), name() ); 00071 00072 std::string SubAlg_type, SubAlg_name, SubAlg_param, SubAlg_NameParam,AlgNameFromConfig ; 00073 Algorithm* pAlg; 00074 Algorithm* bAlg; 00075 00076 //read in algorithms in sequence and initialize them 00077 log<< MSG::DEBUG << "Sequence " << sequence->getSeqID() 00078 <<" has " << sequence->algoNum() << " algorithms " << endreq; 00079 00080 std::vector<Algorithm*> helpAlgVec; 00081 std::vector<std::string>::iterator algI = sequence->algoVector().begin(); 00082 00083 for ( ; algI != sequence->algoVector().end(); algI++){ 00084 std::string alg_def = *algI; 00085 log << MSG::DEBUG << "algorithm : " << alg_def << endreq; 00086 findAlgTypeName(alg_def,SubAlg_type,SubAlg_NameParam); 00087 findParamSet(SubAlg_NameParam,AlgNameFromConfig,SubAlg_param); 00088 SubAlg_name=AlgNameFromConfig+"_"+SubAlg_param; 00089 00090 //check if the name exists, don't create again the subalgorithm, just added to the AlgoTePairs vector 00091 bool subAlgExist = doesExistAlready(SubAlg_name); 00092 if(!subAlgExist) { 00093 StatusCode sc = createSubAlgorithm(SubAlg_type, SubAlg_name, pAlg); 00094 if(sc.isFailure() ) { 00095 log << MSG::FATAL << alg_def <<" sub-algorithm create failed!" << endreq; 00096 return sc; 00097 } 00098 log << MSG::DEBUG << "created " << SubAlg_type << "/" << SubAlg_name << endreq; 00099 bAlg = dynamic_cast<Algorithm*>(pAlg); 00100 bAlg->initialize(); 00101 bAlg->beginRun(); 00102 StringProperty paramSet("ParamSetFile", SubAlg_param); 00103 bAlg->setProperty(paramSet); 00104 00105 helpAlgVec.push_back(bAlg); 00106 } else { 00107 pAlg = existingAlg(SubAlg_name); 00108 bAlg = dynamic_cast<Algorithm*>(pAlg); 00109 //bAlg->set_isReRunable(); 00110 StringProperty paramSet("ParamSetFile",SubAlg_param); 00111 bAlg->setProperty(paramSet); 00112 helpAlgVec.push_back(bAlg); 00113 } 00114 } 00115 m_AlgMap[sequence->getSeqID()] = helpAlgVec; 00116 00117 log << MSG::INFO << "Initialization of "<< name() << " completed successfully" << endreq; 00118 return StatusCode::SUCCESS; 00119 }
virtual bool StepSequencer::isEnabled | ( | ) | const [inline, virtual] |
void StepSequencer::reset | ( | ) |
Definition at line 50 of file StepSequencer.cxx.
References Bes_Common::DEBUG, genRecEmupikp::i, and m_AlgMap.
Referenced by StepHandler::execute().
00051 { 00052 MsgStream log( messageService(), name() ); 00053 std::map<std::string, std::vector<Algorithm*> >::iterator it = m_AlgMap.begin(); 00054 log << MSG::DEBUG << "the size of algorithm map is " << m_AlgMap.size() << endreq; 00055 for ( ; it != m_AlgMap.end(); it++) { 00056 log << MSG::DEBUG << "reset() of " << it->first << endreq; 00057 const std::vector<Algorithm*>& algs = it->second; 00058 int n = algs.size(); 00059 for (int i = 0; i < n; i++) { 00060 if (IEFAlgorithm* ialg = dynamic_cast<IEFAlgorithm*>(algs[i])) { 00061 //std::cout << " @reset(): " << algs[i]->name() << " p: " << ialg << std::endl; 00062 ialg->reset(); 00063 } 00064 } 00065 } 00066 }
std::vector< Algorithm * > StepSequencer::searchAlgForEachTE_o | ( | HltProcessor::Sequence * | ) |
Definition at line 185 of file StepSequencer.cxx.
References HltProcessor::Sequence::algoVector(), findAlgTypeName(), findParamSet(), deljobs::string, and vMatchAlg.
00186 { 00187 00188 MsgStream log( messageService(), name() ); 00189 std::string SubAlg_type, SubAlg_name, SubAlg_param, SubAlg_NameParam,AlgNameFromConfig; 00190 00191 /* std::string n=name(); 00192 std::string::size_type p_end, p_begin; 00193 p_end=n.size(); 00194 p_begin=p_end-3; 00195 std::string instance=n.substr( p_begin, p_end);*/ 00196 00197 vMatchAlg.clear(); 00198 std::vector<std::string>::iterator It = seq->algoVector().begin(); 00199 for ( ; It < seq->algoVector().end(); It++) { 00200 std::string alg_defin = *It; 00201 findAlgTypeName(alg_defin,SubAlg_type,SubAlg_NameParam); 00202 findParamSet(SubAlg_NameParam,AlgNameFromConfig,SubAlg_param); 00203 SubAlg_name=AlgNameFromConfig+"_"+SubAlg_param; 00204 00205 /*std::vector<std::pair<Algorithm*,HltElement* > >::iterator I; 00206 for(I=AlgoTEPairs.begin();I!=AlgoTEPairs.end();++I) { 00207 00208 if( SubAlg_name==(I->first)->name() && (I->second)->label()==seq->outputLabel() ) { 00209 matchAlg=I->first; 00210 vMatchAlg.push_back(matchAlg); 00211 } 00212 }*/ 00213 } 00214 return vMatchAlg; 00215 }
std::map<std::string, std::vector<Algorithm* > > StepSequencer::m_AlgMap [private] |
Definition at line 40 of file StepSequencer.h.
Referenced by execSequencer(), initSequencer(), and reset().
bool StepSequencer::m_isEnabled [private] |
Algorithm* StepSequencer::matchAlg [private] |
Definition at line 37 of file StepSequencer.h.
std::vector<Algorithm* > StepSequencer::vMatchAlg [private] |