artdaq
v3_00_01
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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/SharedMemoryEventManager.hh"
5
#include "artdaq/Application/MPI2/MPISentry.hh"
6
#include "cetlib/exception.h"
7
#include "fhiclcpp/make_ParameterSet.h"
8
#include "artdaq/Application/LoadParameterSet.hh"
9
10
#include <cstddef>
11
#include <iostream>
12
#include <string>
13
#include <vector>
14
15
using
artdaq::FragmentPtrs;
16
using
artdaq::GenericFragmentSimulator
;
17
using
artdaq::SharedMemoryEventManager
;
18
using
std::size_t;
19
20
21
int
main(
int
argc,
char
* argv[])
22
{
23
auto
pset = LoadParameterSet(argc, argv);
24
artdaq::MPISentry
mpiSentry(&argc, &argv);
25
int
rc = -1;
26
try
27
{
28
size_t
const
NUM_FRAGS_PER_EVENT = 5;
29
SharedMemoryEventManager::run_id_t
const
RUN_ID = 2112;
30
size_t
const
NUM_EVENTS = 100;
31
pset.put(
"expected_fragments_per_event"
, NUM_FRAGS_PER_EVENT);
32
pset.put(
"run_number"
, RUN_ID);
33
pset.put(
"print_event_store_stats"
,
true
);
34
pset.put(
"event_queue_wait_time"
, 10.0);
35
pset.put(
"max_event_size_bytes"
, 0x100000);
36
pset.put(
"buffer_count"
, 10);
37
pset.put(
"send_init_fragments"
,
false
);
38
39
auto
temp = pset.to_string() +
" source.waiting_time: 10"
;
40
pset = fhicl::ParameterSet();
41
fhicl::make_ParameterSet(temp, pset);
42
// Eventually, this test should make a mixed-up streams of
43
// Fragments; this has too clean a pattern to be an interesting
44
// test of the EventStore's ability to deal with multiple events
45
// simulatenously.
46
GenericFragmentSimulator
sim(pset);
47
SharedMemoryEventManager
events(pset, pset);
48
events.startRun(RUN_ID);
49
FragmentPtrs frags;
50
size_t
event_count = 0;
51
while
(frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
52
{
53
TLOG_DEBUG(
"daq_flow_t"
) <<
"Number of fragments: "
<< frags.size() << TLOG_ENDL;
54
assert(frags.size() == NUM_FRAGS_PER_EVENT);
55
for
(
auto
&& frag : frags)
56
{
57
assert(frag !=
nullptr
);
58
artdaq::FragmentPtr tempFrag;
59
auto
sts = events.AddFragment(std::move(frag), 1000000, tempFrag);
60
if
(!sts)
61
{
62
TLOG_ERROR(
"daq_flow_t"
) <<
"Fragment was not added after 1s. Check art thread status!"
<< TLOG_ENDL;
63
exit(1);
64
}
65
}
66
}
67
68
bool
endSucceeded = events.endOfData();
69
if
(endSucceeded)
70
{
71
rc = 0;
72
}
73
else
74
{
75
rc = 15;
76
}
77
}
78
catch
(cet::exception& x)
79
{
80
std::cerr << argv[0] <<
" failure\n"
<< x << std::endl;
81
rc = 1;
82
}
83
catch
(std::string& x)
84
{
85
std::cerr << argv[0] <<
" failure\n"
<< x << std::endl;
86
rc = 2;
87
}
88
catch
(
char
const
* x)
89
{
90
std::cerr << argv[0] <<
" failure\n"
<< x << std::endl;
91
rc = 3;
92
}
93
return
rc;
94
}
artdaq::SharedMemoryEventManager
The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built...
Definition:
SharedMemoryEventManager.hh:61
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
src
test
ArtModules
daq_flow_t.cc
Generated on Sat Jan 27 2018 10:43:22 for artdaq by
1.8.5