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, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::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, boost::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, boost::shared_ptr< LutXml > > getCompressionLutXmlFromAsciiMaster (std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder (std::string _tag, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder (const CaloTPGTranscoderULUT &_coder, std::string _tag, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap (std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap_new (std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromCoder (const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
 
std::map< int, boost::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, boost::shared_ptr< LutXml > > getLutXmlFromAsciiMaster (std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getMasks (int var, std::string _tag, bool split_by_crate=true)
 
std::map< int, boost::shared_ptr< LutXml > > getZdcLutXml (std::string _tag, bool split_by_crate=true)
 
 HcalLutManager ()
 
 HcalLutManager (std::vector< HcalGenericDetId > &map)
 
 HcalLutManager (const HcalElectronicsMap *_emap, const HcalChannelQuality *_cq=0, uint32_t _status_word_to_mask=0x0000)
 
 HcalLutManager (const HcalDbService *conditions, const HcalChannelQuality *_cq=0, 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, boost::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 43 of file HcalLutManager.h.

Constructor & Destructor Documentation

HcalLutManager::HcalLutManager ( void  )

Definition at line 45 of file HcalLutManager.cc.

References init.

46 {
47  init();
48 }
void init(void)
HcalLutManager::HcalLutManager ( std::vector< HcalGenericDetId > &  map)

Definition at line 51 of file HcalLutManager.cc.

References init.

52 {
53  init();
54  _iter . init(map);
55 }
HcalChannelIterator _iter
void init(void)
HcalLutManager::HcalLutManager ( const HcalElectronicsMap _emap,
const HcalChannelQuality _cq = 0,
uint32_t  _status_word_to_mask = 0x0000 
)

Definition at line 58 of file HcalLutManager.cc.

References init.

61 {
62  init();
63  emap = _emap;
64  cq = _cq;
65  status_word_to_mask = _status_word_to_mask;
66 }
const HcalChannelQuality * cq
void init(void)
const HcalElectronicsMap * emap
uint32_t status_word_to_mask
HcalLutManager::HcalLutManager ( const HcalDbService conditions,
const HcalChannelQuality _cq = 0,
uint32_t  _status_word_to_mask = 0x0000 
)

Definition at line 68 of file HcalLutManager.cc.

References HcalDbService::getHcalMapping(), and init.

71 {
72  init();
73  conditions=_conditions;
74  emap = conditions->getHcalMapping();
75  cq = _cq;
76  status_word_to_mask = _status_word_to_mask;
77 }
const HcalChannelQuality * cq
void init(void)
const HcalElectronicsMap * emap
const HcalElectronicsMap * getHcalMapping() const
uint32_t status_word_to_mask
HcalLutManager::~HcalLutManager ( void  )

Definition at line 94 of file HcalLutManager.cc.

95 {
96  delete lut_xml;
97  delete lut_checksums_xml;
98  delete db;
99  delete lmap;
100 }
HCALConfigDB * db
XMLDOMBlock * lut_checksums_xml

Member Function Documentation

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

Definition at line 1202 of file HcalLutManager.cc.

References edm::eventsetup::heterocontainer::insert(), lumiPlot::lut, genParticles_cff::map, trackingPlots::other, and mps_fire::result.

1203 {
1204  for ( std::map<int, boost::shared_ptr<LutXml> >::const_iterator lut=other.begin(); lut!=other.end(); lut++ ){
1205  edm::LogInfo("HcalLutManager") << "Added LUTs for crate " << lut->first;
1206  if ( result.count(lut->first)==0 ){
1207  result . insert( *lut );
1208  }
1209  else{
1210  *(result[lut->first]) += *(lut->second);
1211  }
1212  }
1213 }
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
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 1495 of file HcalLutManager.cc.

References mps_setup::append, begin, comment, XMLLUTLoader::_lutDBConfig::crate, common_cff::doc, end, cmsPerfSuiteHarvest::file_name, getInt(), HcalQIEManager::splitString(), AlCaHLTBitMon_QueryRunRegistry::string, XMLProcessor::_DBConfig::subversion, ntuplemaker::time, jets_cff::version, XMLProcessor::_DBConfig::version, and TriggerAnalyzer::write().

Referenced by main().

1496 {
1497  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs...";
1498  //std::cout << _prefix << "..." << tag_name << std::endl;
1499 
1503 
1504  baseConf . tag_name = tag_name;
1505  //baseConf . comment_description = tag_name;
1506  baseConf . comment_description = comment;
1507  baseConf . iov_begin = "1";
1508  baseConf . iov_end = "-1";
1509 
1510  conf . version = version;
1511 
1512  std::stringstream _subversion;
1513  _subversion << subversion;
1514  conf . subversion = _subversion.str();
1515 
1516  CSconf . version = conf . version;
1517  CSconf . subversion = conf . subversion;
1518  CSconf . trig_prim_lookuptbl_data_file = _prefix + "_checksums.xml.dat";
1519  CSconf . comment_description = tag_name;
1520 
1521  XMLLUTLoader doc( &baseConf );
1522 
1523  std::vector<int> crate_number;
1524  std::vector<std::string> file_name = HcalQIEManager::splitString(file_list);
1525  for (std::vector<std::string>::const_iterator _f = file_name.begin(); _f != file_name.end(); _f++){
1526  int crate_begin = _f->rfind("_");
1527  int crate_end = _f->rfind(".xml.dat");
1528  crate_number . push_back(getInt(_f->substr(crate_begin+1,crate_end-crate_begin-1)));
1529  }
1530  //
1531  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1532  //
1533  char _buf[128];
1534  time_t _offset = time(nullptr);
1535  sprintf( _buf, "%d", (uint32_t)_offset );
1536  conf.version.append(".");
1537  conf.version.append(_buf);
1538  CSconf.version = conf.version;
1539  //
1540  for ( std::vector<std::string>::const_iterator _file = file_name . begin(); _file != file_name . end(); _file++ )
1541  {
1542  conf . trig_prim_lookuptbl_data_file = *_file;
1543  //conf . trig_prim_lookuptbl_data_file += ".dat";
1544  conf . crate = crate_number[ _file - file_name . begin() ];
1545  //
1546  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1547  //
1548  sprintf( _buf, "%.2d", conf.crate );
1549  conf.subversion.clear();
1550  conf.subversion.append(_buf);
1551  sprintf( _buf, "CRATE%.2d", conf . crate );
1552  std::string _namelabel;
1553  _namelabel . append( _buf );
1554  conf . name_label = _namelabel;
1555  doc . addLUT( &conf );
1556  }
1557 
1558  doc . addChecksums( &CSconf );
1559  //doc . write( _prefix + "_Loader.xml" );
1560  doc . write( tag_name + "_Loader.xml" );
1561 
1562  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs... done.";
1563 
1564  return 0;
1565 }
static std::vector< std::string > splitString(const std::string &fLine)
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
static int getInt(std::string number)
def write(self, setup)
#define comment(par)
Definition: vmac.h:163
int HcalLutManager::createAllLutXmlFiles ( std::string  _tag,
std::string  _lin_file,
std::string  _comp_file,
bool  split_by_crate = true 
)

Definition at line 1061 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1062 {
1063  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1064  std::map<int, boost::shared_ptr<LutXml> > xml;
1065  if ( !lut_checksums_xml ){
1066  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1067  }
1068 
1069  if ( !_lin_file.empty() ){
1070  //addLutMap( xml, getLutXmlFromAsciiMaster( _lin_file, _tag, -1, split_by_crate ) );
1071  addLutMap( xml, getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate ) );
1072  }
1073  if ( !_comp_file.empty() ){
1074  //std::cout << "DEBUG1!!!!" << std::endl;
1075  addLutMap( xml, getCompressionLutXmlFromAsciiMaster( _comp_file, _tag, -1, split_by_crate ) );
1076  //std::cout << "DEBUG2!!!!" << std::endl;
1077  }
1078  writeLutXmlFiles( xml, _tag, split_by_crate );
1079 
1080  std::string checksums_file = _tag + "_checksums.xml";
1081  lut_checksums_xml -> write( checksums_file );
1082 
1083  return 0;
1084 }
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromAsciiMaster(std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
def write(self, setup)
int HcalLutManager::createAllLutXmlFilesFromCoder ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1104 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1105 {
1106  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1107  std::map<int, boost::shared_ptr<LutXml> > xml;
1108  if ( !lut_checksums_xml ){
1109  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1110  }
1111 
1112  //addLutMap( xml, getLinearizationLutXmlFromCoder( _coder, _tag, split_by_crate ) );
1113  addLutMap( xml, getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate ) );
1114  addLutMap( xml, getCompressionLutXmlFromCoder( _tag, 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 }
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
def write(self, setup)
int HcalLutManager::createAllLutXmlFilesLinAsciiCompCoder ( std::string  _tag,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1180 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1181 {
1182  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1183  std::map<int, boost::shared_ptr<LutXml> > xml;
1184  if ( !lut_checksums_xml ){
1185  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1186  }
1187 
1188  if ( !_lin_file.empty() ){
1189  addLutMap( xml, getLutXmlFromAsciiMaster( _lin_file, _tag, -1, split_by_crate ) );
1190  }
1191  addLutMap( xml, getCompressionLutXmlFromCoder( _tag, split_by_crate ) );
1192  writeLutXmlFiles( xml, _tag, split_by_crate );
1193 
1194  std::string checksums_file = _tag + "_checksums.xml";
1195  lut_checksums_xml -> write( checksums_file );
1196 
1197  return 0;
1198 }
std::map< int, boost::shared_ptr< LutXml > > getLutXmlFromAsciiMaster(std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
def write(self, setup)
int HcalLutManager::createCompLutXmlFilesFromCoder ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1086 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1087 {
1088  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1089  std::map<int, boost::shared_ptr<LutXml> > xml;
1090  if ( !lut_checksums_xml ){
1091  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1092  }
1093 
1094  addLutMap( xml, getCompressionLutXmlFromCoder( _tag, split_by_crate ) );
1095 
1096  writeLutXmlFiles( xml, _tag, split_by_crate );
1097 
1098  std::string checksums_file = _tag + "_checksums.xml";
1099  lut_checksums_xml -> write( checksums_file );
1100 
1101  return 0;
1102 }
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
def write(self, setup)
int HcalLutManager::createLinLutXmlFiles ( std::string  _tag,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1042 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1043 {
1044  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1045  std::map<int, boost::shared_ptr<LutXml> > xml;
1046  if ( !lut_checksums_xml ){
1047  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1048  }
1049 
1050  if ( !_lin_file.empty() ){
1051  addLutMap( xml, getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate ) );
1052  }
1053  writeLutXmlFiles( xml, _tag, split_by_crate );
1054 
1055  std::string checksums_file = _tag + "_checksums.xml";
1056  lut_checksums_xml -> write( checksums_file );
1057 
1058  return 0;
1059 }
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
def write(self, setup)
int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii ( std::string  _tag,
const HcalTPGCoder _coder,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1153 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1154 {
1155  std::map<int, boost::shared_ptr<LutXml> > xml;
1156  if ( !lut_checksums_xml ){
1157  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1158  }
1159 
1160  if ( !_lin_file.empty() ){
1161  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_ascii_xml = getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate );
1162  addLutMap( xml, _lin_lut_ascii_xml );
1163  }
1164  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_xml = getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate );
1165  addLutMap( xml, _lin_lut_xml );
1166  //
1167  const std::map<int, boost::shared_ptr<LutXml> > _comp_lut_xml = getCompressionLutXmlFromCoder( _tag, split_by_crate );
1168  addLutMap( xml, _comp_lut_xml );
1169 
1170  writeLutXmlFiles( xml, _tag, split_by_crate );
1171 
1172  std::string checksums_file = _tag + "_checksums.xml";
1173  lut_checksums_xml -> write( checksums_file );
1174 
1175  return 0;
1176 }
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
def write(self, setup)
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 1127 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

1128 {
1129  std::map<int, boost::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  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_ascii_xml = getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate );
1136  addLutMap( xml, _lin_lut_ascii_xml );
1137  }
1138  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_xml = getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate );
1139  addLutMap( xml, _lin_lut_xml );
1140  //
1141  const std::map<int, boost::shared_ptr<LutXml> > _comp_lut_xml = getCompressionLutXmlFromCoder( _transcoder, _tag, split_by_crate );
1142  addLutMap( xml, _comp_lut_xml );
1143 
1144  writeLutXmlFiles( xml, _tag, split_by_crate );
1145 
1146  std::string checksums_file = _tag + "_checksums.xml";
1147  lut_checksums_xml -> write( checksums_file );
1148 
1149  return 0;
1150 }
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
def write(self, setup)
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 1630 of file HcalLutManager.cc.

References masks, AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

Referenced by HcalLutGenerator::analyze().

1631 {
1632  std::map<int, boost::shared_ptr<LutXml> > xml;
1633  if ( !lut_checksums_xml ){
1634  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1635  }
1636 
1637  if ( !_lin_file.empty() ){
1638  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_ascii_xml = getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate );
1639  addLutMap( xml, _lin_lut_ascii_xml );
1640  }
1641  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_xml = getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate );
1642  addLutMap( xml, _lin_lut_xml );
1643  //
1644  const std::map<int, boost::shared_ptr<LutXml> > _comp_lut_xml = getCompressionLutXmlFromCoder( _transcoder, _tag, split_by_crate );
1645  addLutMap( xml, _comp_lut_xml );
1646 
1647  for(auto masktype: {0,1,2}){
1648  const auto masks=getMasks(masktype, _tag, split_by_crate);
1649  addLutMap(xml, masks);
1650  }
1651  //
1652  const std::map<int, boost::shared_ptr<LutXml> > _zdc_lut_xml = getZdcLutXml( _tag, split_by_crate );
1653  addLutMap( xml, _zdc_lut_xml );
1654 
1655  writeLutXmlFiles( xml, _tag, split_by_crate );
1656 
1657  std::string checksums_file = _tag + "_checksums.xml";
1658  lut_checksums_xml -> write( checksums_file );
1659 
1660  return 0;
1661 }
std::map< int, boost::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
void addLutMap(std::map< int, boost::shared_ptr< LutXml > > &result, const std::map< int, boost::shared_ptr< LutXml > > &other)
std::map< int, boost::shared_ptr< LutXml > > getZdcLutXml(std::string _tag, bool split_by_crate=true)
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
XMLDOMBlock * lut_checksums_xml
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
std::map< int, boost::shared_ptr< LutXml > > getMasks(int var, std::string _tag, bool split_by_crate=true)
constexpr uint32_t masks[]
Definition: CaloRecHit.cc:12
std::map< int, boost::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
def write(self, setup)
std::map< int, boost::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 1424 of file HcalLutManager.cc.

References connect(), MillePedeFileConverter_cfg::e, XMLProcessor::getInstance(), AlCaHLTBitMon_QueryRunRegistry::string, and toolbox::toString().

1425 {
1426  HCALConfigDB * db = new HCALConfigDB();
1427  XMLProcessor::getInstance(); // initialize xerces-c engine
1428  //const std::string _accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22";
1429  db -> connect( _accessor );
1430  oracle::occi::Connection * _connection = db -> getConnection();
1431 
1432  edm::LogInfo("HcalLutManager") << "Preparing to request the LUT CLOBs from the database...";
1433 
1434  //int crate = 0;
1435 
1436  //
1437  // _____ query is different for the old validation DB _________________
1438  //
1439  //std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_TRIG_LOOKUP_TABLES");
1440  std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_COND.V_HCAL_TRIG_LOOKUP_TABLES");
1441  //query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d", tag.c_str(), crate);
1442  query+=toolbox::toString(" WHERE TAG_NAME='%s'", tag.c_str() );
1443 
1444  std::string brick_set;
1445 
1446  std::map<int, boost::shared_ptr<LutXml> > lut_map;
1447 
1448  try {
1449  //SELECT
1450  edm::LogInfo("HcalLutManager") << "Executing the query...";
1451  Statement* stmt = _connection -> createStatement();
1452  ResultSet *rs = stmt->executeQuery(query);
1453  edm::LogInfo("HcalLutManager") << "Executing the query... done";
1454 
1455  edm::LogInfo("HcalLutManager") << "Processing the query results...";
1456  //RooGKCounter _lines;
1457  while (rs->next()) {
1458  //_lines.count();
1459  oracle::occi::Clob clob = rs->getClob (1);
1460  int crate = rs->getInt(2);
1461  if ( crate != -1 ){ // not a brick with checksums
1462  edm::LogInfo("HcalLutManager") << "Getting LUTs for crate #" << crate << " out of the database...";
1463  brick_set = db -> clobToString(clob);
1464  /*
1465  // FIXME: DEBUG lut xml files from simple strings
1466  stringstream file_name;
1467  ofstream out_file;
1468  file_name << tag << "_" << crate << "_debug" << ".xml";
1469  out_file . open( file_name.str().c_str() );
1470  out_file << brick_set;
1471  out_file . close();
1472  */
1473  const char * bs = brick_set . c_str();
1474  MemBufInputSource * lut_clob = new MemBufInputSource( (const XMLByte *)bs, strlen( bs ), "lut_clob", false );
1475  boost::shared_ptr<LutXml> lut_xml = boost::shared_ptr<LutXml>( new LutXml( *lut_clob ) );
1476  lut_map[crate] = lut_xml;
1477  edm::LogInfo("HcalLutManager") << "done";
1478  }
1479  }
1480  //Always terminate statement
1481  _connection -> terminateStatement(stmt);
1482  //std::cout << "Query line count: " << _lines.getCount() << std::endl;
1483  } catch (SQLException& e) {
1484  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()));
1485  }
1486 
1487  //std::cout << lut_map.size() << std::endl;
1488 
1489  db -> disconnect();
1490  //delete db;
1491  return lut_map;
1492 }
Definition: LutXml.h:27
HCALConfigDB * db
Definition: query.py:1
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
Gather config data from online DB.
Definition: HCALConfigDB.h:21
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:145
std::string HcalLutManager::get_checksum ( std::vector< unsigned int > &  lut)
HcalSubdetector HcalLutManager::get_subdetector ( std::string  _subdet)
static

Definition at line 136 of file HcalLutManager.cc.

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

137 {
139  if ( _det.find("HB") != std::string::npos ) result = HcalBarrel;
140  else if ( _det.find("HE") != std::string::npos ) result = HcalEndcap;
141  else if ( _det.find("HF") != std::string::npos ) result = HcalForward;
142  else if ( _det.find("HO") != std::string::npos ) result = HcalOuter;
143  else result = HcalOther;
144 
145  return result;
146 }
HcalSubdetector
Definition: HcalAssistant.h:31
string HcalLutManager::get_time_stamp ( time_t  _time)
static

Definition at line 1218 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1219 {
1220  char timebuf[50];
1221  //strftime( timebuf, 50, "%c", gmtime( &_time ) );
1222  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S", gmtime( &_time ) );
1223  std::string creationstamp = timebuf;
1224 
1225  return creationstamp;
1226 }
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 1405 of file HcalLutManager.cc.

References genParticles_cff::map, mps_fire::result, and TriggerAnalyzer::write().

1406 {
1407  std::map<int, boost::shared_ptr<LutXml> > lut_map = get_brickSet_from_oracle( tag, db_accessor );
1408  if (split_by_crate){
1409  writeLutXmlFiles( lut_map, tag, split_by_crate );
1410  }
1411  else{
1412  LutXml result;
1413  for( std::map<int, boost::shared_ptr<LutXml> >::const_iterator xml = lut_map.begin(); xml != lut_map.end(); xml++ ){
1414  result += *(xml->second);
1415  }
1416  std::stringstream out_file;
1417  out_file << tag << ".xml";
1418  result . write(out_file.str());
1419  }
1420 
1421  return 0;
1422 }
Definition: LutXml.h:27
std::map< int, boost::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")
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
def write(self, setup)
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromAsciiMaster ( std::string  _filename,
std::string  _tag,
int  _crate = -1,
bool  split_by_crate = true 
)

Definition at line 547 of file HcalLutManager.cc.

References python.rootplot.argparse::_set, 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), CaloTPGTranscoderULUT::HTvalid(), mps_fire::i, LutXml::_Config::ieta, LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

548 {
549  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from ascii master file...";
550  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
551 
552  edm::LogInfo("HcalLutManager") << "instantiating CaloTPGTranscoderULUT in order to check the validity of (ieta,iphi)...";
553  CaloTPGTranscoderULUT _coder;
554 
555  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
556  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
557  EMap _emap(emap);
558  std::vector<EMap::EMapRow> & _map = _emap.get_map();
559  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
560 
561  // read LUTs and their eta/phi/depth/subdet ranges
562  HcalLutSet _set = getLutSetFromFile( _filename, 2 );
563  int lut_set_size = _set.lut.size(); // number of different luts
564  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
565 
566  //loop over all EMap channels
567  RooGKCounter _counter;
568  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
569  LutXml::Config _cfg;
570 
571  // search for the correct LUT for a given channel,
572  // higher LUT numbers have priority in case of overlapping
573  int lut_index=-1;
574  for ( int i=0; i<lut_set_size; i++ ){
575  if ( row->subdet . find("HT") != std::string::npos &&
576  (row->crate == _crate || _crate == -1) && // -1 stands for all crates
577  _set.eta_min[i] <= row->ieta &&
578  _set.eta_max[i] >= row->ieta &&
579  _set.phi_min[i] <= row->iphi &&
580  _set.phi_max[i] >= row->iphi &&
581  _coder.HTvalid(row->ieta, row->iphi, row->idepth / 10) ){
582  lut_index=i;
583  }
584  }
585  if ( lut_index >= 0 ){
586  if ( _xml.count(row->crate) == 0 && split_by_crate ){
587  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
588  }
589  else if ( _xml.count(0) == 0 && !split_by_crate ){
590  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
591  }
592  _cfg.ieta = row->ieta;
593  _cfg.iphi = row->iphi;
594  _cfg.depth = row->idepth;
595  _cfg.crate = row->crate;
596  _cfg.slot = row->slot;
597  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
598  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
599  else if (row->topbottom . find("u") != std::string::npos) _cfg.topbottom = 2;
600  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
601  _cfg.fiber = row->fiber;
602  _cfg.fiberchan = row->fiberchan;
603  if (_set.lut[lut_index].size() == 128) _cfg.lut_type = 1;
604  else _cfg.lut_type = 2;
605  _cfg.creationtag = _tag;
606  _cfg.creationstamp = get_time_stamp( time(nullptr) );
607  _cfg.targetfirmware = "1.0.0";
608  _cfg.formatrevision = "1"; //???
609  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
610  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
611  // ((id.ieta()<0)?(0):(100));
612  _cfg.generalizedindex =
613  _cfg.iphi*10000+
614  (row->ieta>0)*100+abs(row->ieta);
615  _cfg.lut = _set.lut[lut_index];
616  if (split_by_crate ){
617  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
618  _counter.count();
619  }
620  else{
621  _xml[0]->addLut( _cfg, lut_checksums_xml );
622  _counter.count();
623  }
624  }
625  }
626  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
627  << "Generating compression (output) LUTs from ascii master file...DONE" << std::endl;
628  return _xml;
629 }
size
Write out results.
std::vector< std::vector< unsigned int > > lut
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:40
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
std::vector< int > phi_min
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
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:38
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
std::vector< int > eta_max
Definition: LMap.h:94
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
std::vector< int > eta_min
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromCoder ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 947 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), CaloTPGTranscoderULUT::getCompressionLUT(), RooGKCounter::getCount(), CaloTPGTranscoderULUT::HTvalid(), LutXml::_Config::ieta, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

