CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
HcalLutManager Class Reference

Various manipulations with trigger Lookup Tables. More...

#include <HcalLutManager.h>

Public Member Functions

void addLutMap (std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
 
int create_lut_loader (std::string file_list, std::string _prefix, std::string tag_name, std::string comment="default comment", std::string version="V00-01-01", int subversion=1)
 
int createAllLutXmlFiles (std::string _tag, std::string _lin_file, std::string _comp_file, bool split_by_crate=true)
 
int createAllLutXmlFilesFromCoder (const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
 
int createAllLutXmlFilesLinAsciiCompCoder (std::string _tag, std::string _lin_file, bool split_by_crate=true)
 
int createCompLutXmlFilesFromCoder (std::string _tag, bool split_by_crate=true)
 
int createLinLutXmlFiles (std::string _tag, std::string _lin_file, bool split_by_crate=true)
 
int createLutXmlFiles_HBEFFromCoder_HOFromAscii (std::string _tag, const HcalTPGCoder &_coder, std::string _lin_file, bool split_by_crate=true)
 
int createLutXmlFiles_HBEFFromCoder_HOFromAscii (std::string _tag, const HcalTPGCoder &_coder, const CaloTPGTranscoderULUT &_transcoder, std::string _lin_file, bool split_by_crate=true)
 
int createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC (std::string _tag, const HcalTPGCoder &_coder, const CaloTPGTranscoderULUT &_transcoder, std::string _lin_file, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > get_brickSet_from_oracle (std::string tag, const std::string _accessor="occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22")
 
std::string get_checksum (std::vector< unsigned int > &lut)
 
int get_xml_files_from_db (std::string tag, const std::string db_accessor="occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22", bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromAsciiMaster (std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder (std::string _tag, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder (const CaloTPGTranscoderULUT &_coder, std::string _tag, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getHEFineGrainLUTs (std::string _tag, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap (std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap_new (std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoder (const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap (const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
 
std::vector< unsigned int > getLutFromXml (std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt)
 
std::vector< unsigned int > getLutFromXml_old (std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt)
 
HcalLutSet getLutSetFromFile (std::string _filename, int _type=1)
 
std::string & getLutXml (std::vector< unsigned int > &_lut)
 
std::map< int, std::shared_ptr< LutXml > > getLutXmlFromAsciiMaster (std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getMasks (int var, std::string _tag, bool split_by_crate=true)
 
std::map< int, std::shared_ptr< LutXml > > getZdcLutXml (const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true, bool ootpu_lut=false)
 
 HcalLutManager ()
 
 HcalLutManager (std::vector< HcalGenericDetId > &map)
 
 HcalLutManager (const HcalElectronicsMap *_emap, const HcalChannelQuality *_cq=nullptr, uint32_t _status_word_to_mask=0x0000)
 
 HcalLutManager (const HcalDbService *conditions, const HcalChannelQuality *_cq=nullptr, uint32_t _status_word_to_mask=0x0000)
 
void init (void)
 
int initChannelIterator (std::vector< HcalGenericDetId > &map)
 
int local_connect (std::string lut_xml_file, std::string lmap_hbef_file, std::string lmap_ho_file)
 
int read_lmap (std::string lmap_hbef_file, std::string lmap_ho_file)
 
int read_luts (std::string lut_xml_file)
 
int test_direct_xml_parsing (std::string _filename)
 
void test_emap (void)
 
int test_xml_access (std::string _tag, std::string _filename)
 
int writeLutXmlFiles (std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
 
 ~HcalLutManager ()
 

Static Public Member Functions

static HcalSubdetector get_subdetector (std::string _subdet)
 
static std::string get_time_stamp (time_t _time)
 
static int getInt (std::string number)
 

Protected Attributes

HcalAssistant _ass
 
HcalChannelIterator _iter
 
const HcalDbServiceconditions
 
const HcalChannelQualitycq
 
HCALConfigDBdb
 
const HcalElectronicsMapemap
 
LMaplmap
 
XMLDOMBlocklut_checksums_xml
 
LutXmllut_xml
 
uint32_t status_word_to_mask
 

Detailed Description

Various manipulations with trigger Lookup Tables.

Author
Gena Kukartsev, Brown University, March 14, 2008

Definition at line 39 of file HcalLutManager.h.

Constructor & Destructor Documentation

◆ HcalLutManager() [1/4]

HcalLutManager::HcalLutManager ( void  )

Definition at line 46 of file HcalLutManager.cc.

References init.

46 { init(); }
void init(void)

◆ HcalLutManager() [2/4]

HcalLutManager::HcalLutManager ( std::vector< HcalGenericDetId > &  map)

Definition at line 48 of file HcalLutManager.cc.

References init, and genParticles_cff::map.

48  {
49  init();
50  _iter.init(map);
51 }
int init(const std::vector< HcalGenericDetId > &map)
HcalChannelIterator _iter
void init(void)

◆ HcalLutManager() [3/4]

HcalLutManager::HcalLutManager ( const HcalElectronicsMap _emap,
const HcalChannelQuality _cq = nullptr,
uint32_t  _status_word_to_mask = 0x0000 
)

Definition at line 53 of file HcalLutManager.cc.

References init.

55  {
56  init();
57  emap = _emap;
58  cq = _cq;
59  status_word_to_mask = _status_word_to_mask;
60 }
const HcalChannelQuality * cq
void init(void)
const HcalElectronicsMap * emap
uint32_t status_word_to_mask

◆ HcalLutManager() [4/4]

HcalLutManager::HcalLutManager ( const HcalDbService conditions,
const HcalChannelQuality _cq = nullptr,
uint32_t  _status_word_to_mask = 0x0000 
)

Definition at line 62 of file HcalLutManager.cc.

References submitPVValidationJobs::conditions, and init.

64  {
65  init();
66  conditions = _conditions;
68  cq = _cq;
69  status_word_to_mask = _status_word_to_mask;
70 }
const HcalElectronicsMap * getHcalMapping() const
const HcalChannelQuality * cq
void init(void)
const HcalElectronicsMap * emap
uint32_t status_word_to_mask
const HcalDbService * conditions

◆ ~HcalLutManager()

HcalLutManager::~HcalLutManager ( void  )

Definition at line 83 of file HcalLutManager.cc.

References dqmiodatasetharvest::db.

83  {
84  delete lut_xml;
85  delete lut_checksums_xml;
86  delete db;
87  delete lmap;
88 }
HCALConfigDB * db
XMLDOMBlock * lut_checksums_xml

Member Function Documentation

◆ addLutMap()

void HcalLutManager::addLutMap ( std::map< int, std::shared_ptr< LutXml > > &  result,
const std::map< int, std::shared_ptr< LutXml > > &  other 
)

Definition at line 1275 of file HcalLutManager.cc.

References genParticles_cff::map, trackingPlots::other, and mps_fire::result.

1276  {
1277  for (std::map<int, std::shared_ptr<LutXml>>::const_iterator lut = other.begin(); lut != other.end(); lut++) {
1278  edm::LogInfo("HcalLutManager") << "Added LUTs for crate " << lut->first;
1279  if (result.count(lut->first) == 0) {
1280  result.insert(*lut);
1281  } else {
1282  *(result[lut->first]) += *(lut->second);
1283  }
1284  }
1285 }
Log< level::Info, false > LogInfo

◆ create_lut_loader()

int HcalLutManager::create_lut_loader ( std::string  file_list,
std::string  _prefix,
std::string  tag_name,
std::string  comment = "default comment",
std::string  version = "V00-01-01",
int  subversion = 1 
)

Definition at line 1545 of file HcalLutManager.cc.

References findAndChange::_file, XMLLUTLoader::_checksumsDBConfig::comment_description, XMLProcessor::_loaderBaseConfig::comment_description, XMLLUTLoader::_lutDBConfig::crate, hcalRecHitTable_cff::doc, contentValuesCheck::file_name, getInt(), XMLProcessor::_loaderBaseConfig::iov_begin, XMLProcessor::_loaderBaseConfig::iov_end, XMLLUTLoader::_lutDBConfig::name_label, HcalQIEManager::splitString(), AlCaHLTBitMon_QueryRunRegistry::string, XMLProcessor::_DBConfig::subversion, XMLProcessor::_loaderBaseConfig::tag_name, hcalRecHitTable_cff::time, XMLLUTLoader::_lutDBConfig::trig_prim_lookuptbl_data_file, XMLLUTLoader::_checksumsDBConfig::trig_prim_lookuptbl_data_file, BeamSplash_cfg::version, and XMLProcessor::_DBConfig::version.

Referenced by main().

1550  {
1551  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs...";
1552  //std::cout << _prefix << "..." << tag_name << std::endl;
1553 
1557 
1558  baseConf.tag_name = tag_name;
1559  //baseConf . comment_description = tag_name;
1560  baseConf.comment_description = comment;
1561  baseConf.iov_begin = "1";
1562  baseConf.iov_end = "-1";
1563 
1564  conf.version = version;
1565 
1566  std::stringstream _subversion;
1567  _subversion << subversion;
1568  conf.subversion = _subversion.str();
1569 
1570  CSconf.version = conf.version;
1571  CSconf.subversion = conf.subversion;
1572  CSconf.trig_prim_lookuptbl_data_file = _prefix + "_checksums.xml.dat";
1573  CSconf.comment_description = tag_name;
1574 
1575  XMLLUTLoader doc(&baseConf);
1576 
1577  std::vector<int> crate_number;
1578  std::vector<std::string> file_name = HcalQIEManager::splitString(file_list);
1579  for (std::vector<std::string>::const_iterator _f = file_name.begin(); _f != file_name.end(); _f++) {
1580  int crate_begin = _f->rfind("_");
1581  int crate_end = _f->rfind(".xml.dat");
1582  crate_number.push_back(getInt(_f->substr(crate_begin + 1, crate_end - crate_begin - 1)));
1583  }
1584  //
1585  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1586  //
1587  char _buf[128];
1588  time_t _offset = time(nullptr);
1589  sprintf(_buf, "%d", (uint32_t)_offset);
1590  conf.version.append(".");
1591  conf.version.append(_buf);
1592  CSconf.version = conf.version;
1593  //
1594  for (std::vector<std::string>::const_iterator _file = file_name.begin(); _file != file_name.end(); _file++) {
1596  //conf . trig_prim_lookuptbl_data_file += ".dat";
1597  conf.crate = crate_number[_file - file_name.begin()];
1598  //
1599  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1600  //
1601  sprintf(_buf, "%.2d", conf.crate);
1602  conf.subversion.clear();
1603  conf.subversion.append(_buf);
1604  sprintf(_buf, "CRATE%.2d", conf.crate);
1605  std::string _namelabel;
1606  _namelabel.append(_buf);
1607  conf.name_label = _namelabel;
1608  doc.addLUT(&conf);
1609  }
1610 
1611  doc.addChecksums(&CSconf);
1612  //doc . write( _prefix + "_Loader.xml" );
1613  doc.write(tag_name + "_Loader.xml");
1614 
1615  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs... done.";
1616 
1617  return 0;
1618 }
static std::vector< std::string > splitString(const std::string &fLine)
Log< level::Info, false > LogInfo
static int getInt(std::string number)
std::string trig_prim_lookuptbl_data_file
Definition: XMLLUTLoader.h:38

◆ createAllLutXmlFiles()

int HcalLutManager::createAllLutXmlFiles ( std::string  _tag,
std::string  _lin_file,
std::string  _comp_file,
bool  split_by_crate = true 
)

Definition at line 1124 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1127  {
1128  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1129  std::map<int, std::shared_ptr<LutXml>> xml;
1130  if (!lut_checksums_xml) {
1131  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1132  }
1133 
1134  if (!_lin_file.empty()) {
1135  //addLutMap( xml, getLutXmlFromAsciiMaster( _lin_file, _tag, -1, split_by_crate ) );
1136  addLutMap(xml, getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate));
1137  }
1138  if (!_comp_file.empty()) {
1139  //std::cout << "DEBUG1!!!!" << std::endl;
1140  addLutMap(xml, getCompressionLutXmlFromAsciiMaster(_comp_file, _tag, -1, split_by_crate));
1141  //std::cout << "DEBUG2!!!!" << std::endl;
1142  }
1143  writeLutXmlFiles(xml, _tag, split_by_crate);
1144 
1145  std::string checksums_file = _tag + "_checksums.xml";
1146  lut_checksums_xml->write(checksums_file);
1147 
1148  return 0;
1149 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromAsciiMaster(std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)

◆ createAllLutXmlFilesFromCoder()

int HcalLutManager::createAllLutXmlFilesFromCoder ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1168 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1168  {
1169  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1170  std::map<int, std::shared_ptr<LutXml>> xml;
1171  if (!lut_checksums_xml) {
1172  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1173  }
1174 
1175  //addLutMap( xml, getLinearizationLutXmlFromCoder( _coder, _tag, split_by_crate ) );
1176  addLutMap(xml, getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate));
1177  addLutMap(xml, getCompressionLutXmlFromCoder(_tag, split_by_crate));
1178 
1179  writeLutXmlFiles(xml, _tag, split_by_crate);
1180 
1181  std::string checksums_file = _tag + "_checksums.xml";
1182  lut_checksums_xml->write(checksums_file);
1183 
1184  return 0;
1185 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml

◆ createAllLutXmlFilesLinAsciiCompCoder()

int HcalLutManager::createAllLutXmlFilesLinAsciiCompCoder ( std::string  _tag,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1254 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1256  {
1257  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1258  std::map<int, std::shared_ptr<LutXml>> xml;
1259  if (!lut_checksums_xml) {
1260  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1261  }
1262 
1263  if (!_lin_file.empty()) {
1264  addLutMap(xml, getLutXmlFromAsciiMaster(_lin_file, _tag, -1, split_by_crate));
1265  }
1266  addLutMap(xml, getCompressionLutXmlFromCoder(_tag, split_by_crate));
1267  writeLutXmlFiles(xml, _tag, split_by_crate);
1268 
1269  std::string checksums_file = _tag + "_checksums.xml";
1270  lut_checksums_xml->write(checksums_file);
1271 
1272  return 0;
1273 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, std::shared_ptr< LutXml > > getLutXmlFromAsciiMaster(std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)

◆ createCompLutXmlFilesFromCoder()

int HcalLutManager::createCompLutXmlFilesFromCoder ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1151 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1151  {
1152  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1153  std::map<int, std::shared_ptr<LutXml>> xml;
1154  if (!lut_checksums_xml) {
1155  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1156  }
1157 
1158  addLutMap(xml, getCompressionLutXmlFromCoder(_tag, split_by_crate));
1159 
1160  writeLutXmlFiles(xml, _tag, split_by_crate);
1161 
1162  std::string checksums_file = _tag + "_checksums.xml";
1163  lut_checksums_xml->write(checksums_file);
1164 
1165  return 0;
1166 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml

◆ createLinLutXmlFiles()

int HcalLutManager::createLinLutXmlFiles ( std::string  _tag,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1106 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1106  {
1107  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1108  std::map<int, std::shared_ptr<LutXml>> xml;
1109  if (!lut_checksums_xml) {
1110  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1111  }
1112 
1113  if (!_lin_file.empty()) {
1114  addLutMap(xml, getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate));
1115  }
1116  writeLutXmlFiles(xml, _tag, split_by_crate);
1117 
1118  std::string checksums_file = _tag + "_checksums.xml";
1119  lut_checksums_xml->write(checksums_file);
1120 
1121  return 0;
1122 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)

◆ createLutXmlFiles_HBEFFromCoder_HOFromAscii() [1/2]

int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii ( std::string  _tag,
const HcalTPGCoder _coder,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1224 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1227  {
1228  std::map<int, std::shared_ptr<LutXml>> xml;
1229  if (!lut_checksums_xml) {
1230  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1231  }
1232 
1233  if (!_lin_file.empty()) {
1234  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_ascii_xml =
1235  getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate);
1236  addLutMap(xml, _lin_lut_ascii_xml);
1237  }
1238  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_xml =
1239  getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate);
1240  addLutMap(xml, _lin_lut_xml);
1241  //
1242  const std::map<int, std::shared_ptr<LutXml>> _comp_lut_xml = getCompressionLutXmlFromCoder(_tag, split_by_crate);
1243  addLutMap(xml, _comp_lut_xml);
1244 
1245  writeLutXmlFiles(xml, _tag, split_by_crate);
1246 
1247  std::string checksums_file = _tag + "_checksums.xml";
1248  lut_checksums_xml->write(checksums_file);
1249 
1250  return 0;
1251 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)

◆ createLutXmlFiles_HBEFFromCoder_HOFromAscii() [2/2]

int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii ( std::string  _tag,
const HcalTPGCoder _coder,
const CaloTPGTranscoderULUT _transcoder,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1190 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1194  {
1195  std::map<int, std::shared_ptr<LutXml>> xml;
1196  if (!lut_checksums_xml) {
1197  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1198  }
1199 
1200  if (!_lin_file.empty()) {
1201  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_ascii_xml =
1202  getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate);
1203  addLutMap(xml, _lin_lut_ascii_xml);
1204  }
1205  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_xml =
1206  getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate);
1207  addLutMap(xml, _lin_lut_xml);
1208  //
1209  const std::map<int, std::shared_ptr<LutXml>> _comp_lut_xml =
1210  getCompressionLutXmlFromCoder(_transcoder, _tag, split_by_crate);
1211  addLutMap(xml, _comp_lut_xml);
1212 
1213  const std::map<int, std::shared_ptr<LutXml>> _HE_FG_lut_xml = getHEFineGrainLUTs(_tag, split_by_crate);
1214  addLutMap(xml, _HE_FG_lut_xml);
1215 
1216  writeLutXmlFiles(xml, _tag, split_by_crate);
1217 
1218  std::string checksums_file = _tag + "_checksums.xml";
1219  lut_checksums_xml->write(checksums_file);
1220 
1221  return 0;
1222 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, std::shared_ptr< LutXml > > getHEFineGrainLUTs(std::string _tag, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)

◆ createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC()

int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC ( std::string  _tag,
const HcalTPGCoder _coder,
const CaloTPGTranscoderULUT _transcoder,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1677 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HcalLutGenerator::analyze().

1681  {
1682  std::map<int, std::shared_ptr<LutXml>> xml;
1683  if (!lut_checksums_xml) {
1684  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1685  }
1686 
1687  if (!_lin_file.empty()) {
1688  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_ascii_xml =
1689  getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate);
1690  addLutMap(xml, _lin_lut_ascii_xml);
1691  }
1692  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_xml =
1693  getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate);
1694  addLutMap(xml, _lin_lut_xml);
1695  //
1696  const std::map<int, std::shared_ptr<LutXml>> _comp_lut_xml =
1697  getCompressionLutXmlFromCoder(_transcoder, _tag, split_by_crate);
1698  addLutMap(xml, _comp_lut_xml);
1699 
1700  const std::map<int, std::shared_ptr<LutXml>> _HE_FG_lut_xml = getHEFineGrainLUTs(_tag, split_by_crate);
1701  addLutMap(xml, _HE_FG_lut_xml);
1702 
1703  for (auto masktype : {0, 1, 2}) {
1704  const auto masks = getMasks(masktype, _tag, split_by_crate);
1705  addLutMap(xml, masks);
1706  }
1707  //
1708  const auto _zdc_lut_xml = getZdcLutXml(_coder, _tag, split_by_crate, false);
1709  addLutMap(xml, _zdc_lut_xml);
1710 
1711  const auto _zdc_ootpu_lut_xml = getZdcLutXml(_coder, _tag, split_by_crate, true);
1712  addLutMap(xml, _zdc_ootpu_lut_xml);
1713 
1714  writeLutXmlFiles(xml, _tag, split_by_crate);
1715 
1716  std::string checksums_file = _tag + "_checksums.xml";
1717  lut_checksums_xml->write(checksums_file);
1718 
1719  return 0;
1720 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
std::map< int, std::shared_ptr< LutXml > > getZdcLutXml(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true, bool ootpu_lut=false)
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, std::shared_ptr< LutXml > > getHEFineGrainLUTs(std::string _tag, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > getMasks(int var, std::string _tag, bool split_by_crate=true)

◆ get_brickSet_from_oracle()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::get_brickSet_from_oracle ( std::string  tag,
const std::string  _accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22" 
)

Definition at line 1474 of file HcalLutManager.cc.

References cms::cuda::bs, FCDTask_cfi::crate, dqmiodatasetharvest::db, MillePedeFileConverter_cfg::e, XMLProcessor::getInstance(), AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, and toolbox::toString().

1475  {
1476  HCALConfigDB* db = new HCALConfigDB();
1477  XMLProcessor::getInstance(); // initialize xerces-c engine
1478  //const std::string _accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22";
1479  db->connect(_accessor);
1480  oracle::occi::Connection* _connection = db->getConnection();
1481 
1482  edm::LogInfo("HcalLutManager") << "Preparing to request the LUT CLOBs from the database...";
1483 
1484  //int crate = 0;
1485 
1486  //
1487  // _____ query is different for the old validation DB _________________
1488  //
1489  //std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_TRIG_LOOKUP_TABLES");
1490  std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_COND.V_HCAL_TRIG_LOOKUP_TABLES");
1491  //query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d", tag.c_str(), crate);
1492  query += toolbox::toString(" WHERE TAG_NAME='%s'", tag.c_str());
1493 
1494  std::string brick_set;
1495 
1496  std::map<int, std::shared_ptr<LutXml>> lut_map;
1497 
1498  try {
1499  //SELECT
1500  edm::LogInfo("HcalLutManager") << "Executing the query...";
1501  Statement* stmt = _connection->createStatement();
1502  ResultSet* rs = stmt->executeQuery(query);
1503  edm::LogInfo("HcalLutManager") << "Executing the query... done";
1504 
1505  edm::LogInfo("HcalLutManager") << "Processing the query results...";
1506  //RooGKCounter _lines;
1507  while (rs->next()) {
1508  //_lines.count();
1509  oracle::occi::Clob clob = rs->getClob(1);
1510  int crate = rs->getInt(2);
1511  if (crate != -1) { // not a brick with checksums
1512  edm::LogInfo("HcalLutManager") << "Getting LUTs for crate #" << crate << " out of the database...";
1513  brick_set = db->clobToString(clob);
1514  /*
1515  // FIXME: DEBUG lut xml files from simple strings
1516  stringstream file_name;
1517  ofstream out_file;
1518  file_name << tag << "_" << crate << "_debug" << ".xml";
1519  out_file . open( file_name.str().c_str() );
1520  out_file << brick_set;
1521  out_file . close();
1522  */
1523  const char* bs = brick_set.c_str();
1524  MemBufInputSource* lut_clob = new MemBufInputSource((const XMLByte*)bs, strlen(bs), "lut_clob", false);
1525  std::shared_ptr<LutXml> lut_xml = std::make_shared<LutXml>(*lut_clob);
1526  lut_map[crate] = lut_xml;
1527  edm::LogInfo("HcalLutManager") << "done";
1528  }
1529  }
1530  //Always terminate statement
1531  _connection->terminateStatement(stmt);
1532  //std::cout << "Query line count: " << _lines.getCount() << std::endl;
1533  } catch (SQLException& e) {
1534  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
1535  ::toolbox::toString("Oracle exception : %s", e.getMessage().c_str()));
1536  }
1537 
1538  //std::cout << lut_map.size() << std::endl;
1539 
1540  db->disconnect();
1541  //delete db;
1542  return lut_map;
1543 }
void disconnect(void)
Definition: HCALConfigDB.cc:76
HCALConfigDB * db
Definition: query.py:1
oracle::occi::Connection * getConnection(void)
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
Gather config data from online DB.
Definition: HCALConfigDB.h:20
Log< level::Info, false > LogInfo
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:48
std::string clobToString(const oracle::occi::Clob &)
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134

◆ get_checksum()

std::string HcalLutManager::get_checksum ( std::vector< unsigned int > &  lut)

◆ get_subdetector()

HcalSubdetector HcalLutManager::get_subdetector ( std::string  _subdet)
static

Definition at line 117 of file HcalLutManager.cc.

References HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, and mps_fire::result.

117  {
119  if (_det.find("HB") != std::string::npos)
120  result = HcalBarrel;
121  else if (_det.find("HE") != std::string::npos)
122  result = HcalEndcap;
123  else if (_det.find("HF") != std::string::npos)
125  else if (_det.find("HO") != std::string::npos)
126  result = HcalOuter;
127  else
128  result = HcalOther;
129 
130  return result;
131 }
HcalSubdetector
Definition: HcalAssistant.h:31

◆ get_time_stamp()

string HcalLutManager::get_time_stamp ( time_t  _time)
static

Definition at line 1287 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1287  {
1288  char timebuf[50];
1289  //strftime( timebuf, 50, "%c", gmtime( &_time ) );
1290  strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S", gmtime(&_time));
1291  std::string creationstamp = timebuf;
1292 
1293  return creationstamp;
1294 }

◆ get_xml_files_from_db()

int HcalLutManager::get_xml_files_from_db ( std::string  tag,
const std::string  db_accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22",
bool  split_by_crate = true 
)

Definition at line 1457 of file HcalLutManager.cc.

References genParticles_cff::map, DeadROCCounter::out_file, mps_fire::result, and makeGlobalPositionRcd_cfg::tag.

1457  {
1458  std::map<int, std::shared_ptr<LutXml>> lut_map = get_brickSet_from_oracle(tag, db_accessor);
1459  if (split_by_crate) {
1460  writeLutXmlFiles(lut_map, tag, split_by_crate);
1461  } else {
1462  LutXml result;
1463  for (std::map<int, std::shared_ptr<LutXml>>::const_iterator xml = lut_map.begin(); xml != lut_map.end(); xml++) {
1464  result += *(xml->second);
1465  }
1466  std::stringstream out_file;
1467  out_file << tag << ".xml";
1468  result.write(out_file.str());
1469  }
1470 
1471  return 0;
1472 }
Definition: LutXml.h:27
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
std::map< int, std::shared_ptr< LutXml > > get_brickSet_from_oracle(std::string tag, const std::string _accessor="occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22")

◆ getCompressionLutXmlFromAsciiMaster()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromAsciiMaster ( std::string  _filename,
std::string  _tag,
int  _crate = -1,
bool  split_by_crate = true 
)

Definition at line 515 of file HcalLutManager.cc.

References funct::abs(), RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, HcalLutSet::eta_max, HcalLutSet::eta_min, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), CaloTPGTranscoderULUT::HTvalid(), mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

518  {
519  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from ascii master file...";
520  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
521 
522  edm::LogInfo("HcalLutManager")
523  << "instantiating CaloTPGTranscoderULUT in order to check the validity of (ieta,iphi)...";
524  CaloTPGTranscoderULUT _coder;
525 
526  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
527  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
528  EMap _emap(emap);
529  std::vector<EMap::EMapRow>& _map = _emap.get_map();
530  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
531 
532  // read LUTs and their eta/phi/depth/subdet ranges
533  HcalLutSet _set = getLutSetFromFile(_filename, 2);
534  int lut_set_size = _set.lut.size(); // number of different luts
535  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
536 
537  //loop over all EMap channels
538  RooGKCounter _counter;
539  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
540  LutXml::Config _cfg;
541 
542  // search for the correct LUT for a given channel,
543  // higher LUT numbers have priority in case of overlapping
544  int lut_index = -1;
545  for (int i = 0; i < lut_set_size; i++) {
546  if (row->subdet.find("HT") != std::string::npos &&
547  (row->crate == _crate || _crate == -1) && // -1 stands for all crates
548  _set.eta_min[i] <= row->ieta && _set.eta_max[i] >= row->ieta && _set.phi_min[i] <= row->iphi &&
549  _set.phi_max[i] >= row->iphi && _coder.HTvalid(row->ieta, row->iphi, row->idepth / 10)) {
550  lut_index = i;
551  }
552  }
553  if (lut_index >= 0) {
554  if (_xml.count(row->crate) == 0 && split_by_crate) {
555  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
556  } else if (_xml.count(0) == 0 && !split_by_crate) {
557  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
558  }
559  _cfg.ieta = row->ieta;
560  _cfg.iphi = row->iphi;
561  _cfg.depth = row->idepth;
562  _cfg.crate = row->crate;
563  _cfg.slot = row->slot;
564  if (row->topbottom.find('t') != std::string::npos)
565  _cfg.topbottom = 1;
566  else if (row->topbottom.find('b') != std::string::npos)
567  _cfg.topbottom = 0;
568  else if (row->topbottom.find('u') != std::string::npos)
569  _cfg.topbottom = 2;
570  else
571  edm::LogWarning("HcalLutManager") << "fpga out of range...";
572  _cfg.fiber = row->fiber;
573  _cfg.fiberchan = row->fiberchan;
574  if (_set.lut[lut_index].size() == 128)
575  _cfg.lut_type = 1;
576  else
577  _cfg.lut_type = 2;
578  _cfg.creationtag = _tag;
579  _cfg.creationstamp = get_time_stamp(time(nullptr));
580  _cfg.targetfirmware = "1.0.0";
581  _cfg.formatrevision = "1"; //???
582  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
583  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
584  // ((id.ieta()<0)?(0):(100));
585  _cfg.generalizedindex = _cfg.iphi * 10000 + (row->ieta > 0) * 100 + abs(row->ieta);
586  _cfg.lut = _set.lut[lut_index];
587  if (split_by_crate) {
588  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
589  _counter.count();
590  } else {
591  _xml[0]->addLut(_cfg, lut_checksums_xml);
592  _counter.count();
593  }
594  }
595  }
596  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
597  << "Generating compression (output) LUTs from ascii master file...DONE" << std::endl;
598  return _xml;
599 }
std::vector< std::vector< unsigned int > > lut
std::string targetfirmware
Definition: LutXml.h:36
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:37
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
std::vector< int > phi_min
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalLutSet getLutSetFromFile(std::string _filename, int _type=1)
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
std::vector< int > eta_max
Definition: LMap.h:80
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32
std::vector< int > eta_min

◆ getCompressionLutXmlFromCoder() [1/2]

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromCoder ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1012 of file HcalLutManager.cc.

References funct::abs(), RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), CaloTPGTranscoderULUT::getCompressionLUT(), RooGKCounter::getCount(), CaloTPGTranscoderULUT::HTvalid(), LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

1013  {
1014  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT";
1015  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
1016 
1017  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1018  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1019  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1020  EMap _emap(emap);
1021 
1022  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1023  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
1024 
1025  // read LUTs and their eta/phi/depth/subdet ranges
1026  //HcalLutSet _set = getLutSetFromFile( _filename, 2 );
1027  //int lut_set_size = _set.lut.size(); // number of different luts
1028 
1029  CaloTPGTranscoderULUT _coder;
1030 
1031  //loop over all EMap channels
1032  RooGKCounter _counter;
1033  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
1034  LutXml::Config _cfg;
1035 
1036  // only trigger tower channels
1037  // and valid (ieta,iphi)
1038  const int tp_version = row->idepth / 10;
1039  if (row->subdet.find("HT") != std::string::npos && _coder.HTvalid(row->ieta, row->iphi, tp_version)) {
1040  if (_xml.count(row->crate) == 0 && split_by_crate) {
1041  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
1042  } else if (_xml.count(0) == 0 && !split_by_crate) {
1043  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
1044  }
1045  _cfg.ieta = row->ieta;
1046  _cfg.iphi = row->iphi;
1047  _cfg.depth = row->idepth;
1048  _cfg.crate = row->crate;
1049  _cfg.slot = row->slot;
1050  if (row->topbottom.find('t') != std::string::npos)
1051  _cfg.topbottom = 1;
1052  else if (row->topbottom.find('b') != std::string::npos)
1053  _cfg.topbottom = 0;
1054  else if (row->topbottom.find('u') != std::string::npos)
1055  _cfg.topbottom = 2;
1056  else
1057  edm::LogWarning("HcalLutManager") << "fpga out of range...";
1058  _cfg.fiber = row->fiber;
1059  _cfg.fiberchan = row->fiberchan;
1060  _cfg.lut_type = 2;
1061  _cfg.creationtag = _tag;
1062  _cfg.creationstamp = get_time_stamp(time(nullptr));
1063  _cfg.targetfirmware = "1.0.0";
1064  _cfg.formatrevision = "1"; //???
1065  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
1066  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
1067  // ((id.ieta()<0)?(0):(100));
1068  _cfg.generalizedindex = _cfg.iphi * 10000 + (row->ieta > 0) * 100 + abs(row->ieta);
1069 
1070  // FIXME: work around bug in emap v6: rawId wasn't filled
1071  //HcalTrigTowerDetId _detid(row->rawId);
1072  HcalTrigTowerDetId _detid(row->ieta, row->iphi);
1073 
1074  _cfg.lut = _coder.getCompressionLUT(_detid);
1075 
1076  if (split_by_crate) {
1077  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
1078  _counter.count();
1079  } else {
1080  _xml[0]->addLut(_cfg, lut_checksums_xml);
1081  _counter.count();
1082  }
1083  }
1084  }
1085  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1086  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE"
1087  << std::endl;
1088  return _xml;
1089 }
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
int topbottom
Definition: LutXml.h:32
virtual const std::vector< unsigned int > getCompressionLUT(const HcalTrigTowerDetId &id) const
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:80
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32

◆ getCompressionLutXmlFromCoder() [2/2]

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromCoder ( const CaloTPGTranscoderULUT _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 914 of file HcalLutManager.cc.

References funct::abs(), LutXml::_Config::codedvetothreshold, submitPVValidationJobs::conditions, RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), CaloTPGTranscoderULUT::getCompressionLUT(), RooGKCounter::getCount(), mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, cmsswSequenceInfo::maxsize, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, LutXml::_Config::topbottom, and LutXml::_Config::weight.

915  {
916  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT," << std::endl
917  << "initialized from Event Setup" << std::endl;
918  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
919 
920  EMap _emap(emap);
921 
922  std::map<int, unsigned int> maxsize;
923 
924  std::vector<EMap::EMapRow>& _map = _emap.get_map();
925  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
926 
927  //need to equalize compression LUT size in each crate-slot, needed for mixed uHTR
928  for (const auto& row : _map) {
929  if (row.subdet.find("HT") == std::string::npos)
930  continue;
931  HcalTrigTowerDetId _detid(row.rawId);
932  if (!cq->topo()->validHT(_detid))
933  continue;
934  int crot = 100 * row.crate + row.slot;
935  unsigned int size = _coder.getCompressionLUT(_detid).size();
936  if (maxsize.count(crot) == 0 || size > maxsize[crot])
937  maxsize[crot] = size;
938  }
939 
940  RooGKCounter _counter;
941  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
942  LutXml::Config _cfg;
943 
944  if (row->subdet.find("HT") == std::string::npos)
945  continue;
946 
947  HcalTrigTowerDetId _detid(row->rawId);
948 
949  if (!cq->topo()->validHT(_detid))
950  continue;
951 
952  if (_xml.count(row->crate) == 0 && split_by_crate) {
953  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
954  } else if (_xml.count(0) == 0 && !split_by_crate) {
955  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
956  }
957 
958  _cfg.ieta = row->ieta;
959  _cfg.iphi = row->iphi;
960  _cfg.depth = row->idepth;
961  _cfg.crate = row->crate;
962  _cfg.slot = row->slot;
963  if (row->topbottom.find('t') != std::string::npos)
964  _cfg.topbottom = 1;
965  else if (row->topbottom.find('b') != std::string::npos)
966  _cfg.topbottom = 0;
967  else if (row->topbottom.find('u') != std::string::npos)
968  _cfg.topbottom = 2;
969  else
970  edm::LogWarning("HcalLutManager") << "fpga out of range...";
971  _cfg.fiber = row->fiber;
972  _cfg.fiberchan = row->fiberchan;
973  _cfg.lut_type = 2;
974  _cfg.creationtag = _tag;
975  _cfg.creationstamp = get_time_stamp(time(nullptr));
976  _cfg.targetfirmware = "1.0.0";
977  _cfg.formatrevision = "1"; //???
978  _cfg.generalizedindex = _cfg.iphi * 10000 + (row->ieta > 0) * 100 + abs(row->ieta); //is this used for anything?
979 
980  _cfg.lut = _coder.getCompressionLUT(_detid);
981  auto pWeight = conditions->getHcalTPChannelParameter(_detid, false);
982  if (pWeight) {
983  _cfg.weight = pWeight->getauxi1();
984  _cfg.codedvetothreshold = pWeight->getauxi2();
985  }
986 
987  int crot = 100 * row->crate + row->slot;
988  unsigned int size = _cfg.lut.size();
989  if (size < maxsize[crot]) {
990  edm::LogWarning("HcalLutManager") << " resizing LUT for " << _detid << ", channel=[" << _cfg.crate << ":"
991  << _cfg.slot << ":" << _cfg.fiber << ":" << _cfg.fiberchan
992  << "], using value=" << _cfg.lut[size - 1] << std::endl;
993  for (unsigned int i = size; i < maxsize[crot]; ++i)
994  _cfg.lut.push_back(_cfg.lut[size - 1]);
995  }
996 
997  if (split_by_crate) {
998  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
999  _counter.count();
1000  } else {
1001  _xml[0]->addLut(_cfg, lut_checksums_xml);
1002  _counter.count();
1003  }
1004  }
1005  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1006  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE"
1007  << std::endl;
1008 
1009  return _xml;
1010 }
size
Write out results.
bool validHT(const HcalTrigTowerDetId &id) const
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
const HcalTopology * topo() const
int topbottom
Definition: LutXml.h:32
virtual const std::vector< unsigned int > getCompressionLUT(const HcalTrigTowerDetId &id) const
std::vector< unsigned int > lut
Definition: LutXml.h:40
const HcalChannelQuality * cq
std::string creationtag
Definition: LutXml.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int codedvetothreshold
Definition: LutXml.h:39
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId, bool throwOnFail=true) const
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:80
Log< level::Warning, false > LogWarning
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32
const HcalDbService * conditions

◆ getHEFineGrainLUTs()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getHEFineGrainLUTs ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 835 of file HcalLutManager.cc.

References funct::abs(), submitPVValidationJobs::conditions, RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, LutXml::_Config::fiber, LutXml::_Config::fiberchan, HcalTopology::firstHEDoublePhiRing(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), HcalEndcap, mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, dqmdumpme::k, HcalTopology::lastHERing(), LutXml::_Config::lut, LutXml::_Config::lut_type, or, LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

835  {
836  edm::LogInfo("HcalLutManager") << "Generating HE fine grain LUTs";
837  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
838 
839  EMap _emap(emap);
840  std::vector<EMap::EMapRow>& _map = _emap.get_map();
841  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " entries";
842 
843  RooGKCounter _counter;
844  //loop over all EMap channels
845  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
846  if (row->subdet.find("HT") != string::npos && row->subdet.size() == 2) {
847  int abseta = abs(row->ieta);
848  const HcalTopology* topo = cq->topo();
849  if (abseta <= topo->lastHBRing() or abseta > topo->lastHERing())
850  continue;
851  if (abseta >= topo->firstHEDoublePhiRing() and row->fiberchan % 2 == 1)
852  continue; //do only actual physical towers
853  LutXml::Config _cfg;
854 
855  if (_xml.count(row->crate) == 0 && split_by_crate) {
856  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
857  } else if (_xml.count(0) == 0 && !split_by_crate) {
858  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
859  }
860  _cfg.ieta = row->ieta;
861  _cfg.iphi = row->iphi;
862  _cfg.depth = row->idepth;
863  _cfg.crate = row->crate;
864  _cfg.slot = row->slot;
865  if (row->topbottom.find('t') != std::string::npos)
866  _cfg.topbottom = 1;
867  else if (row->topbottom.find('b') != std::string::npos)
868  _cfg.topbottom = 0;
869  else if (row->topbottom.find('u') != std::string::npos)
870  _cfg.topbottom = 2;
871  else
872  edm::LogWarning("HcalLutManager") << "fpga out of range...";
873  _cfg.fiber = row->fiber;
874  _cfg.fiberchan = row->fiberchan;
875  _cfg.lut_type = 4;
876  _cfg.creationtag = _tag;
877  _cfg.creationstamp = get_time_stamp(time(nullptr));
878  _cfg.targetfirmware = "1.0.0";
879  _cfg.formatrevision = "1"; //???
880  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->ieta > 0) * 100 + abs(row->ieta) +
881  (((row->subdet.find("HF") != string::npos) && abs(row->ieta) == 29) ? (4 * 10000) : (0));
882  // fine grain LUTs only relevant for HE
883  HcalSubdetector _subdet = HcalEndcap;
884  HcalDetId _detid(_subdet, row->ieta, row->iphi, row->idepth);
885 
887 
888  // loop over all possible configurations,
889  // computing the LUT for each
890  const int n_fgab_bits = 2048;
891  for (int i = 0; i < 2 * n_fgab_bits; i++) {
893  for (int k = 0; k < 6; k++) {
894  tow[0][k] = (1 << k) & i;
895  tow[1][k] = (1 << (k + 6)) & i;
896  }
897  _cfg.lut.push_back(fg_algo.compute(tow).to_ulong());
898  }
899 
900  if (split_by_crate) {
901  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
902  _counter.count();
903  } else {
904  _xml[0]->addLut(_cfg, lut_checksums_xml);
905  _counter.count();
906  }
907  }
908  }
909  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
910  << "Generating HE fine grain LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
911  return _xml;
912 }
std::array< std::bitset< 6 >, 2 > Tower
std::string targetfirmware
Definition: LutXml.h:36
int getFGVersionHBHE() const
get FineGrain Algorithm Version for HBHE
int generalizedindex
Definition: LutXml.h:37
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
const HcalTopology * topo() const
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
const HcalChannelQuality * cq
std::string creationtag
Definition: LutXml.h:33
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string formatrevision
Definition: LutXml.h:35
const HcalTPParameters * getHcalTPParameters() const
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
int firstHEDoublePhiRing() const
Definition: HcalTopology.h:98
void count(void)
Definition: RooGKCounter.cc:54
int lastHERing() const
Definition: HcalTopology.h:91
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:80
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32
const HcalDbService * conditions

◆ getInt()

int HcalLutManager::getInt ( std::string  number)
static

Definition at line 111 of file HcalLutManager.cc.

References contentValuesFiles::number, and mps_fire::result.

Referenced by getLutSetFromFile().

111  {
112  int result;
113  sscanf(number.c_str(), "%d", &result);
114  return result;
115 }

◆ getLinearizationLutXmlFromAsciiMasterEmap()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap ( std::string  _filename,
std::string  _tag,
int  _crate,
bool  split_by_crate = true 
)

Definition at line 339 of file HcalLutManager.cc.

References funct::abs(), gpuClustering::adc, RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, HcalLutSet::depth_max, HcalLutSet::depth_min, HcalLutSet::eta_max, HcalLutSet::eta_min, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

342  {
343  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
344  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
345 
346  EMap _emap(emap);
347  std::vector<EMap::EMapRow>& _map = _emap.get_map();
348  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " entries";
349 
350  // read LUTs and their eta/phi/depth/subdet ranges
351  HcalLutSet _set = getLutSetFromFile(_filename);
352  int lut_set_size = _set.lut.size(); // number of different luts
353  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
354 
355  // setup "zero" LUT for channel masking
356  std::vector<unsigned int> zeroLut;
357  for (size_t adc = 0; adc < 128; adc++)
358  zeroLut.push_back(0);
359 
360  RooGKCounter _counter;
361  //loop over all EMap channels
362  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
363  if ((row->subdet.find("HB") != string::npos || row->subdet.find("HE") != string::npos ||
364  row->subdet.find("HO") != string::npos || row->subdet.find("HF") != string::npos) &&
365  row->subdet.size() == 2) {
366  LutXml::Config _cfg;
367 
368  // search for the correct LUT for a given channel,
369  // higher LUT numbers have priority in case of overlapping
370  int lut_index = -1;
371  for (int i = 0; i < lut_set_size; i++) {
372  if ((row->crate == _crate || _crate == -1) && // -1 stands for all crates
373  _set.eta_min[i] <= row->ieta && _set.eta_max[i] >= row->ieta && _set.phi_min[i] <= row->iphi &&
374  _set.phi_max[i] >= row->iphi && _set.depth_min[i] <= row->idepth && _set.depth_max[i] >= row->idepth &&
375  _set.subdet[i].find(row->subdet) != string::npos) {
376  lut_index = i;
377  }
378  }
379  if (lut_index >= 0) {
380  if (_xml.count(row->crate) == 0 && split_by_crate) {
381  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
382  } else if (_xml.count(0) == 0 && !split_by_crate) {
383  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
384  }
385  _cfg.ieta = row->ieta;
386  _cfg.iphi = row->iphi;
387  _cfg.depth = row->idepth;
388  _cfg.crate = row->crate;
389  _cfg.slot = row->slot;
390  if (row->topbottom.find('t') != std::string::npos)
391  _cfg.topbottom = 1;
392  else if (row->topbottom.find('b') != std::string::npos)
393  _cfg.topbottom = 0;
394  else if (row->topbottom.find('u') != std::string::npos)
395  _cfg.topbottom = 2;
396  else
397  edm::LogWarning("HcalLutManager") << "fpga out of range...";
398  _cfg.fiber = row->fiber;
399  _cfg.fiberchan = row->fiberchan;
400  _cfg.lut_type = 1;
401  _cfg.creationtag = _tag;
402  _cfg.creationstamp = get_time_stamp(time(nullptr));
403  _cfg.targetfirmware = "1.0.0";
404  _cfg.formatrevision = "1"; //???
405  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
406  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
407  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
408  _cfg.generalizedindex =
409  _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->ieta > 0) * 100 + abs(row->ieta) +
410  (((row->subdet.find("HF") != string::npos) && abs(row->ieta) == 29) ? (4 * 10000) : (0));
411  //
412  // consider channel status here
413  DetId _detId(row->rawId);
414  uint32_t status_word = cq->getValues(_detId)->getValue();
415  if ((status_word & status_word_to_mask) > 0) {
416  _cfg.lut = zeroLut;
417  } else {
418  _cfg.lut = _set.lut[lut_index];
419  }
420  if (split_by_crate) {
421  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
422  _counter.count();
423  } else {
424  _xml[0]->addLut(_cfg, lut_checksums_xml);
425  _counter.count();
426  }
427  }
428  }
429  }
430  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
431  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
432  return _xml;
433 }
std::vector< std::vector< unsigned int > > lut
std::string targetfirmware
Definition: LutXml.h:36
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:37
std::vector< std::string > subdet
std::vector< int > phi_min
std::vector< int > depth_max
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
const Item * getValues(DetId fId, bool throwOnFail=true) const
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
const HcalChannelQuality * cq
std::string creationtag
Definition: LutXml.h:33
std::vector< int > depth_min
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalLutSet getLutSetFromFile(std::string _filename, int _type=1)
std::string formatrevision
Definition: LutXml.h:35
uint32_t getValue() const
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
Definition: DetId.h:17
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
std::vector< int > eta_max
Definition: LMap.h:80
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32
std::vector< int > eta_min
uint32_t status_word_to_mask
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ getLinearizationLutXmlFromAsciiMasterEmap_new()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap_new ( std::string  _filename,
std::string  _tag,
int  _crate,
bool  split_by_crate = true 
)

Definition at line 435 of file HcalLutManager.cc.

References funct::abs(), RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, HcalLutSet::depth_max, HcalLutSet::depth_min, HcalLutSet::eta_max, HcalLutSet::eta_min, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, RooGKCounter::getCount(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, mps_fire::i, LutXml::_Config::ieta, LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, HcalElectronicsId::readoutVMECrateId(), LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

436  {
437  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
438  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
439 
440  // read LUTs and their eta/phi/depth/subdet ranges
441  HcalLutSet _set = getLutSetFromFile(_filename);
442  int lut_set_size = _set.lut.size(); // number of different luts
443  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
444 
445  RooGKCounter _counter;
446  //loop over all EMap channels
447  for (_iter.begin(); !_iter.end(); _iter.next()) {
449  if ((_subdet == HcalBarrel || _subdet == HcalEndcap || _subdet == HcalForward || _subdet == HcalOuter)) {
450  int _ieta = _iter.getIeta();
451  int _iphi = _iter.getIphi();
452  int _depth = _iter.getDepth();
453 
454  // FIXME: this is probably wrong, raw ids are different
456  int aCrate = _eId.readoutVMECrateId();
457  int aSlot = _eId.htrSlot();
458  int aTopBottom = _eId.htrTopBottom();
459  int aFiber = _eId.fiberIndex();
460  int aFiberChan = _eId.fiberChanId();
461 
462  LutXml::Config _cfg;
463 
464  // search for the correct LUT for a given channel,
465  // higher LUT numbers have priority in case of overlapping
466  int lut_index = -1;
467  for (int i = 0; i < lut_set_size; i++) {
468  if ((aCrate == _crate || _crate == -1) && // -1 stands for all crates
469  _set.eta_min[i] <= _ieta && _set.eta_max[i] >= _ieta && _set.phi_min[i] <= _iphi &&
470  _set.phi_max[i] >= _iphi && _set.depth_min[i] <= _depth && _set.depth_max[i] >= _depth &&
471  _set.subdet[i].find(_ass.getSubdetectorString(_subdet)) != string::npos) {
472  lut_index = i;
473  }
474  }
475  if (lut_index >= 0) {
476  if (_xml.count(aCrate) == 0 && split_by_crate) {
477  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(aCrate, std::make_shared<LutXml>()));
478  } else if (_xml.count(0) == 0 && !split_by_crate) {
479  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
480  }
481  _cfg.ieta = _ieta;
482  _cfg.iphi = _iphi;
483  _cfg.depth = _depth;
484  _cfg.crate = aCrate;
485  _cfg.slot = aSlot;
486  _cfg.topbottom = aTopBottom;
487  _cfg.fiber = aFiber;
488  _cfg.fiberchan = aFiberChan;
489  _cfg.lut_type = 1;
490  _cfg.creationtag = _tag;
491  _cfg.creationstamp = get_time_stamp(time(nullptr));
492  _cfg.targetfirmware = "1.0.0";
493  _cfg.formatrevision = "1"; //???
494  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
495  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
496  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
497  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (_ieta > 0) * 100 + abs(_ieta) +
498  (((_subdet == HcalForward) && abs(_ieta) == 29) ? (4 * 10000) : (0));
499  _cfg.lut = _set.lut[lut_index];
500  if (split_by_crate) {
501  _xml[aCrate]->addLut(_cfg, lut_checksums_xml);
502  _counter.count();
503  } else {
504  _xml[0]->addLut(_cfg, lut_checksums_xml);
505  _counter.count();
506  }
507  }
508  }
509  }
510  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
511  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
512  return _xml;
513 }
std::vector< std::vector< unsigned int > > lut
std::string getSubdetectorString(HcalSubdetector _det)
std::string targetfirmware
Definition: LutXml.h:36
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:37
std::vector< std::string > subdet
std::vector< int > phi_min
std::vector< int > depth_max
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
constexpr int32_t readoutVMECrateId() const
get the readout VME crate number
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
std::vector< int > depth_min
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalLutSet getLutSetFromFile(std::string _filename, int _type=1)
HcalChannelIterator _iter
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void count(void)
Definition: RooGKCounter.cc:54
HcalAssistant _ass
static std::string get_time_stamp(time_t _time)
std::vector< int > eta_max
HcalGenericDetId getHcalGenericDetId(void)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
Readout chain identification for Hcal.
int fiberchan
Definition: LutXml.h:32
std::vector< int > eta_min
HcalSubdetector getHcalSubdetector(void)

◆ getLinearizationLutXmlFromCoder()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromCoder ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 601 of file HcalLutManager.cc.

References RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, LMap::get_map(), RooGKCounter::getCount(), HcalTPGCoder::getLinearizationLUT(), HcalForward, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), createfilelist::int, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, LMap::read(), LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

603  {
604  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
605  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
606 
607  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
608  //std::vector<EMap::EMapRow> & _map = _emap.get_map();
609  //std::cout << "EMap contains " << _map . size() << " entries" << std::endl;
610 
611  LMap _lmap;
612  _lmap.read("backup/HCALmapHBEF.txt", "HBEF");
613  // HO is not part of trigger, so TPGCoder cannot generate LUTs for it
614  //_lmap . read( "backup/HCALmapHO.txt", "HO" );
615  std::map<int, LMapRow>& _map = _lmap.get_map();
616  edm::LogInfo("HcalLutManager") << "LMap contains " << _map.size() << " channels";
617 
618  // read LUTs and their eta/phi/depth/subdet ranges
619  //HcalLutSet _set = getLinearizationLutSetFromCoder();
620  //int lut_set_size = _set.lut.size(); // number of different luts
621 
622  //loop over all HCAL channels
623  RooGKCounter _counter;
624  for (std::map<int, LMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
625  LutXml::Config _cfg;
626 
627  if (_xml.count(row->second.crate) == 0 && split_by_crate) {
628  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->second.crate, std::make_shared<LutXml>()));
629  } else if (_xml.count(0) == 0 && !split_by_crate) {
630  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
631  }
632  _cfg.ieta = row->second.side * row->second.eta;
633  _cfg.iphi = row->second.phi;
634  _cfg.depth = row->second.depth;
635  _cfg.crate = row->second.crate;
636  _cfg.slot = row->second.htr;
637  if (row->second.fpga.find("top") != std::string::npos)
638  _cfg.topbottom = 1;
639  else if (row->second.fpga.find("bot") != std::string::npos)
640  _cfg.topbottom = 0;
641  else
642  edm::LogWarning("HcalLutManager") << "fpga out of range...";
643  // FIXME: probably fixed. fiber==htr_fi, not rm_fi in LMAP notation.
644  //_cfg.fiber = row->second.rm_fi;
645  _cfg.fiber = row->second.htr_fi;
646  _cfg.fiberchan = row->second.fi_ch;
647  _cfg.lut_type = 1;
648  _cfg.creationtag = _tag;
649  _cfg.creationstamp = get_time_stamp(time(nullptr));
650  _cfg.targetfirmware = "1.0.0";
651  _cfg.formatrevision = "1"; //???
652  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
653  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
654  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
655  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->second.side > 0) * 100 + row->second.eta +
656  ((row->second.det == HcalForward && row->second.eta == 29) ? (4 * 10000) : (0));
657 
658  //HcalDetId _detid(row->first);
659  HcalDetId _detid(row->second.det, row->second.side * row->second.eta, row->second.phi, row->second.depth);
660  //std::cout << "### DEBUG: rawid = " << _detid.rawId() << std::endl;
661 
662  //std::cout << "### DEBUG: subdetector = " << row->second.det << std::endl;
663  std::vector<unsigned short> coder_lut = _coder.getLinearizationLUT(_detid);
664  for (std::vector<unsigned short>::const_iterator _i = coder_lut.begin(); _i != coder_lut.end(); _i++) {
665  unsigned int _temp = (unsigned int)(*_i);
666  //if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
667  //unsigned int _temp = 0;
668  _cfg.lut.push_back(_temp);
669  }
670  if (split_by_crate) {
671  _xml[row->second.crate]->addLut(_cfg, lut_checksums_xml);
672  _counter.count();
673  } else {
674  _xml[0]->addLut(_cfg, lut_checksums_xml);
675  _counter.count();
676  }
677  }
678  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
679  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
680  return _xml;
681 }
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
virtual std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
Definition: HcalTPGCoder.cc:3
std::map< int, LMapRow > & get_map(void)
Definition: LMap.cc:49
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
int read(std::string accessor, std::string type="HBEF")
Definition: LMap.cc:47
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
Definition: LMap.h:66
int fiberchan
Definition: LutXml.h:32

◆ getLinearizationLutXmlFromCoderEmap()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromCoderEmap ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 757 of file HcalLutManager.cc.

References funct::abs(), RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), HcalTPGCoder::getLinearizationLUT(), HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

759  {
760  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
761  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
762 
763  EMap _emap(emap);
764  std::vector<EMap::EMapRow>& _map = _emap.get_map();
765  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " entries";
766 
767  RooGKCounter _counter;
768  //loop over all EMap channels
769  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
770  if ((row->subdet.find("HB") != string::npos || row->subdet.find("HE") != string::npos ||
771  row->subdet.find("HF") != string::npos) &&
772  row->subdet.size() == 2) {
773  LutXml::Config _cfg;
774 
775  if (_xml.count(row->crate) == 0 && split_by_crate) {
776  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
777  } else if (_xml.count(0) == 0 && !split_by_crate) {
778  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
779  }
780  _cfg.ieta = row->ieta;
781  _cfg.iphi = row->iphi;
782  _cfg.depth = row->idepth;
783  _cfg.crate = row->crate;
784  _cfg.slot = row->slot;
785  if (row->topbottom.find('t') != std::string::npos)
786  _cfg.topbottom = 1;
787  else if (row->topbottom.find('b') != std::string::npos)
788  _cfg.topbottom = 0;
789  else if (row->topbottom.find('u') != std::string::npos)
790  _cfg.topbottom = 2;
791  else
792  edm::LogWarning("HcalLutManager") << "fpga out of range...";
793  _cfg.fiber = row->fiber;
794  _cfg.fiberchan = row->fiberchan;
795  _cfg.lut_type = 1;
796  _cfg.creationtag = _tag;
797  _cfg.creationstamp = get_time_stamp(time(nullptr));
798  _cfg.targetfirmware = "1.0.0";
799  _cfg.formatrevision = "1"; //???
800  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
801  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
802  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
803  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->ieta > 0) * 100 + abs(row->ieta) +
804  (((row->subdet.find("HF") != string::npos) && abs(row->ieta) == 29) ? (4 * 10000) : (0));
805  HcalSubdetector _subdet;
806  if (row->subdet.find("HB") != string::npos)
807  _subdet = HcalBarrel;
808  else if (row->subdet.find("HE") != string::npos)
809  _subdet = HcalEndcap;
810  else if (row->subdet.find("HO") != string::npos)
811  _subdet = HcalOuter;
812  else if (row->subdet.find("HF") != string::npos)
813  _subdet = HcalForward;
814  else
815  _subdet = HcalOther;
816  HcalDetId _detid(_subdet, row->ieta, row->iphi, row->idepth);
817 
818  for (const auto i : _coder.getLinearizationLUT(_detid))
819  _cfg.lut.push_back(i);
820 
821  if (split_by_crate) {
822  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
823  _counter.count();
824  } else {
825  _xml[0]->addLut(_cfg, lut_checksums_xml);
826  _counter.count();
827  }
828  }
829  }
830  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
831  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
832  return _xml;
833 }
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
virtual std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
Definition: HcalTPGCoder.cc:3
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:80
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32

