CMS 3D CMS Logo

MicroGMTLUT.cc
Go to the documentation of this file.
1 
5 
6 l1t::MicroGMTLUT::MicroGMTLUT(l1t::LUT* lut) : m_totalInWidth(0), m_outWidth(0), m_initialized(true) {
7  std::stringstream ss;
8  lut->write(ss);
9  read(ss);
10 }
11 
12 // I/O functions
13 void l1t::MicroGMTLUT::save(std::ofstream& output) { write(output); }
14 
15 int l1t::MicroGMTLUT::load(const std::string& inFileName) {
16  std::ifstream fstream;
17  fstream.open(edm::FileInPath(inFileName.c_str()).fullPath());
18  if (!fstream.good()) {
19  fstream.close();
20  throw cms::Exception("FileOpenError") << "Failed to open LUT file: " << inFileName;
21  }
22  int readCode = read(fstream);
23 
24  m_initialized = true;
25  fstream.close();
26 
27  return readCode;
28 }
29 
30 int l1t::MicroGMTLUT::lookupPacked(const int input) const {
31  if (m_initialized) {
32  return data((unsigned int)input);
33  }
34  throw cms::Exception("Uninitialized") << "If you're not loading a LUT from file you need to implement lookupPacked.";
35  return 0;
36 }
37 
39  if (empty()) {
40  std::stringstream stream;
41  stream << "#<header> V1 " << m_totalInWidth << " " << m_outWidth << " </header> " << std::endl;
42  for (int in = 0; in < (1 << m_totalInWidth); ++in) {
43  int out = lookupPacked(in);
44  stream << in << " " << out << std::endl;
45  }
46  read(stream);
47  }
48  m_initialized = true;
49 }
50 
51 int l1t::MicroGMTLUT::checkedInput(unsigned in, unsigned maxWidth) const {
52  unsigned maxIn = (1 << maxWidth) - 1;
53  return (in < maxIn ? in : maxIn);
54 }
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
l1t::MicroGMTLUT::lookupPacked
virtual int lookupPacked(int input) const
Definition: MicroGMTLUT.cc:30
l1t::MicroGMTLUT::initialize
void initialize()
Definition: MicroGMTLUT.cc:38
l1t::MicroGMTLUT::save
void save(std::ofstream &output)
Definition: MicroGMTLUT.cc:13
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:64
l1t::LUT::read
int read(std::istream &stream)
Definition: LUT.cc:11
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
l1t::MicroGMTLUT::checkedInput
int checkedInput(unsigned in, unsigned maxWidth) const
Definition: MicroGMTLUT.cc:51
recoMuon::in
Definition: RecoMuonEnumerators.h:6
l1t::MicroGMTLUT::MicroGMTLUT
MicroGMTLUT()
Definition: MicroGMTLUT.h:16
l1t::MicroGMTLUT::load
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:15
readEcalDQMStatus.read
read
Definition: readEcalDQMStatus.py:38
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
MicroGMTLUT.h
l1t::LUT
Definition: LUT.h:29
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
SiStripMonitorCluster_cfi.maxWidth
maxWidth
Definition: SiStripMonitorCluster_cfi.py:143
Exception.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
l1t::LUT::write
void write(std::ostream &stream) const
Definition: LUT.cc:65