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
 
virtual HcalTriggerPrimitiveSample hcalCompress (const HcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const
 Compression from linear samples+fine grain in the HTR. More...
 
virtual double hcaletValue (const int &ieta, const int &compressedValue) const
 
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 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 &)
 
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
 
std::vector< int > LUTfactor
 
double nominal_gain_
 
std::vector< std::vector< LUT > > outputLUT_
 
double rctlsb_factor_
 
const HcalTopologytheTopology
 
std::vector< int > ZS
 

Static Private Attributes

static float LSB_HBHE = 0.25f
 
static float LSB_HF = 0.5f
 
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 43 of file CaloTPGTranscoderULUT.h.

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

Definition at line 44 of file CaloTPGTranscoderULUT.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file CaloTPGTranscoderULUT.cc.

References outputLUT_.

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

Definition at line 31 of file CaloTPGTranscoderULUT.cc.

31  {
32 }

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 167 of file CaloTPGTranscoderULUT.cc.

References Exception.

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

Definition at line 205 of file CaloTPGTranscoderULUT.cc.

References getOutputLUTId(), and outputLUT_.

Referenced by HcalLutManager::getCompressionLutXmlFromCoder().

205  {
206  int itower = getOutputLUTId(id);
207  return outputLUT_[itower];
208 }
std::vector< std::vector< LUT > > outputLUT_
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
int CaloTPGTranscoderULUT::getOutputLUTId ( const HcalTrigTowerDetId id) const
virtual

Definition at line 190 of file CaloTPGTranscoderULUT.cc.

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

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

190  {
191  if (!theTopology) {
192  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
193  }
194  return theTopology->detId2denseIdHT(id);
195 }
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
virtual

Definition at line 197 of file CaloTPGTranscoderULUT.cc.

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

197  {
198  if (!theTopology) {
199  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
200  }
201  HcalTrigTowerDetId id(ieta, iphiin);
202  return theTopology->detId2denseIdHT(id);
203 }
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,
bool  fineGrain 
) const
virtual

Compression from linear samples+fine grain in the HTR.

Implements CaloTPGTranscoder.

Definition at line 111 of file CaloTPGTranscoderULUT.cc.

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

111  {
112  int itower = getOutputLUTId(id);
113 
114  if (sample >= OUTPUT_LUT_SIZE) {
115  throw cms::Exception("Out of Range") << "LUT has 1024 entries for " << itower << " but " << sample << " was requested.";
116  sample=OUTPUT_LUT_SIZE - 1;
117  }
118 
119  return HcalTriggerPrimitiveSample(outputLUT_[itower][sample],fineGrain,0,0);
120 }
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 &  compressedValue 
) const
virtual

Implements CaloTPGTranscoder.

Definition at line 135 of file CaloTPGTranscoderULUT.cc.

References getOutputLUTId(), hcaluncomp_, HTvalid(), and TPGMAX.

135  {
136 // This is now an obsolete method; we return the AVERAGE over all the allowed iphi channels if it's invoked
137 // The user is encouraged to use hcaletValue(const int& ieta, const int& iphi, const int& compET) instead
138 
139  double etvalue = 0.;
140  if (compET < 0 || compET >= (int) TPGMAX) {
141  edm::LogError("CaloTPGTranscoderULUT") << "Compressed value out of range: eta, cET = " << ieta << ", " << compET;
142  } else {
143  int nphi = 0;
144  for (int iphi=1; iphi <= 72; iphi++) {
145  if (HTvalid(ieta,iphi)) {
146  nphi++;
147  int itower = getOutputLUTId(ieta,iphi);
148  etvalue += hcaluncomp_[itower][compET];
149  }
150  }
151  if (nphi > 0) {
152  etvalue /= nphi;
153  } else {
154  edm::LogError("CaloTPGTranscoderULUT") << "No decompression LUTs found for any iphi for ieta = " << ieta;
155  }
156  }
157  return(etvalue);
158 }
std::vector< RCTdecompression > hcaluncomp_
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
virtual bool HTvalid(const int ieta, const int iphi) const
static const unsigned int TPGMAX
double CaloTPGTranscoderULUT::hcaletValue ( const int &  ieta,
const int &  iphi,
const int &  compressedValue 
) const
virtual

Implements CaloTPGTranscoder.

Definition at line 122 of file CaloTPGTranscoderULUT.cc.

References getOutputLUTId(), hcaluncomp_, and TPGMAX.

