Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:15:09

0001 /* 
0002  * File:   MP7PacketReader.h
0003  * Author: ale
0004  *
0005  * Created on August 22, 2014, 6:26 PM
0006  */
0007 
0008 #ifndef EventFilter_L1TRawToDigi_MP7PacketReader_h
0009 #define EventFilter_L1TRawToDigi_MP7PacketReader_h
0010 
0011 #include "EventFilter/L1TRawToDigi/interface/MP7FileReader.h"
0012 
0013 typedef std::pair<uint32_t, uint32_t> PacketRange;
0014 
0015 class Packet {
0016 public:
0017   typedef std::map<uint32_t, std::vector<uint32_t> > LinkMap;
0018 
0019   size_t size() const { return last_ - first_ + 1; }
0020   uint32_t first_;
0021   uint32_t last_;
0022   LinkMap links_;
0023 };
0024 
0025 class PacketData {
0026 public:
0027   const std::string& name() const { return name_; }
0028 
0029   typedef std::vector<Packet>::const_iterator const_iterator;
0030 
0031   const_iterator begin() const { return packets_.begin(); }
0032 
0033   const_iterator end() const { return packets_.end(); }
0034 
0035   size_t size() const { return packets_.size(); }
0036 
0037 private:
0038   std::string name_;
0039   std::vector<Packet> packets_;
0040 
0041   friend class MP7PacketReader;
0042 };
0043 
0044 class MP7PacketReader {
0045 public:
0046   typedef std::vector<PacketData>::const_iterator const_iterator;
0047 
0048   MP7PacketReader(const std::string& path, uint32_t striphdr = 0, uint32_t stripftr = 0, uint32_t ikey = 0);
0049 
0050   //    MP7PacketReader( MP7FileReader rdr, uint32_t striphdr = 0, uint32_t stripftr = 0);
0051 
0052   virtual ~MP7PacketReader();
0053 
0054   bool valid() const { return reader_.valid(); }
0055 
0056   const PacketData& get(size_t i) { return buffers_.at(i); }
0057 
0058   const_iterator begin() const { return buffers_.begin(); }
0059 
0060   const_iterator end() const { return buffers_.end(); }
0061 
0062   size_t size() const { return buffers_.size(); }
0063 
0064 private:
0065   void load();
0066   static std::vector<PacketRange> findPackets(std::vector<uint64_t> data);
0067 
0068   std::vector<PacketData> buffers_;
0069   MP7FileReader reader_;
0070   uint32_t header_;
0071   uint32_t footer_;
0072   uint32_t ikey_;
0073 };
0074 
0075 #endif /* TMTREADER_H */