Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-13 23:02:51

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 
0010 #include <bitset>
0011 #include <vector>
0012 
0013 class HcalDbService;
0014 
0015 /** \class HcaluLUTTPGCoder
0016   *  
0017   * The nominal coder uses a user-supplied table to linearize the ADC values.
0018   *
0019   * <pre>
0020   * [number of ieta slices]
0021   * [low tower 1] [low tower 2] ...
0022   * [high tower 1] [ high tower 2] ...
0023   * [LUT 1(0)] [LUT 2(0)] ...
0024   * [LUT 1(1)] [LUT 2(1)] ...
0025   * . . .
0026   * [LUT 1(127)] [LUT 2(127)] ...
0027   * </pre>
0028   *
0029   * \author M. Weinberger -- TAMU
0030   * \author Tulika Bose and Greg Landsberg -- Brown
0031   */
0032 class HcaluLUTTPGCoder : public HcalTPGCoder {
0033 public:
0034   static const float lsb_;
0035 
0036   HcaluLUTTPGCoder();
0037   HcaluLUTTPGCoder(const HcalTopology* topo, const HcalTimeSlew* delay);
0038   ~HcaluLUTTPGCoder() override;
0039 
0040   void init(const HcalTopology* top, const HcalTimeSlew* delay);
0041 
0042   void adc2Linear(const HBHEDataFrame& df, IntegerCaloSamples& ics) const override;
0043   void adc2Linear(const HFDataFrame& df, IntegerCaloSamples& ics) const override;
0044   void adc2Linear(const QIE10DataFrame& df, IntegerCaloSamples& ics) const override;
0045   void adc2Linear(const QIE11DataFrame& df, IntegerCaloSamples& ics) const override;
0046   std::vector<unsigned short> group0FGbits(const QIE11DataFrame& df) const;
0047   void compress(const IntegerCaloSamples& ics,
0048                 const std::vector<bool>& featureBits,
0049                 HcalTriggerPrimitiveDigi& tp) const override;
0050   unsigned short adc2Linear(HcalQIESample sample, HcalDetId id) const override;
0051   float getLUTPedestal(HcalDetId id) const override;
0052   float getLUTGain(HcalDetId id) const override;
0053   std::vector<unsigned short> getLinearizationLUT(HcalDetId id) const override;
0054 
0055   double cosh_ieta(int ieta, int depth, HcalSubdetector subdet);
0056   void make_cosh_ieta_map(void);
0057   void update(const HcalDbService& conditions);
0058   void update(const char* filename, bool appendMSB = false);
0059   void updateXML(const char* filename);
0060   void setLUTGenerationMode(bool gen) { LUTGenerationMode_ = gen; };
0061   void setFGHFthresholds(const std::vector<uint32_t>& fgthresholds) { FG_HF_thresholds_ = fgthresholds; };
0062   void setMaskBit(int bit) { bitToMask_ = bit; };
0063   void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap) {
0064     allLinear_ = linear;
0065     linearLSB_QIE8_ = lsb8;
0066     linearLSB_QIE11_ = lsb11;
0067     linearLSB_QIE11Overlap_ = lsb11overlap;
0068   };
0069   void set1TSContainHB(bool contain1TSHB) { contain1TSHB_ = contain1TSHB; }
0070   void set1TSContainHE(bool contain1TSHE) { contain1TSHE_ = contain1TSHE; }
0071   void setContainPhaseHB(double containPhaseNSHB) { containPhaseNSHB_ = containPhaseNSHB; }
0072   void setContainPhaseHE(double containPhaseNSHE) { containPhaseNSHE_ = containPhaseNSHE; }
0073   void setApplyFixPCC(double applyFixPCC) { applyFixPCC_ = applyFixPCC; }
0074   void setOverrideDBweightsAndFilterHB(bool overrideDBweightsAndFilterHB) {
0075     overrideDBweightsAndFilterHB_ = overrideDBweightsAndFilterHB;
0076   }
0077   void setOverrideDBweightsAndFilterHE(bool overrideDBweightsAndFilterHE) {
0078     overrideDBweightsAndFilterHE_ = overrideDBweightsAndFilterHE;
0079   }
0080   void lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const;
0081   void lookupMSB(const QIE10DataFrame& df, std::vector<std::bitset<2>>& msb) const;
0082   void lookupMSB(const QIE11DataFrame& df, std::vector<std::bitset<2>>& msb) const;
0083   bool getMSB(const HcalDetId& id, int adc) const;
0084   int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const;
0085   int getLUTId(uint32_t rawid) const;
0086   int getLUTId(const HcalDetId& detid) const;
0087 
0088   static const int QIE8_LUT_BITMASK = 0x3FF;
0089   static const int QIE10_LUT_BITMASK = 0x7FF;
0090   static const int QIE11_LUT_BITMASK = 0x3FF;
0091 
0092 private:
0093   // typedef
0094   typedef unsigned short LutElement;
0095   typedef std::vector<LutElement> Lut;
0096 
0097   // constants
0098   static const size_t INPUT_LUT_SIZE = 128;
0099   static const size_t UPGRADE_LUT_SIZE = 256;
0100   static const int nFi_ = 72;
0101 
0102   static const int QIE8_LUT_MSB = 0x400;
0103   static const int QIE11_LUT_MSB0 = 0x400;
0104   static const int QIE11_LUT_MSB1 = 0x800;
0105   static const int QIE10_LUT_MSB0 = 0x1000;
0106   static const int QIE10_LUT_MSB1 = 0x2000;
0107 
0108   // member variables
0109   const HcalTopology* topo_;
0110   const HcalTimeSlew* delay_;
0111   bool LUTGenerationMode_;
0112   std::vector<uint32_t> FG_HF_thresholds_;
0113   int bitToMask_;
0114   int firstHBEta_, lastHBEta_, nHBEta_, maxDepthHB_, sizeHB_;
0115   int firstHEEta_, lastHEEta_, nHEEta_, maxDepthHE_, sizeHE_;
0116   int firstHFEta_, lastHFEta_, nHFEta_, maxDepthHF_, sizeHF_;
0117   std::vector<Lut> inputLUT_;
0118   std::vector<float> gain_;
0119   std::vector<float> ped_;
0120   std::vector<double> cosh_ieta_;
0121   // edge cases not covered by the cosh_ieta_ map
0122   double cosh_ieta_28_HE_low_depths_, cosh_ieta_28_HE_high_depths_, cosh_ieta_29_HE_;
0123   bool allLinear_;
0124   bool contain1TSHB_, contain1TSHE_;
0125   double containPhaseNSHB_ = 6.0;
0126   double containPhaseNSHE_ = 6.0;
0127   bool applyFixPCC_;
0128   double linearLSB_QIE8_, linearLSB_QIE11_, linearLSB_QIE11Overlap_;
0129   std::unique_ptr<HcalPulseContainmentManager> pulseCorr_;
0130   bool overrideDBweightsAndFilterHB_ = false;
0131   bool overrideDBweightsAndFilterHE_ = false;
0132 };
0133 
0134 #endif