◆ getLutFromXml()

std::vector< unsigned int > HcalLutManager::getLutFromXml ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt 
)

Definition at line 1396 of file HcalLutManager.cc.

References mps_fire::result.

1398  {
1399  edm::LogInfo("HcalLutManager") << "getLutFromXml (new version) is not implemented. Use getLutFromXml_old() for now";
1400 
1401  std::vector<unsigned int> result;
1402 
1403  return result;
1404 }
Log< level::Info, false > LogInfo

◆ getLutFromXml_old()

std::vector< unsigned int > HcalLutManager::getLutFromXml_old ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt 
)

Definition at line 1407 of file HcalLutManager.cc.

References dqmiodatasetharvest::db, beamvalidation::exit(), mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, and makeGlobalPositionRcd_cfg::tag.

1409  {
1410  if (!lmap) {
1411  edm::LogError("HcalLutManager") << "Cannot find LUT without LMAP, exiting...";
1412  exit(-1);
1413  }
1414  if (!db) {
1415  edm::LogError("HcalLutManager") << "Cannot find LUT, no source (local XML file), exiting...";
1416  exit(-1);
1417  }
1418 
1419  std::vector<unsigned int> result;
1420 
1421  std::map<int, LMapRow>& _map = lmap->get_map();
1422  //std::cout << "HcalLutManager: LMap contains " << _map . size() << " channels (out of 9072 total)" << std::endl;
1423 
1424  HcalDetId _id(_rawid);
1425 
1426  unsigned int _crate, _slot, _fiber, _channel;
1427  std::string _fpga;
1428  int topbottom, luttype;
1429 
1430  // FIXME: check validity of _rawid
1431  if (_map.find(_rawid) != _map.end()) {
1432  _crate = _map[_rawid].crate;
1433  _slot = _map[_rawid].htr;
1434  _fiber = _map[_rawid].htr_fi;
1435  _channel = _map[_rawid].fi_ch;
1436  _fpga = _map[_rawid].fpga;
1437 
1438  if (_fpga.find("top") != std::string::npos)
1439  topbottom = 1;
1440  else if (_fpga.find("bot") != std::string::npos)
1441  topbottom = 0;
1442  else {
1443  edm::LogError("HcalLutManager") << "Irregular LMAP fpga value... do not know what to do - exiting";
1444  exit(-1);
1445  }
1446  if (_lt == hcal::ConfigurationDatabase::LinearizerLUT)
1447  luttype = 1;
1448  else
1449  luttype = 2;
1450 
1451  result = db->getOnlineLUT(tag, _crate, _slot, topbottom, _fiber, _channel, luttype);
1452  }
1453 
1454  return result;
1455 }
Log< level::Error, false > LogError
HCALConfigDB * db
std::map< int, LMapRow > & get_map(void)
Definition: LMap.cc:49
std::vector< unsigned int > getOnlineLUT(std::string tag, int crate, int slot, int topbottom, int fiber, int channel, int luttype)
Definition: HCALConfigDB.cc:83
def exit(msg="")