122  {
123  double etvalue = 0.;
124  int itower = getOutputLUTId(ieta,iphi);
125  if (itower < 0) {
126  edm::LogError("CaloTPGTranscoderULUT") << "No decompression LUT found for ieta, iphi = " << ieta << ", " << iphi;
127  } else if (compET < 0 || compET >= (int) TPGMAX) {
128  edm::LogError("CaloTPGTranscoderULUT") << "Compressed value out of range: eta, phi, cET = " << ieta << ", " << iphi << ", " << compET;
129  } else {
130  etvalue = hcaluncomp_[itower][compET];
131  }
132  return(etvalue);
133 }
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 160 of file CaloTPGTranscoderULUT.cc.

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

160  {
161  int compET = hc.compressedEt(); // to be within the range by the class
162  int itower = getOutputLUTId(hid);
163  double etvalue = hcaluncomp_[itower][compET];
164  return etvalue;
165 }
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
virtual

Definition at line 182 of file CaloTPGTranscoderULUT.cc.

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

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

182  {
183  HcalTrigTowerDetId id(ieta, iphiin);
184  if (!theTopology) {
185  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
186  }
187  return theTopology->validHT(id);
188 }
const HcalTopology * theTopology
bool validHT(const HcalTrigTowerDetId &id) const
void CaloTPGTranscoderULUT::loadHCALCompress ( HcalLutMetadata const &  lutMetadata,
HcalTrigTowerGeometry const &  theTrigTowerGeometry 
)
private

Definition at line 34 of file CaloTPGTranscoderULUT.cc.

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

Referenced by setup().

35  {
36  // Initialize analytical compression LUT's here
37  if (OUTPUT_LUT_SIZE != (unsigned int) 0x400)
38  edm::LogError("CaloTPGTranscoderULUT") << "Analytic compression expects 10-bit LUT; found LUT with " << OUTPUT_LUT_SIZE << " entries instead";
39 
40  if (!theTopology) {
41  throw cms::Exception("CaloTPGTranscoderULUT") << "Topology not set! Use CaloTPGTranscoderULUT::setup(...) first!";
42  }
43 
44  std::array<unsigned int, OUTPUT_LUT_SIZE> analyticalLUT;
45  std::array<unsigned int, OUTPUT_LUT_SIZE> identityLUT;
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  identityLUT[i] = min(i, TPGMAX - 1);
51  }
52 
53  std::vector<DetId> allChannels = lutMetadata.getAllChannels();
54 
55  for(std::vector<DetId>::iterator i=allChannels.begin(); i!=allChannels.end(); ++i){
56 
57  if (not HcalGenericDetId(*i).isHcalTrigTowerDetId()) {
58  if (not HcalGenericDetId(*i).isHcalDetId())
59  edm::LogWarning("CaloTPGTranscoderULUT") << "Encountered invalid HcalDetId " << HcalGenericDetId(*i);
60  continue;
61  }
62 
63  HcalTrigTowerDetId id(*i);
64  if(!theTopology->validHT(id)) continue;
65 
66 
67  unsigned int index = getOutputLUTId(id);
68 
69  if(index >= outputLUT_.size()){
70  outputLUT_.resize(index+1);
71  hcaluncomp_.resize(index+1);
72  }
73 
74  const HcalLutMetadatum *meta = lutMetadata.getValues(id);
75  unsigned int threshold = meta->getOutputLutThreshold();
76 
77  int ieta=id.ieta();
78  int version=id.version();
79  bool isHBHE = (abs(ieta) < theTrigTowerGeometry.firstHFTower(version));
80 
81  for (unsigned int i = 0; i < threshold; ++i) outputLUT_[index].push_back(0);
82  for (unsigned int i = threshold; i < OUTPUT_LUT_SIZE; ++i){
83  LUT value = isHBHE ? analyticalLUT[i] : identityLUT[i];
84  outputLUT_[index].push_back(value);
85  }
86 
87  //now uncompression LUTs
88  hcaluncomp_[index].resize(TPGMAX);
89 
90  double eta_low = 0., eta_high = 0.;
91  theTrigTowerGeometry.towerEtaBounds(ieta,version,eta_low,eta_high);
92  double cosh_ieta = fabs(cosh((eta_low + eta_high)/2.));
93  double granularity = meta->getLutGranularity();
94 
95  double factor = isHBHE ? (nominal_gain_ / cosh_ieta * granularity) : rctlsb_factor_;
96 
97  LUT tpg = outputLUT_[index][0];
98  int low = 0;
99  for (unsigned int i = 0; i < OUTPUT_LUT_SIZE; ++i){
100  if (outputLUT_[index][i] != tpg){
101  unsigned int mid = (low + i)/2;
102  hcaluncomp_[index][tpg] = (tpg == 0 ? low : factor * mid);
103  low = i;
104  tpg = outputLUT_[index][i];
105  }
106  }
107  hcaluncomp_[index][tpg] = factor * low;
108  }
109 }
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 171 of file CaloTPGTranscoderULUT.cc.