948 {
949  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT";
950  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
951 
952  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
953  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
954  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
955  EMap _emap(emap);
956 
957  std::vector<EMap::EMapRow> & _map = _emap.get_map();
958  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
959 
960  // read LUTs and their eta/phi/depth/subdet ranges
961  //HcalLutSet _set = getLutSetFromFile( _filename, 2 );
962  //int lut_set_size = _set.lut.size(); // number of different luts
963 
964  CaloTPGTranscoderULUT _coder;
965 
966  //loop over all EMap channels
967  RooGKCounter _counter;
968  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
969  LutXml::Config _cfg;
970 
971  // only trigger tower channels
972  // and valid (ieta,iphi)
973  const int tp_version = row->idepth / 10;
974  if ( row->subdet . find("HT") != std::string::npos && _coder.HTvalid(row->ieta, row->iphi, tp_version) ){
975  if ( _xml.count(row->crate) == 0 && split_by_crate ){
976  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
977  }
978  else if ( _xml.count(0) == 0 && !split_by_crate ){
979  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
980  }
981  _cfg.ieta = row->ieta;
982  _cfg.iphi = row->iphi;
983  _cfg.depth = row->idepth;
984  _cfg.crate = row->crate;
985  _cfg.slot = row->slot;
986  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
987  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
988  else if (row->topbottom . find("u") != std::string::npos) _cfg.topbottom = 2;
989  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
990  _cfg.fiber = row->fiber;
991  _cfg.fiberchan = row->fiberchan;
992  _cfg.lut_type = 2;
993  _cfg.creationtag = _tag;
994  _cfg.creationstamp = get_time_stamp( time(nullptr) );
995  _cfg.targetfirmware = "1.0.0";
996  _cfg.formatrevision = "1"; //???
997  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
998  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
999  // ((id.ieta()<0)?(0):(100));
1000  _cfg.generalizedindex =
1001  _cfg.iphi*10000+
1002  (row->ieta>0)*100+abs(row->ieta);
1003 
1004  // FIXME: work around bug in emap v6: rawId wasn't filled
1005  //HcalTrigTowerDetId _detid(row->rawId);
1006  HcalTrigTowerDetId _detid(row->ieta, row->iphi);
1007 
1008  _cfg.lut = _coder.getCompressionLUT(_detid);
1009 
1010  if (split_by_crate ){
1011  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
1012  _counter.count();
1013  }
1014  else{
1015  _xml[0]->addLut( _cfg, lut_checksums_xml );
1016  _counter.count();
1017  }
1018  }
1019  }
1020  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1021  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE" << std::endl;
1022  return _xml;
1023 }
size
Write out results.
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
virtual const std::vector< unsigned int > getCompressionLUT(const HcalTrigTowerDetId &id) const
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string formatrevision
Definition: LutXml.h:38
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:94
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromCoder ( const CaloTPGTranscoderULUT _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 859 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), CaloTPGTranscoderULUT::getCompressionLUT(), RooGKCounter::getCount(), mps_fire::i, LutXml::_Config::ieta, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

