BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnProfRawTools.h
Go to the documentation of this file.
1/*
2 *
3 * Author: Yulia Topko
4 */
5#ifndef BMNPROFRAWTOOLS_H
6#define BMNPROFRAWTOOLS_H
7
8#include <bitset>
9#include <iostream>
10#include <map>
11#include <stdint.h>
12#include <vector>
13using namespace std;
14
16{
17 public:
18 constexpr static const size_t ChannelCnt() { return ASIC_channel; }
19
20 constexpr static const size_t ChannelDigitCnt() { return 6 * ASIC_channel; }
21 //-------------------------------
22 //------ functions
23 //-------------------------------
24 /*
25 Data format
26 | DATA (1)| holdb_cntr | adc_num| fco | hgfedcba ch|
27 | 31 | 30 : 18 | 17 | 16 | 15 : 0 |
28 OR
29 | #Trig(0)| AA - control word | trig_cntr_psd |
30 | #Trig(0)| AB - control word | trig_cntr_nsd |
31 | 31 | 30 : 23 | 22 : 0 |
32
33 Holdb counter width = 13 * 2 = 26;
34 Holdb for every adc.
35
36 trig_p counter width = 23; in adc1
37 trig_n counter width = 23; in adc2
38 */
39
40 static void endian_swap(uint32_t& x);
41 //---------------------
42 // Return value:
43 // true - data
44 // false - trigger
45 //---------------------
46 static bool data_or_trig(const uint32_t& word);
47
48 //---------------------
49 // Return value: holdb counter
50 // if data_or_trig() = true (data)
51 //---------------------
52 static uint32_t holdb_cntr(const uint32_t& word);
53
54 //---------------------
55 // Return value: self-trigger counter
56 // if data_or_trig() = false (trigger)
57 // bool function for P and N detector side
58 //---------------------
59 static bool trig_psd(const uint32_t& word);
60
61 static bool trig_nsd(const uint32_t& word);
62
63 static uint32_t trig_cntr(const uint32_t& word);
64
65 //---------------------
66 // Return value: number of ADC:
67 // 0 - 1st ADC; 1 - 2nd ADC
68 //---------------------
69 static bool adc_num(const bitset<32>& word);
70 static bool adc_num(const uint32_t& word);
71
72 //---------------------
73 // Return value: frame
74 // 0 - data belongs to one frame;
75 // 1 - to another
76 //---------------------
77 static bool fco(const bitset<32>& word);
78 static bool fco(const uint32_t& word);
79
80 //---------------------
81 // Return value:
82 // value of N ADC channel
83 //---------------------
84 static int adc_ch(vector<bitset<32>>& adc_word, char channel_name);
85 static int adc_ch(vector<bitset<32>>& adc_word, size_t start_index, char channel_name);
86 // static int adc_ch(vector<uint32_t> &adc_word, size_t start_index, char channel_name);
87
88 template<typename UIntType>
89 static int adc_ch(UIntType* adc_word, size_t start_index, char channel_name)
90 {
91 UIntType result = 0;
92 map<char, size_t> offsets{{'A', 0}, {'B', 2}, {'C', 4}, {'D', 6}, {'E', 8}, {'F', 10}, {'G', 12}, {'H', 14}};
93 for (size_t i = 0; i < 6; i++) {
94 result += ((adc_word[start_index + i] >> offsets[channel_name]) & 1) << (10 - 2 * i + 1);
95 result += ((adc_word[start_index + i] >> (offsets[channel_name] + 1)) & 1) << (10 - 2 * i);
96 }
97 return result - 0x800;
98 // return result.to_ulong();
99 }
100
101 template<typename UIntType>
102 static int adc_ch(vector<UIntType> adc_word, size_t start_index, char channel_name)
103 {
104 uint32_t result = 0;
105 map<char, size_t> offsets{{'A', 0}, {'B', 2}, {'C', 4}, {'D', 6}, {'E', 8}, {'F', 10}, {'G', 12}, {'H', 14}};
106 for (size_t i = 0; i < 6; i++) {
107 result += ((adc_word[start_index + i] >> offsets[channel_name]) & 1) << (10 - 2 * i + 1);
108 result += ((adc_word[start_index + i] >> (offsets[channel_name] + 1)) & 1) << (10 - 2 * i);
109 }
110 return result - 0x800;
111 }
112
113 //---------------------------------------------------
114 // Tracker detector 128x128 strip mapping
115 // Y - n+ readout card 3 and 4
116 // X - p+ readout card 1 and 2
117 // Readout card #1 (X - p+ strips 1-64 ) ADC channel-E.
118 // Readout card #2 (X - p+ strips 65-128) ADC channel-F.
119 // Readout card #3 (Y - n+ strips 65-128) ADC channel-G.
120 // Readout card #4 (Y - n+ strips 1-64 ) ADC channel-H.
121 //---------------------------------------------------
122 //---- beam_tracker_map
123 static vector<int> beam_tracker_map(vector<int>& vec, char adc_channel);
124
125 //---- tracker_X1_chE
126 static vector<int> tracker_X1_chE(vector<int>& vec);
127
128 //---- tracker_X2_chF
129 static vector<int> tracker_X2_chF(vector<int>& vec);
130
131 //----- tracker_Y1_chH
132 static vector<int> tracker_Y1_chH(vector<int>& vec);
133
134 //----- tracker_Y2_chG
135 static vector<int> tracker_Y2_chG(vector<int>& vec);
136
137 //----- tracker_test_signal
138 static vector<int> tracker_tst_sgnl(vector<int>& chE, vector<int>& chF, vector<int>& chH, vector<int>& chG);
139
140 private:
141 static const size_t ASIC_channel = 32; // for the beam profilometer
142};
143
144#endif /* BMNPROFRAWTOOLS_H */
int i
Definition P4_F32vec4.h:22
static int adc_ch(vector< bitset< 32 > > &adc_word, size_t start_index, char channel_name)
static int adc_ch(vector< UIntType > adc_word, size_t start_index, char channel_name)
static int adc_ch(vector< bitset< 32 > > &adc_word, char channel_name)
static vector< int > tracker_X2_chF(vector< int > &vec)
static bool adc_num(const bitset< 32 > &word)
static bool fco(const uint32_t &word)
static vector< int > tracker_tst_sgnl(vector< int > &chE, vector< int > &chF, vector< int > &chH, vector< int > &chG)
static constexpr const size_t ChannelDigitCnt()
static uint32_t trig_cntr(const uint32_t &word)
static bool adc_num(const uint32_t &word)
static bool data_or_trig(const uint32_t &word)
static int adc_ch(UIntType *adc_word, size_t start_index, char channel_name)
static bool trig_nsd(const uint32_t &word)
static bool fco(const bitset< 32 > &word)
static vector< int > beam_tracker_map(vector< int > &vec, char adc_channel)
static vector< int > tracker_Y2_chG(vector< int > &vec)
static bool trig_psd(const uint32_t &word)
static constexpr const size_t ChannelCnt()
static const size_t ASIC_channel
static uint32_t holdb_cntr(const uint32_t &word)
static vector< int > tracker_Y1_chH(vector< int > &vec)
static void endian_swap(uint32_t &x)
static vector< int > tracker_X1_chE(vector< int > &vec)
@ UIntType
Definition json.hpp:4446