◆ getLutSetFromFile()

HcalLutSet HcalLutManager::getLutSetFromFile ( std::string  _filename,
int  _type = 1 
)

Definition at line 170 of file HcalLutManager.cc.

References visDQMUpload::buf, HcalLutSet::depth_max, HcalLutSet::depth_min, HcalLutSet::eta_max, HcalLutSet::eta_min, getInt(), mps_fire::i, timingPdfMaker::infile, HcalLutSet::label, HcalLutSet::lut, HcalLutSet::phi_max, HcalLutSet::phi_min, HcalQIEManager::splitString(), AlCaHLTBitMon_QueryRunRegistry::string, and HcalLutSet::subdet.

Referenced by HcalLutManager_test::getLutSetFromFile_test().

170  {
171  HcalLutSet _lutset;
172 
173  ifstream infile(_filename.c_str());
175 
176  if (infile.is_open()) {
177  edm::LogInfo("HcalLutManager") << "File " << _filename << " is open..." << std::endl
178  << "Reading LUTs and their eta/phi/depth/subdet ranges...";
179 
180  // get label
181  getline(infile, _lutset.label);
182 
183  if (_type == 1) { // for linearization LUTs get subdetectors (default)
184  //get subdetectors
185  getline(infile, buf);
187  }
188 
189  //get min etas
190  std::vector<std::string> buf_vec;
191  getline(infile, buf);
192  buf_vec = HcalQIEManager::splitString(buf);
193  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
194  _lutset.eta_min.push_back(HcalLutManager::getInt(*iter));
195  }
196 
197  //get max etas
198  getline(infile, buf);
199  buf_vec = HcalQIEManager::splitString(buf);
200  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
201  _lutset.eta_max.push_back(HcalLutManager::getInt(*iter));
202  }
203 
204  //get min phis
205  getline(infile, buf);
206  buf_vec = HcalQIEManager::splitString(buf);
207  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
208  _lutset.phi_min.push_back(HcalLutManager::getInt(*iter));
209  }
210 
211  //get max phis
212  getline(infile, buf);
213  buf_vec = HcalQIEManager::splitString(buf);
214  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
215  _lutset.phi_max.push_back(HcalLutManager::getInt(*iter));
216  }
217 
218  if (_type == 1) { // for linearization LUTs get depth range (default)
219  //get min depths
220  getline(infile, buf);
221  buf_vec = HcalQIEManager::splitString(buf);
222  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
223  _lutset.depth_min.push_back(HcalLutManager::getInt(*iter));
224  }
225 
226  //get max depths
227  getline(infile, buf);
228  buf_vec = HcalQIEManager::splitString(buf);
229  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
230  _lutset.depth_max.push_back(HcalLutManager::getInt(*iter));
231  }
232  }
233 
234  bool first_lut_entry = true;
235  while (getline(infile, buf)) {
236  buf_vec = HcalQIEManager::splitString(buf);
237  for (unsigned int i = 0; i < buf_vec.size(); i++) {
238  if (first_lut_entry) {
239  std::vector<unsigned int> _l;
240  _lutset.lut.push_back(_l);
241  }
242  _lutset.lut[i].push_back(HcalLutManager::getInt(buf_vec[i]));
243  }
244  first_lut_entry = false;
245  }
246  }
247 
248  edm::LogInfo("HcalLutManager") << "done.";
249 
250  return _lutset;
251 }
std::vector< std::vector< unsigned int > > lut
std::string label
std::vector< int > phi_max
std::vector< std::string > subdet
std::vector< int > phi_min
std::vector< int > depth_max
static std::vector< std::string > splitString(const std::string &fLine)
std::vector< int > depth_min
Log< level::Info, false > LogInfo
static int getInt(std::string number)
std::vector< int > eta_max
std::vector< int > eta_min

