Diana Software
MTimeCutFilter.cc
Go to the documentation of this file.
1 #include "MTimeCutFilter.hh"
2 #include "QEvent.hh"
3 #include "QEventList.hh"
4 #include "QRawEvent.hh"
5 
6 //MinTime and MaxTime must be given in seconds to the cfg file
7 
9 
10 using namespace Diana;
11 
12 
14 {
15 
16  fMinTime = GetDouble("MinTime",(double)Q_DOUBLE_DEFAULT);
17  fMaxTime = GetDouble("MaxTime",(double)Q_DOUBLE_DEFAULT);
18 
19  fIsWarned = false;
20 
21 }
22 
23 
25 {
26 
27  bool passed = false;
28 
29  QHeader header = ev.Get<QHeader>("DAQ","Header");
30  double time = header.GetTime().GetFromStartRunNs()/1.e09;
31 
32 
33  if(fMinTime==Q_DOUBLE_DEFAULT && fMaxTime!=Q_DOUBLE_DEFAULT)
34  {
35  // applies only upper limit
36  if (time <= fMaxTime) passed = true;
37  }
38 
39  if(fMinTime!=Q_DOUBLE_DEFAULT && fMaxTime==Q_DOUBLE_DEFAULT)
40  {
41  // applies only lower limit
42  if (time >= fMinTime) passed = true;
43  }
44 
45  // no range specified
46  if(fMaxTime==Q_DOUBLE_DEFAULT && fMinTime==Q_DOUBLE_DEFAULT && !fIsWarned)
47  {
48  Warn("No range specified. The variable will not be filtered");
49  fIsWarned= true;
50  }
51 
52  // wrong range (max < min)
53  if(fMaxTime!=Q_DOUBLE_DEFAULT && fMinTime!=Q_DOUBLE_DEFAULT && fMaxTime <= fMinTime && !fIsWarned)
54  {
55  Warn("Wrong Range (Max <= Min). The variable will not be filtered");
56  fIsWarned = true;
57  }
58 
59  else
60  {
61  if(time >= fMinTime && time <= fMaxTime) passed = true;
62  }
63 
64 
65  return passed;
66 }
#define Q_DOUBLE_DEFAULT
Definition: QDiana.hh:24
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
one-line description of your filter
bool Filter(const Diana::QEvent &ev)
return true if ev passes the cuts
void GetCuts(const Diana::QEvent &ev)
Get cuts from config file.
diana event
Definition: QEvent.hh:46
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
const Diana::QTime & GetTime() const
get time
Definition: QHeader.hh:28
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...