Classes | Typedefs | Functions | Variables
EventSelExc_t.cpp File Reference
#include "art/Framework/Core/EventSelector.h"
#include "art/Persistency/Provenance/PathSpec.h"
#include "canvas/Persistency/Common/TriggerResults.h"
#include "fhiclcpp/ParameterSetRegistry.h"
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  TrigResults
 

Typedefs

typedef std::vector< std::stringStrings
 
using PathSpecifiers = std::vector< std::string >
 

Functions

std::ostream & operator<< (std::ostream &ost, const Strings &strings)
 
std::ostream & operator<< (std::ostream &ost, const TrigResults &tr)
 
void evSelTest (PathSpecifiers const &path_specifiers, TrigResults const &tr, bool ans)
 
int main ()
 

Variables

Strings const trigger_path_names
 
HLTPathStatus const pass {art::hlt::Pass}
 
HLTPathStatus const fail {art::hlt::Fail}
 
HLTPathStatus const excp {art::hlt::Exception}
 
HLTPathStatus const redy {art::hlt::Ready}
 

Typedef Documentation

Definition at line 34 of file EventSelExc_t.cpp.

Definition at line 33 of file EventSelExc_t.cpp.

Function Documentation

void evSelTest ( PathSpecifiers const &  path_specifiers,
TrigResults const &  tr,
bool  ans 
)

Definition at line 88 of file EventSelExc_t.cpp.

91 {
92  EventSelector selector{path_specifiers};
93 
94  int number_of_trigger_paths = 0;
95  std::vector<unsigned char> bitArray;
96 
97  HLTGlobalStatus bm(tr.bit.size());
98  for (unsigned int b = 0; b < tr.bit.size(); ++b) {
99  bm.at(b) = (tr.bit[b]);
100  // There is an alternate version of the function acceptEvent
101  // that takes an array of characters as an argument instead
102  // of a TriggerResults object. These next few lines build
103  // that array so we can test that also.
104  if ((number_of_trigger_paths % 4) == 0)
105  bitArray.push_back(0);
106  int byteIndex = number_of_trigger_paths / 4;
107  int subIndex = number_of_trigger_paths % 4;
108  bitArray[byteIndex] |= (static_cast<unsigned char>(bm.state(b)))
109  << (subIndex * 2);
110  ++number_of_trigger_paths;
111  }
112 
113  ParameterSet trigger_pset;
114  trigger_pset.put<Strings>("trigger_paths", trigger_path_names);
115  ParameterSetRegistry::put(trigger_pset);
116 
117  TriggerResults const results_id{bm, trigger_pset.id()};
118  bool const result = selector.acceptEvent(ScheduleID::first(), results_id);
119  if (result != ans) {
120  std::cerr
121  << "failed to compare pathspecs with trigger results using pset ID: "
122  << "correct=" << ans << " "
123  << "results=" << std::boolalpha << result << "\n"
124  << "pathspecs =" << path_specifiers << "\n"
125  << "trigger results = " << tr << "\n";
126  abort();
127  }
128 }
static QCString result
Strings const trigger_path_names
ParameterSetID id() const
HLTPathStatus const & at(unsigned const i) const
static bool * b
Definition: config.cpp:1043
std::vector< std::string > Strings
void put(std::string const &key)
int main ( void  )

Definition at line 131 of file EventSelExc_t.cpp.

