Line data Source code
1 : /**
2 : * @file TDEFileCreator.cxx Create a binary file with TDE Frames for reading it from readout
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "fddetdataformats/TDE16Frame.hpp"
10 :
11 : #include <iostream>
12 : #include <fstream>
13 : #include <vector>
14 : #include <random>
15 : #include <algorithm>
16 :
17 : using namespace dunedaq;
18 :
19 0 : int main()
20 : {
21 0 : int num_batches = 5;
22 :
23 0 : std::ofstream out("frames.bin", std::ios::out | std::ios::binary);
24 :
25 0 : std::random_device rd;
26 0 : std::default_random_engine rng(rd());
27 :
28 :
29 0 : for (int batch = 0; batch < num_batches; batch++)
30 : {
31 0 : std::vector<fddetdataformats::TDE16Frame> v;
32 0 : uint64_t timestamp = batch;
33 0 : for (int amc = 0; amc < 12; amc++)
34 : {
35 0 : for (int i = 0; i < 64; i++)
36 : {
37 0 : fddetdataformats::TDE16Frame fr;
38 : // Timestamp
39 0 : fr.set_timestamp(timestamp);
40 : // Channel
41 0 : fr.get_daq_header()->slot_id = amc;
42 0 : fr.get_daq_header()->stream_id = i;
43 0 : fr.get_tde_header()->channel = i;
44 0 : fr.set_adc_sample(batch,0);
45 0 : v.push_back(fr);
46 : }
47 : }
48 0 : std::shuffle(v.begin(), v.end(), rng);
49 0 : for (auto& fr: v) {
50 0 : out.write(reinterpret_cast<char*>(&fr), sizeof(fddetdataformats::TDE16Frame));
51 : }
52 0 : }
53 0 : out.close();
54 :
55 0 : }
|