BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
StepSequencer Class Reference

#include <StepSequencer.h>

+ Inheritance diagram for StepSequencer:

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)
 

Detailed Description

Definition at line 14 of file StepSequencer.h.

Constructor & Destructor Documentation

◆ StepSequencer()

StepSequencer::StepSequencer ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 32 of file StepSequencer.cxx.

32 :
33 Algorithm(name, pSvcLocator) {
34 m_isEnabled = false;
35}

◆ ~StepSequencer()

StepSequencer::~StepSequencer ( )

Definition at line 38 of file StepSequencer.cxx.

38{ }

Member Function Documentation

◆ doesExistAlready()

bool StepSequencer::doesExistAlready ( std::string  aName)

Definition at line 128 of file StepSequencer.cxx.

129{
130 MsgStream log( messageService(), name() );
131 bool doesExist=false;
132 std::vector<Algorithm*>* subAlgms = subAlgorithms();
133
134 if(subAlgms->size()==0) {
135 doesExist=false;
136 return doesExist;
137 }
138 else {
139 std::vector<Algorithm*>::iterator it = subAlgms->begin();
140 for ( ; it != subAlgms->end(); it++) {
141 if(aName==(*it)->name()) {
142 log << MSG::WARNING << aName <<" sub-algorithm already created" << endreq;
143 doesExist=true;
144 break;
145 }
146 }
147 }
148 return doesExist;
149}

Referenced by initSequencer().

◆ execSequencer()

bool StepSequencer::execSequencer ( const std::string &  seqID)

Definition at line 153 of file StepSequencer.cxx.

154{
155 MsgStream log( messageService(), name() );
156 const std::vector<Algorithm*>& algVec = m_AlgMap[seqID];
157 /*log << MSG::DEBUG << " Execute Sequencer on a step with "
158 << algVec.size() << " algorithms." << endreq;*/
159
160 log << MSG::DEBUG << "=============================" << endreq;
161
162 std::vector<Algorithm*>::const_iterator it = algVec.begin();
163 for(; it != algVec.end(); it++) {
164 StatusCode sc = (*it)->execute();
165 if (sc.isFailure()) {
166 log << MSG::ERROR << (*it)->name() << " execute failed" << endreq;
167 return false;
168 }
169 }
170
171 return true;
172}

Referenced by StepHandler::execute().

◆ execute()

StatusCode StepSequencer::execute ( )
inline

Definition at line 23 of file StepSequencer.h.

23{ return StatusCode::SUCCESS; }

◆ existingAlg()

Algorithm * StepSequencer::existingAlg ( std::string  subAlgName)

Definition at line 112 of file StepSequencer.cxx.

113{
114 MsgStream log( messageService(), name() );
115 Algorithm* exAlg;
116 std::vector<Algorithm*>* subAlgms = subAlgorithms();
117 std::vector<Algorithm*>::iterator it = subAlgms->begin();
118 for ( ; it != subAlgms->end(); it++) {
119 if(subAlgName==(*it)->name()) {
120 log << subAlgName<<" already created, return pointer to it "<< endreq;
121 return *it;
122 }
123 }
124 return exAlg;
125}

Referenced by initSequencer().

◆ finalize()

StatusCode StepSequencer::finalize ( )
inline

Definition at line 24 of file StepSequencer.h.

24{ return StatusCode::SUCCESS; }

◆ initialize()

StatusCode StepSequencer::initialize ( )
inline

Definition at line 22 of file StepSequencer.h.

22{ return StatusCode::SUCCESS; }

◆ initSequencer()

StatusCode StepSequencer::initSequencer ( HltProcessor::Sequence sequence)

Definition at line 58 of file StepSequencer.cxx.

