SND@LHC Software
Loading...
Searching...
No Matches
DriftTubes::ChannelId Struct Reference

#include <ShipOnlineDataFormat.h>

Public Member Functions

int GetDetectorId () const
 
int GetDetectorIdCharm () const
 

Public Attributes

uint16_t channel: 8
 
uint16_t TDC: 4
 
uint16_t edge: 1
 
uint16_t padding: 3
 

Detailed Description

Definition at line 34 of file ShipOnlineDataFormat.h.

Member Function Documentation

◆ GetDetectorId()

int DriftTubes::ChannelId::GetDetectorId ( ) const
inline

Definition at line 39 of file ShipOnlineDataFormat.h.

40 {
41 bool trigger = false;
42 bool beamcounter = false;
43 bool RC_signal = false;
44 bool scintillatorA = false;
45 bool scintillatorB = false;
46 bool master_trigger = false;
47 bool blacklisted = false;
48 int module = 0;
49 int station = 0;
50 int channel_offset = 0;
51 switch (TDC) {
52 case 0:
53 trigger = channel == 126;
54 scintillatorA = channel == 127;
55 station = (channel < 96) ? 1 : 2;
56 module = (channel / 48) % 2;
57 blacklisted = channel >= 120;
58 break;
59 case 1:
60 trigger = channel == 0;
61 scintillatorA = channel == 1;
62 station = (channel < 80) ? 2 : 4;
63 channel_offset = (channel < 80) ? 112 : 1;
64 channel_offset += (channel >= 32 && channel < 48) ? +16 : (channel >= 48 && channel < 64) ? -16 : 0;
65 blacklisted = channel < 8;
66 blacklisted |= channel >= 128;
67 break;
68 case 2:
69 trigger = channel == 126;
70 scintillatorB = channel == 127;
71 station = 4;
72 channel_offset = -119;
73 module = (channel / 48) % 3 + 1;
74 blacklisted = channel >= 120;
75 break;
76 case 3:
77 trigger = channel == 0;
78 scintillatorB = channel == 1;
79 station = (channel < 32) ? 4 : 3;
80 channel_offset = (channel < 32) ? 1 : 33;
81 module = ((channel + 16) / 48 + 3) % 4;
82 blacklisted = channel < 8;
83 blacklisted |= channel >= 128;
84 break;
85 case 4:
86 trigger = channel == 96;
87 RC_signal = channel == 97 || channel == 98;
88 master_trigger = channel == 99;
89 beamcounter = channel > 111;
90 module = (channel / 48) % 2 + 2;
91 channel_offset = (channel < 48) * 33;
92 station = 3;
93 blacklisted = channel >= 96;
94 break;
95 }
96 if (trigger) {
97 return 0;
98 } else if (master_trigger) {
99 return 1;
100 } else if (beamcounter || RC_signal) {
101 return -1;
102 } else if (scintillatorA) {
103 return 6;
104 } else if (scintillatorB) {
105 return 7;
106 } else if(blacklisted) {
107 return -2;
108 }
109 bool reverse_x = !(station == 2 || (TDC == 4 && channel >= 48));
110 int _channel = channel + channel_offset;
111 _channel += (_channel < 0) * 0x80;
112 _channel = reverse_x ? (0x80 - _channel % 0x80) % 0x80 : _channel;
113 if (TDC == 0 && channel < 96) {
114 _channel += _channel ? 63 : 191;
115 } else if (TDC == 3 && channel < 96) {
116 _channel += (channel < 32) ? 24 : 32;
117 }
118 if (TDC == 1) {
119 module = (_channel / 48) % 2;
120 }
121
122 int view = (station == 1 || station == 2) * module % 2;
123 int plane = (TDC == 2) ? ((_channel % 48) / 24 + 1) % 2
124 : (station == 3 && TDC == 4) ? 1 - (channel % 48) / 24 : (_channel % 48) / 24;
125 if (station == 4 && TDC == 3) {
126 plane -= 1;
127 }
128 int layer = (TDC == 4) ? 1 - (channel % 24) / 12 : (_channel % 24) / 12;
129 int straw = _channel % 12 + ((station == 3 || station == 4) ? 1 + (3 - module) * 12 : 1);
130 return station * 10000000 + view * 1000000 + plane * 100000 + layer * 10000 + 2000 + straw;
131 };

◆ GetDetectorIdCharm()

int DriftTubes::ChannelId::GetDetectorIdCharm ( ) const
inline

Definition at line 132 of file ShipOnlineDataFormat.h.

133 {
134 bool trigger = false;
135 bool beamcounter = false;
136 bool RC_signal = false;
137 bool master_trigger = false;
138 int module = 0;
139 int station = 0;
140 int module_channel = 0;
141 switch (TDC) {
142 case 0:
143 trigger = channel == 126 || channel == 120;
144 RC_signal = channel == 121 || channel == 122;
145 master_trigger = channel == 123;
146 station = 3;
147 module = (channel < 96) ? 2 + (channel / 48) % 2 : 0;
148 module_channel = channel % 48;
149 //reverse front end board
150 if(module == 3) module_channel = 12*(module_channel/12)+(11-module_channel%12);
151 break;
152 case 1:
153 trigger = channel == 0;
154 beamcounter = channel >=2 && channel <= 5;
155 station = (channel < 80) ? 3 : 4;
156 module = (channel >= 32 && channel < 80) ? 1 : 0;
157 module_channel = (channel + 16) % 48;
158 //cable swap
159 if(module==1) module_channel += ( module_channel < 16 ) ? 16 : ( module_channel < 32 ) ? -16 : 0;
160 break;
161 case 2:
162 trigger = channel == 126;
163 station = 4;
164 module = (channel / 48) + 1 ;
165 module_channel = channel % 48;
166 break;
167 case 3:
168 trigger = channel == 0;
169 station = (channel < 32 || channel >= 80) ? 4 : 3;
170 module = (channel < 32 ) ? 3 : 4;
171 module_channel = (channel + 16) % 48;
172 break;
173 }
174 if (trigger) {
175 return 0;
176 } else if (master_trigger) {
177 return 1;
178 } else if (beamcounter || RC_signal) {
179 return -1;
180 }
181
182 int plane = 1 - (module_channel / 24);
183 int layer = 1 - (module_channel % 24) / 12;
184 int straw = (module >= 4 ? module : 3 - module) * 12 + (11 - (module_channel % 12)) + 1;
185
186 return station * 10000000 + plane * 100000 + layer * 10000 + 2000 + straw;
187 };

Member Data Documentation

◆ channel

uint16_t DriftTubes::ChannelId::channel

Definition at line 35 of file ShipOnlineDataFormat.h.

◆ edge

uint16_t DriftTubes::ChannelId::edge

Definition at line 37 of file ShipOnlineDataFormat.h.

◆ padding

uint16_t DriftTubes::ChannelId::padding

Definition at line 38 of file ShipOnlineDataFormat.h.

◆ TDC

uint16_t DriftTubes::ChannelId::TDC

Definition at line 36 of file ShipOnlineDataFormat.h.


The documentation for this struct was generated from the following file: