source: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc@ 454

Last change on this file since 454 was 454, checked in by harald, 24 years ago
Import the first sources of the MAGIC Analysis and Reconstruction Software. T. Bretz and H. Kornmayer 20.December 2000
File size: 2.2 KB
Line 
1#include "MEvtLoop.h"
2
3#include <iostream.h>
4
5#include <TStopwatch.h>
6
7#include "MParList.h"
8#include "MTaskList.h"
9
10ClassImp(MEvtLoop)
11
12MEvtLoop::MEvtLoop() : fParlist(NULL)
13{
14}
15
16MEvtLoop::~MEvtLoop()
17{
18}
19
20void MEvtLoop::SetParList(MParList *p)
21{
22 fParlist = p;
23}
24
25void MEvtLoop::Eventloop(Int_t maxcnt, const char *ftasks)
26{
27 //
28 // check if the needed parameter list is set.
29 //
30 if (!fParlist)
31 {
32 cout << "MEvtLoop::Eventloop - Error: Parlist not initialized." << endl;
33 return;
34 }
35
36 //
37 // check for the existance of the specified task list
38 // the default name is "MTaskList"
39 //
40 MTaskList *tasks = (MTaskList*)fParlist->FindObject(ftasks);
41 if (!tasks)
42 {
43 cout << "MEvtLoop::Eventloop - Error: Cannot find tasklist '" << ftasks << "' in parameter list." << endl;
44 return;
45 }
46
47 //
48 // execute the preprocess of all tasks
49 // connect the different tasks with the right containers in
50 // the parameter list
51 //
52 if (!tasks->PreProcess(fParlist))
53 {
54 cout << "Error detected while PreProcessing" << endl;
55 return;
56 }
57
58 //
59 // loop over all events and process all tasks for
60 // each event
61 //
62 cout << endl << "Eventloop running (";
63
64 if (maxcnt<0)
65 cout << "all";
66 else
67 cout << dec << maxcnt;
68
69 cout << " events)..." << flush;
70
71 Int_t dummy = maxcnt<0 ? 0 : maxcnt;
72
73 //
74 // start a stopwatch
75 //
76 TStopwatch clock;
77 clock.Start();
78
79 //
80 // This is the MAIN EVENTLOOP which processes the data
81 // if maxcnt<0 the number of processed events is counted
82 // else only maxcnt events are processed
83 //
84 if (maxcnt<0)
85 while (tasks->Process() && ++dummy);
86 else
87 while (tasks->Process() && dummy--);
88
89 //
90 // stop stop-watch, print results
91 //
92 clock.Stop();
93
94 cout << "Ready!" << endl << endl;
95
96 clock.Print();
97
98 cout << dec << endl
99 << "Time: " << clock.CpuTime() << "s"
100 << " for " << (maxcnt<0?dummy:maxcnt) << " Events"
101 << " --> " << (maxcnt<0?dummy:maxcnt)/clock.CpuTime() << " Events/s"
102 << endl << endl;
103
104 //
105 // execute the post process of all tasks
106 //
107 tasks->PostProcess();
108}
109
Note: See TracBrowser for help on using the repository browser.