Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:19

0001 #ifndef DataFormats_HcalRecHit_HcalSpecialTimes_h_
0002 #define DataFormats_HcalRecHit_HcalSpecialTimes_h_
0003 
0004 // This is an excerpt from QIE10/QIE11 TDC specifications (by T. Zimmerman):
0005 //
0006 // Special codes: Special code 62 is generated when the discriminator
0007 // starts high. Special code 63 is generated when the TDC discriminator
0008 // starts low and remains low (nothing happened). Special code 58 indicates
0009 // "Invalid Code". This can be caused by an SEU in the TDC encoder logic.
0010 // It can also happen in certain situations when the TDC is operated in
0011 // "Last Mode", as discussed above. Code 59 is generated if the either
0012 // of the Delay Locked Loops on the QIE10 (the Phase DLL or the TDC DLL)
0013 // are not locked. Code 60 is generated when the Phase DLL is unlocked
0014 // (but the TDC DLL is locked), and code 61 for the TDC DLL unlocked
0015 // (but the Phase DLL is locked). If either of the DLLs on the chip are
0016 // unlocked, this takes precedence over any TDC data that might be present,
0017 // and the appropriate DLL no-lock condition is reported.
0018 //
0019 // (end of Zimmerman's special code explanation).
0020 //
0021 // In addition, during normal operation, codes above 49 are not supposed
0022 // to happen. If, due to jitter or something, the upcrossing would happen
0023 // at TDC=50, it would be reported as TDC=0 in the next BX.
0024 
0025 namespace HcalSpecialTimes {
0026   // Special value for the rise time used in case the QIE10/11 pulse
0027   // is always below the discriminator
0028   constexpr float UNKNOWN_T_UNDERSHOOT = -100.f;
0029 
0030   // "Invalid Code" TDC value
0031   constexpr float UNKNOWN_T_INVALID_CODE = -105.f;
0032 
0033   // Special value for the rise time used in case the QIE10/11 pulse
0034   // is always above the discriminator
0035   constexpr float UNKNOWN_T_OVERSHOOT = -110.f;
0036 
0037   // Any of the codes indicating DLL failures
0038   constexpr float UNKNOWN_T_DLL_FAILURE = -115.f;
0039 
0040   // Special value for the time to use in case the TDC info is
0041   // not available or not meaningful (e.g., for QIE8)
0042   constexpr float UNKNOWN_T_NOTDC = -120.f;
0043 
0044   // Special value which indicates a possible bug in the dataframe
0045   constexpr float UNKNOWN_T_INVALID_RANGE = -125.f;
0046 
0047   // Special value for invalid codes 50-57. I don't know the
0048   // exact explanation why they occur, but they do. Their origin
0049   // is likely to be just a bit-flip.
0050   constexpr float UNKNOWN_T_50TO57 = -130.f;
0051 
0052   // Check if the given time represents one of the special values
0053   constexpr inline bool isSpecial(const float t) { return t <= UNKNOWN_T_UNDERSHOOT; }
0054 
0055   constexpr float DEFAULT_ccTIME = -999.f;
0056 
0057   constexpr inline float getTDCTime(const int tdc) {
0058     constexpr float tdc_to_ns = 0.5f;
0059 
0060     constexpr int six_bits_mask = 0x3f;
0061     constexpr int tdc_code_largestnormal = 49;
0062     constexpr int tdc_code_invalid = 58;
0063     constexpr int tdc_code_overshoot = 62;
0064     constexpr int tdc_code_undershoot = 63;
0065 
0066     float t = tdc_to_ns * tdc;
0067     if (tdc > six_bits_mask || tdc < 0)
0068       t = UNKNOWN_T_INVALID_RANGE;
0069     else if (tdc > tdc_code_largestnormal) {
0070       // The undershoot code happens by far more often
0071       // than any other special code. So check for it first.
0072       if (tdc == tdc_code_undershoot)
0073         t = UNKNOWN_T_UNDERSHOOT;
0074       else if (tdc == tdc_code_overshoot)
0075         t = UNKNOWN_T_OVERSHOOT;
0076       else if (tdc == tdc_code_invalid)
0077         t = UNKNOWN_T_INVALID_CODE;
0078       else if (tdc < tdc_code_invalid)
0079         t = UNKNOWN_T_50TO57;
0080       else
0081         t = UNKNOWN_T_DLL_FAILURE;
0082     }
0083 
0084     return t;
0085   }
0086 }  // namespace HcalSpecialTimes
0087 
0088 #endif  // DataFormats_HcalRecHit_HcalSpecialTimes_h_