Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:10

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   static const float zdc_lsb_;
0036 
0037   HcaluLUTTPGCoder();
0038   HcaluLUTTPGCoder(const HcalTopology* topo, const HcalTimeSlew* delay);
0039   ~HcaluLUTTPGCoder() override;
0040 
0041   void init(const HcalTopology* top, 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   // typedef
0098   typedef unsigned short LutElement;
0099   typedef std::vector<LutElement> Lut;
0100 
0101   // constants
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   // member variables
0113   const HcalTopology* topo_;
0114   const HcalTimeSlew* delay_;
0115   bool LUTGenerationMode_;
0116   std::vector<uint32_t> FG_HF_thresholds_;
0117   int bitToMask_;
0118   int firstHBEta_, lastHBEta_, nHBEta_, maxDepthHB_, sizeHB_;
0119   int firstHEEta_, lastHEEta_, nHEEta_, maxDepthHE_, sizeHE_;
0120   int firstHFEta_, lastHFEta_, nHFEta_, maxDepthHF_, sizeHF_;
0121   int sizeZDC_;
0122   std::vector<Lut> inputLUT_;
0123   std::vector<float> gain_;
0124   std::vector<float> ped_;
0125   std::vector<double> cosh_ieta_;
0126   // edge cases not covered by the cosh_ieta_ map
0127   double cosh_ieta_28_HE_low_depths_, cosh_ieta_28_HE_high_depths_, cosh_ieta_29_HE_;
0128   bool allLinear_;
0129   bool contain1TSHB_, contain1TSHE_;
0130   double containPhaseNSHB_ = 6.0;
0131   double containPhaseNSHE_ = 6.0;
0132   bool applyFixPCC_;
0133   double linearLSB_QIE8_, linearLSB_QIE11_, linearLSB_QIE11Overlap_;
0134   std::unique_ptr<HcalPulseContainmentManager> pulseCorr_;
0135   bool overrideDBweightsAndFilterHB_ = false;
0136   bool overrideDBweightsAndFilterHE_ = false;
0137 };
0138 
0139 #endif