Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:46

0001 #ifndef L1GCTINTERNETSUM_H
0002 #define L1GCTINTERNETSUM_H
0003 
0004 #include <ostream>
0005 #include <string>
0006 #include <cstdint>
0007 
0008 /// \class L1GctInternEtSum
0009 /// \brief L1 GCT internal energy sum
0010 /// \author Jim Brooke
0011 /// \date June 2008
0012 ///
0013 
0014 class L1GctInternEtSum {
0015 public:
0016   /// et sum type - not clear this is required
0017   enum L1GctInternEtSumType {
0018     null,
0019     jet_tot_et,      // from jet_tot_et_and_ht in leaf output
0020     jet_tot_ht,      // from jet_tot_et_and_ht in leaf output
0021     jet_miss_et,     // leaf output
0022     total_et_or_ht,  // conc input, wheel input and output
0023     miss_etx_or_ety  // conc input, wheel input and output
0024   };
0025 
0026   enum numberOfBits {
0027     kTotEtOrHtNBits = 12,
0028     kJetMissEtNBits = 17,
0029     kMissExOrEyNBits = 20,
0030     kTotEtOrHtOFlowBit = 1 << kTotEtOrHtNBits,
0031     kJetMissEtOFlowBit = 1 << kJetMissEtNBits,
0032     kMissExOrEyOFlowBit = 1 << kMissExOrEyNBits,
0033     kTotEtOrHtMaxValue = kTotEtOrHtOFlowBit - 1,
0034     kJetMissEtMaxValue = kJetMissEtOFlowBit - 1,
0035     kMissExOrEyMaxValue = kMissExOrEyOFlowBit - 1,
0036     kTotEtOrHtRawCtorMask = kTotEtOrHtOFlowBit | kTotEtOrHtMaxValue,
0037     kJetMissEtRawCtorMask = kJetMissEtOFlowBit | kJetMissEtMaxValue,
0038     kMissExOrEyRawCtorMask = kMissExOrEyOFlowBit | kMissExOrEyMaxValue
0039   };
0040 
0041   /// default constructor (for vector initialisation etc.)
0042   L1GctInternEtSum();
0043 
0044   /// construct from individual quantities
0045   L1GctInternEtSum(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t et, uint8_t oflow);
0046 
0047   /// destructor
0048   ~L1GctInternEtSum();
0049 
0050   // named ctors
0051   static L1GctInternEtSum fromJetTotEt(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t data);
0052 
0053   static L1GctInternEtSum fromJetTotHt(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t data);
0054 
0055   static L1GctInternEtSum fromJetMissEt(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t data);
0056 
0057   static L1GctInternEtSum fromTotalEtOrHt(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t data);
0058 
0059   static L1GctInternEtSum fromMissEtxOrEty(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t data);
0060 
0061   static L1GctInternEtSum fromEmulatorJetTotEt(unsigned totEt, bool overFlow, int16_t bx);
0062 
0063   static L1GctInternEtSum fromEmulatorJetTotHt(unsigned totHt, bool overFlow, int16_t bx);
0064 
0065   static L1GctInternEtSum fromEmulatorJetMissEt(int missEtxOrEty, bool overFlow, int16_t bx);
0066 
0067   static L1GctInternEtSum fromEmulatorTotalEtOrHt(unsigned totEtOrHt, bool overFlow, int16_t bx);
0068 
0069   static L1GctInternEtSum fromEmulatorMissEtxOrEty(int missEtxOrEty, bool overFlow, int16_t bx);
0070 
0071   /// metadata
0072 
0073   /// 'type' of object - not required?
0074   L1GctInternEtSum::L1GctInternEtSumType type() const { return type_; }
0075 
0076   /// get capture block
0077   uint16_t capBlock() const { return capBlock_; }
0078 
0079   /// get index within capture block
0080   uint16_t capIndex() const { return capIndex_; }
0081 
0082   /// get BX number
0083   int16_t bx() const { return bx_; }
0084 
0085   /// is the sum non-zero
0086   bool empty() const { return (data_ == 0); }
0087 
0088   /// get the actual bits
0089 
0090   /// get the raw data
0091   uint32_t raw() const { return data_; }
0092 
0093   /// get value
0094   uint32_t value() const { return data_ & 0x7fffffff; }
0095 
0096   /// get et
0097   uint32_t et() const { return value(); }
0098 
0099   /// get count
0100   uint32_t count() const { return value(); }
0101 
0102   /// get oflow
0103   uint8_t oflow() const { return (data_ >> 31) & 0x1; }
0104 
0105   // setters
0106 
0107   /// set cap block
0108   void setCapBlock(uint16_t capBlock) { capBlock_ = capBlock; }
0109 
0110   /// set cap index
0111   void setCapIndex(uint16_t capIndex) { capIndex_ = capIndex; }
0112 
0113   /// set bx
0114   void setBx(uint16_t bx) { bx_ = bx; }
0115 
0116   /// set type
0117   void setType(L1GctInternEtSumType type) { type_ = type; }
0118 
0119   /// set value
0120   void setValue(uint32_t val);
0121 
0122   /// set Et sum
0123   void setEt(uint32_t et);
0124 
0125   /// set count
0126   void setCount(uint32_t count);
0127 
0128   /// set overflow bit
0129   void setOflow(uint8_t oflow);
0130 
0131   /// operators
0132 
0133   /// equality operator
0134   bool operator==(const L1GctInternEtSum& c) const;
0135 
0136   /// inequality operator
0137   bool operator!=(const L1GctInternEtSum& c) const { return !(*this == c); }
0138 
0139 private:
0140   // type of data
0141   L1GctInternEtSumType type_;
0142 
0143   // source of the data
0144   uint16_t capBlock_;
0145   uint16_t capIndex_;
0146   int16_t bx_;
0147 
0148   // the captured data
0149   uint32_t data_;
0150 };
0151 
0152 std::ostream& operator<<(std::ostream& s, const L1GctInternEtSum& c);
0153 
0154 #endif