CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 > > 
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)
 
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 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 ( void  )

Definition at line 82 of file HcalLutManager.cc.

References EcalCondDB::db.

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

Member Function Documentation

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

Definition at line 1109 of file HcalLutManager.cc.

References edm::eventsetup::heterocontainer::insert(), lumiPlot::lut, and mps_fire::result.

1110 {
1111  for ( std::map<int, boost::shared_ptr<LutXml> >::const_iterator lut=other.begin(); lut!=other.end(); lut++ ){
1112  edm::LogInfo("HcalLutManager") << "Added LUTs for crate " << lut->first;
1113  if ( result.count(lut->first)==0 ){
1114  result . insert( *lut );
1115  }
1116  else{
1117  *(result[lut->first]) += *(lut->second);
1118  }
1119  }
1120 }
tuple result
Definition: mps_fire.py:84
tuple lut
Definition: lumiPlot.py:244
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 1402 of file HcalLutManager.cc.

References bitset_utilities::append(), begin, comment, XMLLUTLoader::_lutDBConfig::crate, end, cmsHarvester::file_name, getInt(), NULL, HcalQIEManager::splitString(), AlCaHLTBitMon_QueryRunRegistry::string, XMLProcessor::_DBConfig::subversion, XMLProcessor::_DBConfig::version, relval_steps::version, and TablePrint::write.

1403 {
1404  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs...";
1405  //std::cout << _prefix << "..." << tag_name << std::endl;
1406 
1410 
1411  baseConf . tag_name = tag_name;
1412  //baseConf . comment_description = tag_name;
1413  baseConf . comment_description = comment;
1414  baseConf . iov_begin = "1";
1415  baseConf . iov_end = "-1";
1416 
1417  conf . version = version;
1418 
1419  std::stringstream _subversion;
1420  _subversion << subversion;
1421  conf . subversion = _subversion.str();
1422 
1423  CSconf . version = conf . version;
1424  CSconf . subversion = conf . subversion;
1425  CSconf . trig_prim_lookuptbl_data_file = _prefix + "_checksums.xml.dat";
1426  CSconf . comment_description = tag_name;
1427 
1428  XMLLUTLoader doc( &baseConf );
1429 
1430  std::vector<int> crate_number;
1431  std::vector<std::string> file_name = HcalQIEManager::splitString(file_list);
1432  for (std::vector<std::string>::const_iterator _f = file_name.begin(); _f != file_name.end(); _f++){
1433  int crate_begin = _f->rfind("_");
1434  int crate_end = _f->rfind(".xml.dat");
1435  crate_number . push_back(getInt(_f->substr(crate_begin+1,crate_end-crate_begin-1)));
1436  }
1437  //
1438  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1439  //
1440  char _buf[128];
1441  time_t _offset = time(NULL);
1442  sprintf( _buf, "%d", (uint32_t)_offset );
1443  conf.version.append(".");
1444  conf.version.append(_buf);
1445  CSconf.version = conf.version;
1446  //
1447  for ( std::vector<std::string>::const_iterator _file = file_name . begin(); _file != file_name . end(); _file++ )
1448  {
1449  conf . trig_prim_lookuptbl_data_file = *_file;
1450  //conf . trig_prim_lookuptbl_data_file += ".dat";
1451  conf . crate = crate_number[ _file - file_name . begin() ];
1452  //
1453  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1454  //
1455  sprintf( _buf, "%.2d", conf.crate );
1456  conf.subversion.clear();
1457  conf.subversion.append(_buf);
1458  sprintf( _buf, "CRATE%.2d", conf . crate );
1459  std::string _namelabel;
1460  _namelabel . append( _buf );
1461  conf . name_label = _namelabel;
1462  doc . addLUT( &conf );
1463  }
1464 
1465  doc . addChecksums( &CSconf );
1466  //doc . write( _prefix + "_Loader.xml" );
1467  doc . write( tag_name + "_Loader.xml" );
1468 
1469  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs... done.";
1470 
1471  return 0;
1472 }
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
#define NULL
Definition: scimark2.h:8
static std::vector< std::string > splitString(const std::string &fLine)
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
static int getInt(std::string number)
#define comment(par)
Definition: vmac.h:161
int HcalLutManager::createAllLutXmlFiles ( std::string  _tag,
std::string  _lin_file,
std::string  _comp_file,
bool  split_by_crate = true 
)

Definition at line 968 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

