CMS 3D CMS Logo

BoardDataWriter.h
Go to the documentation of this file.
1 
2 #ifndef L1Trigger_DemonstratorTools_BoardDataWriter_h
3 #define L1Trigger_DemonstratorTools_BoardDataWriter_h
4 
5 #include <functional>
6 
11 
12 namespace l1t::demo {
13 
14  // Writes I/O buffer files created from hardware/firmware tests, ensuring that
15  // the data conforms to the declared packet structure (by inserting invalid
16  // frames automatically), concatenating data from each event (accounting for
17  // different TM periods of specific links, and of the data-processor itself),
18  // and transparently switching to new output files when the data would overrun
19  // the length of the board's I/O buffers
21  public:
22  // map of logical channel ID -> [TMUX period, interpacket-gap & offset; channel indices]
23  typedef std::map<LinkId, std::pair<ChannelSpec, std::vector<size_t>>> ChannelMap_t;
24 
26  const std::string& filePath,
27  const size_t framesPerBX,
28  const size_t tmux,
29  const size_t maxFramesPerFile,
30  const ChannelMap_t&);
31 
33  const std::string& filePath,
34  const size_t framesPerBX,
35  const size_t tmux,
36  const size_t maxFramesPerFile,
37  const std::map<LinkId, std::vector<size_t>>&,
38  const std::map<std::string, ChannelSpec>&);
39 
40  void addEvent(const EventData& data);
41 
42  // If there are events that have not been written to file, forces creation of a board data file containing them
43  void flush();
44 
45  private:
46  static ChannelMap_t mergeMaps(const std::map<LinkId, std::vector<size_t>>&,
47  const std::map<std::string, ChannelSpec>&);
48 
49  void resetBoardData();
50 
52 
53  std::function<std::string(const size_t)> filePathGen_;
54 
55  std::vector<std::string> fileNames_;
56 
57  size_t framesPerBX_;
58 
59  size_t boardTMUX_;
60 
62 
64 
65  size_t eventIndex_;
66 
67  // Number of events stored in boardData_
69 
71 
72  // map of logical channel ID -> [TMUX period, interpacket-gap & offset; channel indices]
74  };
75 
76 } // namespace l1t::demo
77 
78 #endif
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
Definition: LinkId.h:10
BoardDataWriter(FileFormat, const std::string &filePath, const size_t framesPerBX, const size_t tmux, const size_t maxFramesPerFile, const ChannelMap_t &)
void addEvent(const EventData &data)
std::function< std::string(const size_t)> filePathGen_
static ChannelMap_t mergeMaps(const std::map< LinkId, std::vector< size_t >> &, const std::map< std::string, ChannelSpec > &)
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< std::string > fileNames_
Class representing information that&#39;s stored in the input or output buffers on a phase-2 board...
Definition: BoardData.h:13
Class representing information phase-2 ATCA I/O data corresponding to a single event, with logical channel IDs (essentially string-uint pairs, e.g. tracks-0 to tracks-17).
Definition: EventData.h:28