CMS 3D CMS Logo

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

#include <PtLUTWriter.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
 
 PtLUTWriter ()
 
void push_back (const content_t &pt)
 
void set_version (content_t ver)
 
void write (const std::string &lut_full_path, const uint16_t num_, const uint16_t denom_) const
 
 ~PtLUTWriter ()
 

Private Attributes

bool ok_
 
table_t ptlut_
 
content_t version_
 

Detailed Description

Definition at line 9 of file PtLUTWriter.h.

Member Typedef Documentation

typedef uint64_t PtLUTWriter::address_t

Definition at line 15 of file PtLUTWriter.h.

typedef uint16_t PtLUTWriter::content_t

Definition at line 14 of file PtLUTWriter.h.

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

Definition at line 16 of file PtLUTWriter.h.

Constructor & Destructor Documentation

PtLUTWriter::PtLUTWriter ( )
explicit

Definition at line 11 of file PtLUTWriter.cc.

References ptlut_, and PTLUT_SIZE.

11  :
12  ptlut_(),
13  version_(7), // Initial version, but not hard-coded: gets set by "set_version"
14  ok_(false)
15 {
16  ptlut_.reserve(PTLUT_SIZE / 64); // Hack! Hard-code / manually set denom_ for now - AWB 24.05.17
17 }
#define PTLUT_SIZE
Definition: PtLUTWriter.cc:9
content_t version_
Definition: PtLUTWriter.h:28
table_t ptlut_
Definition: PtLUTWriter.h:27
PtLUTWriter::~PtLUTWriter ( )

Definition at line 19 of file PtLUTWriter.cc.

19  {
20 
21 }

Member Function Documentation

content_t PtLUTWriter::get_version ( ) const
inline

Definition at line 24 of file PtLUTWriter.h.

References version_.

24 { return version_; }
content_t version_
Definition: PtLUTWriter.h:28
void PtLUTWriter::push_back ( const content_t pt)

Definition at line 73 of file PtLUTWriter.cc.

References ptlut_.

73  {
74  ptlut_.push_back(pt);
75 }
table_t ptlut_
Definition: PtLUTWriter.h:27
void PtLUTWriter::set_version ( content_t  ver)
inline

Definition at line 22 of file PtLUTWriter.h.

References version_.

22 { version_ = ver; }
content_t version_
Definition: PtLUTWriter.h:28
void PtLUTWriter::write ( const std::string &  lut_full_path,
const uint16_t  num_,
const uint16_t  denom_ 
) const

Definition at line 23 of file PtLUTWriter.cc.

References gather_cfg::cout, lumiCalc2::outfile, ptlut_, PTLUT_SIZE, and version_.

23  {
24  //if (ok_) return;
25  if (not(denom_ == 64)) // Check consistency for temporary hack - AWB 24.05.17
26  { edm::LogError("L1T") << "denom_ = " << denom_; return; }
27 
28  std::cout << "Writing LUT, this might take a while..." << std::endl;
29 
30  std::ofstream outfile(lut_full_path, std::ios::binary);
31  if (!outfile.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  if (ptlut_.size() != (PTLUT_SIZE / denom_)) {
38  char what[256];
39  snprintf(what, sizeof(what), "ptlut_.size() is %lu != %i", ptlut_.size(), PTLUT_SIZE);
40  throw std::invalid_argument(what);
41  }
42 
43  if (num_ == 1)
44  ptlut_.at(0) = version_; // address 0 is the pT LUT version number
45 
46  typedef uint64_t full_word_t;
47  full_word_t full_word;
48  full_word_t sub_word[4] = {0, 0, 0, 0};
49 
50  table_t::const_iterator ptlut_it = ptlut_.begin();
51  table_t::const_iterator ptlut_end = ptlut_.end();
52 
53  while (ptlut_it != ptlut_end) {
54  sub_word[0] = *ptlut_it++;
55  sub_word[1] = *ptlut_it++;
56  sub_word[2] = *ptlut_it++;
57  sub_word[3] = *ptlut_it++;
58 
59  full_word = 0;
60  full_word |= ((sub_word[0] & 0x1FF) << 0);
61  full_word |= ((sub_word[1] & 0x1FF) << 9);
62  full_word |= ((sub_word[2] & 0x1FF) << 32);
63  full_word |= ((sub_word[3] & 0x1FF) << (32+9));
64 
65  outfile.write(reinterpret_cast<char*>(&full_word), sizeof(full_word_t));
66  }
67  outfile.close();
68 
69  //ok_ = true;
70  return;
71 }
#define PTLUT_SIZE
Definition: PtLUTWriter.cc:9
content_t version_
Definition: PtLUTWriter.h:28
unsigned long long uint64_t
Definition: Time.h:15
table_t ptlut_
Definition: PtLUTWriter.h:27

Member Data Documentation

bool PtLUTWriter::ok_
private

Definition at line 29 of file PtLUTWriter.h.

table_t PtLUTWriter::ptlut_
mutableprivate

Definition at line 27 of file PtLUTWriter.h.

Referenced by PtLUTWriter(), push_back(), and write().

content_t PtLUTWriter::version_
private

Definition at line 28 of file PtLUTWriter.h.

Referenced by get_version(), set_version(), and write().