CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
MP7PacketReader Class Reference

#include <MP7PacketReader.h>

Public Types

typedef std::vector
< PacketData >::const_iterator 
const_iterator
 

Public Member Functions

const_iterator begin () const
 
const_iterator end () const
 
const PacketDataget (size_t i)
 
 MP7PacketReader (const std::string &path, uint32_t striphdr=0, uint32_t stripftr=0)
 
size_t size () const
 
bool valid () const
 
virtual ~MP7PacketReader ()
 

Private Member Functions

void load ()
 

Static Private Member Functions

static std::vector< PacketRangefindPackets (std::vector< uint64_t > data)
 

Private Attributes

std::vector< PacketDatabuffers_
 
uint32_t footer_
 
uint32_t header_
 
MP7FileReader reader_
 

Detailed Description

Definition at line 46 of file MP7PacketReader.h.

Member Typedef Documentation

Definition at line 48 of file MP7PacketReader.h.

Constructor & Destructor Documentation

MP7PacketReader::MP7PacketReader ( const std::string &  path,
uint32_t  striphdr = 0,
uint32_t  stripftr = 0 
)

Definition at line 9 of file MP7PacketReader.cc.

References load(), reader_, and MP7FileReader::valid().

9  : reader_( path ), header_(striphdr), footer_(stripftr) {
10  if ( !reader_.valid() ) return;
11  load();
12 }
tuple path
else: Piece not in the list, fine.
MP7FileReader reader_
bool valid() const
reader status. valid() == 1 indicates that data was successfully read from file
Definition: MP7FileReader.h:56
MP7PacketReader::~MP7PacketReader ( )
virtual

Definition at line 25 of file MP7PacketReader.cc.

25  {
26 }

Member Function Documentation

const_iterator MP7PacketReader::begin ( void  ) const
inline

Definition at line 60 of file MP7PacketReader.h.

References buffers_.

Referenced by findPackets().

60 { return buffers_.begin(); }
std::vector< PacketData > buffers_
const_iterator MP7PacketReader::end ( void  ) const
inline

Definition at line 62 of file MP7PacketReader.h.

References buffers_.

Referenced by Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), and findPackets().

62 { return buffers_.end(); }
std::vector< PacketData > buffers_
std::vector< PacketRange > MP7PacketReader::findPackets ( std::vector< uint64_t >  data)
staticprivate

Definition at line 87 of file MP7PacketReader.cc.

References begin(), end(), i, diffTwoXMLs::ranges, findQualityFiles::v, and x.

Referenced by load().

87  {
88  std::vector<PacketRange> ranges;
89  bool v = false;
90  int32_t begin(-1), end(-1);
91  for ( size_t i(0); i < data.size(); ++i) {
92  uint64_t x = data[i];
93  if (not v) {
94  if ((x >> 32) & 1) {
95  v = true;
96  begin = i;
97  }
98  continue;
99  } else {
100  if ( not ((x >> 32 ) & 1 ) ) {
101  v = false;
102  end = i-1;
103  ranges.push_back(std::make_pair(begin,end) );
104  }
105  continue;
106  }
107  }
108 
109  if ( v && (begin != -1 ) ) {
110  end = data.size()-1;
111  ranges.push_back(std::make_pair(begin,end) );
112  }
113 
114  return ranges;
115 
116 }
int i
Definition: DBlmapReader.cc:9
const_iterator end() const
string ranges
Definition: diffTwoXMLs.py:78
unsigned long long uint64_t
Definition: Time.h:15
const_iterator begin() const
const PacketData& MP7PacketReader::get ( size_t  i)
inline
void MP7PacketReader::load ( )
private

Definition at line 29 of file MP7PacketReader.cc.

References FileData::begin(), MP7FileReader::begin(), buffers_, AlCaHLTBitMon_QueryRunRegistry::data, FileData::end(), MP7FileReader::end(), findPackets(), Packet::first_, footer_, header_, relval_steps::k, Packet::last_, FileData::link(), Packet::links_, FileData::name(), PacketData::name_, AlCaHLTBitMon_ParallelJobs::p, PacketData::packets_, diffTwoXMLs::ranges, reader_, FileData::size(), and MP7FileReader::size().

Referenced by MP7PacketReader().

