Diana Software
MFilterWithNeighboursResult.cc
Go to the documentation of this file.
2 #include "QEvent.hh"
3 #include "QEventList.hh"
4 #include "QBool.hh"
5 
6 using namespace Diana;
7 
9 
10 void MFilterWithNeighboursResult::GetCuts(const QEvent& ev)
11 {
12  fBoolLabel = GetString("BoolLabel","NODEFAULT@NODEFAULT");
13  std::string modeString = GetString("Mode","ALL");
14  if(modeString == "ALL") fMode = M_ALL;
15  else if(modeString == "ONE") fMode = M_ONE;
16  else {
17  Error("Mode \"%s\" not allowed (allowed are \"ALL\" and \"ONE\") setting mode to \"ALL\"");
18  fMode = M_ALL;
19  }
20  ev.RequireByLabel<QBool>(fBoolLabel);
21 }
22 
24 {
25  if(neigh.Empty()) return false;
26 
27  for(size_t i =0; i< neigh.Size(); i++) {
28  const bool result = neigh[i].GetByLabel<QBool>(fBoolLabel);
29  if(fMode == M_ALL && !result) return false;
30  else if(fMode == M_ONE && result) return true;
31  }
32 
33  if(fMode == M_ALL) return true;
34 
35  return false;
36 
37 }
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Filter a main QEvent using a QBool variable in neighbours.
bool Filter(const Diana::QEvent &ev, const Diana::QEventList &neigh)
return true if ev passes the cuts
bool wrapped into a QObject
Definition: QBool.hh:17
list of references to const QEvent (s)
Definition: QEventList.hh:21
bool Empty() const
check if the list is empty
Definition: QEventList.hh:39
size_t Size() const
number of QEvent (s)
Definition: QEventList.hh:36
diana event
Definition: QEvent.hh:46
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...