58 {
59 MsgStream log( messageService(), name() );
60
61 std::string SubAlg_type, SubAlg_name, SubAlg_param, SubAlg_NameParam,AlgNameFromConfig ;
62 Algorithm* pAlg;
63 Algorithm* bAlg;
64
65 //read in algorithms in sequence and initialize them
66 log<< MSG::DEBUG << "Sequence " << sequence->getSeqID()
67 <<" has " << sequence->algoNum() << " algorithms " << endreq;
68
69 std::vector<Algorithm*> helpAlgVec;
70 std::vector<std::string>::iterator algI = sequence->algoVector().begin();
71
72 for ( ; algI != sequence->algoVector().end(); algI++){
73 std::string alg_def = *algI;
74 log << MSG::DEBUG << "algorithm : " << alg_def << endreq;
75 findAlgTypeName(alg_def,SubAlg_type,SubAlg_NameParam);
76 findParamSet(SubAlg_NameParam,AlgNameFromConfig,SubAlg_param);
77 SubAlg_name=AlgNameFromConfig+"_"+SubAlg_param;
78
79 //check if the name exists, don't create again the subalgorithm, just added to the AlgoTePairs vector
80 bool subAlgExist = doesExistAlready(SubAlg_name);
81 if(!subAlgExist) {
82 StatusCode sc = createSubAlgorithm(SubAlg_type, SubAlg_name, pAlg);
83 if(sc.isFailure() ) {
84 log << MSG::FATAL << alg_def <<" sub-algorithm create failed!" << endreq;
85 return sc;
86 }
87 log << MSG::DEBUG << "created " << SubAlg_type << "/" << SubAlg_name << endreq;
88 bAlg = dynamic_cast<Algorithm*>(pAlg);
89 bAlg->initialize();
90 bAlg->beginRun();
91 StringProperty paramSet("ParamSetFile", SubAlg_param);
92 bAlg->setProperty(paramSet);
93
94 helpAlgVec.push_back(bAlg);
95 } else {
96 pAlg = existingAlg(SubAlg_name);
97 bAlg = dynamic_cast<Algorithm*>(pAlg);
98 //bAlg->set_isReRunable();
99 StringProperty paramSet("ParamSetFile",SubAlg_param);
100 bAlg->setProperty(paramSet);
101 helpAlgVec.push_back(bAlg);
102 }
103 }
104 m_AlgMap[sequence->getSeqID()] = helpAlgVec;
105
106 log << MSG::INFO << "Initialization of "<< name() << " completed successfully" << endreq;
107 return StatusCode::SUCCESS;
108}
void findParamSet(const std::string &property, std::string &SubAlg_name, std::string &SubAlg_param)
void findAlgTypeName(const std::string &property, std::string &SubAlg_type, std::string &SubAlg_NameParam)
int algoNum() const
Retrieve number of algorithms.
Definition: Sequence.cxx:18
const std::string & getSeqID() const
Definition: Sequence.h:25
std::vector< std::string > & algoVector()
Retrieve algorithm vector reference.
Definition: Sequence.cxx:13
Algorithm * existingAlg(std::string)
bool doesExistAlready(std::string)

Referenced by StepHandler::beginRun().

◆ isEnabled()

virtual bool StepSequencer::isEnabled ( ) const
inlinevirtual

Definition at line 21 of file StepSequencer.h.

21{return m_isEnabled;};

◆ reset()

void StepSequencer::reset ( )

Definition at line 41 of file StepSequencer.cxx.

42{
43 std::map<std::string, std::vector<Algorithm*> >::iterator it = m_AlgMap.begin();
44 for ( ; it != m_AlgMap.end(); it++) {
45 //std::cout << "@reset(): " << it->first << std::endl;
46 const std::vector<Algorithm*>& algs = it->second;
47 int n = algs.size();
48 for (int i = 0; i < n; i++) {
49 if (IEFAlgorithm* ialg = dynamic_cast<IEFAlgorithm*>(algs[i])) {
50 //std::cout << " @reset(): " << algs[i]->name() << " p: " << ialg << std::endl;
51 ialg->reset();
52 }
53 }
54 }
55}
const Int_t n

Referenced by StepHandler::execute().

◆ searchAlgForEachTE_o()

std::vector< Algorithm * > StepSequencer::searchAlgForEachTE_o ( HltProcessor::Sequence seq)

Definition at line 174 of file StepSequencer.cxx.

175{
176
177 MsgStream log( messageService(), name() );
178 std::string SubAlg_type, SubAlg_name, SubAlg_param, SubAlg_NameParam,AlgNameFromConfig;
179
180 /* std::string n=name();
181 std::string::size_type p_end, p_begin;
182 p_end=n.size();
183 p_begin=p_end-3;
184 std::string instance=n.substr( p_begin, p_end);*/
185
186 vMatchAlg.clear();
187 std::vector<std::string>::iterator It = seq->algoVector().begin();
188 for ( ; It < seq->algoVector().end(); It++) {
189 std::string alg_defin = *It;
190 findAlgTypeName(alg_defin,SubAlg_type,SubAlg_NameParam);
191 findParamSet(SubAlg_NameParam,AlgNameFromConfig,SubAlg_param);
192 SubAlg_name=AlgNameFromConfig+"_"+SubAlg_param;
193
194 /*std::vector<std::pair<Algorithm*,HltElement* > >::iterator I;
195 for(I=AlgoTEPairs.begin();I!=AlgoTEPairs.end();++I) {
196
197 if( SubAlg_name==(I->first)->name() && (I->second)->label()==seq->outputLabel() ) {
198 matchAlg=I->first;
199 vMatchAlg.push_back(matchAlg);
200 }
201 }*/
202 }
203 return vMatchAlg;
204}

The documentation for this class was generated from the following files: