artdaq
v2_03_02
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Pages
src
test
ArtModules
daq_flow_t.cc
1
#include "art/Framework/Art/artapp.h"
2
#include "artdaq-core/Data/Fragment.hh"
3
#include "artdaq/DAQdata/GenericFragmentSimulator.hh"
4
#include "artdaq/DAQrate/EventStore.hh"
5
#include "artdaq/Application/MPI2/MPISentry.hh"
6
#include "cetlib/exception.h"
7
#include "fhiclcpp/ParameterSet.h"
8
9
#include <cstddef>
10
#include <iostream>
11
#include <string>
12
#include <vector>
13
14
using
artdaq::EventStore
;
15
using
artdaq::FragmentPtrs;
16
using
artdaq::GenericFragmentSimulator
;
17
using
fhicl::ParameterSet;
18
using
std::size_t;
19
20
21
int
main(
int
argc,
char
* argv[])
22
{
23
artdaq::MPISentry
mpiSentry(&argc, &argv);
24
int
rc = -1;
25
try
26
{
27
size_t
const
NUM_FRAGS_PER_EVENT = 5;
28
EventStore::run_id_t
const
RUN_ID = 2112;
29
size_t
const
NUM_EVENTS = 100;
30
// We may want to add ParameterSet parsing to this code, but right
31
// now this will do...
32
ParameterSet sim_config;
33
sim_config.put(
"fragments_per_event"
, NUM_FRAGS_PER_EVENT);
34
sim_config.put(
"run_number"
, RUN_ID);
35
sim_config.put(
"print_event_store_stats"
,
true
);
36
sim_config.put(
"event_queue_wait_time"
, 10.0);
37
// Eventually, this test should make a mixed-up streams of
38
// Fragments; this has too clean a pattern to be an interesting
39
// test of the EventStore's ability to deal with multiple events
40
// simulatenously.
41
GenericFragmentSimulator
sim(sim_config);
42
EventStore
events(sim_config, NUM_FRAGS_PER_EVENT, RUN_ID, argc, argv, &artapp);
43
FragmentPtrs frags;
44
size_t
event_count = 0;
45
while
(frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
46
{
47
LOG_DEBUG(
"main"
) <<
"Number of fragments: "
<< frags.size() <<
'\n'
;
48
assert(frags.size() == NUM_FRAGS_PER_EVENT);
49
for
(
auto
&& frag : frags)
50
{
51
assert(frag !=
nullptr
);
52
events.insert(std::move(frag));
53
}
54
}
55
56
int
readerReturnValue;
57
bool
endSucceeded = events.endOfData(readerReturnValue);
58
if
(endSucceeded)
59
{
60
rc = readerReturnValue;
61
}
62
else
63
{
64
rc = 15;
65
}
66
}
67
catch
(cet::exception& x)
68
{
69
std::cerr << argv[0] <<
" failure\n"
<< x << std::endl;
70
rc = 1;
71
}
72
catch
(std::string& x)
73
{
74
std::cerr << argv[0] <<
" failure\n"
<< x << std::endl;
75
rc = 2;
76
}
77
catch
(
char
const
* x)
78
{
79
std::cerr << argv[0] <<
" failure\n"
<< x << std::endl;
80
rc = 3;
81
}
82
return
rc;
83
}
artdaq::MPISentry
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition:
MPISentry.hh:15
artdaq::GenericFragmentSimulator
GenericFragmentSimulator creates simulated Generic events, with data distributed according to a "hist...
Definition:
GenericFragmentSimulator.hh:26
artdaq::EventStore
The EventStore class collects Fragment objects, until it receives a complete event, at which point the event is handed over to the art thread.
Definition:
EventStore.hh:49
Generated on Wed Aug 16 2017 18:25:48 for artdaq by
1.8.5