Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:45:15

0001 /****************************************************************************
0002 *
0003 * This is a part of the TOTEM offline software.
0004 * Authors:
0005 *   Edoardo Bossini
0006 *   Laurent Forthomme
0007 *
0008 ****************************************************************************/
0009 
0010 #ifndef EventFilter_CTPPSRawToDigi_TotemT2VFATFrame
0011 #define EventFilter_CTPPSRawToDigi_TotemT2VFATFrame
0012 
0013 #include "EventFilter/CTPPSRawToDigi/interface/VFATFrame.h"
0014 
0015 #include <cstdint>
0016 
0017 /**
0018  * Utilitary namespace to retrieve timing/status information from nT2 VFAT frame
0019 **/
0020 namespace totem::nt2::vfat {
0021   /// multiplicity of 32-bit words combined into a single channel payload
0022   static constexpr size_t num_words_per_channel = 4;
0023   /// multiplicity of channels combined into a single payload
0024   static constexpr size_t num_channels_per_payload = 2;
0025   static constexpr size_t header_offset = 3;
0026   /// get timing information for single leading edge
0027   inline uint16_t leadingEdgeTime(const VFATFrame& frame, size_t ch_id) {
0028     return frame.getData()[header_offset + 2 + num_words_per_channel * ch_id] & 0xffff;
0029   }
0030   /// get timing information for single trailing edge
0031   inline uint16_t trailingEdgeTime(const VFATFrame& frame, size_t ch_id) {
0032     return frame.getData()[header_offset + 3 + num_words_per_channel * ch_id] & 0xffff;
0033   }
0034   /// retrieve this channel marker
0035   inline uint8_t channelMarker(const VFATFrame& frame, size_t ch_id) {
0036     return frame.getData()[header_offset + 1 + num_words_per_channel * ch_id] & 0x1f;
0037   }
0038 
0039   /// retrieve the header status flags
0040   inline uint8_t statusMarker(const VFATFrame& frame) { return (frame.getData()[header_offset - 1] >> 8) & 0xf; }
0041 
0042   /// retrieve the HW identifier for this channel, in firmware >2.1
0043   inline uint16_t newChannelId(const VFATFrame& frame, size_t ch_id) {
0044     return frame.getData()[header_offset + 0 + num_words_per_channel * ch_id] & 0xffff;
0045   }
0046 }  // namespace totem::nt2::vfat
0047 
0048 #endif