CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
l1t::MicroGMTLUT Class Reference

#include <MicroGMTLUT.h>

Inheritance diagram for l1t::MicroGMTLUT:
l1t::MicroGMTAbsoluteIsolationCheckLUT l1t::MicroGMTCaloIndexSelectionLUT l1t::MicroGMTExtrapolationLUT l1t::MicroGMTMatchQualLUT l1t::MicroGMTRankPtQualLUT l1t::MicroGMTRelativeIsolationCheckLUT

Public Member Functions

int checkedInput (unsigned in, unsigned maxWidth) const
 
void contentsToStream (std::stringstream &stream)
 
void headerToStream (std::stringstream &stream) const
 
void initialize ()
 
void load (const std::string &inFileName)
 
virtual int lookupPacked (int input) const
 
 MicroGMTLUT ()
 
void save (std::ofstream &output)
 
virtual ~MicroGMTLUT ()
 

Protected Attributes

std::map< int, int > m_contents
 
std::string m_fname
 
bool m_initialized
 
std::vector
< MicroGMTConfiguration::input_t
m_inputs
 
unsigned m_outWidth
 
unsigned m_totalInWidth
 

Detailed Description

Definition at line 13 of file MicroGMTLUT.h.

Constructor & Destructor Documentation

l1t::MicroGMTLUT::MicroGMTLUT ( )
inline

Definition at line 15 of file MicroGMTLUT.h.

15 : m_totalInWidth(0), m_outWidth(0), m_initialized(false) {};
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:35
unsigned m_outWidth
Definition: MicroGMTLUT.h:36
virtual l1t::MicroGMTLUT::~MicroGMTLUT ( )
inlinevirtual

Definition at line 16 of file MicroGMTLUT.h.

16 {};

Member Function Documentation

int l1t::MicroGMTLUT::checkedInput ( unsigned  in,
unsigned  maxWidth 
) const

Definition at line 70 of file MicroGMTLUT.cc.

References SiStripMonitorClusterAlca_cfi::maxWidth.

71 {
72  unsigned maxIn = (1 << maxWidth) - 1;
73  return (in < maxIn ? in : maxIn);
74 }
void l1t::MicroGMTLUT::contentsToStream ( std::stringstream &  stream)

Definition at line 77 of file MicroGMTLUT.cc.

References recoMuon::in.

Referenced by save().

78 {
79  stream << "\"CONTENT\" : [ ";
80 
81  int maxVal = (1<<m_totalInWidth);
82  for (int in = 0; in < maxVal; ++in) {
83  stream << lookupPacked(in);
84  if (in != maxVal - 1) {
85  stream << ", ";
86  }
87  }
88  stream << "] " << std::endl;
89 }
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:35
virtual int lookupPacked(int input) const
Definition: MicroGMTLUT.cc:49
void l1t::MicroGMTLUT::headerToStream ( std::stringstream &  stream) const

Definition at line 92 of file MicroGMTLUT.cc.

Referenced by save().

93 {
94  stream << "{" << std::endl;
95  stream << "\"NAME\" : \"Name of the LUT\","<< std::endl;
96  stream << "\"INSTNACES\" : \"List (space separated) of instances of this LUT (differing contents but same in/output)\"," << std::endl;
97  stream << "\"INPUTS\" : \"List (space separated) of inputs in format <input_name>(<input_width>)\"," << std::endl;
98  stream << "\"OUTPUTS\" : \"List (space separated) of outputs in format <output_name>(<output_width>)\"," << std::endl;
99  stream << "\"IPBUS_ADD\" : \"Address for access via IPBus\"," << std::endl;
100  stream << "\"CONTENT_X\" : \"List (space separated) of outputs from packed int for zero-indexed instance X\"," << std::endl;
101 }
void l1t::MicroGMTLUT::initialize ( void  )

Definition at line 60 of file MicroGMTLUT.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by l1t::MicroGMTMatchQualLUT::MicroGMTMatchQualLUT(), and l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT().

