Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DIGIHCAL_HOTRIGGERPRIMITIVEDIGI_H
0002 #define DIGIHCAL_HOTRIGGERPRIMITIVEDIGI_H
0003 
0004 #include <ostream>
0005 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0006 #include <cstdint>
0007 
0008 /** \class HOTriggerprimitiveDigi
0009  *  Simple container packer/unpacker for a single 
0010  *  Trigger Primitive from an HO HTR
0011  *
0012  *
0013  *  \author J. St. John - Boston U
0014  */
0015 class HOTriggerPrimitiveDigi {
0016 public:
0017   typedef HcalDetId key_type;  ///< For the sorted collection
0018 
0019   HOTriggerPrimitiveDigi() { theHO_TP = 0; }
0020   HOTriggerPrimitiveDigi(uint32_t data) { theHO_TP = data; }
0021   HOTriggerPrimitiveDigi(int ieta, int iphi, int nsamples, int whichSampleTriggered, int databits);
0022 
0023   const HcalDetId id() const { return HcalDetId(HcalOuter, ieta(), iphi(), 4); }
0024 
0025   /// get the raw (packed) Triger Primitive
0026   uint32_t raw() const { return theHO_TP; }
0027   /// get the raw ieta value
0028   int raw_ieta() const { return theHO_TP & 0x1F; }
0029   /// get the sign of ieta (int: +/- 1)
0030   int ieta_sign() const { return ((theHO_TP & 0x10) ? (-1) : (1)); }
0031   /// get the absolute value of ieta
0032   int ieta_abs() const { return (theHO_TP & 0x000F); }
0033   /// get the signed ieta value
0034   int ieta() const { return ieta_abs() * ieta_sign(); }
0035   /// get the iphi value
0036   int iphi() const { return (theHO_TP >> 5) & 0x007F; }
0037   /// get the number of samples used to compute the TP
0038   int nsamples() const { return (theHO_TP >> 12) & 0x000F; }
0039   /// get the number of the triggering sample
0040   int whichSampleTriggered() const { return (theHO_TP >> 16) & 0x000F; }
0041   /// get the single-bit data
0042   int bits() const { return (theHO_TP >> 20) & 0x03FF; }
0043 
0044   static const int HO_TP_SAMPLES_MAX = 10;
0045 
0046   /// get one bit from the single-bit data.
0047   /// required to be called with a legal value.
0048   bool data(int whichbit = HO_TP_SAMPLES_MAX) const;
0049 
0050   /// for streaming
0051   uint32_t operator()() { return theHO_TP; }
0052 
0053 private:
0054   uint32_t theHO_TP;
0055 };
0056 
0057 std::ostream& operator<<(std::ostream&, const HOTriggerPrimitiveDigi&);
0058 
0059 #endif