969 {
970  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
971  std::map<int, boost::shared_ptr<LutXml> > xml;
972  if ( !lut_checksums_xml ){
973  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
974  }
975 
976  if ( _lin_file.size() != 0 ){
977  //addLutMap( xml, getLutXmlFromAsciiMaster( _lin_file, _tag, -1, split_by_crate ) );
978  addLutMap( xml, getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate ) );
979  }
980  if ( _comp_file.size() != 0 ){
981  //std::cout << "DEBUG1!!!!" << std::endl;
982  addLutMap( xml, getCompressionLutXmlFromAsciiMaster( _comp_file, _tag, -1, split_by_crate ) );
983  //std::cout << "DEBUG2!!!!" << std::endl;
984  }
985  writeLutXmlFiles( xml, _tag, split_by_crate );
986 
987  std::string checksums_file = _tag + "_checksums.xml";
988  lut_checksums_xml -> write( checksums_file . c_str() );
989 
990  return 0;
991 }
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)
int HcalLutManager::createAllLutXmlFilesFromCoder ( const HcalTPGCoder _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 1011 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

1012 {
1013  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1014  std::map<int, boost::shared_ptr<LutXml> > xml;
1015  if ( !lut_checksums_xml ){
1016  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1017  }
1018 
1019  //addLutMap( xml, getLinearizationLutXmlFromCoder( _coder, _tag, split_by_crate ) );
1020  addLutMap( xml, getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate ) );
1021  addLutMap( xml, getCompressionLutXmlFromCoder( _tag, split_by_crate ) );
1022 
1023  writeLutXmlFiles( xml, _tag, split_by_crate );
1024 
1025  std::string checksums_file = _tag + "_checksums.xml";
1026  lut_checksums_xml -> write( checksums_file . c_str() );
1027 
1028  return 0;
1029 }
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)
int HcalLutManager::createAllLutXmlFilesLinAsciiCompCoder ( std::string  _tag,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1087 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

1088 {
1089  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1090  std::map<int, boost::shared_ptr<LutXml> > xml;
1091  if ( !lut_checksums_xml ){
1092  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1093  }
1094 
1095  if ( _lin_file.size() != 0 ){
1096  addLutMap( xml, getLutXmlFromAsciiMaster( _lin_file, _tag, -1, split_by_crate ) );
1097  }
1098  addLutMap( xml, getCompressionLutXmlFromCoder( _tag, split_by_crate ) );
1099  writeLutXmlFiles( xml, _tag, split_by_crate );
1100 
1101  std::string checksums_file = _tag + "_checksums.xml";
1102  lut_checksums_xml -> write( checksums_file . c_str() );
1103 
1104  return 0;
1105 }
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
int HcalLutManager::createCompLutXmlFilesFromCoder ( std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 993 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

994 {
995  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
996  std::map<int, boost::shared_ptr<LutXml> > xml;
997  if ( !lut_checksums_xml ){
998  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
999  }
1000 
1001  addLutMap( xml, getCompressionLutXmlFromCoder( _tag, split_by_crate ) );
1002 
1003  writeLutXmlFiles( xml, _tag, split_by_crate );
1004 
1005  std::string checksums_file = _tag + "_checksums.xml";
1006  lut_checksums_xml -> write( checksums_file . c_str() );
1007 
1008  return 0;
1009 }
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
int HcalLutManager::createLinLutXmlFiles ( std::string  _tag,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 949 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

950 {
951  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
952  std::map<int, boost::shared_ptr<LutXml> > xml;
953  if ( !lut_checksums_xml ){
954  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
955  }
956 
957  if ( _lin_file.size() != 0 ){
958  addLutMap( xml, getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate ) );
959  }
960  writeLutXmlFiles( xml, _tag, split_by_crate );
961 
962  std::string checksums_file = _tag + "_checksums.xml";
963  lut_checksums_xml -> write( checksums_file . c_str() );
964 
965  return 0;
966 }
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)
int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii ( std::string  _tag,
const HcalTPGCoder _coder,
std::string  _lin_file,
bool  split_by_crate = true 
)

Definition at line 1060 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

1061 {
1062  std::map<int, boost::shared_ptr<LutXml> > xml;
1063  if ( !lut_checksums_xml ){
1064  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1065  }
1066 
1067  if ( _lin_file.size() != 0 ){
1068  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_ascii_xml = getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate );
1069  addLutMap( xml, _lin_lut_ascii_xml );
1070  }
1071  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_xml = getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate );
1072  addLutMap( xml, _lin_lut_xml );
1073  //
1074  const std::map<int, boost::shared_ptr<LutXml> > _comp_lut_xml = getCompressionLutXmlFromCoder( _tag, split_by_crate );
1075  addLutMap( xml, _comp_lut_xml );
1076 
1077  writeLutXmlFiles( xml, _tag, split_by_crate );
1078 
1079  std::string checksums_file = _tag + "_checksums.xml";
1080  lut_checksums_xml -> write( checksums_file . c_str() );
1081 
1082  return 0;
1083 }
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)
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 1034 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

1035 {
1036  std::map<int, boost::shared_ptr<LutXml> > xml;
1037  if ( !lut_checksums_xml ){
1038  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1039  }
1040 
1041  if ( _lin_file.size() != 0 ){
1042  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_ascii_xml = getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate );
1043  addLutMap( xml, _lin_lut_ascii_xml );
1044  }
1045  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_xml = getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate );
1046  addLutMap( xml, _lin_lut_xml );
1047  //
1048  const std::map<int, boost::shared_ptr<LutXml> > _comp_lut_xml = getCompressionLutXmlFromCoder( _transcoder, _tag, split_by_crate );
1049  addLutMap( xml, _comp_lut_xml );
1050 
1051  writeLutXmlFiles( xml, _tag, split_by_crate );
1052 
1053  std::string checksums_file = _tag + "_checksums.xml";
1054  lut_checksums_xml -> write( checksums_file . c_str() );
1055 
1056  return 0;
1057 }
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)
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 1537 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

1538 {
1539  std::map<int, boost::shared_ptr<LutXml> > xml;
1540  if ( !lut_checksums_xml ){
1541  lut_checksums_xml = new XMLDOMBlock( "CFGBrick", 1 );
1542  }
1543 
1544  if ( _lin_file.size() != 0 ){
1545  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_ascii_xml = getLinearizationLutXmlFromAsciiMasterEmap( _lin_file, _tag, -1, split_by_crate );
1546  addLutMap( xml, _lin_lut_ascii_xml );
1547  }
1548  const std::map<int, boost::shared_ptr<LutXml> > _lin_lut_xml = getLinearizationLutXmlFromCoderEmap( _coder, _tag, split_by_crate );
1549  addLutMap( xml, _lin_lut_xml );
1550  //
1551  const std::map<int, boost::shared_ptr<LutXml> > _comp_lut_xml = getCompressionLutXmlFromCoder( _transcoder, _tag, split_by_crate );
1552  addLutMap( xml, _comp_lut_xml );
1553  //
1554  const std::map<int, boost::shared_ptr<LutXml> > _zdc_lut_xml = getZdcLutXml( _tag, split_by_crate );
1555  addLutMap( xml, _zdc_lut_xml );
1556 
1557  writeLutXmlFiles( xml, _tag, split_by_crate );
1558 
1559  std::string checksums_file = _tag + "_checksums.xml";
1560  lut_checksums_xml -> write( checksums_file . c_str() );
1561 
1562  return 0;
1563 }
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 > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
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 1331 of file HcalLutManager.cc.

References convertSQLitetoXML_cfg::connect, EcalCondDB::db, alignCSCRings::e, XMLProcessor::getInstance(), o2o::query, AlCaHLTBitMon_QueryRunRegistry::string, and toolbox::toString().

