File indexing completed on 2024-11-27 03:17:25
0001 #ifndef CALIBCALORIMETRY_HCALTPGALGOS_HCALNOMINALTPGCODER_H
0002 #define CALIBCALORIMETRY_HCALTPGALGOS_HCALNOMINALTPGCODER_H 1
0003
0004 #include "CalibFormats/HcalObjects/interface/HcalTPGCoder.h"
0005 #include "CalibFormats/HcalObjects/interface/HcalNominalCoder.h"
0006 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0007 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0008 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseContainmentManager.h"
0009 #include "CondFormats/HcalObjects/interface/HcalElectronicsMap.h"
0010
0011 #include <bitset>
0012 #include <vector>
0013
0014 class HcalDbService;
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class HcaluLUTTPGCoder : public HcalTPGCoder {
0034 public:
0035 static const float lsb_;
0036
0037 HcaluLUTTPGCoder();
0038 HcaluLUTTPGCoder(const HcalTopology* topo, const HcalElectronicsMap* emap, const HcalTimeSlew* delay);
0039 ~HcaluLUTTPGCoder() override;
0040
0041 void init(const HcalTopology* top, const HcalElectronicsMap* emap, const HcalTimeSlew* delay);
0042
0043 void adc2Linear(const HBHEDataFrame& df, IntegerCaloSamples& ics) const override;
0044 void adc2Linear(const HFDataFrame& df, IntegerCaloSamples& ics) const override;
0045 void adc2Linear(const QIE10DataFrame& df, IntegerCaloSamples& ics, bool ootpu_lut) const override;
0046 void adc2Linear(const QIE11DataFrame& df, IntegerCaloSamples& ics) const override;
0047 std::vector<unsigned short> group0FGbits(const QIE11DataFrame& df) const;
0048 void compress(const IntegerCaloSamples& ics,
0049 const std::vector<bool>& featureBits,
0050 HcalTriggerPrimitiveDigi& tp) const override;
0051 unsigned short adc2Linear(HcalQIESample sample, HcalDetId id) const override;
0052 float getLUTPedestal(HcalDetId id) const override;
0053 float getLUTGain(HcalDetId id) const override;
0054 std::vector<unsigned short> getLinearizationLUT(HcalDetId id) const override;
0055 std::vector<unsigned short> getLinearizationLUT(HcalZDCDetId id, bool ootpu_lut) const override;
0056
0057 double cosh_ieta(int ieta, int depth, HcalSubdetector subdet);
0058 void make_cosh_ieta_map(void);
0059 void update(const HcalDbService& conditions);
0060 void update(const char* filename, bool appendMSB = false);
0061 void updateXML(const char* filename);
0062 void setLUTGenerationMode(bool gen) { LUTGenerationMode_ = gen; };
0063 void setFGHFthresholds(const std::vector<uint32_t>& fgthresholds) { FG_HF_thresholds_ = fgthresholds; };
0064 void setMaskBit(int bit) { bitToMask_ = bit; };
0065 void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap) {
0066 allLinear_ = linear;
0067 linearLSB_QIE8_ = lsb8;
0068 linearLSB_QIE11_ = lsb11;
0069 linearLSB_QIE11Overlap_ = lsb11overlap;
0070 };
0071 void set1TSContainHB(bool contain1TSHB) { contain1TSHB_ = contain1TSHB; }
0072 void set1TSContainHE(bool contain1TSHE) { contain1TSHE_ = contain1TSHE; }
0073 void setContainPhaseHB(double containPhaseNSHB) { containPhaseNSHB_ = containPhaseNSHB; }
0074 void setContainPhaseHE(double containPhaseNSHE) { containPhaseNSHE_ = containPhaseNSHE; }
0075 void setApplyFixPCC(double applyFixPCC) { applyFixPCC_ = applyFixPCC; }
0076 void setOverrideDBweightsAndFilterHB(bool overrideDBweightsAndFilterHB) {
0077 overrideDBweightsAndFilterHB_ = overrideDBweightsAndFilterHB;
0078 }
0079 void setOverrideDBweightsAndFilterHE(bool overrideDBweightsAndFilterHE) {
0080 overrideDBweightsAndFilterHE_ = overrideDBweightsAndFilterHE;
0081 }
0082 void lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const;
0083 void lookupMSB(const QIE10DataFrame& df, std::vector<std::bitset<2>>& msb) const;
0084 void lookupMSB(const QIE11DataFrame& df, std::vector<std::bitset<2>>& msb) const;
0085 bool getMSB(const HcalDetId& id, int adc) const;
0086 int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const;
0087 int getLUTId(uint32_t rawid) const;
0088 int getLUTId(const HcalDetId& detid) const;
0089 int getLUTId(const HcalZDCDetId& detid) const;
0090
0091 static const int QIE8_LUT_BITMASK = 0x3FF;
0092 static const int QIE10_LUT_BITMASK = 0x7FF;
0093 static const int QIE11_LUT_BITMASK = 0x3FF;
0094 static const int QIE10_ZDC_LUT_BITMASK = 0x3FF;
0095
0096 private:
0097
0098 typedef unsigned short LutElement;
0099 typedef std::vector<LutElement> Lut;
0100
0101
0102 static const size_t INPUT_LUT_SIZE = 128;
0103 static const size_t UPGRADE_LUT_SIZE = 256;
0104 static const int nFi_ = 72;
0105
0106 static const int QIE8_LUT_MSB = 0x400;
0107 static const int QIE11_LUT_MSB0 = 0x400;
0108 static const int QIE11_LUT_MSB1 = 0x800;
0109 static const int QIE10_LUT_MSB0 = 0x1000;
0110 static const int QIE10_LUT_MSB1 = 0x2000;
0111
0112
0113 const HcalTopology* topo_;
0114 const HcalElectronicsMap* emap_;
0115 const HcalTimeSlew* delay_;
0116 bool LUTGenerationMode_;
0117 std::vector<uint32_t> FG_HF_thresholds_;
0118 int bitToMask_;
0119 int firstHBEta_, lastHBEta_, nHBEta_, maxDepthHB_, sizeHB_;
0120 int firstHEEta_, lastHEEta_, nHEEta_, maxDepthHE_, sizeHE_;
0121 int firstHFEta_, lastHFEta_, nHFEta_, maxDepthHF_, sizeHF_;
0122 int sizeZDC_;
0123 std::vector<Lut> inputLUT_;
0124 std::vector<float> gain_;
0125 std::vector<float> ped_;
0126 std::vector<double> cosh_ieta_;
0127
0128 double cosh_ieta_28_HE_low_depths_, cosh_ieta_28_HE_high_depths_, cosh_ieta_29_HE_;
0129 bool allLinear_;
0130 bool contain1TSHB_, contain1TSHE_;
0131 double containPhaseNSHB_ = 6.0;
0132 double containPhaseNSHE_ = 6.0;
0133 bool applyFixPCC_;
0134 double linearLSB_QIE8_, linearLSB_QIE11_, linearLSB_QIE11Overlap_;
0135 std::unique_ptr<HcalPulseContainmentManager> pulseCorr_;
0136 bool overrideDBweightsAndFilterHB_ = false;
0137 bool overrideDBweightsAndFilterHE_ = false;
0138 };
0139
0140 #endif