121 #include "StHbtMaker/Infrastructure/StHbtManager.h"
134 StHbtManager::StHbtManager(){
135 mAnalysisCollection =
new StHbtAnalysisCollection;
136 mEventWriterCollection =
new StHbtEventWriterCollection;
140 StHbtManager::~StHbtManager(){
143 StHbtAnalysisIterator AnalysisIter;
144 for (AnalysisIter=mAnalysisCollection->begin();AnalysisIter!=mAnalysisCollection->end();AnalysisIter++){
145 delete *AnalysisIter;
148 delete mAnalysisCollection;
150 StHbtEventWriterIterator EventWriterIter;
151 for (EventWriterIter=mEventWriterCollection->begin();EventWriterIter!=mEventWriterCollection->end();EventWriterIter++){
152 delete *EventWriterIter;
153 *EventWriterIter = 0;
155 delete mEventWriterCollection;
158 int StHbtManager::Init(){
159 StHbtString readerMessage;
160 readerMessage +=
"*** *** *** *** *** *** *** *** *** *** *** *** \n";
163 if (mEventReader->Init(
"r",readerMessage)){
164 cout <<
" StHbtManager::Init() - Reader initialization failed " << endl;
167 readerMessage += mEventReader->Report();
170 StHbtEventWriterIterator EventWriterIter;
171 for (EventWriterIter=mEventWriterCollection->begin();EventWriterIter!=mEventWriterCollection->end();EventWriterIter++){
175 StHbtString writerMessage = readerMessage;
176 writerMessage +=
"*** *** *** *** *** *** *** *** *** *** *** *** \n";
177 writerMessage += (*EventWriterIter)->Report();
178 if (*EventWriterIter) {
179 if ( (*EventWriterIter)->Init(
"w",writerMessage)){
180 cout <<
" StHbtManager::Init() - Writer initialization failed " << endl;
190 void StHbtManager::Finish(){
192 if (mEventReader) mEventReader->Finish();
194 StHbtEventWriterIterator EventWriterIter;
196 for (EventWriterIter=mEventWriterCollection->begin();EventWriterIter!=mEventWriterCollection->end();EventWriterIter++){
197 currentEventWriter = *EventWriterIter;
198 currentEventWriter->Finish();
201 StHbtAnalysisIterator AnalysisIter;
203 for (AnalysisIter=mAnalysisCollection->begin();AnalysisIter!=mAnalysisCollection->end();AnalysisIter++){
204 currentAnalysis = *AnalysisIter;
205 currentAnalysis->Finish();
209 StHbtString StHbtManager::Report(){
213 stemp = mEventReader->Report();
215 sprintf(ctemp,
"\nStHbtManager Reporting %u EventWriters\n",mEventWriterCollection->size());
217 StHbtEventWriterIterator EventWriterIter;
219 for (EventWriterIter=mEventWriterCollection->begin();EventWriterIter!=mEventWriterCollection->end();EventWriterIter++){
220 cout <<
"StHbtManager - asking for EventWriter Report" << endl;
221 currentEventWriter = *EventWriterIter;
222 stemp+=currentEventWriter->Report();
225 sprintf(ctemp,
"\nStHbtManager Reporting %u Analyses\n",mAnalysisCollection->size());
227 StHbtAnalysisIterator AnalysisIter;
229 for (AnalysisIter=mAnalysisCollection->begin();AnalysisIter!=mAnalysisCollection->end();AnalysisIter++){
230 cout <<
"StHbtManager - asking for Analysis Report" << endl;
231 currentAnalysis = *AnalysisIter;
232 stemp+=currentAnalysis->Report();
235 StHbtString returnThis = stemp;
240 if ( n<0 || n > (
int) mAnalysisCollection->size() )
242 StHbtAnalysisIterator iter = mAnalysisCollection->begin();
243 for (
int i=0; i<n ;i++){
250 if ( n<0 || n > (
int) mEventWriterCollection->size() )
252 StHbtEventWriterIterator iter = mEventWriterCollection->begin();
253 for (
int i=0; i<n ;i++){
259 int StHbtManager::ProcessEvent(){
260 cout <<
"StHbtManager::ProcessEvent" << endl;
262 StHbtEvent* currentHbtEvent = mEventReader->ReturnHbtEvent();
263 cout <<
"Event reader has returned control to manager" << endl;
269 if (!currentHbtEvent){
270 cout <<
"StHbtManager::ProcessEvent() - Reader::ReturnHbtEvent() has returned null pointer\n";
271 return mEventReader->Status();
275 StHbtEventWriterIterator EventWriterIter;
276 for (EventWriterIter=mEventWriterCollection->begin();EventWriterIter!=mEventWriterCollection->end();EventWriterIter++){
278 cout <<
" *EventWriterIter " << *EventWriterIter << endl;
280 (*EventWriterIter)->WriteHbtEvent(currentHbtEvent);
284 StHbtAnalysisIterator AnalysisIter;
285 for (AnalysisIter=mAnalysisCollection->begin();AnalysisIter!=mAnalysisCollection->end();AnalysisIter++){
286 (*AnalysisIter)->ProcessEvent(currentHbtEvent);
289 if (currentHbtEvent)
delete currentHbtEvent;
291 cout <<
"StHbtManager::ProcessEvent() - return to caller ... " << endl;