References Exception.

173  {
174  throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::rctEGammaUncompress";
175 }
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 176 of file CaloTPGTranscoderULUT.cc.

References Exception.

178  {
179  throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::rctJetUncompress";
180 }
void CaloTPGTranscoderULUT::setup ( HcalLutMetadata const &  lutMetadata,
HcalTrigTowerGeometry const &  theTrigTowerGeometry 
)
virtual

Definition at line 210 of file CaloTPGTranscoderULUT.cc.

References compressionFile_, decompressionFile_, Exception, HcalLutMetadata::getNominalGain(), HcalLutMetadata::getRctLsb(), loadHCALCompress(), LSB_HBHE, LSB_HF, nominal_gain_, rctlsb_factor_, theTopology, and HcalCondObjectContainerBase::topo().

211 {
212  theTopology = lutMetadata.topo();
213  nominal_gain_ = lutMetadata.getNominalGain();
214  float rctlsb =lutMetadata.getRctLsb();
215  if (rctlsb != LSB_HBHE && rctlsb != LSB_HF)
216  throw cms::Exception("RCTLSB") << " value=" << rctlsb << " (should be " << LSB_HBHE
217  << " or " << LSB_HF << ")" << std::endl;
218  rctlsb_factor_ = rctlsb;
219 
220  if (compressionFile_.empty() && decompressionFile_.empty()) {
221  loadHCALCompress(lutMetadata,theTrigTowerGeometry);
222  }
223  else {
224  throw cms::Exception("Not Implemented") << "setup of CaloTPGTranscoderULUT from text files";
225  }
226 }
const HcalTopology * theTopology
void loadHCALCompress(HcalLutMetadata const &, HcalTrigTowerGeometry const &)

Member Data Documentation

std::string CaloTPGTranscoderULUT::compressionFile_
private

Definition at line 62 of file CaloTPGTranscoderULUT.h.

Referenced by setup().

std::string CaloTPGTranscoderULUT::decompressionFile_
private

Definition at line 63 of file CaloTPGTranscoderULUT.h.

Referenced by setup().

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

Definition at line 70 of file CaloTPGTranscoderULUT.h.

Referenced by hcaletValue(), and loadHCALCompress().

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

Definition at line 65 of file CaloTPGTranscoderULUT.h.

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

Definition at line 64 of file CaloTPGTranscoderULUT.h.

float CaloTPGTranscoderULUT::LSB_HBHE = 0.25f
staticprivate

Definition at line 53 of file CaloTPGTranscoderULUT.h.

Referenced by setup().

float CaloTPGTranscoderULUT::LSB_HF = 0.5f
staticprivate

Definition at line 54 of file CaloTPGTranscoderULUT.h.

Referenced by setup().

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

Definition at line 67 of file CaloTPGTranscoderULUT.h.

const bool CaloTPGTranscoderULUT::newHFphi = true
staticprivate

Definition at line 51 of file CaloTPGTranscoderULUT.h.

double CaloTPGTranscoderULUT::nominal_gain_
private

Definition at line 60 of file CaloTPGTranscoderULUT.h.

Referenced by loadHCALCompress(), and setup().

const int CaloTPGTranscoderULUT::NOUTLUTS = 4176
staticprivate

Definition at line 48 of file CaloTPGTranscoderULUT.h.

const unsigned int CaloTPGTranscoderULUT::OUTPUT_LUT_SIZE = 1024
staticprivate

Definition at line 49 of file CaloTPGTranscoderULUT.h.

Referenced by hcalCompress(), and loadHCALCompress().

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

Definition at line 61 of file CaloTPGTranscoderULUT.h.

Referenced by loadHCALCompress(), and setup().

const HcalTopology* CaloTPGTranscoderULUT::theTopology
private

Definition at line 46 of file CaloTPGTranscoderULUT.h.

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

const unsigned int CaloTPGTranscoderULUT::TPGMAX = 256
staticprivate

Definition at line 50 of file CaloTPGTranscoderULUT.h.

Referenced by hcaletValue(), and loadHCALCompress().

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

Definition at line 66 of file CaloTPGTranscoderULUT.h.