1332 {
1333  HCALConfigDB * db = new HCALConfigDB();
1334  XMLProcessor::getInstance(); // initialize xerces-c engine
1335  //const std::string _accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22";
1336  db -> connect( _accessor );
1337  oracle::occi::Connection * _connection = db -> getConnection();
1338 
1339  edm::LogInfo("HcalLutManager") << "Preparing to request the LUT CLOBs from the database...";
1340 
1341  //int crate = 0;
1342 
1343  //
1344  // _____ query is different for the old validation DB _________________
1345  //
1346  //std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_TRIG_LOOKUP_TABLES");
1347  std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_COND.V_HCAL_TRIG_LOOKUP_TABLES");
1348  //query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d", tag.c_str(), crate);
1349  query+=toolbox::toString(" WHERE TAG_NAME='%s'", tag.c_str() );
1350 
1351  std::string brick_set;
1352 
1353  std::map<int, boost::shared_ptr<LutXml> > lut_map;
1354 
1355  try {
1356  //SELECT
1357  edm::LogInfo("HcalLutManager") << "Executing the query...";
1358  Statement* stmt = _connection -> createStatement();
1359  ResultSet *rs = stmt->executeQuery(query.c_str());
1360  edm::LogInfo("HcalLutManager") << "Executing the query... done";
1361 
1362  edm::LogInfo("HcalLutManager") << "Processing the query results...";
1363  //RooGKCounter _lines;
1364  while (rs->next()) {
1365  //_lines.count();
1366  oracle::occi::Clob clob = rs->getClob (1);
1367  int crate = rs->getInt(2);
1368  if ( crate != -1 ){ // not a brick with checksums
1369  edm::LogInfo("HcalLutManager") << "Getting LUTs for crate #" << crate << " out of the database...";
1370  brick_set = db -> clobToString(clob);
1371  /*
1372  // FIXME: DEBUG lut xml files from simple strings
1373  stringstream file_name;
1374  ofstream out_file;
1375  file_name << tag << "_" << crate << "_debug" << ".xml";
1376  out_file . open( file_name.str().c_str() );
1377  out_file << brick_set;
1378  out_file . close();
1379  */
1380  const char * bs = brick_set . c_str();
1381  MemBufInputSource * lut_clob = new MemBufInputSource( (const XMLByte *)bs, strlen( bs ), "lut_clob", false );
1382  boost::shared_ptr<LutXml> lut_xml = boost::shared_ptr<LutXml>( new LutXml( *lut_clob ) );
1383  lut_map[crate] = lut_xml;
1384  edm::LogInfo("HcalLutManager") << "done";
1385  }
1386  }
1387  //Always terminate statement
1388  _connection -> terminateStatement(stmt);
1389  //std::cout << "Query line count: " << _lines.getCount() << std::endl;
1390  } catch (SQLException& e) {
1391  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()));
1392  }
1393 
1394  //std::cout << lut_map.size() << std::endl;
1395 
1396  db -> disconnect();
1397  //delete db;
1398  return lut_map;
1399 }
Definition: LutXml.h:27
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
HCALConfigDB * db
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
Gather config data from online DB.
Definition: HCALConfigDB.h:21
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple query
Definition: o2o.py:269
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 124 of file HcalLutManager.cc.

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

125 {
127  if ( _det.find("HB") != std::string::npos ) result = HcalBarrel;
128  else if ( _det.find("HE") != std::string::npos ) result = HcalEndcap;
129  else if ( _det.find("HF") != std::string::npos ) result = HcalForward;
130  else if ( _det.find("HO") != std::string::npos ) result = HcalOuter;
131  else result = HcalOther;
132 
133  return result;
134 }
tuple result
Definition: mps_fire.py:84
HcalSubdetector
Definition: HcalAssistant.h:31
string HcalLutManager::get_time_stamp ( time_t  _time)
static

Definition at line 1125 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1126 {
1127  char timebuf[50];
1128  //strftime( timebuf, 50, "%c", gmtime( &_time ) );
1129  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S", gmtime( &_time ) );
1130  std::string creationstamp = timebuf;
1131 
1132  return creationstamp;
1133 }
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 1312 of file HcalLutManager.cc.

References DeadROCCounter::out_file, mps_fire::result, and TablePrint::write.

1313 {
1314  std::map<int, boost::shared_ptr<LutXml> > lut_map = get_brickSet_from_oracle( tag, db_accessor );
1315  if (split_by_crate){
1316  writeLutXmlFiles( lut_map, tag, split_by_crate );
1317  }
1318  else{
1319  LutXml result;
1320  for( std::map<int, boost::shared_ptr<LutXml> >::const_iterator xml = lut_map.begin(); xml != lut_map.end(); xml++ ){
1321  result += *(xml->second);
1322  }
1323  std::stringstream out_file;
1324  out_file << tag << ".xml";
1325  result . write(out_file.str());
1326  }
1327 
1328  return 0;
1329 }
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")
tuple result
Definition: mps_fire.py:84
int writeLutXmlFiles(std::map< int, boost::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
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 534 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(), 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, and LutXml::_Config::topbottom.

535 {
536  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from ascii master file...";
537  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
538 
539  edm::LogInfo("HcalLutManager") << "instantiating CaloTPGTranscoderULUT in order to check the validity of (ieta,iphi)...";
540  CaloTPGTranscoderULUT _coder;
541 
542  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
543  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
544  EMap _emap(emap);
545  std::vector<EMap::EMapRow> & _map = _emap.get_map();
546  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
547 
548  // read LUTs and their eta/phi/depth/subdet ranges
549  HcalLutSet _set = getLutSetFromFile( _filename, 2 );
550  int lut_set_size = _set.lut.size(); // number of different luts
551  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
552 
553  //loop over all EMap channels
554  RooGKCounter _counter;
555  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
556  LutXml::Config _cfg;
557 
558  // search for the correct LUT for a given channel,
559  // higher LUT numbers have priority in case of overlapping
560  int lut_index=-1;
561  for ( int i=0; i<lut_set_size; i++ ){
562  if ( row->subdet . find("HT") != std::string::npos &&
563  (row->crate == _crate || _crate == -1) && // -1 stands for all crates
564  _set.eta_min[i] <= row->ieta &&
565  _set.eta_max[i] >= row->ieta &&
566  _set.phi_min[i] <= row->iphi &&
567  _set.phi_max[i] >= row->iphi &&
568  _coder.HTvalid(row->ieta, row->iphi, row->idepth / 10) ){
569  lut_index=i;
570  }
571  }
572  if ( lut_index >= 0 ){
573  if ( _xml.count(row->crate) == 0 && split_by_crate ){
574  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
575  }
576  else if ( _xml.count(0) == 0 && !split_by_crate ){
577  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
578  }
579  _cfg.ieta = row->ieta;
580  _cfg.iphi = row->iphi;
581  _cfg.depth = row->idepth;
582  _cfg.crate = row->crate;
583  _cfg.slot = row->slot;
584  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
585  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
586  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
587  _cfg.fiber = row->fiber;
588  _cfg.fiberchan = row->fiberchan;
589  if (_set.lut[lut_index].size() == 128) _cfg.lut_type = 1;
590  else _cfg.lut_type = 2;
591  _cfg.creationtag = _tag;
592  _cfg.creationstamp = get_time_stamp( time(0) );
593  _cfg.targetfirmware = "1.0.0";
594  _cfg.formatrevision = "1"; //???
595  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
596  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
597  // ((id.ieta()<0)?(0):(100));
598  _cfg.generalizedindex =
599  _cfg.iphi*10000+
600  (row->ieta>0)*100+abs(row->ieta);
601  _cfg.lut = _set.lut[lut_index];
602  if (split_by_crate ){
603  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
604  _counter.count();
605  }
606  else{
607  _xml[0]->addLut( _cfg, lut_checksums_xml );
608  _counter.count();
609  }
610  }
611  }
612  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
613  << "Generating compression (output) LUTs from ascii master file...DONE" << std::endl;
614  return _xml;
615 }
int i
Definition: DBlmapReader.cc:9
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:7
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
tuple size
Write out results.
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 855 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, and LutXml::_Config::topbottom.

