CMS-HGCAL / cmssw

CMS Offline Software
http://cms-sw.github.io/
Apache License 2.0
3 stars 2 forks source link

Bug fix: TcTp > 1 for TOT #80

Closed IzaakWN closed 11 months ago

IzaakWN commented 11 months ago

As discussed yesterday in the CMG HGCal Chat with @asteencern, @adavidzh, @pfs: TcTp has a 2-bit value, and TOT should be used for TcTp > 1.

From p. 33 in the HGCROC3 spec working document:

Tc and Tp Interpretation:

  • 0b00 : The TOT is not in operation (not busy), normal behaviour with ADC data (TOT filled with 0)
  • 0b01 : The TOT is busy (integration or undershoot), Tp highlights the fact that provided ADC correspond to saturation (during integration) or undershoot (TOT filled with 0)
  • 0b10 : should not appear => we only output value when TOT is busy
  • 0b11 : The TOT value is output, normal behaviour with TOT data (ADC value is between saturation and undershoot)

While this PR is open, @hqucms, do you know if the compiler should already optimize this? (See https://en.wikipedia.org/wiki/Constant_folding):

       return tctp>1 ? energy*(1<<12)*8000 : energy*gain/(1<<10)*80; // fC
        //                TOT / 2^12 * 8000 fC = TOT * 1.953125 fC
        // ( ADC - pedestal ) / 2^10 *   80 fC = ( ADC - pedestal ) * 0.078125 fC

Also for the record: @adavidzh proposed to look into branchless programming for optimizing cond ? branch1 : branch2.