◆ getLutXml()

std::string & HcalLutManager::getLutXml ( std::vector< unsigned int > &  _lut)

Definition at line 95 of file HcalLutManager.cc.

References LutXml::_Config::lut.

95  {
96  if (lut_xml)
97  delete lut_xml;
98 
99  lut_xml = new LutXml();
100 
101  LutXml::Config _config;
102  _config.lut = _lut;
103  lut_xml->addLut(_config);
104  lut_xml->addLut(_config);
105  lut_xml->addLut(_config);
106 
107  //return lut_xml->getString();
108  return lut_xml->getCurrentBrick();
109 }
Definition: LutXml.h:27
void addLut(Config &_config, XMLDOMBlock *checksums_xml=nullptr)
Definition: LutXml.cc:82
std::string & getCurrentBrick(void)
Definition: LutXml.cc:210
std::vector< unsigned int > lut
Definition: LutXml.h:40

◆ getLutXmlFromAsciiMaster()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getLutXmlFromAsciiMaster ( std::string  _filename,
std::string  _tag,
int  _crate = -1,
bool  split_by_crate = true 
)

Definition at line 253 of file HcalLutManager.cc.

References RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, HcalLutSet::depth_max, HcalLutSet::depth_min, HcalLutSet::eta_max, HcalLutSet::eta_min, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, LMap::get_map(), RooGKCounter::getCount(), HcalForward, mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, LMap::read(), LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, and LutXml::_Config::topbottom.

