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 |
|
---|
41 | ClassImp(MFTriggerLvl1);
|
---|
42 |
|
---|
43 |
|
---|
44 | // --------------------------------------------------------------------------
|
---|
45 | //
|
---|
46 | MFTriggerLvl1::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 | //
|
---|
55 | MFTriggerLvl1::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 | //
|
---|
63 | void 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 | //
|
---|
81 | Bool_t MFTriggerLvl1::IsExpressionTrue() const
|
---|
82 | {
|
---|
83 | return fResult;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // --------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | Bool_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 | //
|
---|
103 | Bool_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 |
|
---|
120 | void MFTriggerLvl1::StreamPrimitive(ofstream &out) const
|
---|
121 | {
|
---|
122 | if (fMcTrig)
|
---|
123 | fMcTrig->SavePrimitive(out);
|
---|
124 |
|
---|
125 | out << " MFTriggerLvl1 " << ToLower(fName) << "(";
|
---|
126 |
|
---|
127 | if (fMcTrig)
|
---|
128 | out << "&" << ToLower(fMcTrig->GetName());
|
---|
129 | else
|
---|
130 | out << "\"" << fContName << "\"";
|
---|
131 |
|
---|
132 | out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
|
---|
133 |
|
---|
134 | }
|
---|