Skip to content

Commit

Permalink
Merge pull request #12654 from matz-e/hf-1x1-tp-algo-v5
Browse files Browse the repository at this point in the history
HF 1x1 TP production along 2x3 TP
  • Loading branch information
davidlange6 committed Dec 16, 2015
2 parents 26a7757 + d724d25 commit 37383df
Show file tree
Hide file tree
Showing 19 changed files with 749 additions and 660 deletions.
364 changes: 88 additions & 276 deletions CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.cc

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include <memory>
#include <vector>
#include "CalibFormats/CaloTPG/interface/CaloTPGTranscoder.h"

// tmp
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "CondFormats/HcalObjects/interface/HcalLutMetadata.h"


Expand Down Expand Up @@ -34,29 +33,25 @@ class CaloTPGTranscoderULUT : public CaloTPGTranscoder {
virtual double hcaletValue(const int& ieta, const int& iphi, const int& compressedValue) const;
virtual double hcaletValue(const HcalTrigTowerDetId& hid, const HcalTriggerPrimitiveSample& hc) const;
virtual bool HTvalid(const int ieta, const int iphi) const;
virtual std::vector<unsigned char> getCompressionLUT(HcalTrigTowerDetId id) const;
virtual std::vector<unsigned int> getCompressionLUT(HcalTrigTowerDetId id) const;
virtual void setup(HcalLutMetadata const&, HcalTrigTowerGeometry const&);
virtual int getOutputLUTId(const HcalTrigTowerDetId& id) const;
virtual int getOutputLUTId(const int ieta, const int iphi) const;

private:
// Typedef
typedef unsigned int LUT;
typedef std::vector<double> RCTdecompression;

const HcalTopology* theTopology;
// Constant
// TODO prefix k
static const int NOUTLUTS = 4176;
static const unsigned int OUTPUT_LUT_SIZE = 1024;
static const int TPGMAX = 256;
static const bool newHFphi = true;

// Member functions
void loadHCALCompress(HcalLutMetadata const&, HcalTrigTowerGeometry const&) ; //Analytical compression tables
void loadHCALCompress(const std::string& filename, HcalLutMetadata const&, HcalTrigTowerGeometry const&) ; //Compression tables from file
void loadHCALUncompress(HcalLutMetadata const&, HcalTrigTowerGeometry const&) ; //Analytical decompression
void loadHCALUncompress(const std::string& filename, HcalLutMetadata const&, HcalTrigTowerGeometry const&) ; //Decompression tables from file
//int getLutGranularity(const DetId& id) const;
//int getLutThreshold(const DetId& id) const;

// Member Variables
double nominal_gain_;
Expand All @@ -68,7 +63,7 @@ class CaloTPGTranscoderULUT : public CaloTPGTranscoder {
std::vector<int> ZS;
std::vector<int> LUTfactor;

LUT *outputLUT_[NOUTLUTS];
std::vector<std::vector<LUT> > outputLUT_;
std::vector<RCTdecompression> hcaluncomp_;
};
#endif
23 changes: 12 additions & 11 deletions CalibCalorimetry/HcalTPGAlgos/src/LutXml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h"
#include "CalibCalorimetry/HcalTPGAlgos/interface/XMLProcessor.h"
#include "FWCore/Utilities/interface/md5.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CalibCalorimetry/HcalTPGAlgos/interface/HcalEmap.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"
Expand Down Expand Up @@ -134,7 +135,7 @@ std::vector<unsigned int> * LutXml::getLutFast( uint32_t det_id ){
}
*/
if (lut_map.find(det_id) != lut_map.end()) return &(lut_map)[det_id];
std::cerr << "LUT not found, null pointer is returned" << std::endl;
edm::LogError("LutXml") << "LUT not found, null pointer is returned";
return 0;
}

Expand Down Expand Up @@ -238,7 +239,7 @@ void LutXml::addLut( LutXml::Config & _config, XMLDOMBlock * checksums_xml )
addData( "1024", "hex", _config.lut );
}
else{
std::cout << "Unknown LUT type...produced XML will be incorrect" << std::endl;
edm::LogError("LutXml") << "Unknown LUT type...produced XML will be incorrect";
}

// if the pointer to the checksums XML was given,
Expand Down Expand Up @@ -358,7 +359,7 @@ std::string LutXml::get_checksum( std::vector<unsigned int> & lut )
}
}
else{
std::cout << "ERROR: irregular LUT size, do not know how to compute checksum, exiting..." << std::endl;
edm::LogError("LutXml") << "Irregular LUT size, do not know how to compute checksum, exiting...";
exit(-1);
}
md5_finish(&md5er,digest);
Expand All @@ -374,16 +375,15 @@ std::string LutXml::get_checksum( std::vector<unsigned int> & lut )

int LutXml::test_access( std::string filename ){
//create_lut_map();
//std::cout << "Created map size: " << lut_map->size() << std::endl;
std::cout << "Created map size: " << lut_map.size() << std::endl;
edm::LogInfo("LutXml") << "Created map size: " << lut_map.size();

struct timeval _t;
gettimeofday( &_t, NULL );
double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;

HcalEmap _emap("./backup/official_emap_v6.04_080905.txt");
std::vector<HcalEmap::HcalEmapRow> & _map = _emap.get_map();
std::cout << "HcalEmap contains " << _map . size() << " entries" << std::endl;
edm::LogInfo("LutXml") << "HcalEmap contains " << _map . size() << " entries";

int _counter=0;
for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); ++row){
Expand Down Expand Up @@ -413,7 +413,7 @@ int LutXml::test_access( std::string filename ){
}
}
gettimeofday( &_t, NULL );
std::cout << "access to " << _counter << " HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time << "sec" << std::endl;
edm::LogInfo("LutXml") << "access to " << _counter << " HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time << "sec";

//std::cout << std::endl;
//for (std::vector<unsigned int>::const_iterator i=l->begin();i!=l->end();i++){
Expand Down Expand Up @@ -455,11 +455,12 @@ int LutXml::test_xpath( std::string filename ){
}
*/

HcalSubdetector LutXml::subdet_from_crate(int crate, int eta, int depth){
HcalSubdetector LutXml::subdet_from_crate(int crate_, int eta, int depth){
HcalSubdetector result;
// HBHE: 0,1,4,5,10,11,14,15,17
// HF: 2,9,12
// HO: 3,6,7,13
int crate=crate_<20? crate_ : crate_-20;

if (crate==2 || crate==9 || crate==12) result=HcalForward;
else if (crate==3 || crate==6 || crate==7 || crate==13) result=HcalOuter;
Expand All @@ -469,12 +470,12 @@ HcalSubdetector LutXml::subdet_from_crate(int crate, int eta, int depth){
else if (eta==16 && depth!=3) result=HcalBarrel;
else if (eta==16 && depth==3) result=HcalEndcap;
else{
std::cerr << "Impossible to determine HCAL subdetector!!!" << std::endl;
edm::LogError("LutXml") << "Impossible to determine HCAL subdetector!!!";
exit(-1);
}
}
else{
std::cerr << "Impossible to determine HCAL subdetector!!!" << std::endl;
edm::LogError("LutXml") << "Impossible to determine HCAL subdetector!!!";
exit(-1);
}

Expand Down Expand Up @@ -573,7 +574,7 @@ int LutXml::create_lut_map( void ){
}
}
else{
std::cerr << "XML file with LUTs is not loaded, cannot create map!" << std::endl;
edm::LogError("LutXml") << "XML file with LUTs is not loaded, cannot create map!";
}


Expand Down
Loading

0 comments on commit 37383df

Please sign in to comment.