source: branches/start/MagicSoft/Mars/mbase/MLoopEvt.cc@ 6339

Last change on this file since 6339 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
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#include "MLoopEvt.h"
2
3#include <iostream.h>
4
5#include <TStopwatch.h>
6
7#include "MParList.h"
8#include "MTaskList.h"
9
10ClassImp(MLoopEvt)
11
12MLoopEvt::MLoopEvt() : fTasks(NULL), fParlist(NULL)
13{
14}
15
16MLoopEvt::~MLoopEvt()
17{
18}
19
20void MLoopEvt::SetTaskList(MTaskList *t)
21{
22 fTasks = t;
23}
24
25void MLoopEvt::SetParList(MParList *p)
26{
27 fParlist = p;
28
29 //
30 // check if the task list is already known
31 //
32 if (fTasks)
33 {
34 cout << "MLoopEvt::SetParList - Warning: Task List already set, using this one" << endl;
35 return;
36 }
37
38 //
39 // get the task list from the parameter list
40 //
41 fTasks = (MTaskList*)fParlist->FindObject("MTaskList");
42
43 if (!fTasks)
44 cout << "MLoopEvt::SetParList - Warning: MTaskList not found." << endl;
45}
46
47void MLoopEvt::Eventloop(Int_t maxcnt)
48{
49 //
50 // check if the parameter list is known
51 //
52 if (!fParlist)
53 {
54 cout << "MLoopEvt::Eventloop - Error: ParList not set." << endl;
55 return;
56 }
57
58 //
59 // check if the task list could be retrieved from the parameter list
60 //
61 if (!fTasks)
62 {
63 cout << "MLoopEvt::Eventloop - Error: TaskList not set." << endl;
64 return;
65 }
66
67 //
68 // execute the preprocess of all tasks
69 // connect the different tasks with the right containers in
70 // the parameter list
71
72 if (!fTasks->PreProcess(fParlist))
73 {
74 cout << "Error detected while PreProcessing" << endl;
75 return;
76 }
77
78 //
79 // loop over all events and process all tasks for
80 // each event
81 //
82 cout << endl << "Eventloop running (";
83
84 if (maxcnt<0)
85 cout << "all";
86 else
87 cout << dec << maxcnt;
88
89 cout << " events)..." << flush;
90
91 Int_t dummy = maxcnt<0 ? 0 : maxcnt;
92
93 TStopwatch clock;
94 clock.Start();
95
96 if (maxcnt<0)
97 while (fTasks->Process() && ++dummy);
98 else
99 while (fTasks->Process() && dummy--);
100
101 clock.Stop();
102
103 cout << "Ready!" << endl << endl;
104
105 clock.Print();
106
107 cout << dec << endl
108 << "Time: " << clock.CpuTime() << "s"
109 << " for " << (maxcnt<0?dummy:maxcnt) << " Events"
110 << " --> " << (maxcnt<0?dummy:maxcnt)/clock.CpuTime() << " Events/s"
111 << endl << endl;
112
113 //
114 // execute the post process of all tasks
115 //
116 fTasks->PostProcess();
117}
118
Note: See TracBrowser for help on using the repository browser.