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_t ()=default
 
 tower_t (ap_uint< 12 > et, ap_uint< 4 > hoe)
 

Public Attributes

ap_uint< 16 > data = 0
 

Detailed Description

Definition at line 668 of file Phase2L1CaloEGammaUtils.h.

Constructor & Destructor Documentation

◆ tower_t() [1/2]

p2eg::tower_t::tower_t ( )
default

◆ tower_t() [2/2]

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

Definition at line 673 of file Phase2L1CaloEGammaUtils.h.

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

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

Member Function Documentation

◆ applyCalibration()

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

Definition at line 683 of file Phase2L1CaloEGammaUtils.h.

References data, and getEt().

Referenced by Phase2L1CaloEGammaEmulator::produce().

683  {
684  // Get the new pT as a float
685  float newEt = getEt() * factor;
686 
687  // Convert the new pT to an unsigned int (16 bits so we can take the logical OR with the bit mask later)
688  ap_uint<16> newEt_uint = (ap_uint<16>)(int)(newEt * 8.0);
689  // Make sure the first four bits are zero
690  newEt_uint = (newEt_uint & 0x0FFF);
691 
692  // Modify 'data'
693  ap_uint<16> bitMask = 0xF000; // last twelve digits are zero
694  data = (data & bitMask); // zero out the last twelve digits
695  data = (data | newEt_uint); // write in the new ET
696  }

◆ et()

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

Definition at line 675 of file Phase2L1CaloEGammaUtils.h.

References data.

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

675 { return (data & 0xFFF); }

◆ getEt()

float p2eg::tower_t::getEt ( )
inline

Definition at line 678 of file Phase2L1CaloEGammaUtils.h.

References p2eg::ECAL_LSB, and et().

Referenced by applyCalibration().

678 { 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 700 of file Phase2L1CaloEGammaUtils.h.

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

Referenced by Phase2L1CaloEGammaEmulator::produce().

700  {
701  // Convert HCAL ET to ECAL ET convention
702  ap_uint<12> HCAL = convertHcalETtoEcalET(HCAL_inHcalConvention);
703  ap_uint<4> hoeOut;
704  ap_uint<1> hoeLSB = 0;
705  ap_uint<4> hoe = 0;
706  ap_uint<12> A;
707  ap_uint<12> B;
708 
709  A = (ECAL > HCAL) ? ECAL : HCAL;
710  B = (ECAL > HCAL) ? HCAL : ECAL;
711 
712  if (ECAL == 0 || HCAL == 0 || HCAL >= ECAL)
713  hoeLSB = 0;
714  else
715  hoeLSB = 1;
716  if (A > B) {
717  if (A > 2 * B)
718  hoe = 0x1;
719  if (A > 4 * B)
720  hoe = 0x2;
721  if (A > 8 * B)
722  hoe = 0x3;
723  if (A > 16 * B)
724  hoe = 0x4;
725  if (A > 32 * B)
726  hoe = 0x5;
727  if (A > 64 * B)
728  hoe = 0x6;
729  if (A > 128 * B)
730  hoe = 0x7;
731  }
732  hoeOut = hoeLSB | (hoe << 1);
733  ap_uint<16> hoeOutLong =
734  ((((ap_uint<16>)hoeOut) << 12) | 0x0000); // e.g. 0b ____ 0000 0000 0000 where ___ are the hoe digits
735  // Take the logical OR to preserve the saturation and tower ET bits
736  ap_uint<16> bitMask = 0x0FFF; // 0000 1111 1111 1111 : zero-out the HoE bits
737  data = (data & bitMask); // zero-out the HoE bits
738  data = (data | hoeOutLong); // write in the new HoE bits
739  }
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 676 of file Phase2L1CaloEGammaUtils.h.

References data.

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

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

◆ operator uint16_t()

p2eg::tower_t::operator uint16_t ( )
inline

Definition at line 680 of file Phase2L1CaloEGammaUtils.h.

References data.

680 { return (uint16_t)data; }

Member Data Documentation

◆ data

ap_uint<16> p2eg::tower_t::data = 0