860 {
861  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT," << std::endl
862  << "initialized from Event Setup" << std::endl;
863  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
864 
865  EMap _emap(emap);
866 
867  std::map<int,unsigned int> maxsize;
868 
869  std::vector<EMap::EMapRow> & _map = _emap.get_map();
870  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
871 
872  //need to equalize compression LUT size in each crate-slot, needed for mixed uHTR
873  for(const auto& row : _map){
874  if ( row.subdet.find("HT") == std::string::npos) continue;
875  HcalTrigTowerDetId _detid(row.rawId);
876  if(!cq->topo()->validHT(_detid)) continue;
877  int crot=100*row.crate+row.slot;
878  unsigned int size=_coder.getCompressionLUT(_detid).size();
879  if(maxsize.count(crot)==0 || size>maxsize[crot]) maxsize[crot]=size;
880  }
881 
882 
883  RooGKCounter _counter;
884  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
885  LutXml::Config _cfg;
886 
887  if ( row->subdet.find("HT") == std::string::npos) continue;
888 
889  HcalTrigTowerDetId _detid(row->rawId);
890 
891  if(!cq->topo()->validHT(_detid)) continue;
892 
893 
894  if ( _xml.count(row->crate) == 0 && split_by_crate ){
895  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
896  }
897  else if ( _xml.count(0) == 0 && !split_by_crate ){
898  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
899  }
900 
901  _cfg.ieta = row->ieta;
902  _cfg.iphi = row->iphi;
903  _cfg.depth = row->idepth;
904  _cfg.crate = row->crate;
905  _cfg.slot = row->slot;
906  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
907  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
908  else if (row->topbottom . find("u") != std::string::npos) _cfg.topbottom = 2;
909  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
910  _cfg.fiber = row->fiber;
911  _cfg.fiberchan = row->fiberchan;
912  _cfg.lut_type = 2;
913  _cfg.creationtag = _tag;
914  _cfg.creationstamp = get_time_stamp( time(nullptr) );
915  _cfg.targetfirmware = "1.0.0";
916  _cfg.formatrevision = "1"; //???
917  _cfg.generalizedindex =_cfg.iphi*10000+ (row->ieta>0)*100+abs(row->ieta); //is this used for anything?
918 
919  _cfg.lut = _coder.getCompressionLUT(_detid);
920 
921  int crot=100*row->crate+row->slot;
922  unsigned int size=_cfg.lut.size();
923  if(size<maxsize[crot]){
924  edm::LogWarning("HcalLutManager") << " resizing LUT for " << _detid
925  << ", channel=[" <<_cfg.crate<<":"<<_cfg.slot<<":"<<_cfg.fiber<<":"<<_cfg.fiberchan
926  << "], using value=" << _cfg.lut[size-1] << std::endl;
927  for(unsigned int i=size; i<maxsize[crot]; ++i) _cfg.lut.push_back(_cfg.lut[size-1]);
928  }
929 
930  if (split_by_crate ){
931  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
932  _counter.count();
933  }
934  else{
935  _xml[0]->addLut( _cfg, lut_checksums_xml );
936  _counter.count();
937  }
938  }
939  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
940  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE" << std::endl;
941 
942  return _xml;
943 }
size
Write out results.
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
virtual const std::vector< unsigned int > getCompressionLUT(const HcalTrigTowerDetId &id) const
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
const HcalChannelQuality * cq
std::string creationtag
Definition: LutXml.h:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string formatrevision
Definition: LutXml.h:38
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:94
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
const HcalTopology * topo() const
bool validHT(const HcalTrigTowerDetId &id) const
int HcalLutManager::getInt ( std::string  number)
static

