source: trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc@ 5005

Last change on this file since 5005 was 4991, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.2 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 09/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MFDeltaT
28//
29// for more details see Construtor and Process()
30//
31/////////////////////////////////////////////////////////////////////////////
32#include "MFDeltaT.h"
33
34#include <fstream>
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39#include "MParList.h"
40
41#include "MMcEvt.hxx"
42
43ClassImp(MFDeltaT);
44
45using namespace std;
46
47// --------------------------------------------------------------------------
48//
49// Constructor. First argument is the upper limit of the filter (default=0.5).
50// Second argument is the name of the parameter container storing the time.
51// (default="MTime")
52//
53MFDeltaT::MFDeltaT(Float_t max, const char *time,
54 const char *name, const char *title)
55{
56 Init(name, title, max, time);
57}
58
59// --------------------------------------------------------------------------
60//
61// Default Constructor. Initializes upper limit of the filter (default=0.5)
62// and name of the parameter container storing the time (default="MTime")
63//
64MFDeltaT::MFDeltaT(const char *name, const char *title)
65{
66 Init(name, title);
67}
68
69// --------------------------------------------------------------------------
70//
71void MFDeltaT::Init(const char *name, const char *title,
72 Float_t max, const char *time)
73{
74 fName = name ? name : "MFDeltaT";
75 fTitle = title ? title : "Filter for time differences of consecutive events";
76
77 fUpperLimit = max;
78 fNameTime = time;
79
80 fErrors.Set(4);
81
82 AddToBranchList(Form("%s.*", (const char*)fNameTime));
83}
84
85// --------------------------------------------------------------------------
86//
87// Return result of conditional
88//
89Bool_t MFDeltaT::IsExpressionTrue() const
90{
91 return fResult;
92}
93
94// --------------------------------------------------------------------------
95//
96// Search for fNameTime [MTime]
97//
98Int_t MFDeltaT::PreProcess(MParList *pList)
99{
100 fErrors.Reset();
101
102 fTime = (MTime*)pList->FindObject(fNameTime, "MTime");
103 if (fTime)
104 return kTRUE;
105
106 *fLog << err << fNameTime << " [MTime] not found... aborting." << endl;
107 return kFALSE;
108}
109
110// --------------------------------------------------------------------------
111//
112// Calculate the consition. The consition is true if the time difference
113// between two consecutive events are >0 or <= upper limit.
114//
115Int_t MFDeltaT::Process()
116{
117 fResult = kFALSE;
118
119 const Double_t dt = *fTime - fLastTime;
120 fLastTime = *fTime;
121
122 Int_t i=0;
123
124 if (GetNumExecutions()>0)
125 {
126 if (dt<0)
127 i=1;
128 if (dt==0)
129 i=2;
130 if (dt>fUpperLimit)
131 i=3;
132 }
133
134 fResult = i==0;
135 fErrors[i]++;
136 return kTRUE;
137}
138
139// --------------------------------------------------------------------------
140//
141// Print some statistics.
142//
143Int_t MFDeltaT::PostProcess()
144{
145 if (GetNumExecutions()==0)
146 return kTRUE;
147
148 *fLog << inf << endl;
149 *fLog << GetDescriptor() << " filter statistics:" << endl;
150 *fLog << dec << setfill(' ');
151 PrintSkipped(fErrors[1], "Delta-T < 0");
152 PrintSkipped(fErrors[2], "Delta-T == 0");
153 PrintSkipped(fErrors[3], Form("Delta-T > %.2fs", fUpperLimit));
154 *fLog << " " << (int)fErrors[0] << " (" << (int)(100.*fErrors[0]/GetNumExecutions()) << "%) Evts fullfilled filter condition!" << endl;
155 *fLog << endl;
156
157 return kTRUE;
158}
Note: See TracBrowser for help on using the repository browser.