CMS 3D CMS Logo

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, uint32_t ikey=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_
 
uint32_t ikey_
 
MP7FileReader reader_
 

Detailed Description

Definition at line 44 of file MP7PacketReader.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 46 of file MP7PacketReader.h.

Constructor & Destructor Documentation

◆ MP7PacketReader()

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

Definition at line 8 of file MP7PacketReader.cc.

9  : reader_(path), header_(striphdr), footer_(stripftr), ikey_(ikey) {
10  if (!reader_.valid())
11  return;
12  load();
13 }

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

◆ ~MP7PacketReader()

MP7PacketReader::~MP7PacketReader ( )
virtual

Definition at line 26 of file MP7PacketReader.cc.

26 {}

Member Function Documentation

◆ begin()

const_iterator MP7PacketReader::begin ( void  ) const
inline

Definition at line 58 of file MP7PacketReader.h.

58 { return buffers_.begin(); }

References buffers_.

Referenced by findPackets().

◆ end()

const_iterator MP7PacketReader::end ( void  ) const
inline

Definition at line 60 of file MP7PacketReader.h.

60 { return buffers_.end(); }

References buffers_.

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

◆ findPackets()

std::vector< PacketRange > MP7PacketReader::findPackets ( std::vector< uint64_t >  data)
staticprivate

Definition at line 79 of file MP7PacketReader.cc.

79  {
80  std::vector<PacketRange> ranges;
81  bool v = false;
82  int32_t begin(-1), end(-1);
83  for (size_t i(0); i < data.size(); ++i) {
84  uint64_t x = data[i];
85  if (not v) {
86  if ((x >> 32) & 1) {
87  v = true;
88  begin = i;
89  }
90  continue;
91  } else {
92  if (not((x >> 32) & 1)) {
93  v = false;
94  end = i - 1;
95  ranges.push_back(std::make_pair(begin, end));
96  }
97  continue;
98  }
99  }
100 
101  if (v && (begin != -1)) {
102  end = data.size() - 1;
103  ranges.push_back(std::make_pair(begin, end));
104  }
105 
106  return ranges;
107 }

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

Referenced by load().

◆ get()

const PacketData& MP7PacketReader::get ( size_t  i)
inline

◆ load()

void MP7PacketReader::load ( )
private

Definition at line 28 of file MP7PacketReader.cc.

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

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

Referenced by MP7PacketReader().

◆ size()

size_t MP7PacketReader::size ( void  ) const
inline

Definition at line 62 of file MP7PacketReader.h.

62 { return buffers_.size(); }

References buffers_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

◆ valid()

bool MP7PacketReader::valid ( ) const
inline

Definition at line 54 of file MP7PacketReader.h.

54 { return reader_.valid(); }

References reader_, and MP7FileReader::valid().

Member Data Documentation

◆ buffers_

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

Definition at line 68 of file MP7PacketReader.h.

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

◆ footer_

uint32_t MP7PacketReader::footer_
private

Definition at line 71 of file MP7PacketReader.h.

Referenced by load().

◆ header_

uint32_t MP7PacketReader::header_
private

Definition at line 70 of file MP7PacketReader.h.

Referenced by load().

◆ ikey_

uint32_t MP7PacketReader::ikey_
private

Definition at line 72 of file MP7PacketReader.h.

Referenced by load().

◆ reader_

MP7FileReader MP7PacketReader::reader_
private

Definition at line 69 of file MP7PacketReader.h.

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

diffTwoXMLs.ranges
string ranges
Definition: diffTwoXMLs.py:79
MP7PacketReader::findPackets
static std::vector< PacketRange > findPackets(std::vector< uint64_t > data)
Definition: MP7PacketReader.cc:79
mps_fire.i
i
Definition: mps_fire.py:428
FileData::name
const std::string & name() const
Definition: MP7FileReader.h:27
FileData
Definition: MP7FileReader.h:21
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MP7PacketReader::reader_
MP7FileReader reader_
Definition: MP7PacketReader.h:69
PacketData
Definition: MP7PacketReader.h:25
DDAxes::x
MP7FileReader::size
size_t size() const
number of rawdata objects stored
Definition: MP7FileReader.h:71
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FileData::link
const std::vector< uint64_t > & link(uint32_t i) const
Definition: MP7FileReader.cc:25
MP7PacketReader::buffers_
std::vector< PacketData > buffers_
Definition: MP7PacketReader.h:68
FileData::const_iterator
LinkMap::const_iterator const_iterator
Definition: MP7FileReader.h:25
FileData::size
size_t size() const
Definition: MP7FileReader.h:31
MP7FileReader::valid
bool valid() const
reader status. valid() == 1 indicates that data was successfully read from file
Definition: MP7FileReader.h:53
Packet::last_
uint32_t last_
Definition: MP7PacketReader.h:21
dqmdumpme.k
k
Definition: dqmdumpme.py:60
FileData::begin
LinkMap::const_iterator begin() const
Definition: MP7FileReader.h:33
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:39
MP7PacketReader::load
void load()
Definition: MP7PacketReader.cc:28
MP7PacketReader::header_
uint32_t header_
Definition: MP7PacketReader.h:70
FileData::end
LinkMap::const_iterator end() const
Definition: MP7FileReader.h:34
Packet::links_
LinkMap links_
Definition: MP7PacketReader.h:22
Packet::first_
uint32_t first_
Definition: MP7PacketReader.h:20
MP7FileReader::end
const_iterator end()
vector's end iterator
Definition: MP7FileReader.h:68
MP7FileReader::const_iterator
std::vector< FileData >::const_iterator const_iterator
expose vector's const iterator
Definition: MP7FileReader.h:46
MP7PacketReader::ikey_
uint32_t ikey_
Definition: MP7PacketReader.h:72
Packet
Definition: MP7PacketReader.h:15
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
MP7FileReader::begin
const_iterator begin()
vector's begin iterator
Definition: MP7FileReader.h:65
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
MP7PacketReader::footer_
uint32_t footer_
Definition: MP7PacketReader.h:71
MP7PacketReader::end
const_iterator end() const
Definition: MP7PacketReader.h:60
MP7PacketReader::begin
const_iterator begin() const
Definition: MP7PacketReader.h:58