File indexing completed on 2024-04-06 11:57:33
0001 #ifndef CALOTPGTRANSCODERULUT_H
0002 #define CALOTPGTRANSCODERULUT_H 1
0003
0004 #include <memory>
0005 #include <vector>
0006 #include <set>
0007 #include "CalibFormats/CaloTPG/interface/CaloTPGTranscoder.h"
0008 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0009 #include "CondFormats/HcalObjects/interface/HcalLutMetadata.h"
0010
0011
0012
0013
0014
0015
0016 class HcalTrigTowerGeometry;
0017
0018 class CaloTPGTranscoderULUT : public CaloTPGTranscoder {
0019 public:
0020 CaloTPGTranscoderULUT(const std::string& compressionFile = "", const std::string& decompressionFile = "");
0021 ~CaloTPGTranscoderULUT() override;
0022 HcalTriggerPrimitiveSample hcalCompress(const HcalTrigTowerDetId& id,
0023 unsigned int sample,
0024 int fineGrain) const override;
0025 EcalTriggerPrimitiveSample ecalCompress(const EcalTrigTowerDetId& id,
0026 unsigned int sample,
0027 bool fineGrain) const override;
0028
0029 void rctEGammaUncompress(const HcalTrigTowerDetId& hid,
0030 const HcalTriggerPrimitiveSample& hc,
0031 const EcalTrigTowerDetId& eid,
0032 const EcalTriggerPrimitiveSample& ec,
0033 unsigned int& et,
0034 bool& egVecto,
0035 bool& activity) const override;
0036 void rctJetUncompress(const HcalTrigTowerDetId& hid,
0037 const HcalTriggerPrimitiveSample& hc,
0038 const EcalTrigTowerDetId& eid,
0039 const EcalTriggerPrimitiveSample& ec,
0040 unsigned int& et) const override;
0041 double hcaletValue(const int& ieta, const int& iphi, const int& version, const int& compressedValue) const override;
0042 double hcaletValue(const HcalTrigTowerDetId& hid, const HcalTriggerPrimitiveSample& hc) const override;
0043 virtual bool HTvalid(const int ieta, const int iphi, const int version) const;
0044 virtual const std::vector<unsigned int> getCompressionLUT(const HcalTrigTowerDetId& id) const;
0045 virtual void setup(HcalLutMetadata const&,
0046 HcalTrigTowerGeometry const&,
0047 int nctScaleShift,
0048 int rctScaleShift,
0049 double lsbQIE8,
0050 double lsbQIE11,
0051 bool allLinear);
0052 virtual int getOutputLUTId(const HcalTrigTowerDetId& id) const;
0053 virtual int getOutputLUTId(const int ieta, const int iphi, const int version) const;
0054
0055 private:
0056
0057 static const int NOUTLUTS = 4176;
0058
0059
0060 static const unsigned int REDUCE10BIT = 1024;
0061 static const unsigned int REDUCE11BIT = 2048;
0062
0063
0064 static const unsigned int QIE8_OUTPUT_LUT_SIZE = REDUCE10BIT;
0065 static const unsigned int QIE10_OUTPUT_LUT_SIZE = REDUCE11BIT;
0066 static const unsigned int QIE11_OUTPUT_LUT_SIZE = REDUCE11BIT;
0067 static const unsigned int OUTPUT_LUT_SIZE =
0068 std::max({QIE8_OUTPUT_LUT_SIZE, QIE10_OUTPUT_LUT_SIZE, QIE11_OUTPUT_LUT_SIZE});
0069 static const unsigned int TPGMAX = 256;
0070
0071
0072 typedef uint8_t LUT;
0073 typedef std::array<float, TPGMAX> RCTdecompression;
0074
0075 const HcalTopology* theTopology;
0076 static const bool newHFphi = true;
0077
0078
0079 unsigned int getOutputLUTSize(const HcalTrigTowerDetId& id) const;
0080 bool isOnlyQIE11(const HcalTrigTowerDetId& id) const;
0081 void loadHCALCompress(HcalLutMetadata const&, HcalTrigTowerGeometry const&);
0082
0083
0084 bool allLinear_ = false;
0085 double nominal_gain_;
0086 double lsb_factor_;
0087 double rct_factor_;
0088 double nct_factor_;
0089 double lin8_factor_;
0090 double lin11_factor_;
0091 const std::string compressionFile_;
0092 const std::string decompressionFile_;
0093 std::vector<int> ietal;
0094 std::vector<int> ietah;
0095 std::vector<int> ZS;
0096 std::vector<int> LUTfactor;
0097
0098 std::vector<std::vector<LUT>> outputLUT_;
0099 std::vector<RCTdecompression> hcaluncomp_;
0100
0101 std::set<HcalDetId> plan1_towers_;
0102 };
0103 #endif