source: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc@ 2097

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