132 {
133  // 01 - Non-wildcard positives, exception accepted
134  PathSpecifiers const ps_a{"ap2"};
135  TrigResults tr_01{fail, pass, fail, fail, fail, fail, excp, fail};
136  evSelTest(ps_a, tr_01, true);
137  tr_01 = {fail, pass, fail, fail, fail, fail, fail, fail};
138  evSelTest(ps_a, tr_01, true);
139  tr_01 = {pass, fail, pass, pass, fail, fail, fail, pass};
140  evSelTest(ps_a, tr_01, false);
141  tr_01 = {pass, excp, pass, pass, fail, fail, fail, pass};
142  evSelTest(ps_a, tr_01, false);
143  tr_01 = {pass, redy, pass, pass, fail, fail, fail, pass};
144  evSelTest(ps_a, tr_01, false);
145 
146  // 02 - Non-wildcard negatives, exception accepted
147  PathSpecifiers const ps_b{"!aq2"};
148  TrigResults tr_02{pass, pass, pass, fail, pass, pass, excp, pass};
149  evSelTest(ps_b, tr_02, true);
150  tr_02 = {pass, pass, pass, fail, pass, pass, pass, pass};
151  evSelTest(ps_b, tr_02, true);
152  tr_02 = {pass, pass, pass, pass, pass, pass, pass, pass};
153  evSelTest(ps_b, tr_01, false);
154  tr_02 = {pass, pass, pass, excp, pass, pass, pass, pass};
155  evSelTest(ps_b, tr_01, false);
156  tr_02 = {pass, pass, pass, redy, pass, pass, pass, pass};
157  evSelTest(ps_b, tr_01, false);
158 
159  // 03 - Non-wildcard positives and negatives mixed, exception accepted
160  PathSpecifiers const ps_c{"bp1", "!aq1", "!bq2"};
161  TrigResults tr_03{pass, pass, pass, pass, fail, pass, pass, pass};
162  evSelTest(ps_c, tr_03, false);
163  tr_03 = {excp, pass, pass, pass, pass, pass, pass, pass};
164  evSelTest(ps_c, tr_03, true);
165  tr_03 = {excp, pass, fail, pass, fail, pass, pass, pass};
166  evSelTest(ps_c, tr_03, true);
167  tr_03 = {excp, pass, pass, pass, fail, pass, pass, fail};
168  evSelTest(ps_c, tr_03, true);
169  tr_03 = {redy, pass, pass, pass, pass, pass, pass, fail};
170  evSelTest(ps_c, tr_03, true);
171 
172  // 04 - Non-wildcard positives, exception not accepted
173  PathSpecifiers const ps_d{"ap2&noexception"};
174  TrigResults tr_04{fail, pass, fail, fail, fail, fail, excp, fail};
175  evSelTest(ps_d, tr_04, false);
176  tr_04 = {fail, pass, fail, fail, fail, fail, fail, fail};
177  evSelTest(ps_d, tr_04, true);
178  tr_04 = {pass, fail, pass, pass, fail, fail, fail, pass};
179  evSelTest(ps_d, tr_04, false);
180  tr_04 = {pass, excp, pass, pass, fail, fail, fail, pass};
181  evSelTest(ps_d, tr_04, false);
182  tr_04 = {pass, pass, pass, pass, fail, fail, redy, pass};
183  evSelTest(ps_d, tr_04, true);
184 
185  // 05 - Non-wildcard negatives, exception not accepted, mixed with 01 case
186  PathSpecifiers const ps_e{"bp1", "!aq1&noexception", "!bq2"};
187  TrigResults tr_05{pass, pass, pass, pass, fail, pass, pass, pass};
188  evSelTest(ps_e, tr_05, false);
189  tr_05 = {excp, pass, pass, pass, pass, pass, pass, pass};
190  evSelTest(ps_e, tr_05, true);
191  tr_05 = {pass, pass, fail, pass, fail, pass, pass, pass};
192  evSelTest(ps_e, tr_05, true);
193  tr_05 = {pass, pass, fail, pass, fail, pass, excp, pass};
194  evSelTest(ps_e, tr_05, false);
195 
196  // 06 - Wildcard positives, exception accepted
197  PathSpecifiers const ps_f{"a*2", "?p2"};
198  TrigResults tr_06{fail, pass, fail, fail, fail, fail, excp, fail};
199  evSelTest(ps_f, tr_06, true);
200  tr_06 = {fail, fail, fail, pass, fail, fail, fail, fail};
201  evSelTest(ps_f, tr_06, true);
202  tr_06 = {pass, fail, pass, fail, fail, pass, excp, excp};
203  evSelTest(ps_f, tr_06, true);
204  tr_06 = {pass, fail, pass, fail, pass, fail, pass, pass};
205  evSelTest(ps_f, tr_06, false);
206 
207  // 07 - Wildcard negatives, exception accepted
208  PathSpecifiers const ps_g{"!*2", "!ap?"};
209  TrigResults tr_07{fail, pass, fail, fail, fail, fail, fail, fail};
210  evSelTest(ps_g, tr_07, false);
211  tr_07 = {pass, fail, pass, fail, excp, fail, pass, fail};
212  evSelTest(ps_g, tr_07, true);
213  tr_07 = {fail, fail, pass, pass, fail, pass, excp, excp};
214  evSelTest(ps_g, tr_07, true);
215  tr_07 = {pass, fail, fail, fail, fail, fail, fail, redy};
216  evSelTest(ps_g, tr_07, false);
217 
218  // 08 - Wildcard positives, exception not accepted
219  PathSpecifiers const ps_h{"a*2&noexception", "?p2"};
220  TrigResults tr_08{fail, pass, fail, fail, fail, fail, excp, fail};
221  evSelTest(ps_h, tr_08, true);
222  tr_08 = {fail, fail, fail, pass, fail, fail, excp, fail};
223  evSelTest(ps_h, tr_08, false);
224  tr_08 = {pass, fail, pass, fail, fail, pass, excp, excp};
225  evSelTest(ps_h, tr_08, true);
226  tr_08 = {pass, fail, pass, fail, pass, fail, pass, pass};
227  evSelTest(ps_h, tr_08, false);
228  tr_08 = {excp, fail, pass, pass, pass, fail, pass, pass};
229  evSelTest(ps_h, tr_08, false);
230 
231  // 09 - Wildcard negatives, exception not accepted
232  PathSpecifiers const ps_i{"!*2&noexception"};
233  TrigResults tr_09{fail, pass, fail, fail, fail, fail, fail, fail};
234  evSelTest(ps_i, tr_09, false);
235  tr_09 = {pass, fail, pass, fail, excp, fail, pass, fail};
236  evSelTest(ps_i, tr_09, false);
237  tr_09 = {fail, fail, pass, pass, fail, pass, excp, excp};
238  evSelTest(ps_i, tr_09, false);
239  tr_09 = {pass, fail, fail, fail, fail, fail, fail, redy};
240  evSelTest(ps_i, tr_09, false);
241  tr_09 = {fail, fail, pass, fail, fail, fail, pass, fail};
242  evSelTest(ps_i, tr_09, true);
243 
244  // 10 - Everything except exceptions
245  PathSpecifiers const ps_j{"*&noexception", "!*&noexception"};
246  TrigResults tr_10{fail, pass, fail, fail, fail, fail, fail, fail};
247  evSelTest(ps_j, tr_10, true);
248  tr_10 = {pass, fail, pass, fail, excp, fail, pass, fail};
249  evSelTest(ps_j, tr_10, false);
250  tr_10 = {fail, fail, pass, pass, fail, pass, excp, excp};
251  evSelTest(ps_j, tr_10, false);
252  tr_10 = {fail, fail, fail, fail, fail, fail, fail, redy};
253  evSelTest(ps_j, tr_10, false);
254  tr_10 = {fail, fail, fail, fail, fail, fail, fail, fail};
255  evSelTest(ps_j, tr_10, true);
256  tr_10 = {pass, pass, pass, pass, pass, pass, pass, pass};
257  evSelTest(ps_j, tr_10, true);
258  tr_10 = {redy, redy, redy, redy, redy, redy, redy, redy};
259  evSelTest(ps_j, tr_10, false); // rejected because all Ready fails !*
260 
261  // 11 - Exception demanded
262  PathSpecifiers const ps_k{"exception@*"};
263  TrigResults tr_11{fail, pass, fail, fail, fail, fail, fail, fail};
264  evSelTest(ps_k, tr_11, false);
265  tr_11 = {pass, fail, pass, fail, excp, fail, pass, fail};
266  evSelTest(ps_k, tr_11, true);
267  tr_11 = {redy, redy, redy, redy, redy, redy, redy, excp};
268  evSelTest(ps_k, tr_11, true);
269  tr_11 = {pass, pass, pass, pass, pass, pass, pass, excp};
270  evSelTest(ps_k, tr_11, true);
271  tr_11 = {redy, redy, redy, redy, redy, redy, redy, redy};
272  evSelTest(ps_k, tr_11, false);
273  tr_11 = {pass, fail, fail, fail, fail, fail, fail, excp};
274  evSelTest(ps_k, tr_11, true);
275 
276  // 12 - Specific and wildcarded exceptions
277  PathSpecifiers const ps_m{"exception@a*", "exception@bp1"};
278  TrigResults tr_12{fail, pass, fail, fail, fail, fail, fail, fail};
279  evSelTest(ps_m, tr_12, false);
280  tr_12 = {pass, fail, pass, fail, excp, fail, pass, fail};
281  evSelTest(ps_m, tr_12, true);
282  tr_12 = {redy, redy, excp, redy, redy, redy, redy, excp};
283  evSelTest(ps_m, tr_12, true);
284  tr_12 = {pass, pass, pass, pass, pass, pass, pass, excp};
285  evSelTest(ps_m, tr_12, false);
286 
287  // 13 - Everything - also tests that it accepts all Ready
288  PathSpecifiers const ps_n{"*", "!*", "exception@*"};
289  TrigResults tr_13{fail, pass, fail, fail, fail, fail, fail, fail};
290  evSelTest(ps_n, tr_13, true);
291  tr_13 = {pass, pass, pass, pass, pass, pass, pass, pass};
292  evSelTest(ps_n, tr_13, true);
293  tr_13 = {redy, redy, redy, redy, redy, redy, redy, excp};
294  evSelTest(ps_n, tr_13, true);
295  tr_13 = {redy, redy, redy, redy, redy, redy, redy, redy};
296  evSelTest(ps_n, tr_13, true);
297  tr_13 = {pass, pass, pass, pass, pass, pass, pass, excp};
298  evSelTest(ps_n, tr_13, true);
299  tr_13 = {excp, excp, excp, excp, excp, excp, excp, excp};
300  evSelTest(ps_n, tr_13, true);
301  tr_13 = {fail, redy, redy, redy, redy, redy, redy, redy};
302  evSelTest(ps_n, tr_13, true);
303  tr_13 = {fail, fail, fail, fail, fail, fail, fail, fail};
304  evSelTest(ps_n, tr_13, true);
305 }
std::vector< std::string > PathSpecifiers
HLTPathStatus const pass
void evSelTest(PathSpecifiers const &path_specifiers, TrigResults const &tr, bool ans)
HLTPathStatus const fail
HLTPathStatus const redy
HLTPathStatus const excp
std::ostream& operator<< ( std::ostream &  ost,
const Strings strings 
)