856 {
857  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT";
858  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
859 
860  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
861  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
862  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
863  EMap _emap(emap);
864 
865  std::vector<EMap::EMapRow> & _map = _emap.get_map();
866  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
867 
868  // read LUTs and their eta/phi/depth/subdet ranges
869  //HcalLutSet _set = getLutSetFromFile( _filename, 2 );
870  //int lut_set_size = _set.lut.size(); // number of different luts
871 
872  CaloTPGTranscoderULUT _coder;
873 
874  //loop over all EMap channels
875  RooGKCounter _counter;
876  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
877  LutXml::Config _cfg;
878 
879  // only trigger tower channels
880  // and valid (ieta,iphi)
881  const int tp_version = row->idepth / 10;
882  if ( row->subdet . find("HT") != std::string::npos && _coder.HTvalid(row->ieta, row->iphi, tp_version) ){
883  if ( _xml.count(row->crate) == 0 && split_by_crate ){
884  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
885  }
886  else if ( _xml.count(0) == 0 && !split_by_crate ){
887  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
888  }
889  _cfg.ieta = row->ieta;
890  _cfg.iphi = row->iphi;
891  _cfg.depth = row->idepth;
892  _cfg.crate = row->crate;
893  _cfg.slot = row->slot;
894  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
895  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
896  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
897  _cfg.fiber = row->fiber;
898  _cfg.fiberchan = row->fiberchan;
899  _cfg.lut_type = 2;
900  _cfg.creationtag = _tag;
901  _cfg.creationstamp = get_time_stamp( time(0) );
902  _cfg.targetfirmware = "1.0.0";
903  _cfg.formatrevision = "1"; //???
904  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
905  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
906  // ((id.ieta()<0)?(0):(100));
907  _cfg.generalizedindex =
908  _cfg.iphi*10000+
909  (row->ieta>0)*100+abs(row->ieta);
910 
911  // FIXME: work around bug in emap v6: rawId wasn't filled
912  //HcalTrigTowerDetId _detid(row->rawId);
913  HcalTrigTowerDetId _detid(row->ieta, row->iphi);
914 
915  _cfg.lut = _coder.getCompressionLUT(_detid);
916 
917  if (split_by_crate ){
918  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
919  _counter.count();
920  }
921  else{
922  _xml[0]->addLut( _cfg, lut_checksums_xml );
923  _counter.count();
924  }
925  }
926  }
927  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
928  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE" << std::endl;
929  return _xml;
930 }
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
unsigned long int getCount(void)
virtual const std::vector< unsigned int > & getCompressionLUT(const HcalTrigTowerDetId &id) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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
tuple size
Write out results.
std::map< int, boost::shared_ptr< LutXml > > HcalLutManager::getCompressionLutXmlFromCoder ( const CaloTPGTranscoderULUT _coder,
std::string  _tag,
bool  split_by_crate = true 
)

Definition at line 790 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(), LutXml::_Config::ieta, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

791 {
792  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT," << std::endl
793  << "initialized from Event Setup" << std::endl;
794  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
795 
796  EMap _emap(emap);
797 
798  std::vector<EMap::EMapRow> & _map = _emap.get_map();
799  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
800 
801  RooGKCounter _counter;
802  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
803  LutXml::Config _cfg;
804 
805  if ( row->subdet.find("HT") == std::string::npos) continue;
806 
807  HcalTrigTowerDetId _detid(row->rawId);
808 
809  if(!cq->topo()->validHT(_detid)) continue;
810 
811 
812  if ( _xml.count(row->crate) == 0 && split_by_crate ){
813  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
814  }
815  else if ( _xml.count(0) == 0 && !split_by_crate ){
816  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
817  }
818 
819  _cfg.ieta = row->ieta;
820  _cfg.iphi = row->iphi;
821  _cfg.depth = row->idepth;
822  _cfg.crate = row->crate;
823  _cfg.slot = row->slot;
824  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
825  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
826  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
827  _cfg.fiber = row->fiber;
828  _cfg.fiberchan = row->fiberchan;
829  _cfg.lut_type = 2;
830  _cfg.creationtag = _tag;
831  _cfg.creationstamp = get_time_stamp( time(0) );
832  _cfg.targetfirmware = "1.0.0";
833  _cfg.formatrevision = "1"; //???
834  _cfg.generalizedindex =_cfg.iphi*10000+ (row->ieta>0)*100+abs(row->ieta); //is this used for anything?
835 
836  _cfg.lut = _coder.getCompressionLUT(_detid);
837 
838 
839  if (split_by_crate ){
840  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
841  _counter.count();
842  }
843  else{
844  _xml[0]->addLut( _cfg, lut_checksums_xml );
845  _counter.count();
846  }
847  }
848  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
849  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE" << std::endl;
850  return _xml;
851 }
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
unsigned long int getCount(void)
virtual const std::vector< unsigned int > & getCompressionLUT(const HcalTrigTowerDetId &id) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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
tuple size
Write out results.
const HcalTopology * topo() const
bool validHT(const HcalTrigTowerDetId &id) const
int HcalLutManager::getInt ( std::string  number)
static

