Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InttMonConstants.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file InttMonConstants.cc
1 #include "InttMonConstants.h"
2 
3 void INTT::GetFelixBinFromIndexes(int& b, int felix_channel, struct Indexes_s const& indexes)
4 {
5  int s = 1;
6  b = 0;
7 
8  b += indexes.adc * s;
9  s *= ADC;
10 
11  b += indexes.chn * s;
12  s *= CHANNEL;
13 
14  b += indexes.chp * s;
15  s *= CHIP;
16 
17  b += felix_channel * s;
18 
19  ++b;
20 }
21 
22 void INTT::GetFelixIndexesFromBin(int b, int& felix_channel, struct Indexes_s& indexes)
23 {
24  --b;
25 
26  indexes.adc = b % ADC;
27  b /= ADC;
28 
29  indexes.chn = b % CHANNEL;
30  b /= CHANNEL;
31 
32  indexes.chp = b % CHIP;
33  b /= CHIP;
34 
35  felix_channel = b;
36 }
37 
38 
39 void INTT::GetGlobalChipBinXYFromIndexes(int& bin_x, int& bin_y, struct Indexes_s const& indexes)
40 {
41  bin_x = 2 * indexes.ldr + (indexes.arm != (indexes.chp / (INTT::CHIP / 2)));
42  ++bin_x;
43  bin_y = indexes.arm ? INTT::CHIP - indexes.chp % (INTT::CHIP / 2) - 1 : indexes.chp % (INTT::CHIP / 2);
44  ++bin_y;
45 }
46 
47 void INTT::GetIndexesFromGlobalChipBinXY(int const& bin_x, int const& bin_y, struct Indexes_s& indexes)
48 {
49  indexes.ldr = bin_x / 2;
50  indexes.arm = bin_y / (INTT::CHIP / 2);
51 
52  indexes.chp = bin_y < INTT::CHIP / 2 ? bin_y : INTT::CHIP - bin_y - 1;
53  indexes.chp += (indexes.arm != (bin_x % 2)) * (INTT::CHIP / 2);
54 }
55 
56 void INTT::GetLocalChannelBinXYFromIndexes(int& bin_x, int& bin_y, struct Indexes_s const& indexes)
57 {
58  bin_x = indexes.chn;
59  ++bin_x;
60  bin_y = indexes.adc;
61  ++bin_y;
62 }
63 
64 void INTT::GetIndexesFromLocalChannelBinXY(int const& bin_x, int const& bin_y, struct Indexes_s& indexes)
65 {
66  indexes.chn = bin_x;
67  indexes.adc = bin_y;
68 }
69 
70 
71 void INTT::GetGlobalLadderBinXYFromIndexes(int& bin_x, int& bin_y, struct Indexes_s const& indexes)
72 {
73  bin_x = indexes.ldr;
74  ++bin_x;
75  bin_y = indexes.chp;
76  ++bin_y;
77 }
78 
79 void INTT::GetIndexesFromGlobalLadderBinXY(int const& bin_x, int const& bin_y, struct Indexes_s& indexes)
80 {
81  indexes.ldr = bin_x;
82  indexes.arm = bin_y;
83 }
84 
85 void INTT::GetLocalChipBinXYFromIndexes(int& bin_x, int& bin_y, struct Indexes_s const& indexes)
86 {
87  bin_x = (indexes.arm != indexes.chp / (INTT::CHIP / 2)) ? 2 * INTT::CHANNEL - indexes.chn - 1 : indexes.chn;
88  ++bin_x;
89  bin_y = indexes.arm ? INTT::CHIP / 2 - indexes.chp % (INTT::CHIP / 2) - 1 : indexes.chp % (INTT::CHIP / 2);
90  ++bin_y;
91 }
92 
93 void INTT::GetIndexesFromLocalChipBinXY(int const& bin_x, int const& bin_y, struct Indexes_s& indexes)
94 {
95  indexes.chp = indexes.arm ? INTT::CHIP / 2 - bin_y - 1 : bin_y;
96  indexes.chp += (indexes.arm != (bin_x % 2)) * (INTT::CHIP / 2);
97 
98  indexes.chn = bin_x < INTT::CHANNEL ? bin_x : 2 * INTT::CHANNEL - bin_x - 1;
99 }