source: branches/MarsISDCBranchBasedOn17887/mfilter/MFTriggerLvl1.cc@ 18592

Last change on this file since 18592 was 7804, checked in by tbretz, 18 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>
33
34#include "MLog.h"
35#include "MLogManip.h"
36
37#include "MParList.h"
38
39#include "MMcTrig.hxx"
40
41ClassImp(MFTriggerLvl1);
42
43using namespace std;
44
45// --------------------------------------------------------------------------
46//
47MFTriggerLvl1::MFTriggerLvl1(const char *cname, const char type, const Int_t val,
48 const char *name, const char *title) : fMcTrig(NULL)
49{
50 fContName = cname;
51 Init(type, val, name, title);
52}
53
54// --------------------------------------------------------------------------
55//
56MFTriggerLvl1::MFTriggerLvl1(MMcTrig *mctrig, const char type, const Int_t val,
57 const char *name, const char *title) : fMcTrig(mctrig)
58{
59 Init(type, val, name, title);
60}
61
62// --------------------------------------------------------------------------
63//
64void MFTriggerLvl1::Init(const char type, const Int_t val,
65 const char *name, const char *title)
66{
67 fName = name ? name : "MFTriggerLvl1";
68 fTitle = title ? title : "Filter using number of 1st level triggers";
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.fNumFirstLevel", (const char*)fContName));
78}
79
80// --------------------------------------------------------------------------
81//
82Bool_t MFTriggerLvl1::IsExpressionTrue() const
83{
84 return fResult;
85}
86
87// --------------------------------------------------------------------------
88//
89Int_t MFTriggerLvl1::PreProcess(MParList *pList)
90{
91 if (fMcTrig)
92 return kTRUE;
93
94 fMcTrig = (MMcTrig*)pList->FindObject(fContName);
95 if (fMcTrig)
96 return kTRUE;
97
98 *fLog << err << dbginf << fContName << " [MMcTrig] not found... aborting." << endl;
99 return kFALSE;
100}
101
102// --------------------------------------------------------------------------
103//
104Int_t MFTriggerLvl1::Process()
105{
106 const Int_t lvl1 = fMcTrig->GetFirstLevel();
107
108 switch (fFilterType)
109 {
110 case kELowerThan:
111 fResult = (lvl1 < fValue);
112 break;
113 case kEGreaterThan:
114 fResult = (lvl1 > fValue);
115 break;
116 }
117
118 return kTRUE;
119}
120
121void MFTriggerLvl1::StreamPrimitive(ostream &out) const
122{
123 if (fMcTrig)
124 fMcTrig->SavePrimitive(out);
125
126 out << " MFTriggerLvl1 " << GetUniqueName() << "(";
127
128 if (fMcTrig)
129 out << "&" << fMcTrig->GetUniqueName();
130 else
131 out << "\"" << fContName << "\"";
132
133 out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
134
135}
Note: See TracBrowser for help on using the repository browser.