CMS 3D CMS Logo

MP7FileReader.h
Go to the documentation of this file.
1 /*
2  * File: MP7FileReader.h
3  * Author: ale
4  *
5  * Created on August 22, 2014, 10:30 AM
6  */
7 
8 #ifndef EventFilter_L1TRawToDigi_MP7FileReader_h
9 #define EventFilter_L1TRawToDigi_MP7FileReader_h
10 
11 // C++ Headers
12 #include <string>
13 #include <fstream>
14 #include <map>
15 #include <cstdint>
16 #include <vector>
17 
18 // Boost Headers
19 #include <boost/regex.hpp>
20 
21 class FileData {
22 public:
23  typedef std::map<uint32_t, std::vector<uint64_t> > LinkMap;
25  typedef LinkMap::const_iterator const_iterator;
26 
27  const std::string& name() const { return name_; }
28 
29  const std::vector<uint64_t>& link(uint32_t i) const;
30 
31  size_t size() const { return links_.size(); }
32 
33  LinkMap::const_iterator begin() const { return links_.begin(); }
34  LinkMap::const_iterator end() const { return links_.end(); }
35 
36 private:
38  LinkMap links_;
39 
40  friend class MP7FileReader;
41 };
42 
44 public:
46  typedef std::vector<FileData>::const_iterator const_iterator;
47 
49 
50  virtual ~MP7FileReader();
51 
53  bool valid() const { return valid_; }
54 
56  const std::string& path() const { return path_; }
57 
59  const FileData& get(size_t k) const;
60 
62  std::vector<std::string> names() const;
63 
65  const_iterator begin() { return buffers_.begin(); }
66 
68  const_iterator end() { return buffers_.end(); }
69 
71  size_t size() const { return buffers_.size(); }
72 
73 private:
74  std::string searchBoard();
75 
76  std::vector<uint32_t> searchLinks();
77 
78  std::vector<std::vector<uint64_t> > readRows();
79 
80  static uint64_t validStrToUint64(const std::string& token);
81 
82  void load();
83 
84  bool valid_;
86  std::ifstream file_;
87 
88 public:
89  std::vector<FileData> buffers_;
90 
91 private:
92  static boost::regex reBoard_;
93  static boost::regex reLink_;
94  static boost::regex reQuadChan_;
95  static boost::regex reFrame_;
96  static boost::regex reValid_;
97 };
98 
99 #endif /* READER_H */
static boost::regex reBoard_
Definition: MP7FileReader.h:92
static boost::regex reFrame_
Definition: MP7FileReader.h:95
std::ifstream file_
Definition: MP7FileReader.h:86
const_iterator end()
vector&#39;s end iterator
Definition: MP7FileReader.h:68
const std::string & path() const
source file path
Definition: MP7FileReader.h:56
LinkMap links_
Definition: MP7FileReader.h:38
static const uint16_t valid_
Definition: Constants.h:17
LinkMap::const_iterator begin() const
Definition: MP7FileReader.h:33
const std::string names[nVars_]
size_t size() const
number of rawdata objects stored
Definition: MP7FileReader.h:71
size_t size() const
Definition: MP7FileReader.h:31
static boost::regex reLink_
Definition: MP7FileReader.h:93
LinkMap::const_iterator const_iterator
Definition: MP7FileReader.h:25
LinkMap::value_type value_type
Definition: MP7FileReader.h:24
friend class MP7FileReader
Definition: MP7FileReader.h:40
std::string path_
Definition: MP7FileReader.h:85
std::string name_
Definition: MP7FileReader.h:37
static boost::regex reQuadChan_
Definition: MP7FileReader.h:94
unsigned long long uint64_t
Definition: Time.h:13
std::vector< FileData > buffers_
Definition: MP7FileReader.h:89
def load(fileName)
Definition: svgfig.py:547
std::string & path_
const std::string & name() const
Definition: MP7FileReader.h:27
LinkMap::const_iterator end() const
Definition: MP7FileReader.h:34
static boost::regex reValid_
Definition: MP7FileReader.h:96
std::vector< FileData >::const_iterator const_iterator
expose vector&#39;s const iterator
Definition: MP7FileReader.h:46
std::map< uint32_t, std::vector< uint64_t > > LinkMap
Definition: MP7FileReader.h:23
const std::vector< uint64_t > & link(uint32_t i) const
bool valid() const
reader status. valid() == 1 indicates that data was successfully read from file
Definition: MP7FileReader.h:53
const_iterator begin()
vector&#39;s begin iterator
Definition: MP7FileReader.h:65