Definition at line 129 of file HcalLutManager.cc.

References mps_fire::result.

Referenced by getLutSetFromFile().

130 {
131  int result;
132  sscanf(number.c_str(), "%d", &result);
133  return result;
134 }
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap ( std::string  _filename,
std::string  _tag,
int  _crate,
bool  split_by_crate = true 
)

Definition at line 353 of file HcalLutManager.cc.

References python.rootplot.argparse::_set, funct::abs(), ecalMGPA::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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), mps_fire::i, LutXml::_Config::ieta, LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, findQualityFiles::size, LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

354 {
355  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
356  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
357 
358  EMap _emap(emap);
359  std::vector<EMap::EMapRow> & _map = _emap.get_map();
360  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " entries";
361 
362  // read LUTs and their eta/phi/depth/subdet ranges
363  HcalLutSet _set = getLutSetFromFile( _filename );
364  int lut_set_size = _set.lut.size(); // number of different luts
365  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
366 
367  // setup "zero" LUT for channel masking
368  std::vector<unsigned int> zeroLut;
369  for (size_t adc = 0; adc < 128; adc++) zeroLut.push_back(0);
370 
371  RooGKCounter _counter;
372  //loop over all EMap channels
373  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
374  if( (row->subdet.find("HB")!=string::npos ||
375  row->subdet.find("HE")!=string::npos ||
376  row->subdet.find("HO")!=string::npos ||
377  row->subdet.find("HF")!=string::npos ) &&
378  row->subdet.size()==2
379  ){
380  LutXml::Config _cfg;
381 
382  // search for the correct LUT for a given channel,
383  // higher LUT numbers have priority in case of overlapping
384  int lut_index=-1;
385  for ( int i=0; i<lut_set_size; i++ ){
386  if ( (row->crate == _crate || _crate == -1) && // -1 stands for all crates
387  _set.eta_min[i] <= row->ieta &&
388  _set.eta_max[i] >= row->ieta &&
389  _set.phi_min[i] <= row->iphi &&
390  _set.phi_max[i] >= row->iphi &&
391  _set.depth_min[i] <= row->idepth &&
392  _set.depth_max[i] >= row->idepth &&
393  _set.subdet[i].find(row->subdet)!=string::npos ){
394  lut_index=i;
395  }
396  }
397  if ( lut_index >= 0 ){
398  if ( _xml.count(row->crate) == 0 && split_by_crate ){
399  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
400  }
401  else if ( _xml.count(0) == 0 && !split_by_crate ){
402  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
403  }
404  _cfg.ieta = row->ieta;
405  _cfg.iphi = row->iphi;
406  _cfg.depth = row->idepth;
407  _cfg.crate = row->crate;
408  _cfg.slot = row->slot;
409  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
410  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
411  else if (row->topbottom . find("u") != std::string::npos) _cfg.topbottom = 2;
412  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
413  _cfg.fiber = row->fiber;
414  _cfg.fiberchan = row->fiberchan;
415  _cfg.lut_type = 1;
416  _cfg.creationtag = _tag;
417  _cfg.creationstamp = get_time_stamp( time(nullptr) );
418  _cfg.targetfirmware = "1.0.0";
419  _cfg.formatrevision = "1"; //???
420  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
421  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
422  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
423  _cfg.generalizedindex =
424  _cfg.iphi*10000 + _cfg.depth*1000 +
425  (row->ieta>0)*100 + abs(row->ieta) +
426  (((row->subdet.find("HF")!=string::npos) && abs(row->ieta)==29)?(4*10000):(0));
427  //
428  // consider channel status here
429  DetId _detId(row->rawId);
430  uint32_t status_word = cq->getValues(_detId)->getValue();
431  if ((status_word & status_word_to_mask) > 0){
432  _cfg.lut = zeroLut;
433  }
434  else{
435  _cfg.lut = _set.lut[lut_index];
436  }
437  if (split_by_crate ){
438  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
439  _counter.count();
440  }
441  else{
442  _xml[0]->addLut( _cfg, lut_checksums_xml );
443  _counter.count();
444  }
445  }
446  }
447  }
448  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
449  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
450  return _xml;
451 }
int adc(sample_type sample)
get the ADC sample (12 bits)
size
Write out results.
std::vector< std::vector< unsigned int > > lut
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:40
std::vector< std::string > subdet
std::vector< int > phi_min
std::vector< int > depth_max
const Item * getValues(DetId fId, bool throwOnFail=true) const
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
const HcalChannelQuality * cq
std::string creationtag
Definition: LutXml.h:36
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:38
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
Definition: DetId.h:18
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
std::vector< int > eta_max
Definition: LMap.h:94
uint32_t getValue() const
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
std::vector< int > eta_min
uint32_t status_word_to_mask
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap_new ( std::string  _filename,
std::string  _tag,
int  _crate,
bool  split_by_crate = true 
)

