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

Last change on this file since 8785 was 7005, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.4 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(6);
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 condition. The condition 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 Int_t i=0;
120
121 if (GetNumExecutions()>0)
122 {
123 if (*fTime-fLastTime>fUpperLimit)
124 i=1;
125 if (*fTime<fLastTime)
126 i=2;
127 if (*fTime==fLastTime)
128 i=3;
129 if (fTime->IsMidnight())
130 i=4;
131 if (*fTime==MTime())
132 i=5;
133 }
134
135 fLastTime = *fTime;
136
137 fResult = i==0;
138 fErrors[i]++;
139 return kTRUE;
140}
141
142// --------------------------------------------------------------------------
143//
144// Print some statistics.
145//
146Int_t MFDeltaT::PostProcess()
147{
148 if (GetNumExecutions()==0)
149 return kTRUE;
150
151 *fLog << inf << endl;
152 *fLog << GetDescriptor() << " filter statistics:" << endl;
153 *fLog << dec << setfill(' ');
154 PrintSkipped(fErrors[2], "Delta-T < 0");
155 PrintSkipped(fErrors[3], "Delta-T == 0");
156 PrintSkipped(fErrors[1], Form("Delta-T > %.2fs", fUpperLimit));
157 PrintSkipped(fErrors[4], "MTime is midnight");
158 PrintSkipped(fErrors[5], "MTime not initialized");
159 *fLog << " " << (int)fErrors[0] << " (";
160 *fLog << Form("%5.1f", 100.*fErrors[0]/GetNumExecutions());
161 *fLog << "%) Evts fullfilled filter condition!" << endl;
162 *fLog << endl;
163
164 return kTRUE;
165}
Note: See TracBrowser for help on using the repository browser.