File indexing completed on 2025-08-05 08:15:10
0001 #ifndef __TpcTimeFrameBuilder_H__
0002 #define __TpcTimeFrameBuilder_H__
0003
0004 #include <algorithm>
0005 #include <cstdint>
0006 #include <deque>
0007 #include <functional>
0008 #include <iostream>
0009 #include <map>
0010 #include <string>
0011 #include <vector>
0012 #include <limits>
0013
0014 #include <fun4all/SubsysReco.h>
0015
0016 class Packet;
0017 class TTree;
0018 class TFile;
0019
0020 class TpcTimeFrameChecker: public SubsysReco
0021 {
0022 public:
0023 explicit TpcTimeFrameChecker(const int packet_id);
0024 virtual ~TpcTimeFrameChecker();
0025
0026
0027
0028
0029
0030
0031 int InitRun(PHCompositeNode *topNode) override;
0032
0033
0034
0035
0036 int process_event(PHCompositeNode *topNode) override;
0037
0038
0039 int End(PHCompositeNode *topNode) override;
0040
0041
0042
0043 std::string getDebugTTreeFile() const { return m_debugTTreeFile; }
0044 void setDebugTTreeFile(const std::string& debugTTree) { m_debugTTreeFile = debugTTree; }
0045
0046
0047 int ProcessPacket(Packet *);
0048
0049 void setVerbosity(const int i) { m_verbosity = i; }
0050
0051 protected:
0052
0053 std::string m_debugTTreeFile;
0054 TFile *m_file = nullptr;
0055 TTree *m_TaggerTree = nullptr;
0056
0057
0058 static const size_t DAM_DMA_WORD_BYTE_LENGTH = 16;
0059
0060 static const unsigned short MAGIC_KEY_0 = 0xfe;
0061
0062 static const unsigned short MAGIC_KEY_1 = 0xed;
0063 static const uint16_t FEE_MAGIC_KEY = 0xba00;
0064 static const uint16_t GTM_MAGIC_KEY = 0xbb00;
0065 static const uint16_t GTM_LVL1_ACCEPT_MAGIC_KEY = 0xbbf0;
0066 static const uint16_t GTM_ENDAT_MAGIC_KEY = 0xbbf1;
0067 static const unsigned short GTM_MODEBIT_MAGIC_KEY = 0xbbf2;
0068
0069 static const uint16_t MAX_FEECOUNT = 26;
0070 static const uint16_t MAX_CHANNELS = 8 * 32;
0071 static const uint16_t HEADER_LENGTH = 5;
0072
0073 int decode_gtm_data(uint16_t gtm[DAM_DMA_WORD_BYTE_LENGTH]);
0074
0075 struct gtm_payload {
0076 unsigned short pkt_type = 0;
0077 bool is_endat = false;
0078 bool is_lvl1 = false;
0079 bool is_modebit = false;
0080 unsigned long long bco = 0;
0081 unsigned int lvl1_count = 0;
0082 unsigned int endat_count = 0;
0083 unsigned long long last_bco = 0;
0084 unsigned char modebits = 0;
0085 unsigned char userbits = 0;
0086 };
0087 gtm_payload m_payload;
0088 int m_frame = 0;
0089
0090
0091 int m_verbosity = 0;
0092 int m_packet_id = 0;
0093
0094
0095 std::string m_HistoPrefix;
0096
0097 };
0098
0099 #endif