Definition at line 454 of file HcalLutManager.cc.

References python.rootplot.argparse::_set, 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, LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

455 {
456  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
457  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
458 
459  // read LUTs and their eta/phi/depth/subdet ranges
460  HcalLutSet _set = getLutSetFromFile( _filename );
461  int lut_set_size = _set.lut.size(); // number of different luts
462  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
463 
464  RooGKCounter _counter;
465  //loop over all EMap channels
466  for( _iter.begin(); !_iter.end(); _iter.next() ){
468  if( (_subdet == HcalBarrel ||
469  _subdet == HcalEndcap ||
470  _subdet == HcalForward ||
471  _subdet == HcalOuter )
472  ){
473  int _ieta = _iter.getIeta();
474  int _iphi = _iter.getIphi();
475  int _depth = _iter.getDepth();
476 
477  // FIXME: this is probably wrong, raw ids are different
479  int aCrate = _eId . readoutVMECrateId();
480  int aSlot = _eId . htrSlot();
481  int aTopBottom = _eId . htrTopBottom();
482  int aFiber = _eId . fiberIndex();
483  int aFiberChan = _eId . fiberChanId();
484 
485  LutXml::Config _cfg;
486 
487  // search for the correct LUT for a given channel,
488  // higher LUT numbers have priority in case of overlapping
489  int lut_index=-1;
490  for ( int i=0; i<lut_set_size; i++ ){
491  if ( (aCrate == _crate || _crate == -1) && // -1 stands for all crates
492  _set.eta_min[i] <= _ieta &&
493  _set.eta_max[i] >= _ieta &&
494  _set.phi_min[i] <= _iphi &&
495  _set.phi_max[i] >= _iphi &&
496  _set.depth_min[i] <= _depth &&
497  _set.depth_max[i] >= _depth &&
498  _set.subdet[i].find(_ass.getSubdetectorString(_subdet))!=string::npos ){
499  lut_index=i;
500  }
501  }
502  if ( lut_index >= 0 ){
503  if ( _xml.count(aCrate) == 0 && split_by_crate ){
504  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(aCrate,boost::shared_ptr<LutXml>(new LutXml())) );
505  }
506  else if ( _xml.count(0) == 0 && !split_by_crate ){
507  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
508  }
509  _cfg.ieta = _ieta;
510  _cfg.iphi = _iphi;
511  _cfg.depth = _depth;
512  _cfg.crate = aCrate;
513  _cfg.slot = aSlot;
514  _cfg.topbottom = aTopBottom;
515  _cfg.fiber = aFiber;
516  _cfg.fiberchan = aFiberChan;
517  _cfg.lut_type = 1;
518  _cfg.creationtag = _tag;
519  _cfg.creationstamp = get_time_stamp( time(nullptr) );
520  _cfg.targetfirmware = "1.0.0";
521  _cfg.formatrevision = "1"; //???
522  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
523  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
524  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
525  _cfg.generalizedindex =
526  _cfg.iphi*10000 + _cfg.depth*1000 +
527  (_ieta>0)*100 + abs(_ieta) +
528  (((_subdet==HcalForward) && abs(_ieta)==29)?(4*10000):(0));
529  _cfg.lut = _set.lut[lut_index];
530  if (split_by_crate ){
531  _xml[aCrate]->addLut( _cfg, lut_checksums_xml );
532  _counter.count();
533  }
534  else{
535  _xml[0]->addLut( _cfg, lut_checksums_xml );
536  _counter.count();
537  }
538  }
539  }
540  }
541  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
542  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
543  return _xml;
544 }
std::vector< std::vector< unsigned int > > lut
std::string getSubdetectorString(HcalSubdetector _det)
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
std::vector< int > phi_max
int generalizedindex
Definition: LutXml.h:40
std::vector< std::string > subdet
std::vector< int > phi_min
std::vector< int > depth_max
unsigned long int getCount(void)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
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:38
XMLDOMBlock * lut_checksums_xml
void count(void)
Definition: RooGKCounter.cc:66
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:35
std::string creationstamp
Definition: LutXml.h:37
Readout chain identification for Hcal.
int fiberchan
Definition: LutXml.h:35
std::vector< int > eta_min
HcalSubdetector getHcalSubdetector(void)
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromCoder ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 632 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, LMap::get_map(), RooGKCounter::getCount(), HcalForward, LutXml::_Config::ieta, createfilelist::int, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

633 {
634  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
635  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
636 
637  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
638  //std::vector<EMap::EMapRow> & _map = _emap.get_map();
639  //std::cout << "EMap contains " << _map . size() << " entries" << std::endl;
640 
641  LMap _lmap;
642  _lmap . read( "backup/HCALmapHBEF.txt", "HBEF" );
643  // HO is not part of trigger, so TPGCoder cannot generate LUTs for it
644  //_lmap . read( "backup/HCALmapHO.txt", "HO" );
645  std::map<int,LMapRow> & _map = _lmap.get_map();
646  edm::LogInfo("HcalLutManager") << "LMap contains " << _map . size() << " channels";
647 
648  // read LUTs and their eta/phi/depth/subdet ranges
649  //HcalLutSet _set = getLinearizationLutSetFromCoder();
650  //int lut_set_size = _set.lut.size(); // number of different luts
651 
652  //loop over all HCAL channels
653  RooGKCounter _counter;
654  for( std::map<int,LMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
655  LutXml::Config _cfg;
656 
657  if ( _xml.count(row->second.crate) == 0 && split_by_crate ){
658  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->second.crate,boost::shared_ptr<LutXml>(new LutXml())) );
659  }
660  else if ( _xml.count(0) == 0 && !split_by_crate ){
661  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
662  }
663  _cfg.ieta = row->second.side*row->second.eta;
664  _cfg.iphi = row->second.phi;
665  _cfg.depth = row->second.depth;
666  _cfg.crate = row->second.crate;
667  _cfg.slot = row->second.htr;
668  if (row->second.fpga . find("top") != std::string::npos) _cfg.topbottom = 1;
669  else if (row->second.fpga . find("bot") != std::string::npos) _cfg.topbottom = 0;
670  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
671  // FIXME: probably fixed. fiber==htr_fi, not rm_fi in LMAP notation.
672  //_cfg.fiber = row->second.rm_fi;
673  _cfg.fiber = row->second.htr_fi;
674  _cfg.fiberchan = row->second.fi_ch;
675  _cfg.lut_type = 1;
676  _cfg.creationtag = _tag;
677  _cfg.creationstamp = get_time_stamp( time(nullptr) );
678  _cfg.targetfirmware = "1.0.0";
679  _cfg.formatrevision = "1"; //???
680  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
681  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
682  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
683  _cfg.generalizedindex =
684  _cfg.iphi*10000 + _cfg.depth*1000 +
685  (row->second.side>0)*100 + row->second.eta +
686  ((row->second.det==HcalForward && row->second.eta==29)?(4*10000):(0));
687 
688  //HcalDetId _detid(row->first);
689  HcalDetId _detid(row->second.det, row->second.side*row->second.eta, row->second.phi, row->second.depth);
690  //std::cout << "### DEBUG: rawid = " << _detid.rawId() << std::endl;
691 
692  //std::cout << "### DEBUG: subdetector = " << row->second.det << std::endl;
693  std::vector<unsigned short> coder_lut = _coder . getLinearizationLUT(_detid);
694  for (std::vector<unsigned short>::const_iterator _i=coder_lut.begin(); _i!=coder_lut.end();_i++){
695  unsigned int _temp = (unsigned int)(*_i);
696  //if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
697  //unsigned int _temp = 0;
698  _cfg.lut.push_back(_temp);
699  }
700  if (split_by_crate ){
701  _xml[row->second.crate]->addLut( _cfg, lut_checksums_xml );
702  _counter.count();
703  }
704  else{
705  _xml[0]->addLut( _cfg, lut_checksums_xml );
706  _counter.count();
707  }
708  }
709  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
710  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
711  return _xml;
712 }
size
Write out results.
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::map< int, LMapRow > & get_map(void)
Definition: LMap.cc:60
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
std::string formatrevision
Definition: LutXml.h:38
XMLDOMBlock * lut_checksums_xml
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
Definition: LMap.h:75
int fiberchan
Definition: LutXml.h:35
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getLinearizationLutXmlFromCoderEmap ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 784 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, EMap::get_map(), RooGKCounter::getCount(), HcalTPGCoder::getLinearizationLUT(), HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, mps_fire::i, LutXml::_Config::ieta, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

