Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:45

0001 // Tell emacs that this is a C++ source
0002 // This file is really -*- C++ -*-.
0003 
0004 #ifndef MICROMEGAS_MICROMEGASDEFS_H
0005 #define MICROMEGAS_MICROMEGASDEFS_H
0006 
0007 /*!
0008  * \file MicromegasDefs.h
0009  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0010  */
0011 
0012 #include <trackbase/TrkrDefs.h>
0013 
0014 #include <array>
0015 #include <cstdint>
0016 
0017 namespace MicromegasDefs
0018 {
0019 
0020   //! tells the direction along which a given cylinder is segmented
0021   enum class SegmentationType: uint8_t
0022   {
0023     SEGMENTATION_Z,
0024     SEGMENTATION_PHI
0025   };
0026 
0027   //! tells the drift direction for a given micromegas layer
0028   /*! this is needed for properly implementing transverse diffusion in the layer */
0029   enum class DriftDirection: uint8_t
0030   {
0031     INWARD,
0032     OUTWARD
0033   };
0034 
0035   /*!
0036    * @brief Generate a hitsetkey for the micromegas
0037    * @param[in] layer Layer index
0038    * @param[in] tile tile index
0039    * @param[out] hitsetkey
0040    *
0041    * Generate a hitsetkey for the mvtx. The tracker id is known
0042    * implicitly and used in the function.
0043    */
0044   TrkrDefs::hitsetkey genHitSetKey(uint8_t layer, SegmentationType segmentation, uint8_t tile );
0045 
0046   /*!
0047    * @brief Get the segmentation type from hitsetkey
0048    * @param[in] hitsetkey
0049    * @param[out] segmentation
0050    s*/
0051   SegmentationType getSegmentationType(TrkrDefs::hitsetkey);
0052 
0053   /*!
0054    * @brief Get the tile id from hitsetkey
0055    * @param[in] hitsetkey
0056    * @param[out] tile id
0057    s*/
0058   uint8_t getTileId(TrkrDefs::hitsetkey);
0059 
0060   /*!
0061    * @brief Generate a hitkey from strip index inside tile
0062    * @param[in] strip strip index
0063    */
0064   TrkrDefs::hitkey genHitKey(uint16_t strip );
0065 
0066   //! get strip from hit key
0067   uint16_t getStrip(TrkrDefs::hitkey);
0068 
0069   /*!
0070    * @brief Get the segmentation type from cluster key
0071    * @param[in] cluskey
0072    * @param[out] segmentation
0073    s*/
0074   SegmentationType getSegmentationType(TrkrDefs::cluskey);
0075 
0076   /*!
0077    * @brief Get the tile id from cluster key
0078    * @param[in] cluskey
0079    * @param[out] tile id
0080    s*/
0081   uint8_t getTileId(TrkrDefs::cluskey);
0082 
0083   //! number of TPOT tiles
0084   static constexpr int m_ntiles = 8;
0085 
0086   //! TPOT packet ids
0087   /**
0088    * note: TPOT only uses 2 packets.
0089    * For early runs (before 07/28/2023) they are 5000 and 5001
0090    * For later run, (after 07/28/2023) and because, as instructed by Martin, they are 5001 and 5002
0091    * We keep all 3 values here in order to be able to read both type of runs
0092    * One might need to change this in the future when 5000 becomes used by a different subsystem
0093    */
0094   static constexpr int m_npackets = 3;
0095   static constexpr int m_npackets_active = 2;
0096   static constexpr std::array<unsigned int,m_npackets> m_packet_ids = {5000, 5001, 5002};
0097 
0098   //! number of channels per fee board
0099   static constexpr int m_nchannels_fee = 256;
0100 
0101   //! number of sampa chips per fee board
0102   static constexpr int m_nsampa_fee = 8;
0103 
0104   //! number of fee boards
0105   static constexpr int m_nfee = 16;
0106 
0107   //! total number of channels
0108   static constexpr int m_nchannels_total = m_nfee*m_nchannels_fee;
0109 
0110   //! maximum valid ADC
0111   static constexpr uint16_t m_adc_max = 1024;
0112 
0113   //! mark invalid ADC values
0114   static constexpr uint16_t m_adc_invalid = 65000;
0115 
0116   /* see: https://git.racf.bnl.gov/gitea/Instrumentation/sampa_data/src/branch/fmtv2/README.md */
0117   // TODO: should move to online_distribution
0118   enum SampaDataType
0119   {
0120     HEARTBEAT_T = 0b000,
0121     TRUNCATED_DATA_T = 0b001,
0122     TRUNCATED_TRIG_EARLY_DATA_T = 0b011,
0123     NORMAL_DATA_T = 0b100,
0124     LARGE_DATA_T = 0b101,
0125     TRIG_EARLY_DATA_T = 0b110,
0126     TRIG_EARLY_LARGE_DATA_T = 0b111,
0127   };
0128 
0129 }
0130 
0131 #endif