29  {
30 
31  buffers_.reserve(reader_.size());
33  for( ; it != reader_.end(); ++it ) {
34  const FileData& raw = *it;
35 
36  // Check channel alignment
37  std::set< std::vector<PacketRange > > rangeSet;
38 
39  for( size_t k(0); k<raw.size(); ++k) {
40  std::vector<PacketRange > ranges = findPackets(raw.link(0));
41  rangeSet.insert(ranges);
42  }
43  //cout << "Number of different patterns: " << rangeSet.size() << endl;
44  if ( rangeSet.size() != 1 )
45  throw std::runtime_error("Links are not aligned!");
46 
47  std::vector<PacketRange > pr = *(rangeSet.begin());
48 
49  // Create the container
51  data.name_ = raw.name();
52 
53  data.packets_.reserve(pr.size());
54 
55  // loop over the ranges to build packets
56  BOOST_FOREACH(PacketRange p, pr) {
57 
58  // Check if the header/footer zeroed the packet
59  if ( p.second-p.first-header_-footer_<= 0 ) {
60  // Turn this into an error message
61  //cout << "Error: packet length is zero (or less) after header/footer stripping. Skipping." << endl;
62  continue;
63  }
64 
65  Packet pkt;
66  FileData::const_iterator lIt = raw.begin();
67  for( ; lIt != raw.end(); ++lIt ) {
68  // Here the 64 bit uint is converted into a 32 bit uint, the data valid bit is stripped in the 64->32 bit conversion.
69  pkt.links_[lIt->first] = std::vector<uint32_t>(
70  lIt->second.begin() + p.first + header_,
71  lIt->second.begin() + p.second - footer_ + 1
72  );
73  }
74  pkt.first_ = p.first + header_;
75  pkt.last_ = p.second - footer_;
76 
77  data.packets_.push_back(pkt);
78  }
79 
80  buffers_.push_back(data);
81 
82 
83  }
84 }
LinkMap links_
const_iterator end()
vector&#39;s end iterator
Definition: MP7FileReader.h:71
std::string name_
LinkMap::const_iterator begin() const
Definition: MP7FileReader.h:34
size_t size() const
number of rawdata objects stored
Definition: MP7FileReader.h:74
size_t size() const
Definition: MP7FileReader.h:32
uint32_t last_
MP7FileReader reader_
std::vector< Packet > packets_
std::vector< PacketData > buffers_
std::pair< uint32_t, uint32_t > PacketRange
LinkMap::const_iterator const_iterator
Definition: MP7FileReader.h:26
string ranges
Definition: diffTwoXMLs.py:78
uint32_t first_
const std::string & name() const
Definition: MP7FileReader.h:28
LinkMap::const_iterator end() const
Definition: MP7FileReader.h:35
std::vector< FileData >::const_iterator const_iterator
expose vector&#39;s const iterator
Definition: MP7FileReader.h:49
const std::vector< uint64_t > & link(uint32_t i) const
static std::vector< PacketRange > findPackets(std::vector< uint64_t > data)
const_iterator begin()
vector&#39;s begin iterator
Definition: MP7FileReader.h:68
size_t MP7PacketReader::size ( void  ) const
inline

Definition at line 64 of file MP7PacketReader.h.

References buffers_.

64 { return buffers_.size(); }
std::vector< PacketData > buffers_
bool MP7PacketReader::valid ( ) const
inline

Definition at line 56 of file MP7PacketReader.h.

References reader_, and MP7FileReader::valid().

56 { return reader_.valid(); }
MP7FileReader reader_
bool valid() const
reader status. valid() == 1 indicates that data was successfully read from file
Definition: MP7FileReader.h:56

Member Data Documentation

std::vector< PacketData > MP7PacketReader::buffers_
private

Definition at line 71 of file MP7PacketReader.h.

Referenced by begin(), end(), get(), load(), and size().

uint32_t MP7PacketReader::footer_
private

Definition at line 74 of file MP7PacketReader.h.

Referenced by load().

uint32_t MP7PacketReader::header_
private

Definition at line 73 of file MP7PacketReader.h.

Referenced by load().

MP7FileReader MP7PacketReader::reader_
private

Definition at line 72 of file MP7PacketReader.h.

Referenced by load(), MP7PacketReader(), and valid().