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 addHoverEToTower (ap_uint< 12 > ECAL, ap_uint< 12 > HCAL)
 
void applyCalibration (float factor)
 
ap_uint< 12 > et ()
 
float getEt ()
 
ap_uint< 4 > hoe ()
 
 operator uint16_t ()
 
 tower_t ()
 
 tower_t (ap_uint< 12 > et, ap_uint< 4 > hoe)
 

Public Attributes

ap_uint< 16 > data
 

Detailed Description

Definition at line 634 of file Phase2L1CaloEGammaUtils.h.

Constructor & Destructor Documentation

◆ tower_t() [1/2]

p2eg::tower_t::tower_t ( )
inline

Definition at line 638 of file Phase2L1CaloEGammaUtils.h.

References data.

638 { data = 0; }

◆ tower_t() [2/2]

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

Definition at line 640 of file Phase2L1CaloEGammaUtils.h.

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

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

Member Function Documentation

◆ addHoverEToTower()

void p2eg::tower_t::addHoverEToTower ( ap_uint< 12 >  ECAL,
ap_uint< 12 >  HCAL 
)
inline

Definition at line 667 of file Phase2L1CaloEGammaUtils.h.

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

Referenced by Phase2L1CaloEGammaEmulator::produce().

667  {
668  ap_uint<4> hoeOut;
669  ap_uint<1> hoeLSB = 0;
670  ap_uint<4> hoe = 0;
671  ap_uint<12> A;
672  ap_uint<12> B;
673 
674  A = (ECAL > HCAL) ? ECAL : HCAL;
675  B = (ECAL > HCAL) ? HCAL : ECAL;
676 
677  if (ECAL == 0 || HCAL == 0 || HCAL >= ECAL)
678  hoeLSB = 0;
679  else
680  hoeLSB = 1;
681  if (A > B) {
682  if (A > 2 * B)
683  hoe = 0x1;
684  if (A > 4 * B)
685  hoe = 0x2;
686  if (A > 8 * B)
687  hoe = 0x3;
688  if (A > 16 * B)
689  hoe = 0x4;
690  if (A > 32 * B)
691  hoe = 0x5;
692  if (A > 64 * B)
693  hoe = 0x6;
694  if (A > 128 * B)
695  hoe = 0x7;
696  }
697  hoeOut = hoeLSB | (hoe << 1);
698  ap_uint<16> hoeOutLong =
699  ((((ap_uint<16>)hoeOut) << 12) | 0x0000); // e.g. 0b ____ 0000 0000 0000 where ___ are the hoe digits
700  // Take the logical OR to preserve the saturation and tower ET bits
701  ap_uint<16> bitMask = 0x0FFF; // 0000 1111 1111 1111 : zero-out the HoE bits
702  data = (data & bitMask); // zero-out the HoE bits
703  data = (data | hoeOutLong); // write in the new HoE bits
704  }
Definition: APVGainStruct.h:7
Definition: HCAL.py:1
Definition: APVGainStruct.h:7

◆ applyCalibration()

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

Definition at line 650 of file Phase2L1CaloEGammaUtils.h.

References data, p2eg::ECAL_LSB, and getEt().

Referenced by Phase2L1CaloEGammaEmulator::produce().

650  {
651  // Get the new pT as a float
652  float newEt = getEt() * factor;
653 
654  // Convert the new pT to an unsigned int (16 bits so we can take the logical OR with the bit mask later)
655  ap_uint<16> newEt_uint = (ap_uint<16>)(int)(newEt / ECAL_LSB);
656  // Make sure the first four bits are zero
657  newEt_uint = (newEt_uint & 0x0FFF);
658 
659  // Modify 'data'
660  ap_uint<16> bitMask = 0xF000; // last twelve digits are zero
661  data = (data & bitMask); // zero out the last twelve digits
662  data = (data | newEt_uint); // write in the new ET
663  }
static constexpr float ECAL_LSB

◆ et()

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

Definition at line 642 of file Phase2L1CaloEGammaUtils.h.

References data.

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

642 { return (data & 0xFFF); }

◆ getEt()

float p2eg::tower_t::getEt ( )
inline

Definition at line 645 of file Phase2L1CaloEGammaUtils.h.

References p2eg::ECAL_LSB, and et().

Referenced by applyCalibration().

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

◆ hoe()

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

Definition at line 643 of file Phase2L1CaloEGammaUtils.h.

References data.

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

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

◆ operator uint16_t()

p2eg::tower_t::operator uint16_t ( )
inline

Definition at line 647 of file Phase2L1CaloEGammaUtils.h.

References data.

647 { return (uint16_t)data; }

Member Data Documentation

◆ data

ap_uint<16> p2eg::tower_t::data