785 {
786  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
787  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
788 
789  EMap _emap(emap);
790  std::vector<EMap::EMapRow> & _map = _emap.get_map();
791  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " entries";
792 
793  RooGKCounter _counter;
794  //loop over all EMap channels
795  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
796  if( (row->subdet.find("HB")!=string::npos ||
797  row->subdet.find("HE")!=string::npos ||
798  row->subdet.find("HF")!=string::npos ) &&
799  row->subdet.size()==2
800  ){
801  LutXml::Config _cfg;
802 
803  if ( _xml.count(row->crate) == 0 && split_by_crate ){
804  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
805  }
806  else if ( _xml.count(0) == 0 && !split_by_crate ){
807  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
808  }
809  _cfg.ieta = row->ieta;
810  _cfg.iphi = row->iphi;
811  _cfg.depth = row->idepth;
812  _cfg.crate = row->crate;
813  _cfg.slot = row->slot;
814  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
815  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
816  else if (row->topbottom . find("u") != std::string::npos) _cfg.topbottom = 2;
817  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
818  _cfg.fiber = row->fiber;
819  _cfg.fiberchan = row->fiberchan;
820  _cfg.lut_type = 1;
821  _cfg.creationtag = _tag;
822  _cfg.creationstamp = get_time_stamp( time(nullptr) );
823  _cfg.targetfirmware = "1.0.0";
824  _cfg.formatrevision = "1"; //???
825  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
826  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
827  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
828  _cfg.generalizedindex =
829  _cfg.iphi*10000 + _cfg.depth*1000 +
830  (row->ieta>0)*100 + abs(row->ieta) +
831  (((row->subdet.find("HF")!=string::npos) && abs(row->ieta)==29)?(4*10000):(0));
832  HcalSubdetector _subdet;
833  if ( row->subdet.find("HB")!=string::npos ) _subdet = HcalBarrel;
834  else if ( row->subdet.find("HE")!=string::npos ) _subdet = HcalEndcap;
835  else if ( row->subdet.find("HO")!=string::npos ) _subdet = HcalOuter;
836  else if ( row->subdet.find("HF")!=string::npos ) _subdet = HcalForward;
837  else _subdet = HcalOther;
838  HcalDetId _detid(_subdet, row->ieta, row->iphi, row->idepth);
839 
840  for (const auto i : _coder.getLinearizationLUT(_detid)) _cfg.lut.push_back(i);
841 
842  if (split_by_crate ){
843  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
844  _counter.count();
845  }
846  else{
847  _xml[0]->addLut( _cfg, lut_checksums_xml );
848  _counter.count();
849  }
850  }
851  }
852  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
853  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
854  return _xml;
855 }
size
Write out results.
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string formatrevision
Definition: LutXml.h:38
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
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:94
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
std::vector< unsigned int > HcalLutManager::getLutFromXml ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt 
)

Definition at line 1345 of file HcalLutManager.cc.

References mps_fire::result.

1346 {
1347  edm::LogInfo("HcalLutManager") << "getLutFromXml (new version) is not implemented. Use getLutFromXml_old() for now";
1348 
1349  std::vector<unsigned int> result;
1350 
1351 
1352 
1353  return result;
1354 }
std::vector< unsigned int > HcalLutManager::getLutFromXml_old ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt 
)

Definition at line 1358 of file HcalLutManager.cc.