256  {
257  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
258  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
259 
260  LMap _lmap;
261  _lmap.read("./backup/HCALmapHBEF.txt", "HBEF");
262  _lmap.read("./backup/HCALmapHO.txt", "HO");
263  std::map<int, LMapRow>& _map = _lmap.get_map();
264  edm::LogInfo("HcalLutManager") << "LMap contains " << _map.size() << " channels";
265 
266  // read LUTs and their eta/phi/depth/subdet ranges
267  HcalLutSet _set = getLutSetFromFile(_filename);
268  int lut_set_size = _set.lut.size(); // number of different luts
269 
270  RooGKCounter _counter;
271  //loop over all HCAL channels
272  for (std::map<int, LMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
273  LutXml::Config _cfg;
274 
275  // search for the correct LUT for a given channel,
276  // higher LUT numbers have priority in case of overlapping
277  int lut_index = -1;
278  for (int i = 0; i < lut_set_size; i++) {
279  if ((row->second.crate == _crate || _crate == -1) && // -1 stands for all crates
280  _set.eta_min[i] <= row->second.side * row->second.eta &&
281  _set.eta_max[i] >= row->second.side * row->second.eta && _set.phi_min[i] <= row->second.phi &&
282  _set.phi_max[i] >= row->second.phi && _set.depth_min[i] <= row->second.depth &&
283  _set.depth_max[i] >= row->second.depth && get_subdetector(_set.subdet[i]) == row->second.det) {
284  lut_index = i;
285  }
286  }
287  if (lut_index >= 0) {
288  if (_xml.count(row->second.crate) == 0 && split_by_crate) {
289  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->second.crate, std::make_shared<LutXml>()));
290  } else if (_xml.count(0) == 0 && !split_by_crate) {
291  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
292  }
293  _cfg.ieta = row->second.side * row->second.eta;
294  _cfg.iphi = row->second.phi;
295  _cfg.depth = row->second.depth;
296  _cfg.crate = row->second.crate;
297  _cfg.slot = row->second.htr;
298  if (row->second.fpga.find("top") != std::string::npos)
299  _cfg.topbottom = 1;
300  else if (row->second.fpga.find("bot") != std::string::npos)
301  _cfg.topbottom = 0;
302  else
303  edm::LogWarning("HcalLutManager") << "fpga out of range...";
304  // FIXME: probably fixed. fiber==htr_fi, not rm_fi in LMAP notation.
305  //_cfg.fiber = row->second.rm_fi;
306  _cfg.fiber = row->second.htr_fi;
307  _cfg.fiberchan = row->second.fi_ch;
308  if (_set.lut[lut_index].size() == 128)
309  _cfg.lut_type = 1;
310  else
311  _cfg.lut_type = 2;
312  _cfg.creationtag = _tag;
313  _cfg.creationstamp = get_time_stamp(time(nullptr));
314  _cfg.targetfirmware = "1.0.0";
315  _cfg.formatrevision = "1"; //???
316  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
317  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
318  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
319  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->second.side > 0) * 100 + row->second.eta +
320  ((row->second.det == HcalForward && row->second.eta == 29) ? (4 * 10000) : (0));
321  _cfg.lut = _set.lut[lut_index];
322  if (split_by_crate) {
323  _xml[row->second.crate]->addLut(_cfg, lut_checksums_xml);
324  _counter.count();
325  } else {
326  _xml[0]->addLut(_cfg, lut_checksums_xml);
327  _counter.count();
328  }
329  }
330  }
331  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
332  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
333  return _xml;
334 }
std::vector< std::vector< unsigned int > > lut
std::string targetfirmware
Definition: LutXml.h:36
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:37
std::vector< std::string > subdet
std::vector< int > phi_min
std::vector< int > depth_max
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
static HcalSubdetector get_subdetector(std::string _subdet)
std::map< int, LMapRow > & get_map(void)
Definition: LMap.cc:49
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
int read(std::string accessor, std::string type="HBEF")
Definition: LMap.cc:47
std::vector< int > depth_min
HcalLutSet getLutSetFromFile(std::string _filename, int _type=1)
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
std::vector< int > eta_max
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
Definition: LMap.h:66
int fiberchan
Definition: LutXml.h:32
std::vector< int > eta_min

