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 | // Input Containers:
|
---|
34 | // -/-
|
---|
35 | //
|
---|
36 | // Output Containers:
|
---|
37 | // -/-
|
---|
38 | //
|
---|
39 | /////////////////////////////////////////////////////////////////////////////
|
---|
40 | #include "MContinue.h"
|
---|
41 |
|
---|
42 | #include "MLog.h"
|
---|
43 | #include "MLogManip.h"
|
---|
44 |
|
---|
45 | #include "MF.h"
|
---|
46 | #include "MParList.h"
|
---|
47 | #include "MTaskList.h"
|
---|
48 |
|
---|
49 | ClassImp(MContinue);
|
---|
50 |
|
---|
51 | // --------------------------------------------------------------------------
|
---|
52 | //
|
---|
53 | // Use this constructor if a rule (see MF for more details) shell be used.
|
---|
54 | // MContinue will create a MF object and use it as a filter for the
|
---|
55 | // instance. The MF-Task is added to the tasklist in front of the MContinue
|
---|
56 | // instance and also automatically deleted, eg.
|
---|
57 | // MContinue cont("MHillas.fSize<20");
|
---|
58 | // tasklist.AddToList(&cont);
|
---|
59 | // would skip all events which fullfill "MHillas.fSize<20" from this point
|
---|
60 | // in the tasklist.
|
---|
61 | // It is not necessary to put the filter in the tasklist. The PreProcess
|
---|
62 | // will search for the filter and if it isn't found in the tasklist it
|
---|
63 | // is added to the tasklist in front of MContinue.
|
---|
64 | //
|
---|
65 | MContinue::MContinue(const TString rule, const char *name, const char *title)
|
---|
66 | {
|
---|
67 | fName = name ? name : "MContinue";
|
---|
68 | fTitle = title ? title : "Task returning kCONTINUE";
|
---|
69 |
|
---|
70 | if (rule.IsNull())
|
---|
71 | return;
|
---|
72 |
|
---|
73 | SetBit(kIsOwner);
|
---|
74 |
|
---|
75 | MTask::SetFilter(new MF(rule, TString("MF(")+fName+")"));
|
---|
76 | }
|
---|
77 |
|
---|
78 | // --------------------------------------------------------------------------
|
---|
79 | //
|
---|
80 | // Use this if you have a filter. Would be the same as if you would call:
|
---|
81 | // MContinue cont;
|
---|
82 | // cont.SetFilter(f);
|
---|
83 | // It is not necessary to put the filter in the tasklist. The PreProcess
|
---|
84 | // will search for the filter and if it isn't found in the tasklist it
|
---|
85 | // is added to the tasklist in front of MContinue.
|
---|
86 | //
|
---|
87 | MContinue::MContinue(MFilter *f, const char *name, const char *title)
|
---|
88 | {
|
---|
89 | fName = name ? name : "MContinue";
|
---|
90 | fTitle = title ? title : "Task returning kCONTINUE";
|
---|
91 |
|
---|
92 | SetFilter(f);
|
---|
93 | }
|
---|
94 |
|
---|
95 | // --------------------------------------------------------------------------
|
---|
96 | //
|
---|
97 | // Delete the filter if it was created automatically
|
---|
98 | //
|
---|
99 | MContinue::~MContinue()
|
---|
100 | {
|
---|
101 | if (TestBit(kIsOwner))
|
---|
102 | delete GetFilter();
|
---|
103 | }
|
---|
104 |
|
---|
105 | // --------------------------------------------------------------------------
|
---|
106 | //
|
---|
107 | // In case the filter was created automatically, PreProcess tries to find
|
---|
108 | // the tasklist MTaskList, adds the filter before this instance to the
|
---|
109 | // tasklist and preprocesses the filter.
|
---|
110 | //
|
---|
111 | Bool_t MContinue::PreProcess(MParList *list)
|
---|
112 | {
|
---|
113 | if (!TestBit(kIsOwner))
|
---|
114 | return kTRUE;
|
---|
115 |
|
---|
116 | MTaskList *tlist = (MTaskList*)list->FindObject("MTaskList");
|
---|
117 | if (!tlist)
|
---|
118 | {
|
---|
119 | *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
|
---|
120 | return kFALSE;
|
---|
121 | }
|
---|
122 |
|
---|
123 | if (!GetFilter())
|
---|
124 | {
|
---|
125 | *fLog << err << dbginf << "Unknown fatal Error! (fFilter=NULL?!?)" << endl;
|
---|
126 | return kFALSE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | if (!tlist->AddToListBefore(GetFilter(), this))
|
---|
130 | {
|
---|
131 | *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
|
---|
132 | return kFALSE;
|
---|
133 | }
|
---|
134 |
|
---|
135 | return GetFilter()->CallPreProcess(list);
|
---|
136 | }
|
---|