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

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