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 1108 of file HcalLutManager.cc.

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

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

1402 {
1403  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs...";
1404  //std::cout << _prefix << "..." << tag_name << std::endl;
1405 
1409 
1410  baseConf . tag_name = tag_name;
1411  //baseConf . comment_description = tag_name;
1412  baseConf . comment_description = comment;
1413  baseConf . iov_begin = "1";
1414  baseConf . iov_end = "-1";
1415 
1416  conf . version = version;
1417 
1418  std::stringstream _subversion;
1419  _subversion << subversion;
1420  conf . subversion = _subversion.str();
1421 
1422  CSconf . version = conf . version;
1423  CSconf . subversion = conf . subversion;
1424  CSconf . trig_prim_lookuptbl_data_file = _prefix + "_checksums.xml.dat";
1425  CSconf . comment_description = tag_name;
1426 
1427  XMLLUTLoader doc( &baseConf );
1428 
1429  std::vector<int> crate_number;
1430  std::vector<std::string> file_name = HcalQIEManager::splitString(file_list);
1431  for (std::vector<std::string>::const_iterator _f = file_name.begin(); _f != file_name.end(); _f++){
1432  int crate_begin = _f->rfind("_");
1433  int crate_end = _f->rfind(".xml.dat");
1434  crate_number . push_back(getInt(_f->substr(crate_begin+1,crate_end-crate_begin-1)));
1435  }
1436  //
1437  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1438  //
1439  char _buf[128];
1440  time_t _offset = time(NULL);
1441  sprintf( _buf, "%d", (uint32_t)_offset );
1442  conf.version.append(".");
1443  conf.version.append(_buf);
1444  CSconf.version = conf.version;
1445  //
1446  for ( std::vector<std::string>::const_iterator _file = file_name . begin(); _file != file_name . end(); _file++ )
1447  {
1448  conf . trig_prim_lookuptbl_data_file = *_file;
1449  //conf . trig_prim_lookuptbl_data_file += ".dat";
1450  conf . crate = crate_number[ _file - file_name . begin() ];
1451  //
1452  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1453  //
1454  sprintf( _buf, "%.2d", conf.crate );
1455  conf.subversion.clear();
1456  conf.subversion.append(_buf);
1457  sprintf( _buf, "CRATE%.2d", conf . crate );
1458  std::string _namelabel;
1459  _namelabel . append( _buf );
1460  conf . name_label = _namelabel;
1461  doc . addLUT( &conf );
1462  }
1463 
1464  doc . addChecksums( &CSconf );
1465  //doc . write( _prefix + "_Loader.xml" );
1466  doc . write( tag_name + "_Loader.xml" );
1467 
1468  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs... done.";
1469 
1470  return 0;
1471 }
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 967 of file HcalLutManager.cc.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Definition at line 1124 of file HcalLutManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

References query::result, and TablePrint::write.

1312 {
1313  std::map<int, boost::shared_ptr<LutXml> > lut_map = get_brickSet_from_oracle( tag, db_accessor );
1314  if (split_by_crate){
1315  writeLutXmlFiles( lut_map, tag, split_by_crate );
1316  }
1317  else{
1318  LutXml result;
1319  for( std::map<int, boost::shared_ptr<LutXml> >::const_iterator xml = lut_map.begin(); xml != lut_map.end(); xml++ ){
1320  result += *(xml->second);
1321  }
1322  std::stringstream out_file;
1323  out_file << tag << ".xml";
1324  result . write(out_file.str());
1325  }
1326 
1327  return 0;
1328 }
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: query.py:137
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) ){
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
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
virtual bool HTvalid(const int ieta, const int iphi) const
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  if ( row->subdet . find("HT") != std::string::npos && _coder.HTvalid(row->ieta, row->iphi) ){
882  if ( _xml.count(row->crate) == 0 && split_by_crate ){
883  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(row->crate,boost::shared_ptr<LutXml>(new LutXml())) );
884  }
885  else if ( _xml.count(0) == 0 && !split_by_crate ){
886  _xml.insert( std::pair<int,boost::shared_ptr<LutXml> >(0,boost::shared_ptr<LutXml>(new LutXml())) );
887  }
888  _cfg.ieta = row->ieta;
889  _cfg.iphi = row->iphi;
890  _cfg.depth = row->idepth;
891  _cfg.crate = row->crate;
892  _cfg.slot = row->slot;
893  if (row->topbottom . find("t") != std::string::npos) _cfg.topbottom = 1;
894  else if (row->topbottom . find("b") != std::string::npos) _cfg.topbottom = 0;
895  else edm::LogWarning("HcalLutManager") << "fpga out of range...";
896  _cfg.fiber = row->fiber;
897  _cfg.fiberchan = row->fiberchan;
898  _cfg.lut_type = 2;
899  _cfg.creationtag = _tag;
900  _cfg.creationstamp = get_time_stamp( time(0) );
901  _cfg.targetfirmware = "1.0.0";
902  _cfg.formatrevision = "1"; //???
903  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
904  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
905  // ((id.ieta()<0)?(0):(100));
906  _cfg.generalizedindex =
907  _cfg.iphi*10000+
908  (row->ieta>0)*100+abs(row->ieta);
909 
910  // FIXME: work around bug in emap v6: rawId wasn't filled
911  //HcalTrigTowerDetId _detid(row->rawId);
912  HcalTrigTowerDetId _detid(row->ieta, row->iphi);
913 
914  _cfg.lut = _coder.getCompressionLUT(_detid);
915 
916  if (split_by_crate ){
917  _xml[row->crate]->addLut( _cfg, lut_checksums_xml );
918  _counter.count();
919  }
920  else{
921  _xml[0]->addLut( _cfg, lut_checksums_xml );
922  _counter.count();
923  }
924  }
925  }
926  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
927  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE" << std::endl;
928  return _xml;
929 }
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
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
virtual bool HTvalid(const int ieta, const int iphi) const
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 query::result.

Referenced by getLutSetFromFile().

118 {
119  int result;
120  sscanf(number.c_str(), "%d", &result);
121  return result;
122 }
tuple result
Definition: query.py:137
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 1251 of file HcalLutManager.cc.

References query::result.

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

Definition at line 1264 of file HcalLutManager.cc.

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

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

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

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

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

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

Definition at line 1229 of file HcalLutManager.cc.

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

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

Definition at line 1503 of file HcalLutManager.cc.

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

Definition at line 1473 of file HcalLutManager.cc.

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

1473  {
1474  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1475  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1476  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1477  EMap _emap(emap);
1478  std::vector<EMap::EMapRow> & _map = _emap.get_map();
1479  std::stringstream s;
1480  s << "EMap contains " << _map . size() << " channels" << std::endl;
1481 
1482  //loop over all EMap channels
1483  //RooGKCounter _c;
1484  for( std::vector<EMap::EMapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++ ){
1485 
1486  // only trigger tower channels
1487  if ( row->subdet . find("HT") != std::string::npos ){
1488  s << " -----> Subdet = " << row->subdet << std::endl;
1489 
1490  if (abs(row->ieta)>28){
1491  //if (row->iphi == 71){
1492  s << " ==> (ieta,iphi) = " << row->ieta << ", " << row->iphi << std::endl;
1493  }
1494  }
1495  }
1496  edm::LogInfo("HcalLutManager") << s.str();
1497 }
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 1137 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.

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

References cmsHarvester::output_file_name.

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

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.