◆ getMasks()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getMasks ( int  var,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 683 of file HcalLutManager.cc.

References DummyCfis::c, submitPVValidationJobs::conditions, RooGKCounter::count(), LutXml::_Config::crate, FCDTask_cfi::crate, LutXml::_Config::creationtag, FCDTask_cfi::fiber, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, mps_fire::i, LutXml::_Config::lut_type, LutXml::_Config::mask, findQualityFiles::size, LutXml::_Config::slot, FCDTask_cfi::slot, AlCaHLTBitMon_QueryRunRegistry::string, and LutXml::_Config::targetfirmware.

683  {
684  edm::LogInfo("HcalLutManager") << "Generating TDC masks...";
685 
686  EMap _emap(emap);
687  std::vector<EMap::EMapRow>& _map = _emap.get_map();
688  edm::LogInfo("HcalLutManager") << "EMap contains new" << _map.size() << " entries";
689 
690  std::map<int, std::vector<uint64_t>> masks;
691 
692  for (const auto& row : _map) {
693  std::string subdet = row.subdet;
694  if (subdet != "HF")
695  continue;
696  int crate = row.crate;
697  int slot = row.slot;
698  int crot = 100 * crate + slot;
699  int fiber = row.fiber;
700  int channel = row.fiberchan;
701  unsigned int finel = 4 * fiber + channel;
702  if (masks.count(crot) == 0)
703  masks[crot] = {};
704  if (finel >= masks[crot].size())
705  masks[crot].resize(finel + 1);
706 
707  if (masktype == 0) {
708  HcalSubdetector _subdet;
709  if (row.subdet.find("HB") != string::npos)
710  _subdet = HcalBarrel;
711  else if (row.subdet.find("HE") != string::npos)
712  _subdet = HcalEndcap;
713  else if (row.subdet.find("HO") != string::npos)
714  _subdet = HcalOuter;
715  else if (row.subdet.find("HF") != string::npos)
716  _subdet = HcalForward;
717  else
718  _subdet = HcalOther;
719  HcalDetId _detid(_subdet, row.ieta, row.iphi, row.idepth);
720  masks[crot][finel] = conditions->getHcalTPChannelParameter(_detid)->getMask();
721  } else {
723  masks[crot][finel] = masktype == 1 ? parameters->getADCThresholdHF() : parameters->getTDCMaskHF();
724  }
725  }
726 
727  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
728  RooGKCounter _counter;
729 
730  for (const auto& i : masks) {
731  int crot = i.first;
732  int crate = crot / 100;
733 
734  LutXml::Config _cfg;
735  _cfg.lut_type = 5 + masktype;
736  _cfg.crate = crate;
737  _cfg.slot = crot % 100;
738  _cfg.generalizedindex = crot;
739  _cfg.mask = i.second;
740  _cfg.creationtag = _tag;
741  _cfg.targetfirmware = "1.0.0";
742  _cfg.formatrevision = "1";
743 
744  int c = split_by_crate ? crate : 0;
745  if (_xml.count(c) == 0)
746  _xml[c] = std::make_shared<LutXml>();
747 
748  _xml[c]->addLut(_cfg);
749  _counter.count();
750  }
751 
752  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
753  << "Generating Masks...DONE" << std::endl;
754  return _xml;
755 }
size
Write out results.
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
uint32_t getMask() const
get mask for channel validity and self trigger information
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
std::string creationtag
Definition: LutXml.h:33
HcalSubdetector
Definition: HcalAssistant.h:31
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId, bool throwOnFail=true) const
std::string formatrevision
Definition: LutXml.h:35
const HcalTPParameters * getHcalTPParameters() const
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:54
Definition: LMap.h:80
int lut_type
Definition: LutXml.h:32
const HcalDbService * conditions
std::vector< uint64_t > mask
Definition: LutXml.h:41

