source: trunk/MagicSoft/Mars/mfilter/MFAlpha.cc@ 4376

Last change on this file since 4376 was 2206, 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 01/2002 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MFAlpha //
28// //
29/////////////////////////////////////////////////////////////////////////////
30#include "MFAlpha.h"
31
32#include <math.h>
33#include <fstream>
34
35#include "MLog.h"
36#include "MLogManip.h"
37
38#include "MParList.h"
39
40#include "MHillasSrc.h"
41
42ClassImp(MFAlpha);
43
44using namespace std;
45
46// --------------------------------------------------------------------------
47//
48MFAlpha::MFAlpha(const char *cname, const char type, const Float_t val,
49 const char *name, const char *title) : fHillas(NULL)
50{
51 fContName = cname;
52 Init(type, val, name, title);
53}
54
55// --------------------------------------------------------------------------
56//
57MFAlpha::MFAlpha(MHillasSrc *hillas, const char type, const Float_t val,
58 const char *name, const char *title) : fHillas(hillas)
59{
60 Init(type, val, name, title);
61}
62
63// --------------------------------------------------------------------------
64//
65void MFAlpha::Init(const char type, const Float_t val,
66 const char *name, const char *title)
67{
68 fName = name ? name : "MFAlpha";
69 fTitle = title ? title : "Filter using the alpha angle";
70
71 fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
72
73 if (type!='<' && type!='>')
74 *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
75
76 fValue = val;
77
78 AddToBranchList(Form("%s.fAlpha", (const char*)fContName));
79}
80
81// --------------------------------------------------------------------------
82//
83Int_t MFAlpha::PreProcess(MParList *pList)
84{
85 if (fHillas)
86 return kTRUE;
87
88 fHillas = (MHillasSrc*)pList->FindObject(fContName);
89 if (fHillas)
90 return kTRUE;
91
92 *fLog << err << dbginf << fContName << " [MHillas] not found... aborting." << endl;
93 return kFALSE;
94}
95
96// --------------------------------------------------------------------------
97//
98Int_t MFAlpha::Process()
99{
100 const Float_t alpha = fabs(fHillas->GetAlpha());
101
102 switch (fFilterType)
103 {
104 case kELowerThan:
105 fResult = (alpha < fValue);
106 break;
107 case kEGreaterThan:
108 fResult = (alpha > fValue);
109 break;
110 }
111
112 return kTRUE;
113}
114
115void MFAlpha::StreamPrimitive(ofstream &out) const
116{
117 if (fHillas)
118 fHillas->SavePrimitive(out);
119
120 out << " MFParticleId " << GetUniqueName() << "(";
121
122 if (fHillas)
123 out << "&" << fHillas->GetUniqueName();
124 else
125 out << "\"" << fContName << "\"";
126
127 out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
128
129}
Note: See TracBrowser for help on using the repository browser.