Definition at line 62 of file EventSelExc_t.cpp.

63 {
64  for (auto const& element : strings) {
65  ost << element << " ";
66  }
67  return ost;
68 }
std::ostream& operator<< ( std::ostream &  ost,
const TrigResults tr 
)

Definition at line 71 of file EventSelExc_t.cpp.

72 {
73  for (unsigned int i = 0; i < tr.bit.size(); ++i) {
74  HLTPathStatus b = tr.bit[i];
75  if (b.state() == art::hlt::Ready)
76  ost << "ready ";
77  if (b.state() == art::hlt::Pass)
78  ost << "pass ";
79  if (b.state() == art::hlt::Fail)
80  ost << "fail ";
81  if (b.state() == art::hlt::Exception)
82  ost << "excp ";
83  }
84  return ost;
85 }
std::vector< HLTPathStatus > bit
static bool * b
Definition: config.cpp:1043
hlt::HLTState state() const

Variable Documentation

Definition at line 50 of file EventSelExc_t.cpp.

Definition at line 49 of file EventSelExc_t.cpp.

Definition at line 48 of file EventSelExc_t.cpp.

Definition at line 51 of file EventSelExc_t.cpp.

Strings const trigger_path_names
Initial value:
{"0:ap1",
"1:ap2",
"2:aq1",
"3:aq2",
"4:bp1",
"5:bp2",
"6:bq1",
"7:bq2"}

Definition at line 39 of file EventSelExc_t.cpp.