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 9 of file PtLUTReader.h.

Member Typedef Documentation

typedef uint64_t PtLUTReader::address_t

Definition at line 15 of file PtLUTReader.h.

typedef uint16_t PtLUTReader::content_t

Definition at line 14 of file PtLUTReader.h.

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

Definition at line 16 of file PtLUTReader.h.

Constructor & Destructor Documentation

PtLUTReader::PtLUTReader ( )
explicit

Definition at line 9 of file PtLUTReader.cc.

9  :
10  ptlut_(),
11  version_(4),
12  ok_(false)
13 {
14 
15 }
content_t version_
Definition: PtLUTReader.h:26
table_t ptlut_
Definition: PtLUTReader.h:25
PtLUTReader::~PtLUTReader ( )

Definition at line 17 of file PtLUTReader.cc.

17  {
18 
19 }

Member Function Documentation

content_t PtLUTReader::get_version ( ) const
inline

Definition at line 22 of file PtLUTReader.h.

References version_.

22 { return version_; }
content_t version_
Definition: PtLUTReader.h:26
PtLUTReader::content_t PtLUTReader::lookup ( const address_t address) const

Definition at line 67 of file PtLUTReader.cc.

References ptlut_.

Referenced by PtAssignmentEngine::calculate_pt_lut().

67  {
68  return ptlut_.at(address);
69 }
table_t ptlut_
Definition: PtLUTReader.h:25
void PtLUTReader::read ( const std::string &  lut_full_path)

Definition at line 21 of file PtLUTReader.cc.

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

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

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

Member Data Documentation

bool PtLUTReader::ok_
private

Definition at line 27 of file PtLUTReader.h.

Referenced by read().

table_t PtLUTReader::ptlut_
mutableprivate

Definition at line 25 of file PtLUTReader.h.

Referenced by lookup(), and read().

content_t PtLUTReader::version_
private

Definition at line 26 of file PtLUTReader.h.

Referenced by get_version(), and read().