EventSelector.cc
Go to the documentation of this file.
1 #include "EventSelector.h"
2 
3 #include <evt/Event.h>
4 #include <AugerEvent.h>
5 
6 #include <fwk/CentralConfig.h>
7 #include <utl/Reader.h>
8 #include <utl/config.h>
9 
10 #include <string>
11 //#include <iostream>
12 
13 using namespace std;
14 using namespace fwk;
15 using namespace utl;
16 
17 namespace EventSelector
18 {
19 
21 EventSelector::~EventSelector() {}
22 
25 {
26  Branch top=
27  CentralConfig::GetInstance()->GetTopBranch("EventSelector");
28 
29  for (Branch child = top.GetFirstChild(); child; child = child.GetNextSibling())
30  {
31  if (child.GetName() == "selectEventId")
32  {
33  string id;
34  child.GetData(id);
35  fSelectIds.push_back(id);
36  cout << "EventSelector: selecting ID " << id << "\n";
37  }
38  }
39 
40  if (fSelectIds.size() == 0)
41  cout << "EventSelector: empty select vector, so selecting all event IDs\n";
42 
43  return eSuccess;
44 }
45 
47 EventSelector::Run(evt::Event& event)
48 {
49  const evt::Header& header = event.GetHeader();
50  string id = header.GetId();
51 
52  cout << "Event id = '" << header.GetId() << "\' ";
53 
54  bool selected=idSelected(id);
55 
56  if (!selected)
57  {
58  cout << "skipped ...\n";
59  return eContinueLoop;
60  }
61 
62  //possibly other tests ...
63 
64  cout << "selected ...\n";
65  return eSuccess;
66 }
67 
68 //maybe should rather use set instead of vector ... ;-)
69 bool
70 EventSelector::idSelected(std::string id)
71 {
72  if (fSelectIds.size() == 0)
73  return true;
74 
75  for(vector<string>::const_iterator i=fSelectIds.begin();
76  i!=fSelectIds.end(); ++i)
77  {
78  if (*i == id) return true;
79  }
80  return false;
81 }
82 
83 
85 EventSelector::Finish()
86 {
87  return eSuccess;
88 }
89 
90 }
Branch GetTopBranch() const
Definition: Branch.cc:63
void Init()
Initialise the registry.
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
Class representing a document branch.
Definition: Branch.h:107
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
const std::string & GetId() const
Get the event identifier.
Definition: Event/Header.h:31
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Branch GetFirstChild() const
Get first child of this Branch.
Definition: Branch.cc:98
Global event header.
Definition: Event/Header.h:27

, generated on Tue Sep 26 2023.