1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 10/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MContinue
|
---|
28 | //
|
---|
29 | // Does nothing than return kCONTINUE in the Process-function
|
---|
30 | // (use with filters). For more details see the description of the
|
---|
31 | // constructors.
|
---|
32 | //
|
---|
33 | // To invert the meaning of the contained filter call SetInverted()
|
---|
34 | //
|
---|
35 | // Input Containers:
|
---|
36 | // -/-
|
---|
37 | //
|
---|
38 | // Output Containers:
|
---|
39 | // -/-
|
---|
40 | //
|
---|
41 | /////////////////////////////////////////////////////////////////////////////
|
---|
42 | #include "MContinue.h"
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MF.h"
|
---|
48 | #include "MParList.h"
|
---|
49 | #include "MTaskList.h"
|
---|
50 |
|
---|
51 | ClassImp(MContinue);
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Use this constructor if a rule (see MF for more details) shell be used.
|
---|
58 | // MContinue will create a MF object and use it as a filter for the
|
---|
59 | // instance. The MF-Task is added to the tasklist in front of the MContinue
|
---|
60 | // instance and also automatically deleted, eg.
|
---|
61 | // MContinue cont("MHillas.fSize<20");
|
---|
62 | // tasklist.AddToList(&cont);
|
---|
63 | // would skip all events which fullfill "MHillas.fSize<20" from this point
|
---|
64 | // in the tasklist.
|
---|
65 | // It is not necessary to put the filter in the tasklist. The PreProcess
|
---|
66 | // will search for the filter and if it isn't found in the tasklist it
|
---|
67 | // is added to the tasklist in front of MContinue.
|
---|
68 | //
|
---|
69 | MContinue::MContinue(const TString rule, const char *name, const char *title)
|
---|
70 | {
|
---|
71 | fName = name ? name : "MContinue";
|
---|
72 | fTitle = title ? title : "Task returning kCONTINUE";
|
---|
73 |
|
---|
74 | if (rule.IsNull())
|
---|
75 | return;
|
---|
76 |
|
---|
77 | SetBit(kIsOwner);
|
---|
78 |
|
---|
79 | MTask::SetFilter(new MF(rule, TString("MF(")+fName+")"));
|
---|
80 | }
|
---|
81 |
|
---|
82 | // --------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // Use this if you have a filter. Would be the same as if you would call:
|
---|
85 | // MContinue cont;
|
---|
86 | // cont.SetFilter(f);
|
---|
87 | // It is not necessary to put the filter in the tasklist. The PreProcess
|
---|
88 | // will search for the filter and if it isn't found in the tasklist it
|
---|
89 | // is added to the tasklist in front of MContinue.
|
---|
90 | //
|
---|
91 | MContinue::MContinue(MFilter *f, const char *name, const char *title)
|
---|
92 | {
|
---|
93 | fName = name ? name : "MContinue";
|
---|
94 | fTitle = title ? title : "Task returning kCONTINUE";
|
---|
95 |
|
---|
96 | SetFilter(f);
|
---|
97 | }
|
---|
98 |
|
---|
99 | // --------------------------------------------------------------------------
|
---|
100 | //
|
---|
101 | // Delete the filter if it was created automatically
|
---|
102 | //
|
---|
103 | MContinue::~MContinue()
|
---|
104 | {
|
---|
105 | if (TestBit(kIsOwner))
|
---|
106 | delete GetFilter();
|
---|
107 | }
|
---|
108 |
|
---|
109 | // --------------------------------------------------------------------------
|
---|
110 | //
|
---|
111 | // PreProcess tries to find the tasklist MTaskList, adds the filter
|
---|
112 | // before this instance to the tasklist and preprocesses the filter.
|
---|
113 | //
|
---|
114 | Int_t MContinue::PreProcess(MParList *list)
|
---|
115 | {
|
---|
116 | if (!GetFilter())
|
---|
117 | {
|
---|
118 | *fLog << err << dbginf << "Unknown fatal Error! (fFilter=NULL?!?)" << endl;
|
---|
119 | return kFALSE;
|
---|
120 | }
|
---|
121 |
|
---|
122 | fTaskList = (MTaskList*)list->FindTaskListWithTask(this);
|
---|
123 | if (!fTaskList)
|
---|
124 | {
|
---|
125 | *fLog << err << dbginf << "ERROR - MTasklist not found... abort." << endl;
|
---|
126 | return kFALSE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | if (fTaskList->FindObject(GetFilter()))
|
---|
130 | {
|
---|
131 | *fLog << inf << dbginf << "The filter is already in the tasklist..." << endl;
|
---|
132 | return kTRUE;
|
---|
133 | }
|
---|
134 |
|
---|
135 | if (!fTaskList->AddToListBefore(GetFilter(), this))
|
---|
136 | {
|
---|
137 | *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
|
---|
138 | return kFALSE;
|
---|
139 | }
|
---|
140 |
|
---|
141 | GetFilter()->SetDisplay(fDisplay);
|
---|
142 | GetFilter()->SetLogStream(fLog);
|
---|
143 |
|
---|
144 | SetBit(kFilterIsPrivate);
|
---|
145 |
|
---|
146 | return GetFilter()->CallPreProcess(list);
|
---|
147 | }
|
---|
148 |
|
---|
149 | void MContinue::SetDisplay(MStatusDisplay *d)
|
---|
150 | {
|
---|
151 | if (GetFilter())
|
---|
152 | GetFilter()->SetDisplay(d);
|
---|
153 |
|
---|
154 | MTask::SetDisplay(d);
|
---|
155 | }
|
---|
156 |
|
---|
157 | void MContinue::SetLogStream(MLog *lg)
|
---|
158 | {
|
---|
159 | if (GetFilter())
|
---|
160 | GetFilter()->SetLogStream(lg);
|
---|
161 |
|
---|
162 | MTask::SetLogStream(lg);
|
---|
163 | }
|
---|
164 |
|
---|
165 | // --------------------------------------------------------------------------
|
---|
166 | //
|
---|
167 | // If the filter was added to the tasklist automatically it is removed
|
---|
168 | // from the tasklist.
|
---|
169 | //
|
---|
170 | Int_t MContinue::PostProcess()
|
---|
171 | {
|
---|
172 | if (!TestBit(kFilterIsPrivate))
|
---|
173 | return kTRUE;
|
---|
174 |
|
---|
175 | if (fTaskList->RemoveFromList(GetFilter()))
|
---|
176 | return kTRUE;
|
---|
177 |
|
---|
178 | *fLog << err << "ERROR: MContinue::PostProcess - Cannot remove Filter from tasklist" << endl;
|
---|
179 |
|
---|
180 | return kFALSE;
|
---|
181 | }
|
---|
182 |
|
---|
183 | void MContinue::SetInverted(Bool_t i)
|
---|
184 | {
|
---|
185 | GetFilter()->SetInverted(i);
|
---|
186 | }
|
---|
187 |
|
---|
188 | Bool_t MContinue::IsInverted() const
|
---|
189 | {
|
---|
190 | return GetFilter()->IsInverted();
|
---|
191 | }
|
---|