◆ getZdcLutXml()

std::map< int, std::shared_ptr< LutXml > > HcalLutManager::getZdcLutXml ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true,
bool  ootpu_lut = false 
)

Definition at line 1722 of file HcalLutManager.cc.

References RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, HcalZDCDetId::EM, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), HcalTPGCoder::getLinearizationLUT(), HcalZDCDetId::HAD, mps_fire::i, LutXml::_Config::ieta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, hgcalPlots::section, LutXml::_Config::slot, LutXml::_Config::targetfirmware, hcalRecHitTable_cff::time, LutXml::_Config::topbottom, and HcalZDCDetId::Unknown.

1725  {
1726  edm::LogInfo("HcalLutManager") << "Generating ZDC LUTs ...may the Force be with us...";
1727  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
1728 
1729  EMap _emap(emap);
1730 
1731  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1732  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
1733 
1734  //loop over all EMap channels
1735  RooGKCounter _counter;
1736  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
1737  LutXml::Config _cfg;
1738 
1739  // only ZDC channels
1740  if (row->zdc_section.find("ZDC") != std::string::npos) {
1741  if (_xml.count(row->crate) == 0 && split_by_crate) {
1742  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
1743  } else if (_xml.count(0) == 0 && !split_by_crate) {
1744  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
1745  }
1746  // FIXME: introduce proper tag names in ZDC bricks for logical channel info
1747  _cfg.ieta = row->zdc_channel; // int
1748  //_cfg.ieta = row->zdc_zside; // int
1749  //_cfg.iphi = row->zdc_section; // string
1750  _cfg.depth = row->zdc_zside; // int
1751  _cfg.crate = row->crate;
1752  _cfg.slot = row->slot;
1753  if (row->topbottom.find('t') != std::string::npos)
1754  _cfg.topbottom = 1;
1755  else if (row->topbottom.find('b') != std::string::npos)
1756  _cfg.topbottom = 0;
1757  else if (row->topbottom.find('u') != std::string::npos)
1758  _cfg.topbottom = 2;
1759  else
1760  edm::LogWarning("HcalLutManager") << "fpga out of range...";
1761 
1762  if (ootpu_lut)
1763  _cfg.fiber = row->fiber + 6;
1764  else
1765  _cfg.fiber = row->fiber;
1766 
1767  _cfg.fiberchan = row->fiberchan;
1768  _cfg.lut_type = 1;
1769  _cfg.creationtag = _tag;
1770  _cfg.creationstamp = get_time_stamp(time(nullptr));
1771  _cfg.targetfirmware = "1.0.0";
1772  _cfg.formatrevision = "1"; //???
1773  _cfg.generalizedindex = 0;
1774 
1776  if (row->zdc_section == "ZDC EM") {
1778  _cfg.iphi = 1;
1779  } else if (row->zdc_section == "ZDC HAD") {
1781  _cfg.iphi = 2;
1782  } else if (row->zdc_section == "ZDC LUM") {
1783  continue;
1784  } else if (row->zdc_section == "ZDC RPD") {
1785  continue;
1786  }
1787  HcalZDCDetId _detid(section, (row->zdc_zside > 0), row->zdc_channel);
1788 
1789  for (const auto i : _coder.getLinearizationLUT(_detid, ootpu_lut)) {
1790  _cfg.lut.push_back(i);
1791  }
1792 
1793  if (split_by_crate) {
1794  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
1795  _counter.count();
1796  } else {
1797  _xml[0]->addLut(_cfg, lut_checksums_xml);
1798  _counter.count();
1799  }
1800  //size of lut
1801  }
1802  }
1803 
1804  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1805  << "Generating ZDC LUTs...DONE" << std::endl;
1806 
1807  return _xml;
1808 }
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
virtual std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
Definition: HcalTPGCoder.cc:3
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
std::string formatrevision
Definition: LutXml.h:35
XMLDOMBlock * lut_checksums_xml
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:54
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:80
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32

◆ init()

void HcalLutManager::init ( void  )

Definition at line 72 of file HcalLutManager.cc.

References submitPVValidationJobs::conditions, and dqmiodatasetharvest::db.

