CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
CaloTPGTranscoderULUT Class Reference

#include <CaloTPGTranscoderULUT.h>

Inheritance diagram for CaloTPGTranscoderULUT:
CaloTPGTranscoder

Public Member Functions

 CaloTPGTranscoderULUT (const std::string &compressionFile="", const std::string &decompressionFile="")
 
virtual EcalTriggerPrimitiveSample ecalCompress (const EcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const
 Compression from linear samples+fine grain in the ECAL. More...
 
virtual const std::vector
< unsigned int > & 
getCompressionLUT (const HcalTrigTowerDetId &id) const
 
virtual int getOutputLUTId (const HcalTrigTowerDetId &id) const
 
virtual int getOutputLUTId (const int ieta, const int iphi, const int version) const
 
virtual HcalTriggerPrimitiveSample hcalCompress (const HcalTrigTowerDetId &id, unsigned int sample, int fineGrain) const override
 Compression from linear samples+fine grain in the HTR. More...
 
virtual double hcaletValue (const int &ieta, const int &iphi, const int &version, const int &compressedValue) const
 
virtual double hcaletValue (const HcalTrigTowerDetId &hid, const HcalTriggerPrimitiveSample &hc) const
 
virtual bool HTvalid (const int ieta, const int iphi, const int version) const
 
virtual void rctEGammaUncompress (const HcalTrigTowerDetId &hid, const HcalTriggerPrimitiveSample &hc, const EcalTrigTowerDetId &eid, const EcalTriggerPrimitiveSample &ec, unsigned int &et, bool &egVecto, bool &activity) const
 Uncompression for the Electron/Photon path in the RCT. More...
 
virtual void rctJetUncompress (const HcalTrigTowerDetId &hid, const HcalTriggerPrimitiveSample &hc, const EcalTrigTowerDetId &eid, const EcalTriggerPrimitiveSample &ec, unsigned int &et) const
 Uncompression for the JET path in the RCT. More...
 
virtual void setup (HcalLutMetadata const &, HcalTrigTowerGeometry const &, int, int)
 
virtual ~CaloTPGTranscoderULUT ()
 
- Public Member Functions inherited from CaloTPGTranscoder
 CaloTPGTranscoder ()
 
boost::shared_ptr< const
EcalTPGCompressor
getEcalCompressor () const
 
boost::shared_ptr< const
HcalTPGCompressor
getHcalCompressor () const
 
virtual ~CaloTPGTranscoder ()
 

Private Types

typedef unsigned int LUT
 
typedef std::vector< double > RCTdecompression
 

Private Member Functions

void loadHCALCompress (HcalLutMetadata const &, HcalTrigTowerGeometry const &)
 

Private Attributes

std::string compressionFile_
 
std::string decompressionFile_
 
std::vector< RCTdecompressionhcaluncomp_
 
std::vector< int > ietah
 
std::vector< int > ietal
 
double lsb_factor_
 
std::vector< int > LUTfactor
 
double nct_factor_
 
double nominal_gain_
 
std::vector< std::vector< LUT > > outputLUT_
 
double rct_factor_
 
unsigned int size
 
const HcalTopologytheTopology
 
std::vector< int > ZS
 

Static Private Attributes

static const bool newHFphi = true
 
static const int NOUTLUTS = 4176
 
static const unsigned int OUTPUT_LUT_SIZE = 1024
 
static const unsigned int TPGMAX = 256
 

Additional Inherited Members

- Public Types inherited from CaloTPGTranscoder
enum  Mode { All =0, RCT =1, HcalTPG =2, EcalTPG =3 }
 

Detailed Description

Author
J. Mans - Minnesota

Definition at line 18 of file CaloTPGTranscoderULUT.h.

Member Typedef Documentation

typedef unsigned int CaloTPGTranscoderULUT::LUT
private

Definition at line 42 of file CaloTPGTranscoderULUT.h.

typedef std::vector<double> CaloTPGTranscoderULUT::RCTdecompression
private

Definition at line 43 of file CaloTPGTranscoderULUT.h.

Constructor & Destructor Documentation

CaloTPGTranscoderULUT::CaloTPGTranscoderULUT ( const std::string &  compressionFile = "",
const std::string &  decompressionFile = "" 
)

Definition at line 19 of file CaloTPGTranscoderULUT.cc.

References outputLUT_.

21  : theTopology(0),
23  compressionFile_(compressionFile),
24  decompressionFile_(decompressionFile),
25  size(0)
26 {
27  outputLUT_.clear();
28 }
std::vector< std::vector< LUT > > outputLUT_
const HcalTopology * theTopology
CaloTPGTranscoderULUT::~CaloTPGTranscoderULUT ( )
virtual

Definition at line 30 of file CaloTPGTranscoderULUT.cc.

30  {
31 }

Member Function Documentation

EcalTriggerPrimitiveSample CaloTPGTranscoderULUT::ecalCompress ( const EcalTrigTowerDetId id,
unsigned int  sample,
bool  fineGrain 
) const
virtual

Compression from linear samples+fine grain in the ECAL.

Implements CaloTPGTranscoder.

Definition at line 160 of file CaloTPGTranscoderULUT.cc.

References Exception.

160  {
161  throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::ecalCompress";
162 }
const std::vector< unsigned int > & CaloTPGTranscoderULUT::getCompressionLUT ( const HcalTrigTowerDetId id) const
virtual

Definition at line 200 of file CaloTPGTranscoderULUT.cc.

References getOutputLUTId(), and outputLUT_.

Referenced by HcalLutManager::getCompressionLutXmlFromCoder().

200  {
201  int itower = getOutputLUTId(id);
202  return outputLUT_[itower];
203 }
std::vector< std::vector< LUT > > outputLUT_
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
int CaloTPGTranscoderULUT::getOutputLUTId ( const HcalTrigTowerDetId id) const
virtual

Definition at line 184 of file CaloTPGTranscoderULUT.cc.

References HcalTopology::detId2denseIdHT(), Exception, and theTopology.

Referenced by getCompressionLUT(), hcalCompress(), hcaletValue(), loadHCALCompress(), and L1CaloHcalScaleConfigOnlineProd::newObject().

184  {
185  if (!theTopology) {
186  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
187  }
188  return theTopology->detId2denseIdHT(id);
189 }
unsigned int detId2denseIdHT(const DetId &id) const
return a linear packed id from HT
const HcalTopology * theTopology
int CaloTPGTranscoderULUT::getOutputLUTId ( const int  ieta,
const int  iphi,
const int  version 
) const
virtual

Definition at line 191 of file CaloTPGTranscoderULUT.cc.

References HcalTopology::detId2denseIdHT(), Exception, and theTopology.

191  {
192  if (!theTopology) {
193  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
194  }
195  HcalTrigTowerDetId id(ieta, iphiin);
196  id.setVersion(version);
197  return theTopology->detId2denseIdHT(id);
198 }
unsigned int detId2denseIdHT(const DetId &id) const
return a linear packed id from HT
const HcalTopology * theTopology
HcalTriggerPrimitiveSample CaloTPGTranscoderULUT::hcalCompress ( const HcalTrigTowerDetId id,
unsigned int  sample,
int  fineGrain 
) const
overridevirtual

Compression from linear samples+fine grain in the HTR.

Implements CaloTPGTranscoder.

Definition at line 125 of file CaloTPGTranscoderULUT.cc.

References Exception, getOutputLUTId(), OUTPUT_LUT_SIZE, outputLUT_, and size.

125  {
126  unsigned int itower = getOutputLUTId(id);
127 
128  if (sample >= OUTPUT_LUT_SIZE) {
129  throw cms::Exception("Out of Range") << "LUT has 1024 entries for " << itower << " but " << sample << " was requested.";
130  sample=OUTPUT_LUT_SIZE - 1;
131  }
132 
133  if(itower >= size){
134  throw cms::Exception("Out of Range") << "No decompression LUT found for " << id;
135  }
136 
137  return HcalTriggerPrimitiveSample(outputLUT_[itower][sample], fineGrain);
138 }
std::vector< std::vector< LUT > > outputLUT_
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
static const unsigned int OUTPUT_LUT_SIZE
double CaloTPGTranscoderULUT::hcaletValue ( const int &  ieta,
const int &  iphi,
const int &  version,
const int &  compressedValue 
) const
virtual

Implements CaloTPGTranscoder.

Definition at line 140 of file CaloTPGTranscoderULUT.cc.

References getOutputLUTId(), hcaluncomp_, and TPGMAX.

140  {
141  double etvalue = 0.;
142  int itower = getOutputLUTId(ieta,iphi, version);
143  if (itower < 0) {
144  edm::LogError("CaloTPGTranscoderULUT") << "No decompression LUT found for ieta, iphi = " << ieta << ", " << iphi;
145  } else if (compET < 0 || compET >= (int) TPGMAX) {
146  edm::LogError("CaloTPGTranscoderULUT") << "Compressed value out of range: eta, phi, cET = " << ieta << ", " << iphi << ", " << compET;
147  } else {
148  etvalue = hcaluncomp_[itower][compET];
149  }
150  return(etvalue);
151 }
std::vector< RCTdecompression > hcaluncomp_
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
static const unsigned int TPGMAX
double CaloTPGTranscoderULUT::hcaletValue ( const HcalTrigTowerDetId hid,
const HcalTriggerPrimitiveSample hc 
) const
virtual

Implements CaloTPGTranscoder.

Definition at line 153 of file CaloTPGTranscoderULUT.cc.

References HcalTriggerPrimitiveSample::compressedEt(), getOutputLUTId(), and hcaluncomp_.

153  {
154  int compET = hc.compressedEt(); // to be within the range by the class
155  int itower = getOutputLUTId(hid);
156  double etvalue = hcaluncomp_[itower][compET];
157  return etvalue;
158 }
std::vector< RCTdecompression > hcaluncomp_
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
int compressedEt() const
get the encoded/compressed Et
bool CaloTPGTranscoderULUT::HTvalid ( const int  ieta,
const int  iphi,
const int  version 
) const
virtual

Definition at line 175 of file CaloTPGTranscoderULUT.cc.

References Exception, theTopology, and HcalTopology::validHT().

Referenced by HcalLutManager::getCompressionLutXmlFromAsciiMaster(), HcalLutManager::getCompressionLutXmlFromCoder(), and L1CaloHcalScaleConfigOnlineProd::newObject().

175  {
176  HcalTrigTowerDetId id(ieta, iphiin);
177  id.setVersion(version);
178  if (!theTopology) {
179  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
180  }
181  return theTopology->validHT(id);
182 }
const HcalTopology * theTopology
bool validHT(const HcalTrigTowerDetId &id) const
void CaloTPGTranscoderULUT::loadHCALCompress ( HcalLutMetadata const &  lutMetadata,
HcalTrigTowerGeometry const &  theTrigTowerGeometry 
)
private

Definition at line 33 of file CaloTPGTranscoderULUT.cc.

References funct::abs(), Exception, V0MonitoringClient_cfi::factor, HcalTrigTowerGeometry::firstHFTower(), HcalCondObjectContainer< Item >::getAllChannels(), HcalLutMetadatum::getLutGranularity(), getOutputLUTId(), HcalLutMetadatum::getOutputLutThreshold(), HcalCondObjectContainer< Item >::getValues(), hcaluncomp_, i, cmsHarvester::index, HcalGenericDetId::isHcalDetId(), HcalGenericDetId::isHcalTrigTowerDetId(), dqm-mbProfile::log, lsb_factor_, min(), nct_factor_, nominal_gain_, OUTPUT_LUT_SIZE, outputLUT_, rct_factor_, size, mathSSE::sqrt(), theTopology, dtDQMClient_cfg::threshold, HcalTrigTowerGeometry::towerEtaBounds(), TPGMAX, HcalTopology::validHT(), relativeConstraints::value, and relval_steps::version.

Referenced by setup().

34  {
35  // Initialize analytical compression LUT's here
36  if (OUTPUT_LUT_SIZE != (unsigned int) 0x400)
37  edm::LogError("CaloTPGTranscoderULUT") << "Analytic compression expects 10-bit LUT; found LUT with " << OUTPUT_LUT_SIZE << " entries instead";
38 
39  if (!theTopology) {
40  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
41  }
42 
43  std::array<unsigned int, OUTPUT_LUT_SIZE> analyticalLUT;
44  std::array<unsigned int, OUTPUT_LUT_SIZE> linearRctLUT;
45  std::array<unsigned int, OUTPUT_LUT_SIZE> linearNctLUT;
46 
47  // Compute compression LUT
48  for (unsigned int i=0; i < OUTPUT_LUT_SIZE; i++) {
49  analyticalLUT[i] = (unsigned int)(sqrt(14.94*log(1.+i/14.94)*i) + 0.5);
50  linearRctLUT[i] = min((unsigned int)(i/rct_factor_), TPGMAX - 1);
51  linearNctLUT[i] = min((unsigned int)(i/nct_factor_), TPGMAX - 1);
52  }
53 
54  std::vector<DetId> allChannels = lutMetadata.getAllChannels();
55 
56  for(std::vector<DetId>::iterator i=allChannels.begin(); i!=allChannels.end(); ++i){
57 
58  if (not HcalGenericDetId(*i).isHcalTrigTowerDetId()) {
59  if (not HcalGenericDetId(*i).isHcalDetId())
60  edm::LogWarning("CaloTPGTranscoderULUT") << "Encountered invalid HcalDetId " << HcalGenericDetId(*i);
61  continue;
62  }
63 
64  HcalTrigTowerDetId id(*i);
65  if(!theTopology->validHT(id)) continue;
66 
67 
68  unsigned int index = getOutputLUTId(id);
69 
70  if(index >= size){
71  size=index+1;
72  outputLUT_.resize(size);
73  hcaluncomp_.resize(size);
74  }
75 
76  const HcalLutMetadatum *meta = lutMetadata.getValues(id);
77  unsigned int threshold = meta->getOutputLutThreshold();
78 
79  int ieta=id.ieta();
80  int version=id.version();
81  bool isHBHE = (abs(ieta) < theTrigTowerGeometry.firstHFTower(version));
82 
83  for (unsigned int i = 0; i < threshold; ++i) outputLUT_[index].push_back(0);
84  for (unsigned int i = threshold; i < OUTPUT_LUT_SIZE; ++i){
85  LUT value = isHBHE ? analyticalLUT[i] :
86  (version==0?linearRctLUT[i]:linearNctLUT[i]);
87  outputLUT_[index].push_back(value);
88  }
89 
90  //now uncompression LUTs
91  hcaluncomp_[index].resize(TPGMAX);
92 
93  double eta_low = 0., eta_high = 0.;
94  theTrigTowerGeometry.towerEtaBounds(ieta,version,eta_low,eta_high);
95  double cosh_ieta = fabs(cosh((eta_low + eta_high)/2.));
96  double granularity = meta->getLutGranularity();
97 
98  if(isHBHE){
99  double factor = nominal_gain_ / cosh_ieta * granularity;
100  LUT tpg = outputLUT_[index][0];
101  int low = 0;
102  for (unsigned int i = 0; i < OUTPUT_LUT_SIZE; ++i){
103  if (outputLUT_[index][i] != tpg){
104  unsigned int mid = (low + i)/2;
105  hcaluncomp_[index][tpg] = (tpg == 0 ? low : factor * mid);
106  low = i;
107  tpg = outputLUT_[index][i];
108  }
109  }
110  hcaluncomp_[index][tpg] = factor * low;
111  }
112  else{
113  LUT tpg = outputLUT_[index][0];
114  hcaluncomp_[index][tpg]=0;
115  for (unsigned int i = 0; i < OUTPUT_LUT_SIZE; ++i){
116  if (outputLUT_[index][i] != tpg){
117  tpg = outputLUT_[index][i];
118  hcaluncomp_[index][tpg] = lsb_factor_ * i / (version==0?rct_factor_:nct_factor_);
119  }
120  }
121  }
122  }
123 }
int i
Definition: DBlmapReader.cc:9
std::vector< RCTdecompression > hcaluncomp_
std::vector< std::vector< LUT > > outputLUT_
uint8_t getOutputLutThreshold() const
uint8_t getLutGranularity() const
bool isHcalTrigTowerDetId() const
const HcalTopology * theTopology
T sqrt(T t)
Definition: SSEVec.h:18
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const unsigned int OUTPUT_LUT_SIZE
T min(T a, T b)
Definition: MathUtil.h:58
bool isHcalDetId() const
static const unsigned int TPGMAX
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:32
bool validHT(const HcalTrigTowerDetId &id) const
void CaloTPGTranscoderULUT::rctEGammaUncompress ( const HcalTrigTowerDetId hid,
const HcalTriggerPrimitiveSample hc,
const EcalTrigTowerDetId eid,
const EcalTriggerPrimitiveSample ec,
unsigned int &  et,
bool &  egVeto,
bool &  activity 
) const
virtual

Uncompression for the Electron/Photon path in the RCT.

Implements CaloTPGTranscoder.

Definition at line 164 of file CaloTPGTranscoderULUT.cc.

References Exception.

166  {
167  throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::rctEGammaUncompress";
168 }
void CaloTPGTranscoderULUT::rctJetUncompress ( const HcalTrigTowerDetId hid,
const HcalTriggerPrimitiveSample hc,
const EcalTrigTowerDetId eid,
const EcalTriggerPrimitiveSample ec,
unsigned int &  et 
) const
virtual

Uncompression for the JET path in the RCT.

Implements CaloTPGTranscoder.

Definition at line 169 of file CaloTPGTranscoderULUT.cc.

References Exception.

171  {
172  throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::rctJetUncompress";
173 }
void CaloTPGTranscoderULUT::setup ( HcalLutMetadata const &  lutMetadata,
HcalTrigTowerGeometry const &  theTrigTowerGeometry,
int  nctScaleShift,
int  rctScaleShift 
)
virtual

Definition at line 205 of file CaloTPGTranscoderULUT.cc.

References compressionFile_, decompressionFile_, Exception, HcalLutMetadata::getNominalGain(), HcalLutMetadata::getRctLsb(), loadHCALCompress(), HcaluLUTTPGCoder::lsb_, lsb_factor_, nct_factor_, nominal_gain_, rct_factor_, theTopology, and HcalCondObjectContainerBase::topo().

206 {
207  theTopology = lutMetadata.topo();
208  nominal_gain_ = lutMetadata.getNominalGain();
209  lsb_factor_ = lutMetadata.getRctLsb();
210 
211  rct_factor_ = lsb_factor_/(HcaluLUTTPGCoder::lsb_*(1<<rctScaleShift));
212  nct_factor_ = lsb_factor_/(HcaluLUTTPGCoder::lsb_*(1<<nctScaleShift));
213 
214  if (compressionFile_.empty() && decompressionFile_.empty()) {
215  loadHCALCompress(lutMetadata,theTrigTowerGeometry);
216  }
217  else {
218  throw cms::Exception("Not Implemented") << "setup of CaloTPGTranscoderULUT from text files";
219  }
220 }
static const float lsb_
const HcalTopology * theTopology
void loadHCALCompress(HcalLutMetadata const &, HcalTrigTowerGeometry const &)

Member Data Documentation

std::string CaloTPGTranscoderULUT::compressionFile_
private

Definition at line 60 of file CaloTPGTranscoderULUT.h.

Referenced by setup().

std::string CaloTPGTranscoderULUT::decompressionFile_
private

Definition at line 61 of file CaloTPGTranscoderULUT.h.

Referenced by setup().

std::vector<RCTdecompression> CaloTPGTranscoderULUT::hcaluncomp_
private

Definition at line 69 of file CaloTPGTranscoderULUT.h.

Referenced by hcaletValue(), and loadHCALCompress().

std::vector<int> CaloTPGTranscoderULUT::ietah
private

Definition at line 63 of file CaloTPGTranscoderULUT.h.

std::vector<int> CaloTPGTranscoderULUT::ietal
private

Definition at line 62 of file CaloTPGTranscoderULUT.h.

double CaloTPGTranscoderULUT::lsb_factor_
private

Definition at line 57 of file CaloTPGTranscoderULUT.h.

Referenced by loadHCALCompress(), and setup().

std::vector<int> CaloTPGTranscoderULUT::LUTfactor
private

Definition at line 65 of file CaloTPGTranscoderULUT.h.

double CaloTPGTranscoderULUT::nct_factor_
private

Definition at line 59 of file CaloTPGTranscoderULUT.h.

Referenced by loadHCALCompress(), and setup().

const bool CaloTPGTranscoderULUT::newHFphi = true
staticprivate

Definition at line 50 of file CaloTPGTranscoderULUT.h.

double CaloTPGTranscoderULUT::nominal_gain_
private

Definition at line 56 of file CaloTPGTranscoderULUT.h.

Referenced by loadHCALCompress(), and setup().

const int CaloTPGTranscoderULUT::NOUTLUTS = 4176
staticprivate

Definition at line 47 of file CaloTPGTranscoderULUT.h.

const unsigned int CaloTPGTranscoderULUT::OUTPUT_LUT_SIZE = 1024
staticprivate

Definition at line 48 of file CaloTPGTranscoderULUT.h.

Referenced by hcalCompress(), and loadHCALCompress().

std::vector<std::vector<LUT> > CaloTPGTranscoderULUT::outputLUT_
private
double CaloTPGTranscoderULUT::rct_factor_
private

Definition at line 58 of file CaloTPGTranscoderULUT.h.

Referenced by loadHCALCompress(), and setup().

unsigned int CaloTPGTranscoderULUT::size
private
const HcalTopology* CaloTPGTranscoderULUT::theTopology
private

Definition at line 45 of file CaloTPGTranscoderULUT.h.

Referenced by getOutputLUTId(), HTvalid(), loadHCALCompress(), and setup().

const unsigned int CaloTPGTranscoderULUT::TPGMAX = 256
staticprivate

Definition at line 49 of file CaloTPGTranscoderULUT.h.

Referenced by hcaletValue(), and loadHCALCompress().

std::vector<int> CaloTPGTranscoderULUT::ZS
private

Definition at line 64 of file CaloTPGTranscoderULUT.h.