source: trunk/MagicSoft/Mars/mbase/MContinue.cc@ 1775

Last change on this file since 1775 was 1715, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.7 KB
Line 
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 <mailto:tbretz@astro.uni-wuerzburg.de>, 10/2002
19!
20! Copyright: MAGIC Software Development, 2000-2002
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/////////////////////////////////////////////////////////////////////////////
34#include "MContinue.h"
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39#include "MF.h"
40#include "MParList.h"
41#include "MTaskList.h"
42
43ClassImp(MContinue);
44
45// --------------------------------------------------------------------------
46//
47// Use this constructor if a rule (see MF for more details) shell be used.
48// MContinue will create a MF object and use it as a filter for the
49// instance. The MF-Task is added to the tasklist in front of the MContinue
50// instance and also automatically deleted, eg.
51// MContinue cont("MHillas.fSize<20");
52// tasklist.AddToList(&cont);
53// would skip all events which fullfill "MHillas.fSize<20" from this point
54// in the tasklist.
55//
56MContinue::MContinue(const TString rule, const char *name, const char *title)
57{
58 fName = name ? name : "MContinue";
59 fTitle = title ? title : "Task returning kCONTINUE";
60
61 if (rule.IsNull())
62 return;
63
64 SetBit(kIsOwner);
65
66 MTask::SetFilter(new MF(rule, TString("MF(")+fName+")"));
67}
68
69// --------------------------------------------------------------------------
70//
71// Use this if you have a filter. Would be the same as if you would call:
72// MContinue cont;
73// cont.SetFilter(f);
74//
75MContinue::MContinue(MFilter *f, const char *name, const char *title)
76{
77 fName = name ? name : "MContinue";
78 fTitle = title ? title : "Task returning kCONTINUE";
79
80 SetFilter(f);
81}
82
83// --------------------------------------------------------------------------
84//
85// Delete the filter if it was created automatically
86//
87MContinue::~MContinue()
88{
89 if (TestBit(kIsOwner))
90 delete GetFilter();
91}
92
93// --------------------------------------------------------------------------
94//
95// In case the filter was created automatically, PreProcess tries to find
96// the tasklist MTaskList, adds the filter before this instance to the
97// tasklist and preprocesses the filter.
98//
99Bool_t MContinue::PreProcess(MParList *list)
100{
101 if (!TestBit(kIsOwner))
102 return kTRUE;
103
104 MTaskList *tlist = (MTaskList*)list->FindObject("MTaskList");
105 if (!tlist)
106 {
107 *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
108 return kFALSE;
109 }
110
111 if (!GetFilter())
112 {
113 *fLog << err << dbginf << "Unknown fatal Error! (fFilter=NULL?!?)" << endl;
114 return kFALSE;
115 }
116
117 if (!tlist->AddToListBefore(GetFilter(), this))
118 {
119 *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
120 return kFALSE;
121 }
122
123 return GetFilter()->CallPreProcess(list);
124}
125
Note: See TracBrowser for help on using the repository browser.