72  {
73  lut_xml = nullptr;
74  lut_checksums_xml = nullptr;
75  db = nullptr;
76  lmap = nullptr;
77  emap = nullptr;
78  cq = nullptr;
79  conditions = nullptr;
80  status_word_to_mask = 0x0000;
81 }
HCALConfigDB * db
const HcalChannelQuality * cq
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
uint32_t status_word_to_mask
const HcalDbService * conditions

◆ initChannelIterator()

int HcalLutManager::initChannelIterator ( std::vector< HcalGenericDetId > &  map)

Definition at line 90 of file HcalLutManager.cc.

References genParticles_cff::map.

90  {
91  _iter.init(map);
92  return _iter.size();
93 }
int init(const std::vector< HcalGenericDetId > &map)
HcalChannelIterator _iter

◆ local_connect()

int HcalLutManager::local_connect ( std::string  lut_xml_file,
std::string  lmap_hbef_file,
std::string  lmap_ho_file 
)

Definition at line 1390 of file HcalLutManager.cc.

1390  {
1391  read_lmap(lmap_hbef_file, lmap_ho_file);
1392  read_luts(lut_xml_file);
1393  return 0;
1394 }
int read_luts(std::string lut_xml_file)
int read_lmap(std::string lmap_hbef_file, std::string lmap_ho_file)

◆ read_lmap()

int HcalLutManager::read_lmap ( std::string  lmap_hbef_file,
std::string  lmap_ho_file 
)

Definition at line 1373 of file HcalLutManager.cc.

1373  {
1374  delete lmap;
1375  lmap = new LMap();
1376  lmap->read(lmap_hbef_file, "HBEF");
1377  lmap->read(lmap_ho_file, "HO");
1378  edm::LogInfo("HcalLutManager") << "LMap contains " << lmap->get_map().size()
1379  << " channels (compare to 9072 of all HCAL channels)";
1380  return 0;
1381 }
std::map< int, LMapRow > & get_map(void)
Definition: LMap.cc:49
int read(std::string accessor, std::string type="HBEF")
Definition: LMap.cc:47
Log< level::Info, false > LogInfo
Definition: LMap.h:66

◆ read_luts()

int HcalLutManager::read_luts ( std::string  lut_xml_file)

Definition at line 1383 of file HcalLutManager.cc.

References dqmiodatasetharvest::db.

1383  {
1384  delete db;
1385  db = new HCALConfigDB();
1386  db->connect(lut_xml_file);
1387  return 0;
1388 }
HCALConfigDB * db
Gather config data from online DB.
Definition: HCALConfigDB.h:20
void connect(std::string _accessor)
Definition: HCALConfigDB.cc:48

◆ test_direct_xml_parsing()

int HcalLutManager::test_direct_xml_parsing ( std::string  _filename)

Definition at line 1645 of file HcalLutManager.cc.

1645  {
1646  /*
1647  XMLDOMBlock _xml(_filename);
1648  //DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
1649  DOMNodeList * brick_list = _xml . getDocument() -> getElementsByTagName( XMLProcessor::_toXMLCh( "CFGBrick" ));
1650 
1651  double n_bricks = brick_list->getLength();
1652  std::cout << "amount of LUT bricks: " << n_bricks << std::endl;
1653 
1654  for (int iter=0; iter!=n_bricks; iter++){
1655  DOMElement * _brick = (DOMElement *)(brick_list->item(iter));
1656 
1657  DOMElement * _param = 0;
1658  // loop over brick parameters
1659  int par_iter = 0;
1660  while(1){
1661  _param = (DOMElement *)(_brick->getElementsByTagName(XMLProcessor::_toXMLCh("Parameter")));
1662  std::string _name = _param->getAttribute( XMLProcessor::_toXMLCh( "name" ) );
1663  if (_name.find("IETA")==string::npos) break;
1664 
1665  std::string _tag = "Parameter";
1666  std::cout << "### Parameter IETA = " << _xml.getTagValue( _tag, 0, _brick);
1667  par_iter++;
1668  }
1669  }
1670  */
1671  return 0;
1672 }

◆ test_emap()

void HcalLutManager::test_emap ( void  )

Definition at line 1620 of file HcalLutManager.cc.

References funct::abs(), EMap::get_map(), and alignCSCRings::s.

1620  {
1621  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1622  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1623  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1624  EMap _emap(emap);
1625  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1626  std::stringstream s;
1627  s << "EMap contains " << _map.size() << " channels" << std::endl;
1628 
1629  //loop over all EMap channels
1630  //RooGKCounter _c;
1631  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
1632  // only trigger tower channels
1633  if (row->subdet.find("HT") != std::string::npos) {
1634  s << " -----> Subdet = " << row->subdet << std::endl;
1635 
1636  if (abs(row->ieta) > 28) {
1637  //if (row->iphi == 71){
1638  s << " ==> (ieta,iphi) = " << row->ieta << ", " << row->iphi << std::endl;
1639  }
1640  }
1641  }
1642  edm::LogInfo("HcalLutManager") << s.str();
1643 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
Definition: LMap.h:80

◆ test_xml_access()

int HcalLutManager::test_xml_access ( std::string  _tag,
std::string  _filename 
)

Definition at line 1296 of file HcalLutManager.cc.

References dqmiodatasetharvest::db, EMap::get_map(), HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, mps_fire::i, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, and DetId::rawId().

1296  {
1297  local_connect(_filename, "backup/HCALmapHBEF.txt", "backup/HCALmapHO.txt");
1298 
1299  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1300  EMap _emap(emap);
1301  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1302  int map_size = _map.size();
1303  edm::LogInfo("HcalLutManager") << "EMap contains " << map_size << " channels";
1304 
1305  // make sure that all init is done
1306  std::vector<unsigned int> _lut;
1307  _lut = getLutFromXml(_tag, 1107313727, hcal::ConfigurationDatabase::LinearizerLUT);
1308 
1309  edm::LogInfo("HcalLutManager") << "Testing direct parsing of the LUT XML";
1310  struct timeval _t;
1311  gettimeofday(&_t, nullptr);
1312  double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
1313  test_direct_xml_parsing(_filename);
1314  gettimeofday(&_t, nullptr);
1315  edm::LogInfo("HcalLutManager") << "parsing took that much time: "
1316  << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time;
1317 
1318  gettimeofday(&_t, nullptr);
1319  _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
1320  edm::LogInfo("HcalLutManager") << "before loop over random LUTs: " << _time;
1321  int _raw_id;
1322 
1323  // loop over random LUTs
1324  for (int _iter = 0; _iter < 100; _iter++) {
1325  gettimeofday(&_t, nullptr);
1326  //std::cout << "before getting a LUT: " << _t . tv_sec << "." << _t . tv_usec << std::endl;
1327 
1328  // select valid random emap channel
1329  while (true) {
1330  int _key = (rand() % map_size);
1331  //_key = 3356;
1332  if ((_map[_key].subdet.find("HB") != string::npos || _map[_key].subdet.find("HE") != string::npos ||
1333  _map[_key].subdet.find("HO") != string::npos || _map[_key].subdet.find("HF") != string::npos) &&
1334  _map[_key].subdet.size() == 2) {
1335  HcalSubdetector _subdet;
1336  if (_map[_key].subdet.find("HB") != string::npos)
1337  _subdet = HcalBarrel;
1338  else if (_map[_key].subdet.find("HE") != string::npos)
1339  _subdet = HcalEndcap;
1340  else if (_map[_key].subdet.find("HO") != string::npos)
1341  _subdet = HcalOuter;
1342  else if (_map[_key].subdet.find("HF") != string::npos)
1343  _subdet = HcalForward;
1344  else
1345  _subdet = HcalOther;
1346  HcalDetId _detid(_subdet, _map[_key].ieta, _map[_key].iphi, _map[_key].idepth);
1347  _raw_id = _detid.rawId();
1348  break;
1349  }
1350  }
1351  _lut = getLutFromXml(_tag, _raw_id, hcal::ConfigurationDatabase::LinearizerLUT);
1352 
1353  gettimeofday(&_t, nullptr);
1354  }
1355  double d_time = _t.tv_sec + _t.tv_usec / 1000000.0 - _time;
1356  edm::LogInfo("HcalLutManager") << "after the loop over random LUTs: " << _time + d_time << std::endl
1357  << "total time: " << d_time << std::endl;
1358 
1359  edm::LogInfo("HcalLutManager") << "LUT length = " << _lut.size();
1360  for (std::vector<unsigned int>::const_iterator i = _lut.end() - 1; i != _lut.begin() - 1; i--) {
1361  edm::LogInfo("HcalLutManager") << (i - _lut.begin()) << " " << _lut[(i - _lut.begin())];
1362  break;
1363  }
1364 
1365  db->disconnect();
1366 
1367  delete db;
1368  db = nullptr;
1369 
1370  return 0;
1371 }
void disconnect(void)
Definition: HCALConfigDB.cc:76
HCALConfigDB * db
int test_direct_xml_parsing(std::string _filename)
HcalSubdetector
Definition: HcalAssistant.h:31
HcalChannelIterator _iter
Log< level::Info, false > LogInfo
const HcalElectronicsMap * emap
int local_connect(std::string lut_xml_file, std::string lmap_hbef_file, std::string lmap_ho_file)
std::vector< unsigned int > getLutFromXml(std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt)
Definition: LMap.h:80

◆ writeLutXmlFiles()

int HcalLutManager::writeLutXmlFiles ( std::map< int, std::shared_ptr< LutXml > > &  _xml,
std::string  _tag = "default_tag",
bool  split_by_crate = true 
)

Definition at line 1091 of file HcalLutManager.cc.

References genParticles_cff::map.

1093  {
1094  for (std::map<int, std::shared_ptr<LutXml>>::const_iterator cr = _xml.begin(); cr != _xml.end(); cr++) {
1095  std::stringstream output_file_name;
1096  if (split_by_crate) {
1097  output_file_name << _tag << "_" << cr->first << ".xml";
1098  } else {
1099  output_file_name << _tag << ".xml";
1100  }
1101  cr->second->write(output_file_name.str());
1102  }
1103  return 0;
1104 }

Member Data Documentation

◆ _ass

HcalAssistant HcalLutManager::_ass
protected

Definition at line 186 of file HcalLutManager.h.

◆ _iter

HcalChannelIterator HcalLutManager::_iter
protected

Definition at line 185 of file HcalLutManager.h.

◆ conditions

const HcalDbService* HcalLutManager::conditions
protected

Definition at line 189 of file HcalLutManager.h.

◆ cq

const HcalChannelQuality* HcalLutManager::cq
protected

Definition at line 188 of file HcalLutManager.h.

◆ db

HCALConfigDB* HcalLutManager::db
protected

◆ emap

const HcalElectronicsMap* HcalLutManager::emap
protected

Definition at line 187 of file HcalLutManager.h.

◆ lmap

LMap* HcalLutManager::lmap
protected

Definition at line 184 of file HcalLutManager.h.

◆ lut_checksums_xml

XMLDOMBlock* HcalLutManager::lut_checksums_xml
protected

Definition at line 182 of file HcalLutManager.h.

◆ lut_xml

LutXml* HcalLutManager::lut_xml
protected

Definition at line 181 of file HcalLutManager.h.

◆ status_word_to_mask

uint32_t HcalLutManager::status_word_to_mask
protected

Definition at line 190 of file HcalLutManager.h.