CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
p2eg::tower_t Class Reference

#include <Phase2L1CaloEGammaUtils.h>

Public Member Functions

void applyCalibration (float factor)
 
ap_uint< 12 > et ()
 
float getEt ()
 
void getHoverE (ap_uint< 12 > ECAL, ap_uint< 12 > HCAL_inHcalConvention)
 
ap_uint< 4 > hoe ()
 
 operator uint16_t ()
 
tower_toperator= (const tower_t &rhs)
 
 tower_t ()
 
 tower_t (ap_uint< 12 > et, ap_uint< 4 > hoe)
 

Public Attributes

ap_uint< 16 > data
 

Detailed Description

Definition at line 687 of file Phase2L1CaloEGammaUtils.h.

Constructor & Destructor Documentation

◆ tower_t() [1/2]

p2eg::tower_t::tower_t ( )
inline

Definition at line 691 of file Phase2L1CaloEGammaUtils.h.

References data.

691 { data = 0; }

◆ tower_t() [2/2]

p2eg::tower_t::tower_t ( ap_uint< 12 >  et,
ap_uint< 4 >  hoe 
)
inline

Definition at line 697 of file Phase2L1CaloEGammaUtils.h.

References data, et(), and hoe().

697 { data = (et) | (((ap_uint<16>)hoe) << 12); }

Member Function Documentation

◆ applyCalibration()

void p2eg::tower_t::applyCalibration ( float  factor)
inline

Definition at line 707 of file Phase2L1CaloEGammaUtils.h.

References data, and getEt().

Referenced by Phase2L1CaloEGammaEmulator::produce().

707  {
708  // Get the new pT as a float
709  float newEt = getEt() * factor;
710 
711  // Convert the new pT to an unsigned int (16 bits so we can take the logical OR with the bit mask later)
712  ap_uint<16> newEt_uint = (ap_uint<16>)(int)(newEt * 8.0);
713  // Make sure the first four bits are zero
714  newEt_uint = (newEt_uint & 0x0FFF);
715 
716  // Modify 'data'
717  ap_uint<16> bitMask = 0xF000; // last twelve digits are zero
718  data = (data & bitMask); // zero out the last twelve digits
719  data = (data | newEt_uint); // write in the new ET
720  }

◆ et()

ap_uint<12> p2eg::tower_t::et ( )
inline

Definition at line 699 of file Phase2L1CaloEGammaUtils.h.

References data.

Referenced by getEt(), Phase2L1CaloEGammaEmulator::produce(), and tower_t().

699 { return (data & 0xFFF); }

◆ getEt()

float p2eg::tower_t::getEt ( )
inline

Definition at line 702 of file Phase2L1CaloEGammaUtils.h.

References p2eg::ECAL_LSB, and et().

Referenced by applyCalibration().

702 { return (float)et() * ECAL_LSB; }
static constexpr float ECAL_LSB

◆ getHoverE()

void p2eg::tower_t::getHoverE ( ap_uint< 12 >  ECAL,
ap_uint< 12 >  HCAL_inHcalConvention 
)
inline

Definition at line 724 of file Phase2L1CaloEGammaUtils.h.

References A, B, p2eg::convertHcalETtoEcalET(), data, ECAL, HCAL, and hoe().

Referenced by Phase2L1CaloEGammaEmulator::produce().

724  {
725  // Convert HCAL ET to ECAL ET convention
726  ap_uint<12> HCAL = convertHcalETtoEcalET(HCAL_inHcalConvention);
727  ap_uint<4> hoeOut;
728  ap_uint<1> hoeLSB = 0;
729  ap_uint<4> hoe = 0;
730  ap_uint<12> A;
731  ap_uint<12> B;
732 
733  A = (ECAL > HCAL) ? ECAL : HCAL;
734  B = (ECAL > HCAL) ? HCAL : ECAL;
735 
736  if (ECAL == 0 || HCAL == 0 || HCAL >= ECAL)
737  hoeLSB = 0;
738  else
739  hoeLSB = 1;
740  if (A > B) {
741  if (A > 2 * B)
742  hoe = 0x1;
743  if (A > 4 * B)
744  hoe = 0x2;
745  if (A > 8 * B)
746  hoe = 0x3;
747  if (A > 16 * B)
748  hoe = 0x4;
749  if (A > 32 * B)
750  hoe = 0x5;
751  if (A > 64 * B)
752  hoe = 0x6;
753  if (A > 128 * B)
754  hoe = 0x7;
755  }
756  hoeOut = hoeLSB | (hoe << 1);
757  ap_uint<16> hoeOutLong =
758  ((((ap_uint<16>)hoeOut) << 12) | 0x0000); // e.g. 0b ____ 0000 0000 0000 where ___ are the hoe digits
759  // Take the logical OR to preserve the saturation and tower ET bits
760  ap_uint<16> bitMask = 0x0FFF; // 0000 1111 1111 1111 : zero-out the HoE bits
761  data = (data & bitMask); // zero-out the HoE bits
762  data = (data | hoeOutLong); // write in the new HoE bits
763  }
Definition: APVGainStruct.h:7
Definition: HCAL.py:1
Definition: APVGainStruct.h:7
ap_uint< 12 > convertHcalETtoEcalET(ap_uint< 12 > HCAL)

◆ hoe()

ap_uint<4> p2eg::tower_t::hoe ( )
inline

Definition at line 700 of file Phase2L1CaloEGammaUtils.h.

References data.

Referenced by getHoverE(), Phase2L1CaloEGammaEmulator::produce(), and tower_t().

700 { return ((data >> 12) & 0xF); }

◆ operator uint16_t()

p2eg::tower_t::operator uint16_t ( )
inline

Definition at line 704 of file Phase2L1CaloEGammaUtils.h.

References data.

704 { return (uint16_t)data; }

◆ operator=()

tower_t& p2eg::tower_t::operator= ( const tower_t rhs)
inline

Definition at line 692 of file Phase2L1CaloEGammaUtils.h.

References data.

692  {
693  data = rhs.data;
694  return *this;
695  }

Member Data Documentation

◆ data

ap_uint<16> p2eg::tower_t::data