CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PtLUTReader Class Reference

#include <PtLUTReader.h>

Public Types

typedef uint64_t address_t
 
typedef uint16_t content_t
 
typedef std::vector< content_ttable_t
 

Public Member Functions

content_t get_version () const
 
content_t lookup (const address_t &address) const
 
 PtLUTReader ()
 
void read (const std::string &lut_full_path)
 
 ~PtLUTReader ()
 

Private Attributes

bool ok_
 
table_t ptlut_
 
content_t version_
 

Detailed Description

Definition at line 8 of file PtLUTReader.h.

Member Typedef Documentation

◆ address_t

typedef uint64_t PtLUTReader::address_t

Definition at line 14 of file PtLUTReader.h.

◆ content_t

typedef uint16_t PtLUTReader::content_t

Definition at line 13 of file PtLUTReader.h.

◆ table_t

typedef std::vector<content_t> PtLUTReader::table_t

Definition at line 15 of file PtLUTReader.h.

Constructor & Destructor Documentation

◆ PtLUTReader()

PtLUTReader::PtLUTReader ( )
explicit

Definition at line 9 of file PtLUTReader.cc.

9 : ptlut_(), version_(4), ok_(false) {}

◆ ~PtLUTReader()

PtLUTReader::~PtLUTReader ( )

Definition at line 11 of file PtLUTReader.cc.

11 {}

Member Function Documentation

◆ get_version()

content_t PtLUTReader::get_version ( ) const
inline

Definition at line 21 of file PtLUTReader.h.

21 { return version_; }

References version_.

◆ lookup()

PtLUTReader::content_t PtLUTReader::lookup ( const address_t address) const

Definition at line 60 of file PtLUTReader.cc.

60 { return ptlut_.at(address); }

References ptlut_.

Referenced by PtAssignmentEngine::calculate_pt_lut().

◆ read()

void PtLUTReader::read ( const std::string &  lut_full_path)

Definition at line 13 of file PtLUTReader.cc.

13  {
14  if (ok_)
15  return;
16 
17  std::cout << "EMTF emulator: attempting to read pT LUT binary file from local area" << std::endl;
18  std::cout << lut_full_path << std::endl;
19  std::cout << "Non-standard operation; if it fails, now you know why" << std::endl;
20  std::cout << "Be sure to check that the 'scale_pt' function still matches this LUT" << std::endl;
21  std::cout << "Loading LUT, this might take a while..." << std::endl;
22 
23  std::ifstream infile(lut_full_path, std::ios::binary);
24  if (!infile.good()) {
25  char what[256];
26  snprintf(what, sizeof(what), "Fail to open %s", lut_full_path.c_str());
27  throw std::invalid_argument(what);
28  }
29 
30  ptlut_.reserve(PTLUT_SIZE);
31 
32  typedef uint64_t full_word_t;
33  full_word_t full_word;
34  full_word_t sub_word[4] = {0, 0, 0, 0};
35 
36  while (infile.read(reinterpret_cast<char*>(&full_word), sizeof(full_word_t))) {
37  sub_word[0] = (full_word >> 0) & 0x1FF; // 9-bit
38  sub_word[1] = (full_word >> 9) & 0x1FF;
39  sub_word[2] = (full_word >> 32) & 0x1FF;
40  sub_word[3] = (full_word >> (32 + 9)) & 0x1FF;
41 
42  ptlut_.push_back(sub_word[0]);
43  ptlut_.push_back(sub_word[1]);
44  ptlut_.push_back(sub_word[2]);
45  ptlut_.push_back(sub_word[3]);
46  }
47  infile.close();
48 
49  if (ptlut_.size() != PTLUT_SIZE) {
50  char what[256];
51  snprintf(what, sizeof(what), "ptlut_.size() is %lu != %i", ptlut_.size(), PTLUT_SIZE);
52  throw std::invalid_argument(what);
53  }
54 
55  version_ = ptlut_.at(0); // address 0 is the pT LUT version number
56  ok_ = true;
57  return;
58 }

References gather_cfg::cout, timingPdfMaker::infile, ok_, ptlut_, PTLUT_SIZE, and version_.

Referenced by PtAssignmentEngine::configure_details(), and edmIntegrityCheck.PublishToFileSystem::get().

Member Data Documentation

◆ ok_

bool PtLUTReader::ok_
private

Definition at line 26 of file PtLUTReader.h.

Referenced by read().

◆ ptlut_

table_t PtLUTReader::ptlut_
mutableprivate

Definition at line 24 of file PtLUTReader.h.

Referenced by lookup(), and read().

◆ version_

content_t PtLUTReader::version_
private

Definition at line 25 of file PtLUTReader.h.

Referenced by get_version(), and read().

gather_cfg.cout
cout
Definition: gather_cfg.py:144
PtLUTReader::version_
content_t version_
Definition: PtLUTReader.h:25
PtLUTReader::ok_
bool ok_
Definition: PtLUTReader.h:26
PTLUT_SIZE
#define PTLUT_SIZE
Definition: PtLUTReader.cc:7
PtLUTReader::ptlut_
table_t ptlut_
Definition: PtLUTReader.h:24
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:350
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13