Definition at line 117 of file HcalLutManager.cc.

References mps_fire::result.

Referenced by getLutSetFromFile().

118 {
119  int result;
120  sscanf(number.c_str(), "%d", &result);
121  return result;
122 }
tuple result
Definition: mps_fire.py:84
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 341 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(), 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, and LutXml::_Config::topbottom.

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

442 {
443  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
444  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
445 
446  // read LUTs and their eta/phi/depth/subdet ranges
447  HcalLutSet _set = getLutSetFromFile( _filename );
448  int lut_set_size = _set.lut.size(); // number of different luts
449  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
450 
451  RooGKCounter _counter;
452  //loop over all EMap channels
453  for( _iter.begin(); !_iter.end(); _iter.next() ){
455  if( (_subdet == HcalBarrel ||
456  _subdet == HcalEndcap ||
457  _subdet == HcalForward ||
458  _subdet == HcalOuter )
459  ){
460  int _ieta = _iter.getIeta();
461  int _iphi = _iter.getIphi();
462  int _depth = _iter.getDepth();
463 
464  // FIXME: this is probably wrong, raw ids are different
466  int aCrate = _eId . readoutVMECrateId();
467  int aSlot = _eId . htrSlot();
468  int aTopBottom = _eId . htrTopBottom();
469  int aFiber = _eId . fiberIndex();
470  int aFiberChan = _eId . fiberChanId();
471 
472  LutXml::Config _cfg;
473 
474  // search for the correct LUT for a given channel,
475  // higher LUT numbers have priority in case of overlapping
476  int lut_index=-1;
477  for ( int i=0; i<lut_set_size; i++ ){
478  if ( (aCrate == _crate || _crate == -1) && // -1 stands for all crates
479  _set.eta_min[i] <= _ieta &&
480  _set.eta_max[i] >= _ieta &&
481  _set.phi_min[i] <= _iphi &&
482  _set.phi_max[i] >= _iphi &&
483  _set.depth_min[i] <= _depth &&
484  _set.depth_max[i] >= _depth &&
485  _set.subdet[i].find(_ass.getSubdetectorString(_subdet))!=string::npos ){
486  lut_index=i;
487  }
488  }
489  if ( lut_index >= 0 ){
490  if ( _xml.count(aCrate) == 0 && split_by_crate ){
491  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(aCrate,boost::shared_ptr<LutXml>(new LutXml())) );
492  }
493  else if ( _xml.count(0) == 0 && !split_by_crate ){
494  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
495  }
496  _cfg.ieta = _ieta;
497  _cfg.iphi = _iphi;
498  _cfg.depth = _depth;
499  _cfg.crate = aCrate;
500  _cfg.slot = aSlot;
501  _cfg.topbottom = aTopBottom;
502  _cfg.fiber = aFiber;
503  _cfg.fiberchan = aFiberChan;
504  _cfg.lut_type = 1;
505  _cfg.creationtag = _tag;
506  _cfg.creationstamp = get_time_stamp( time(0) );
507  _cfg.targetfirmware = "1.0.0";
508  _cfg.formatrevision = "1"; //???
509  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
510  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
511  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
512  _cfg.generalizedindex =
513  _cfg.iphi*10000 + _cfg.depth*1000 +
514  (_ieta>0)*100 + abs(_ieta) +
515  (((_subdet==HcalForward) && abs(_ieta)==29)?(4*10000):(0));
516  _cfg.lut = _set.lut[lut_index];
517  if (split_by_crate ){
518  _xml[aCrate]->addLut( _cfg, lut_checksums_xml );
519  _counter.count();
520  }
521  else{
522  _xml[0]->addLut( _cfg, lut_checksums_xml );
523  _counter.count();
524  }
525  }
526  }
527  }
528  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
529  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
530  return _xml;
531 }
int i
Definition: DBlmapReader.cc:9
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 618 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, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, SiPixelLorentzAngle_cfi::read, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

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

Definition at line 703 of file HcalLutManager.cc.

References funct::abs(), ecalMGPA::adc(), 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(), HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, LutXml::_Config::ieta, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

704 {
705  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
706  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
707 
708  EMap _emap(emap);
709  std::vector<EMap::EMapRow> & _map = _emap.get_map();
710  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " entries";
711 
712  std::vector<unsigned int> zeroLut;
713  for (size_t adc = 0; adc < 128; adc++) zeroLut.push_back(0);
714 
715  RooGKCounter _counter;
716  //loop over all EMap channels
717  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
718  if( (row->subdet.find("HB")!=string::npos ||
719  row->subdet.find("HE")!=string::npos ||
720  row->subdet.find("HF")!=string::npos ) &&
721  row->subdet.size()==2
722  ){
723  LutXml::Config _cfg;
724 
725  if ( _xml.count(row->crate) == 0 && split_by_crate ){
726  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
727  }
728  else if ( _xml.count(0) == 0 && !split_by_crate ){
729  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
730  }
731  _cfg.ieta = row->ieta;
732  _cfg.iphi = row->iphi;
733  _cfg.depth = row->idepth;
734  _cfg.crate = row->crate;
735  _cfg.slot = row->slot;
736  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
737  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
738  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
739  _cfg.fiber = row->fiber;
740  _cfg.fiberchan = row->fiberchan;
741  _cfg.lut_type = 1;
742  _cfg.creationtag = _tag;
743  _cfg.creationstamp = get_time_stamp( time(0) );
744  _cfg.targetfirmware = "1.0.0";
745  _cfg.formatrevision = "1"; //???
746  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
747  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
748  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
749  _cfg.generalizedindex =
750  _cfg.iphi*10000 + _cfg.depth*1000 +
751  (row->ieta>0)*100 + abs(row->ieta) +
752  (((row->subdet.find("HF")!=string::npos) && abs(row->ieta)==29)?(4*10000):(0));
753  HcalSubdetector _subdet;
754  if ( row->subdet.find("HB")!=string::npos ) _subdet = HcalBarrel;
755  else if ( row->subdet.find("HE")!=string::npos ) _subdet = HcalEndcap;
756  else if ( row->subdet.find("HO")!=string::npos ) _subdet = HcalOuter;
757  else if ( row->subdet.find("HF")!=string::npos ) _subdet = HcalForward;
758  else _subdet = HcalOther;
759  HcalDetId _detid(_subdet, row->ieta, row->iphi, row->idepth);
760  //
761  // consider channel status here
762  uint32_t status_word = cq->getValues(_detid)->getValue();
763  if ((status_word & status_word_to_mask) > 0){
764  _cfg.lut = zeroLut;
765  }
766  else{
767  std::vector<unsigned short> coder_lut = _coder . getLinearizationLUT(_detid);
768  for (std::vector<unsigned short>::const_iterator _i=coder_lut.begin(); _i!=coder_lut.end();_i++){
769  unsigned int _temp = (unsigned int)(*_i);
770  _cfg.lut.push_back(_temp);
771  }
772  }
773  if (split_by_crate ){
774  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
775  _counter.count();
776  }
777  else{
778  _xml[0]->addLut( _cfg, lut_checksums_xml );
779  _counter.count();
780  }
781  }
782  }
783  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
784  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
785  return _xml;
786 }
int adc(sample_type sample)
get the ADC sample (12 bits)
std::string targetfirmware
Definition: LutXml.h:39
Definition: LutXml.h:27
int generalizedindex
Definition: LutXml.h:40
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:7
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
HcalSubdetector
Definition: HcalAssistant.h:31
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
uint32_t getValue() const
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
tuple size
Write out results.
uint32_t status_word_to_mask
std::vector< unsigned int > HcalLutManager::getLutFromXml ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt 
)

