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