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 629 of file Phase2L1CaloEGammaUtils.h.

Constructor & Destructor Documentation

◆ tower_t() [1/2]

p2eg::tower_t::tower_t ( )
inline

Definition at line 633 of file Phase2L1CaloEGammaUtils.h.

References data.

633 { data = 0; }

◆ tower_t() [2/2]

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

Definition at line 635 of file Phase2L1CaloEGammaUtils.h.

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

635 { 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 662 of file Phase2L1CaloEGammaUtils.h.

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

Referenced by Phase2L1CaloEGammaEmulator::produce().

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

◆ applyCalibration()

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

Definition at line 645 of file Phase2L1CaloEGammaUtils.h.

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

Referenced by Phase2L1CaloEGammaEmulator::produce().

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

◆ et()

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

Definition at line 637 of file Phase2L1CaloEGammaUtils.h.

References data.

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

637 { return (data & 0xFFF); }

◆ getEt()

float p2eg::tower_t::getEt ( )
inline

Definition at line 640 of file Phase2L1CaloEGammaUtils.h.

References p2eg::ECAL_LSB, and et().

Referenced by applyCalibration().

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

◆ hoe()

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

Definition at line 638 of file Phase2L1CaloEGammaUtils.h.

References data.

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

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

◆ operator uint16_t()

p2eg::tower_t::operator uint16_t ( )
inline

Definition at line 642 of file Phase2L1CaloEGammaUtils.h.

References data.

642 { return (uint16_t)data; }

Member Data Documentation

◆ data

ap_uint<16> p2eg::tower_t::data