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 std::string& fileExt,
28  const size_t framesPerBX,
29  const size_t tmux,
30  const size_t maxFramesPerFile,
31  const ChannelMap_t&);
32 
34  const std::string& filePath,
35  const std::string& fileExt,
36  const size_t framesPerBX,
37  const size_t tmux,
38  const size_t maxFramesPerFile,
39  const std::map<LinkId, std::vector<size_t>>&,
40  const std::map<std::string, ChannelSpec>&);
41 
42  // Set ID string that's written at start of board data files
43  void setBoardDataFileID(const std::string&);
44 
45  void addEvent(const EventData& data);
46 
47  // If there are events that have not been written to file, forces creation of a board data file containing them
48  void flush();
49 
50  private:
51  static ChannelMap_t mergeMaps(const std::map<LinkId, std::vector<size_t>>&,
52  const std::map<std::string, ChannelSpec>&);
53 
54  void resetBoardData();
55 
57 
58  // ID string that's written at start of board data files
60 
61  std::function<std::string(const size_t)> filePathGen_;
62 
63  std::vector<std::string> fileNames_;
64 
65  size_t framesPerBX_;
66 
67  size_t boardTMUX_;
68 
70 
72 
73  size_t eventIndex_;
74 
75  // Number of events stored in boardData_
77 
79 
80  // map of logical channel ID -> [TMUX period, interpacket-gap & offset; channel indices]
82  };
83 
84 } // namespace l1t::demo
85 
86 #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 std::string &fileExt, 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:80
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
void setBoardDataFileID(const std::string &)
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