Definition at line 1252 of file HcalLutManager.cc.

References mps_fire::result.

1253 {
1254  edm::LogInfo("HcalLutManager") << "getLutFromXml (new version) is not implemented. Use getLutFromXml_old() for now";
1255 
1256  std::vector<unsigned int> result;
1257 
1258 
1259 
1260  return result;
1261 }
tuple result
Definition: mps_fire.py:84
std::vector< unsigned int > HcalLutManager::getLutFromXml_old ( std::string  tag,
uint32_t  _rawid,
hcal::ConfigurationDatabase::LUTType  _lt 
)

Definition at line 1265 of file HcalLutManager.cc.

References EcalCondDB::db, cmsRelvalreport::exit, spr::find(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

1266 {
1267  if ( !lmap ){
1268  edm::LogError("HcalLutManager") << "Cannot find LUT without LMAP, exiting...";
1269  exit(-1);
1270  }
1271  if ( !db ){
1272  edm::LogError("HcalLutManager") << "Cannot find LUT, no source (local XML file), exiting...";
1273  exit(-1);
1274  }
1275 
1276  std::vector<unsigned int> result;
1277 
1278  std::map<int,LMapRow> & _map = lmap -> get_map();
1279  //std::cout << "HcalLutManager: LMap contains " << _map . size() << " channels (out of 9072 total)" << std::endl;
1280 
1281  HcalDetId _id( _rawid );
1282 
1283  unsigned int _crate, _slot, _fiber, _channel;
1284  std::string _fpga;
1285  int topbottom, luttype;
1286 
1287  // FIXME: check validity of _rawid
1288  if ( _map . find(_rawid) != _map.end() ){
1289  _crate = _map[_rawid] . crate;
1290  _slot = _map[_rawid] . htr;
1291  _fiber = _map[_rawid] . htr_fi;
1292  _channel = _map[_rawid] . fi_ch;
1293  _fpga = _map[_rawid] . fpga;
1294 
1295  if ( _fpga . find("top") != std::string::npos ) topbottom = 1;
1296  else if ( _fpga . find("bot") != std::string::npos ) topbottom = 0;
1297  else{
1298  edm::LogError("HcalLutManager") << "Irregular LMAP fpga value... do not know what to do - exiting";
1299  exit(-1);
1300  }
1301  if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
1302  else luttype = 2;
1303 
1304  result = db -> getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
1305  }
1306 
1307  return result;
1308 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
HCALConfigDB * db
tuple result
Definition: mps_fire.py:84
HcalLutSet HcalLutManager::getLutSetFromFile ( std::string  _filename,
int  _type = 1 
)

Definition at line 169 of file HcalLutManager.cc.

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

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

References LutXml::_Config::lut.

99 {
100 
101  if (lut_xml) delete lut_xml;
102 
103  lut_xml = new LutXml();
104 
105  LutXml::Config _config;
106  _config.lut = _lut;
107  lut_xml -> addLut( _config );
108  lut_xml -> addLut( _config );
109  lut_xml -> addLut( _config );
110 
111  //return lut_xml->getString();
112  return lut_xml->getCurrentBrick();
113 
114 }
Definition: LutXml.h:27
std::string & getCurrentBrick(void)
Definition: LutXml.cc:330
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 255 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(), HcalDbOmds::get_subdetector(), RooGKCounter::getCount(), HcalForward, i, LutXml::_Config::ieta, LutXml::_Config::iphi, HcalLutSet::lut, LutXml::_Config::lut, LutXml::_Config::lut_type, HcalLutSet::phi_max, HcalLutSet::phi_min, SiPixelLorentzAngle_cfi::read, findQualityFiles::size, LutXml::_Config::slot, HcalLutSet::subdet, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

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

Definition at line 1566 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, LutXml::_Config::lut, LutXml::_Config::lut_type, findQualityFiles::size, LutXml::_Config::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

1568 {
1569  edm::LogInfo("HcalLutManager") << "Generating ZDC LUTs ...may the Force be with us...";
1570  std::map<int, boost::shared_ptr<LutXml> > _xml; // index - crate number
1571 
1572  EMap _emap(emap);
1573 
1574  ZdcLut zdc;
1575 
1576  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1577  edm::LogInfo("HcalLutManager") << "EMap contains " << _map . size() << " channels";
1578 
1579  //loop over all EMap channels
1580  RooGKCounter _counter;
1581  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
1582  LutXml::Config _cfg;
1583 
1584  // only ZDC channels
1585  if ( row->zdc_section . find("ZDC") != std::string::npos ){
1586  if ( _xml.count(row->crate) == 0 && split_by_crate ){
1587  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
1588  }
1589  else if ( _xml.count(0) == 0 && !split_by_crate ){
1590  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
1591  }
1592  // FIXME: introduce proper tag names in ZDC bricks for logical channel info
1593  _cfg.ieta = row->zdc_channel; // int
1594  //_cfg.ieta = row->zdc_zside; // int
1595  //_cfg.iphi = row->zdc_section; // string
1596  _cfg.depth = row->idepth; // int
1597  _cfg.crate = row->crate;
1598  _cfg.slot = row->slot;
1599  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
1600  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
1601  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
1602  _cfg.fiber = row->fiber;
1603  _cfg.fiberchan = row->fiberchan;
1604  _cfg.lut_type = 1;
1605  _cfg.creationtag = _tag;
1606  _cfg.creationstamp = get_time_stamp( time(0) );
1607  _cfg.targetfirmware = "1.0.0";
1608  _cfg.formatrevision = "1"; //???
1609  _cfg.generalizedindex = 0;
1610 
1611  //HcalZDCDetId _detid(row->zdc_section, (row->zdc_zside>0), row->zdc_channel);
1612 
1613  std::vector<int> coder_lut = zdc.get_lut(row->zdc_section,
1614  row->zdc_zside,
1615  row->zdc_channel);
1616  edm::LogInfo("HcalLutManager") << "***DEBUG: ZDC lut size: " << coder_lut.size();
1617  if (coder_lut.size()!=0){
1618  for (std::vector<int>::const_iterator _i=coder_lut.begin(); _i!=coder_lut.end();_i++){
1619  unsigned int _temp = (unsigned int)(*_i);
1620  //if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
1621  //unsigned int _temp = 0;
1622  _cfg.lut.push_back(_temp);
1623  }
1624  //_cfg.lut = _set.lut[lut_index];
1625 
1626  if (split_by_crate ){
1627  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
1628  _counter.count();
1629  }
1630  else{
1631  _xml[0]->addLut( _cfg, lut_checksums_xml );
1632  _counter.count();
1633  }
1634  } //size of lut
1635  }
1636  }
1637  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1638  << "Generating ZDC LUTs...DONE" << std::endl;
1639 
1640  return _xml;
1641 }
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:7
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
tuple size
Write out results.
void HcalLutManager::init ( void  )

Definition at line 69 of file HcalLutManager.cc.

References EcalCondDB::db.

70 {
71  lut_xml = 0;
73  db = 0;
74  lmap = 0;
75  emap = 0;
76  cq = 0;
77  status_word_to_mask = 0x0000;
78 }
HCALConfigDB * db
const HcalChannelQuality * cq
XMLDOMBlock * lut_checksums_xml
const HcalElectronicsMap * emap
uint32_t status_word_to_mask
int HcalLutManager::initChannelIterator ( std::vector< HcalGenericDetId > &  map)

Definition at line 91 of file HcalLutManager.cc.

References init.

92 {
93  _iter . init(map);
94  return _iter.size();
95 }
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 1242 of file HcalLutManager.cc.

1243 {
1244  read_lmap( lmap_hbef_file, lmap_ho_file );
1245  read_luts( lut_xml_file );
1246  return 0;
1247 }
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 1218 of file HcalLutManager.cc.

References SiPixelLorentzAngle_cfi::read, and findQualityFiles::size.

1219 {
1220  delete lmap;
1221  lmap = new LMap();
1222  lmap -> read( lmap_hbef_file, "HBEF" );
1223  lmap -> read( lmap_ho_file, "HO" );
1224  edm::LogInfo("HcalLutManager") << "LMap contains " << lmap -> get_map() . size() << " channels (compare to 9072 of all HCAL channels)";
1225  return 0;
1226 }
Definition: LMap.h:75
tuple size
Write out results.
int HcalLutManager::read_luts ( std::string  lut_xml_file)

Definition at line 1230 of file HcalLutManager.cc.

References convertSQLitetoXML_cfg::connect, and EcalCondDB::db.

1231 {
1232  delete db;
1233  db = new HCALConfigDB();
1234  db -> connect( lut_xml_file );
1235  return 0;
1236 }
HCALConfigDB * db
Gather config data from online DB.
Definition: HCALConfigDB.h:21
int HcalLutManager::test_direct_xml_parsing ( std::string  _filename)

Definition at line 1504 of file HcalLutManager.cc.

1504  {
1505  /*
1506  XMLDOMBlock _xml(_filename);
1507  //DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
1508  DOMNodeList * brick_list = _xml . getDocument() -> getElementsByTagName( XMLProcessor::_toXMLCh( "CFGBrick" ));
1509 
1510  double n_bricks = brick_list->getLength();
1511  std::cout << "amount of LUT bricks: " << n_bricks << std::endl;
1512 
1513  for (int iter=0; iter!=n_bricks; iter++){
1514  DOMElement * _brick = (DOMElement *)(brick_list->item(iter));
1515 
1516  DOMElement * _param = 0;
1517  // loop over brick parameters
1518  int par_iter = 0;
1519  while(1){
1520  _param = (DOMElement *)(_brick->getElementsByTagName(XMLProcessor::_toXMLCh("Parameter")));
1521  std::string _name = _param->getAttribute( XMLProcessor::_toXMLCh( "name" ) );
1522  if (_name.find("IETA")==string::npos) break;
1523 
1524  std::string _tag = "Parameter";
1525  std::cout << "### Parameter IETA = " << _xml.getTagValue( _tag, 0, _brick);
1526  par_iter++;
1527  }
1528  }
1529  */
1530  return 0;
1531 }
void HcalLutManager::test_emap ( void  )

Definition at line 1474 of file HcalLutManager.cc.

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

1474  {
1475  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1476  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1477  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1478  EMap _emap(emap);
1479  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1480  std::stringstream s;
1481  s << "EMap contains " << _map . size() << " channels" << std::endl;
1482 
1483  //loop over all EMap channels
1484  //RooGKCounter _c;
1485  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
1486 
1487  // only trigger tower channels
1488  if ( row->subdet . find("HT") != std::string::npos ){
1489  s << " -----> Subdet = " << row->subdet << std::endl;
1490 
1491  if (abs(row->ieta)>28){
1492  //if (row->iphi == 71){
1493  s << " ==> (ieta,iphi) = " << row->ieta << ", " << row->iphi << std::endl;
1494  }
1495  }
1496  }
1497  edm::LogInfo("HcalLutManager") << s.str();
1498 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HcalElectronicsMap * emap
Definition: LMap.h:94
tuple size
Write out results.
int HcalLutManager::test_xml_access ( std::string  _tag,
std::string  _filename 
)

Definition at line 1138 of file HcalLutManager.cc.

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

1139 {
1140  local_connect( _filename, "backup/HCALmapHBEF.txt", "backup/HCALmapHO.txt" );
1141 
1142  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1143  EMap _emap(emap);
1144  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1145  int map_size = _map . size();
1146  edm::LogInfo("HcalLutManager") << "EMap contains " << map_size << " channels";
1147 
1148  // make sure that all init is done
1149  std::vector<unsigned int> _lut;
1150  _lut = getLutFromXml( _tag, 1107313727, hcal::ConfigurationDatabase::LinearizerLUT );
1151 
1152 
1153  edm::LogInfo("HcalLutManager") << "Testing direct parsing of the LUT XML";
1154  struct timeval _t;
1155  gettimeofday( &_t, NULL );
1156  double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
1157  test_direct_xml_parsing(_filename);
1158  gettimeofday( &_t, NULL );
1159  edm::LogInfo("HcalLutManager") << "parsing took that much time: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time;
1160 
1161 
1162  gettimeofday( &_t, NULL );
1163  _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
1164  edm::LogInfo("HcalLutManager") << "before loop over random LUTs: " << _time;
1165  int _raw_id;
1166 
1167  // loop over random LUTs
1168  for (int _iter=0; _iter<100; _iter++){
1169  gettimeofday( &_t, NULL );
1170  //std::cout << "before getting a LUT: " << _t . tv_sec << "." << _t . tv_usec << std::endl;
1171 
1172  // select valid random emap channel
1173  while(1){
1174  int _key = (rand() % map_size);
1175  //_key = 3356;
1176  if( (_map[_key].subdet.find("HB")!=string::npos ||
1177  _map[_key].subdet.find("HE")!=string::npos ||
1178  _map[_key].subdet.find("HO")!=string::npos ||
1179  _map[_key].subdet.find("HF")!=string::npos ) &&
1180  _map[_key].subdet.size()==2
1181  ){
1182  HcalSubdetector _subdet;
1183  if ( _map[_key].subdet.find("HB")!=string::npos ) _subdet = HcalBarrel;
1184  else if ( _map[_key].subdet.find("HE")!=string::npos ) _subdet = HcalEndcap;
1185  else if ( _map[_key].subdet.find("HO")!=string::npos ) _subdet = HcalOuter;
1186  else if ( _map[_key].subdet.find("HF")!=string::npos ) _subdet = HcalForward;
1187  else _subdet = HcalOther;
1188  HcalDetId _detid(_subdet, _map[_key].ieta, _map[_key].iphi, _map[_key].idepth);
1189  _raw_id = _detid.rawId();
1190  break;
1191  }
1192  }
1193  _lut = getLutFromXml( _tag, _raw_id, hcal::ConfigurationDatabase::LinearizerLUT );
1194 
1195  gettimeofday( &_t, NULL );
1196  }
1197  double d_time = _t.tv_sec+_t.tv_usec/1000000.0 - _time;
1198  edm::LogInfo("HcalLutManager") << "after the loop over random LUTs: " << _time+d_time << std::endl
1199  << "total time: " << d_time << std::endl;
1200 
1201  edm::LogInfo("HcalLutManager") << "LUT length = " << _lut . size();
1202  for ( std::vector<unsigned int>::const_iterator i = _lut . end() - 1; i != _lut . begin()-1; i-- )
1203  {
1204  edm::LogInfo("HcalLutManager") << (i-_lut.begin()) << " " << _lut[(i-_lut.begin())];
1205  break;
1206  }
1207 
1208  db -> disconnect();
1209 
1210  delete db;
1211  db = 0;
1212 
1213  return 0;
1214 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
HCALConfigDB * db
int test_direct_xml_parsing(std::string _filename)
HcalSubdetector
Definition: HcalAssistant.h:31
#define end
Definition: vmac.h:37
HcalChannelIterator _iter
const HcalElectronicsMap * emap
#define begin
Definition: vmac.h:30
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
tuple size
Write out results.
int HcalLutManager::writeLutXmlFiles ( std::map< int, boost::shared_ptr< LutXml > > &  _xml,
std::string  _tag = "default_tag",
bool  split_by_crate = true 
)

Definition at line 934 of file HcalLutManager.cc.

References cmsHarvester::output_file_name.

935 {
936  for (std::map<int,boost::shared_ptr<LutXml> >::const_iterator cr = _xml.begin(); cr != _xml.end(); cr++){
937  std::stringstream output_file_name;
938  if ( split_by_crate ){
939  output_file_name << _tag << "_" << cr->first << ".xml";
940  }
941  else{
942  output_file_name << _tag << ".xml";
943  }
944  cr->second->write( output_file_name.str().c_str() );
945  }
946  return 0;
947 }

Member Data Documentation

HcalAssistant HcalLutManager::_ass
protected

Definition at line 157 of file HcalLutManager.h.

HcalChannelIterator HcalLutManager::_iter
protected

Definition at line 156 of file HcalLutManager.h.

const HcalChannelQuality* HcalLutManager::cq
protected

Definition at line 159 of file HcalLutManager.h.

HCALConfigDB* HcalLutManager::db
protected

Definition at line 154 of file HcalLutManager.h.

const HcalElectronicsMap* HcalLutManager::emap
protected

Definition at line 158 of file HcalLutManager.h.

LMap* HcalLutManager::lmap
protected

Definition at line 155 of file HcalLutManager.h.

XMLDOMBlock* HcalLutManager::lut_checksums_xml
protected

Definition at line 153 of file HcalLutManager.h.

LutXml* HcalLutManager::lut_xml
protected

Definition at line 152 of file HcalLutManager.h.

uint32_t HcalLutManager::status_word_to_mask
protected

Definition at line 160 of file HcalLutManager.h.