CMS 3D CMS Logo

MP7PacketReader.h
Go to the documentation of this file.
1 /*
2  * File: MP7PacketReader.h
3  * Author: ale
4  *
5  * Created on August 22, 2014, 6:26 PM
6  */
7 
8 #ifndef EventFilter_L1TRawToDigi_MP7PacketReader_h
9 #define EventFilter_L1TRawToDigi_MP7PacketReader_h
10 
12 
13 typedef std::pair<uint32_t, uint32_t> PacketRange;
14 
15 class Packet {
16 public:
17  typedef std::map<uint32_t, std::vector<uint32_t> > LinkMap;
18 
19  size_t size() const { return last_ - first_ + 1; }
20  uint32_t first_;
21  uint32_t last_;
23 };
24 
25 class PacketData {
26 public:
27  const std::string& name() const { return name_; }
28 
29  typedef std::vector<Packet>::const_iterator const_iterator;
30 
31  const_iterator begin() const { return packets_.begin(); }
32 
33  const_iterator end() const { return packets_.end(); }
34 
35  size_t size() const { return packets_.size(); }
36 
37 private:
39  std::vector<Packet> packets_;
40 
41  friend class MP7PacketReader;
42 };
43 
45 public:
46  typedef std::vector<PacketData>::const_iterator const_iterator;
47 
48  MP7PacketReader(const std::string& path, uint32_t striphdr = 0, uint32_t stripftr = 0, uint32_t ikey = 0);
49 
50  // MP7PacketReader( MP7FileReader rdr, uint32_t striphdr = 0, uint32_t stripftr = 0);
51 
52  virtual ~MP7PacketReader();
53 
54  bool valid() const { return reader_.valid(); }
55 
56  const PacketData& get(size_t i) { return buffers_.at(i); }
57 
58  const_iterator begin() const { return buffers_.begin(); }
59 
60  const_iterator end() const { return buffers_.end(); }
61 
62  size_t size() const { return buffers_.size(); }
63 
64 private:
65  void load();
66  static std::vector<PacketRange> findPackets(std::vector<uint64_t> data);
67 
68  std::vector<PacketData> buffers_;
70  uint32_t header_;
71  uint32_t footer_;
72  uint32_t ikey_;
73 };
74 
75 #endif /* TMTREADER_H */
const_iterator begin() const
LinkMap links_
bool valid() const
reader status. valid() == 1 indicates that data was successfully read from file
Definition: MP7FileReader.h:53
virtual ~MP7PacketReader()
std::vector< PacketData > buffers_
std::string name_
bool valid() const
MP7PacketReader(const std::string &path, uint32_t striphdr=0, uint32_t stripftr=0, uint32_t ikey=0)
const std::string & name() const
uint32_t last_
size_t size() const
size_t size() const
MP7FileReader reader_
std::vector< Packet > packets_
const_iterator begin() const
std::vector< PacketData >::const_iterator const_iterator
std::pair< uint32_t, uint32_t > PacketRange
size_t size() const
const_iterator end() const
const_iterator end() const
uint32_t first_
std::vector< Packet >::const_iterator const_iterator
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::map< uint32_t, std::vector< uint32_t > > LinkMap
static std::vector< PacketRange > findPackets(std::vector< uint64_t > data)