References electrons_cff::_id, cmsRelvalreport::exit, spr::find(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

1359 {
1360  if ( !lmap ){
1361  edm::LogError("HcalLutManager") << "Cannot find LUT without LMAP, exiting...";
1362  exit(-1);
1363  }
1364  if ( !db ){
1365  edm::LogError("HcalLutManager") << "Cannot find LUT, no source (local XML file), exiting...";
1366  exit(-1);
1367  }
1368 
1369  std::vector<unsigned int> result;
1370 
1371  std::map<int,LMapRow> & _map = lmap -> get_map();
1372  //std::cout << "HcalLutManager: LMap contains " << _map . size() << " channels (out of 9072 total)" << std::endl;
1373 
1374  HcalDetId _id( _rawid );
1375 
1376  unsigned int _crate, _slot, _fiber, _channel;
1377  std::string _fpga;
1378  int topbottom, luttype;
1379 
1380  // FIXME: check validity of _rawid
1381  if ( _map . find(_rawid) != _map.end() ){
1382  _crate = _map[_rawid] . crate;
1383  _slot = _map[_rawid] . htr;
1384  _fiber = _map[_rawid] . htr_fi;
1385  _channel = _map[_rawid] . fi_ch;
1386  _fpga = _map[_rawid] . fpga;
1387 
1388  if ( _fpga . find("top") != std::string::npos ) topbottom = 1;
1389  else if ( _fpga . find("bot") != std::string::npos ) topbottom = 0;
1390  else{
1391  edm::LogError("HcalLutManager") << "Irregular LMAP fpga value... do not know what to do - exiting";
1392  exit(-1);
1393  }
1394  if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
1395  else luttype = 2;
1396 
1397  result = db -> getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
1398  }
1399 
1400  return result;
1401 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
HCALConfigDB * db
HcalLutSet HcalLutManager::getLutSetFromFile ( std::string  _filename,
int  _type = 1 
)

Definition at line 181 of file HcalLutManager.cc.

References HcalLutSet::depth_max, HcalLutSet::depth_min, HcalLutSet::eta_max, HcalLutSet::eta_min, getInt(), mps_fire::i, diffTwoXMLs::label, HcalLutSet::lut, lumiPlot::lut, HcalLutSet::phi_max, HcalLutSet::phi_min, HcalQIEManager::splitString(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 110 of file HcalLutManager.cc.

References LutXml::_Config::lut.

111 {
112 
113  if (lut_xml) delete lut_xml;
114 
115  lut_xml = new LutXml();
116 
117  LutXml::Config _config;
118  _config.lut = _lut;
119  lut_xml -> addLut( _config );
120  lut_xml -> addLut( _config );
121  lut_xml -> addLut( _config );
122 
123  //return lut_xml->getString();
124  return lut_xml->getCurrentBrick();
125 
126 }
Definition: LutXml.h:27
std::string & getCurrentBrick(void)
Definition: LutXml.cc:230
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getLutXmlFromAsciiMaster ( std::string  _filename,
std::string  _tag,
int  _crate = -1,
bool  split_by_crate = true 
)

Definition at line 267 of file HcalLutManager.cc.

References python.rootplot.argparse::_set, 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, LMap::get_map(), RooGKCounter::getCount(), HcalForward, mps_fire::i, LutXml::_Config::ieta, LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, findQualityFiles::size, LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, ntuplemaker::time, and LutXml::_Config::topbottom.

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

Definition at line 715 of file HcalLutManager.cc.

References EnergyCorrector::c, RooGKCounter::count(), LutXml::_Config::crate, LutXml::_Config::creationtag, 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, masks, findQualityFiles::size, LutXml::_Config::slot, AlCaHLTBitMon_QueryRunRegistry::string, and LutXml::_Config::targetfirmware.

715  {
716  edm::LogInfo("HcalLutManager") << "Generating TDC masks...";
717 
718  EMap _emap(emap);
719  std::vector<EMap::EMapRow> & _map = _emap.get_map();
720  edm::LogInfo("HcalLutManager") << "EMap contains new" << _map.size() << " entries";
721 
722  std::map<int, std::vector<uint64_t>> masks;
723 
724  for(const auto& row : _map){
725  std::string subdet=row.subdet;
726  if(subdet != "HF") continue;
727  int crate=row.crate;
728  int slot=row.slot;
729  int crot=100*crate+slot;
730  int fiber=row.fiber;
731  int channel=row.fiberchan;
732  unsigned int finel=4*fiber+channel;
733  if(masks.count(crot)==0) masks[crot]={};
734  if(finel>=masks[crot].size()) masks[crot].resize(finel+1);
735 
736  if(masktype==0){
737  HcalSubdetector _subdet;
738  if ( row.subdet.find("HB")!=string::npos ) _subdet = HcalBarrel;
739  else if ( row.subdet.find("HE")!=string::npos ) _subdet = HcalEndcap;
740  else if ( row.subdet.find("HO")!=string::npos ) _subdet = HcalOuter;
741  else if ( row.subdet.find("HF")!=string::npos ) _subdet = HcalForward;
742  else _subdet = HcalOther;
743  HcalDetId _detid(_subdet, row.ieta, row.iphi, row.idepth);
744  masks[crot][finel]= conditions->getHcalTPChannelParameter(_detid)->getMask();
745  }
746  else{
748  masks[crot][finel]= masktype==1 ? parameters->getADCThresholdHF(): parameters->getTDCMaskHF();
749  }
750  }
751 
752  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
753  RooGKCounter _counter;
754 
755  for(const auto &i: masks){
756  int crot=i.first;
757  int crate=crot/100;
758 
759  LutXml::Config _cfg;
760  _cfg.lut_type = 3+masktype;
761  _cfg.crate = crate;
762  _cfg.slot = crot%100;
763  _cfg.generalizedindex = crot;
764  _cfg.mask = i.second;
765  _cfg.creationtag = _tag;
766  _cfg.targetfirmware = "1.0.0";
767  _cfg.formatrevision = "1";
768 
769  int c= split_by_crate ? crate : 0;
770  if ( _xml.count(c) == 0 ) _xml[c]=boost::shared_ptr<LutXml>(new LutXml());
771 
772  _xml[c]->addLut(_cfg);
773  _counter.count();
774  }
775 
776  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
777  << "Generating Masks...DONE" << std::endl;
778  return _xml;
779 }
size
Write out results.
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId) const
unsigned long int getCount(void)
std::string creationtag
Definition: LutXml.h:36
HcalSubdetector
Definition: HcalAssistant.h:31
std::string formatrevision
Definition: LutXml.h:38
const HcalElectronicsMap * emap
const HcalTPParameters * getHcalTPParameters() const
void count(void)
Definition: RooGKCounter.cc:66
constexpr uint32_t masks[]
Definition: CaloRecHit.cc:12
Definition: LMap.h:94
int lut_type
Definition: LutXml.h:35
int getADCThresholdHF() const
get ADC threshold fof TDC mask of HF
uint32_t getMask() const
get mask for channel validity and self trigger information
const HcalDbService * conditions
std::vector< uint64_t > mask
Definition: LutXml.h:42
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getZdcLutXml ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1664 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, spr::find(), LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, ZdcLut::get_lut(), EMap::get_map(), RooGKCounter::getCount(), LutXml::_Config::ieta, createfilelist::int, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, ntuplemaker::time, LutXml::_Config::topbottom, and hcalSimParameters_cfi::zdc.

1666 {
1667  edm::LogInfo("HcalLutManager") << "Generating ZDC LUTs ...may the Force be with us...";
1668  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
1669 
1670  EMap _emap(emap);
1671 
1672  ZdcLut zdc;
1673 
1674  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1675  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
1676 
1677  //loop over all EMap channels
1678  RooGKCounter _counter;
1679  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
1680  LutXml::Config _cfg;
1681 
1682  // only ZDC channels
1683  if ( row->zdc_section . find("ZDC") != std::string::npos ){
1684  if ( _xml.count(row->crate) == 0 && split_by_crate ){
1685  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
1686  }
1687  else if ( _xml.count(0) == 0 && !split_by_crate ){
1688  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
1689  }
1690  // FIXME: introduce proper tag names in ZDC bricks for logical channel info
1691  _cfg.ieta = row->zdc_channel; // int
1692  //_cfg.ieta = row->zdc_zside; // int
1693  //_cfg.iphi = row->zdc_section; // string
1694  _cfg.depth = row->idepth; // int
1695  _cfg.crate = row->crate;
1696  _cfg.slot = row->slot;
1697  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
1698  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
1699  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
1700  _cfg.fiber = row->fiber;
1701  _cfg.fiberchan = row->fiberchan;
1702  _cfg.lut_type = 1;
1703  _cfg.creationtag = _tag;
1704  _cfg.creationstamp = get_time_stamp( time(nullptr) );
1705  _cfg.targetfirmware = "1.0.0";
1706  _cfg.formatrevision = "1"; //???
1707  _cfg.generalizedindex = 0;
1708 
1709  //HcalZDCDetId _detid(row->zdc_section, (row->zdc_zside>0), row->zdc_channel);
1710 
1711  std::vector<int> coder_lut = zdc.get_lut(row->zdc_section,
1712  row->zdc_zside,
1713  row->zdc_channel);
1714  edm::LogInfo("HcalLutManager") << "***DEBUG: ZDC lut size: " << coder_lut.size();
1715  if (!coder_lut.empty()){
1716  for (std::vector<int>::const_iterator _i=coder_lut.begin(); _i!=coder_lut.end();_i++){
1717  unsigned int _temp = (unsigned int)(*_i);
1718  //if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
1719  //unsigned int _temp = 0;
1720  _cfg.lut.push_back(_temp);
1721  }
1722  //_cfg.lut = _set.lut[lut_index];
1723 
1724  if (split_by_crate ){
1725  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
1726  _counter.count();
1727  }
1728  else{
1729  _xml[0]->addLut( _cfg, lut_checksums_xml );
1730  _counter.count();
1731  }
1732  } //size of lut
1733  }
1734  }
1735  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1736  << "Generating ZDC LUTs...DONE" << std::endl;
1737 
1738  return _xml;
1739 }
size
Write out results.
std::vector< int > get_lut(int emap_side, int emap_htr_fiber, int emap_fi_ch)
Definition: ZdcLut.cc:212
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
Generation of ZDC Lookup tables and associate helper methods.
Definition: ZdcLut.h:25
unsigned long int getCount(void)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
std::string formatrevision
Definition: LutXml.h:38
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
void count(void)
Definition: RooGKCounter.cc:66
static std::string get_time_stamp(time_t _time)
Definition: LMap.h:94
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
void HcalLutManager::init ( void  )

Definition at line 80 of file HcalLutManager.cc.

81 {
82  lut_xml = nullptr;
83  lut_checksums_xml = nullptr;
84  db = nullptr;
85  lmap = nullptr;
86  emap = nullptr;
87  cq = nullptr;
88  conditions = nullptr;
89  status_word_to_mask = 0x0000;
90 }
HCALConfigDB * db
const HcalChannelQuality * cq
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
uint32_t status_word_to_mask
const HcalDbService * conditions
int HcalLutManager::initChannelIterator ( std::vector< HcalGenericDetId > &  map)

Definition at line 103 of file HcalLutManager.cc.

References init.

104 {
105  _iter . init(map);
106  return _iter.size();
107 }
HcalChannelIterator _iter
void init(void)
int HcalLutManager::local_connect ( std::string  lut_xml_file,
std::string  lmap_hbef_file,
std::string  lmap_ho_file 
)

Definition at line 1335 of file HcalLutManager.cc.

1336 {
1337  read_lmap( lmap_hbef_file, lmap_ho_file );
1338  read_luts( lut_xml_file );
1339  return 0;
1340 }
int read_luts(std::string lut_xml_file)
int read_lmap(std::string lmap_hbef_file, std::string lmap_ho_file)
int HcalLutManager::read_lmap ( std::string  lmap_hbef_file,
std::string  lmap_ho_file 
)

Definition at line 1311 of file HcalLutManager.cc.

References findQualityFiles::size.

1312 {
1313  delete lmap;
1314  lmap = new LMap();
1315  lmap -> read( lmap_hbef_file, "HBEF" );
1316  lmap -> read( lmap_ho_file, "HO" );
1317  edm::LogInfo("HcalLutManager") << "LMap contains " << lmap -> get_map() . size() << " channels (compare to 9072 of all HCAL channels)";
1318  return 0;
1319 }
size
Write out results.
Definition: LMap.h:75
int HcalLutManager::read_luts ( std::string  lut_xml_file)

Definition at line 1323 of file HcalLutManager.cc.

References connect().

1324 {
1325  delete db;
1326  db = new HCALConfigDB();
1327  db -> connect( lut_xml_file );
1328  return 0;
1329 }
HCALConfigDB * db
Gather config data from online DB.
Definition: HCALConfigDB.h:21
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
int HcalLutManager::test_direct_xml_parsing ( std::string  _filename)

Definition at line 1597 of file HcalLutManager.cc.

1597  {
1598  /*
1599  XMLDOMBlock _xml(_filename);
1600  //DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
1601  DOMNodeList * brick_list = _xml . getDocument() -> getElementsByTagName( XMLProcessor::_toXMLCh( "CFGBrick" ));
1602 
1603  double n_bricks = brick_list->getLength();
1604  std::cout << "amount of LUT bricks: " << n_bricks << std::endl;
1605 
1606  for (int iter=0; iter!=n_bricks; iter++){
1607  DOMElement * _brick = (DOMElement *)(brick_list->item(iter));
1608 
1609  DOMElement * _param = 0;
1610  // loop over brick parameters
1611  int par_iter = 0;
1612  while(1){
1613  _param = (DOMElement *)(_brick->getElementsByTagName(XMLProcessor::_toXMLCh("Parameter")));
1614  std::string _name = _param->getAttribute( XMLProcessor::_toXMLCh( "name" ) );
1615  if (_name.find("IETA")==string::npos) break;
1616 
1617  std::string _tag = "Parameter";
1618  std::cout << "### Parameter IETA = " << _xml.getTagValue( _tag, 0, _brick);
1619  par_iter++;
1620  }
1621  }
1622  */
1623  return 0;
1624 }
void HcalLutManager::test_emap ( void  )

Definition at line 1567 of file HcalLutManager.cc.

References funct::abs(), spr::find(), EMap::get_map(), alignCSCRings::s, and findQualityFiles::size.

1567  {
1568  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1569  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1570  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1571  EMap _emap(emap);
1572  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1573  std::stringstream s;
1574  s << "EMap contains " << _map . size() << " channels" << std::endl;
1575 
1576  //loop over all EMap channels
1577  //RooGKCounter _c;
1578  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
1579 
1580  // only trigger tower channels
1581  if ( row->subdet . find("HT") != std::string::npos ){
1582  s << " -----> Subdet = " << row->subdet << std::endl;
1583 
1584  if (abs(row->ieta)>28){
1585  //if (row->iphi == 71){
1586  s << " ==> (ieta,iphi) = " << row->ieta << ", " << row->iphi << std::endl;
1587  }
1588  }
1589  }
1590  edm::LogInfo("HcalLutManager") << s.str();
1591 }
size
Write out results.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HcalElectronicsMap * emap
Definition: LMap.h:94
int HcalLutManager::test_xml_access ( std::string  _tag,
std::string  _filename 
)

Definition at line 1231 of file HcalLutManager.cc.

References begin, end, EMap::get_map(), HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, mps_fire::i, rand(), DetId::rawId(), and findQualityFiles::size.

1232 {
1233  local_connect( _filename, "backup/HCALmapHBEF.txt", "backup/HCALmapHO.txt" );
1234 
1235  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1236  EMap _emap(emap);
1237  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1238  int map_size = _map . size();
1239  edm::LogInfo("HcalLutManager") << "EMap contains " << map_size << " channels";
1240 
1241  // make sure that all init is done
1242  std::vector<unsigned int> _lut;
1243  _lut = getLutFromXml( _tag, 1107313727, hcal::ConfigurationDatabase::LinearizerLUT );
1244 
1245 
1246  edm::LogInfo("HcalLutManager") << "Testing direct parsing of the LUT XML";
1247  struct timeval _t;
1248  gettimeofday( &_t, nullptr );
1249  double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
1250  test_direct_xml_parsing(_filename);
1251  gettimeofday( &_t, nullptr );
1252  edm::LogInfo("HcalLutManager") << "parsing took that much time: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time;
1253 
1254 
1255  gettimeofday( &_t, nullptr );
1256  _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
1257  edm::LogInfo("HcalLutManager") << "before loop over random LUTs: " << _time;
1258  int _raw_id;
1259 
1260  // loop over random LUTs
1261  for (int _iter=0; _iter<100; _iter++){
1262  gettimeofday( &_t, nullptr );
1263  //std::cout << "before getting a LUT: " << _t . tv_sec << "." << _t . tv_usec << std::endl;
1264 
1265  // select valid random emap channel
1266  while(true){
1267  int _key = (rand() % map_size);
1268  //_key = 3356;
1269  if( (_map[_key].subdet.find("HB")!=string::npos ||
1270  _map[_key].subdet.find("HE")!=string::npos ||
1271  _map[_key].subdet.find("HO")!=string::npos ||
1272  _map[_key].subdet.find("HF")!=string::npos ) &&
1273  _map[_key].subdet.size()==2
1274  ){
1275  HcalSubdetector _subdet;
1276  if ( _map[_key].subdet.find("HB")!=string::npos ) _subdet = HcalBarrel;
1277  else if ( _map[_key].subdet.find("HE")!=string::npos ) _subdet = HcalEndcap;
1278  else if ( _map[_key].subdet.find("HO")!=string::npos ) _subdet = HcalOuter;
1279  else if ( _map[_key].subdet.find("HF")!=string::npos ) _subdet = HcalForward;
1280  else _subdet = HcalOther;
1281  HcalDetId _detid(_subdet, _map[_key].ieta, _map[_key].iphi, _map[_key].idepth);
1282  _raw_id = _detid.rawId();
1283  break;
1284  }
1285  }
1286  _lut = getLutFromXml( _tag, _raw_id, hcal::ConfigurationDatabase::LinearizerLUT );
1287 
1288  gettimeofday( &_t, nullptr );
1289  }
1290  double d_time = _t.tv_sec+_t.tv_usec/1000000.0 - _time;
1291  edm::LogInfo("HcalLutManager") << "after the loop over random LUTs: " << _time+d_time << std::endl
1292  << "total time: " << d_time << std::endl;
1293 
1294  edm::LogInfo("HcalLutManager") << "LUT length = " << _lut . size();
1295  for ( std::vector<unsigned int>::const_iterator i = _lut . end() - 1; i != _lut . begin()-1; i-- )
1296  {
1297  edm::LogInfo("HcalLutManager") << (i-_lut.begin()) << " " << _lut[(i-_lut.begin())];
1298  break;
1299  }
1300 
1301  db -> disconnect();
1302 
1303  delete db;
1304  db = nullptr;
1305 
1306  return 0;
1307 }
size
Write out results.
HCALConfigDB * db
int test_direct_xml_parsing(std::string _filename)
HcalSubdetector
Definition: HcalAssistant.h:31
#define end
Definition: vmac.h:39
HcalChannelIterator _iter
const HcalElectronicsMap * emap
#define begin
Definition: vmac.h:32
Signal rand(Signal arg)
Definition: vlib.cc:442
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:94
int HcalLutManager::writeLutXmlFiles ( std::map< int, boost::shared_ptr< LutXml > > &  _xml,
std::string  _tag = "default_tag",
bool  split_by_crate = true 
)

Definition at line 1027 of file HcalLutManager.cc.

References genParticles_cff::map.

1028 {
1029  for (std::map<int,boost::shared_ptr<LutXml> >::const_iterator cr = _xml.begin(); cr != _xml.end(); cr++){
1030  std::stringstream output_file_name;
1031  if ( split_by_crate ){
1032  output_file_name << _tag << "_" << cr->first << ".xml";
1033  }
1034  else{
1035  output_file_name << _tag << ".xml";
1036  }
1037  cr->second->write( output_file_name.str() );
1038  }
1039  return 0;
1040 }

Member Data Documentation

HcalAssistant HcalLutManager::_ass
protected

Definition at line 164 of file HcalLutManager.h.

HcalChannelIterator HcalLutManager::_iter
protected

Definition at line 163 of file HcalLutManager.h.

const HcalDbService* HcalLutManager::conditions
protected

Definition at line 167 of file HcalLutManager.h.

const HcalChannelQuality* HcalLutManager::cq
protected

Definition at line 166 of file HcalLutManager.h.

HCALConfigDB* HcalLutManager::db
protected
const HcalElectronicsMap* HcalLutManager::emap
protected

Definition at line 165 of file HcalLutManager.h.

LMap* HcalLutManager::lmap
protected

Definition at line 162 of file HcalLutManager.h.

XMLDOMBlock* HcalLutManager::lut_checksums_xml
protected

Definition at line 160 of file HcalLutManager.h.

LutXml* HcalLutManager::lut_xml
protected

Definition at line 159 of file HcalLutManager.h.

uint32_t HcalLutManager::status_word_to_mask
protected

Definition at line 168 of file HcalLutManager.h.