61 {
62  for (int in = 0; in < (1 << m_totalInWidth); ++in) {
63  int out = lookupPacked(in);
64  m_contents[in] = out;
65  }
66  m_initialized = true;
67 }
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:35
std::map< int, int > m_contents
Definition: MicroGMTLUT.h:38
virtual int lookupPacked(int input) const
Definition: MicroGMTLUT.cc:49
tuple out
Definition: dbtoconf.py:99
void l1t::MicroGMTLUT::load ( const std::string &  inFileName)

Definition at line 18 of file MicroGMTLUT.cc.

References Exception, contentValuesFiles::fullPath, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by l1t::MicroGMTMatchQualLUT::MicroGMTMatchQualLUT(), and l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT().

18  {
19  std::ifstream fstream;
20  fstream.open(edm::FileInPath(inFileName.c_str()).fullPath());
21  if (!fstream.good()) {
22  fstream.close();
23  throw cms::Exception("FileOpenError") << "Failed to open LUT file: " << inFileName;
24  }
25 
26 
27  std::string lineID = "";
28 
29  while (!fstream.eof()) {
30  // read until either end of file is reached or the CONTENT line is found
31  lineID = "";
32  fstream >> lineID;
33  if (lineID.find("CONTENT_VECTOR") != std::string::npos) break;
34  }
35 
36  if (fstream.eof()) {
37  fstream.close();
38  throw cms::Exception("FileOpenError") << "Failed to find LUT contents";
39  }
40 
41  for (int cntr = 0; cntr < (1 << m_totalInWidth); ++cntr) {
42  fstream >> m_contents[cntr];
43  }
44  m_initialized = true;
45  fstream.close();
46 }
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:35
std::map< int, int > m_contents
Definition: MicroGMTLUT.h:38
int l1t::MicroGMTLUT::lookupPacked ( int  input) const
virtual

Reimplemented in l1t::MicroGMTMatchQualLUT, and l1t::MicroGMTRankPtQualLUT.

Definition at line 49 of file MicroGMTLUT.cc.

References Exception.

50 {
51  // sort to make sure the hash is correct?
52  if (m_initialized) {
53  return m_contents.at(input);
54  }
55  throw cms::Exception("Unitialized") << "If you're not loading a LUT from file you need to implement lookupPacked.";
56  return 0;
57 }
std::map< int, int > m_contents
Definition: MicroGMTLUT.h:38
static std::string const input
Definition: EdmProvDump.cc:43
void l1t::MicroGMTLUT::save ( std::ofstream &  output)

Definition at line 8 of file MicroGMTLUT.cc.

References contentsToStream(), headerToStream(), and dbtoconf::out.

Referenced by L1TMicroGMTLUTDumper::dumpLut().

9 {
10  std::stringstream out;
11  headerToStream(out);
12  contentsToStream(out);
13  out << "}" << std::endl;
14  output << out.str();
15 }
void contentsToStream(std::stringstream &stream)
Definition: MicroGMTLUT.cc:77
void headerToStream(std::stringstream &stream) const
Definition: MicroGMTLUT.cc:92
tuple out
Definition: dbtoconf.py:99

Member Data Documentation

std::map<int, int> l1t::MicroGMTLUT::m_contents
protected

Definition at line 38 of file MicroGMTLUT.h.

std::string l1t::MicroGMTLUT::m_fname
protected
bool l1t::MicroGMTLUT::m_initialized
protected

Definition at line 40 of file MicroGMTLUT.h.

std::vector<MicroGMTConfiguration::input_t> l1t::MicroGMTLUT::m_inputs
protected
unsigned l1t::MicroGMTLUT::m_outWidth
protected

Definition at line 36 of file MicroGMTLUT.h.

Referenced by l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT().

unsigned l1t::MicroGMTLUT::m_totalInWidth
protected