File indexing completed on 2025-08-05 08:13:29
0001
0002 #ifndef MISALIGNMENT_H
0003 #define MISALIGNMENT_H
0004
0005 #include <cmath>
0006 #include <map>
0007 #include <vector>
0008
0009 #include <TMath.h>
0010
0011 vector<float> misalignment(int c)
0012 {
0013 float shift_1 = 0.001, shift_2 = 0.005, shift_3 = 0.01;
0014
0015 std::map<int, std::vector<float>> Map_MisliagnCase = {{0, {0, 0, 0}},
0016 {1, {shift_1, 0, 0}},
0017 {2, {-1 * shift_1, 0, 0}},
0018 {3, {shift_2, 0, 0}},
0019 {4, {-1 * shift_2, 0, 0}},
0020 {5, {shift_3, 0, 0}},
0021 {6, {-1 * shift_3, 0, 0}},
0022 {7, {0, shift_1, 0}},
0023 {8, {0, shift_1, TMath::Pi() / 6.}},
0024 {9, {0, shift_1, TMath::PiOver4()}},
0025 {10, {0, shift_1, TMath::Pi() / 3.}},
0026 {11, {0, shift_1, TMath::Pi() / 2.}},
0027 {12, {0, shift_1, 3 * TMath::PiOver4()}},
0028 {13, {0, shift_1, 5 * TMath::PiOver4()}},
0029 {14, {0, shift_1, 7 * TMath::PiOver4()}},
0030 {15, {0, shift_2, 0}},
0031 {16, {0, shift_2, TMath::Pi() / 6.}},
0032 {17, {0, shift_2, TMath::PiOver4()}},
0033 {18, {0, shift_2, TMath::Pi() / 3.}},
0034 {19, {0, shift_2, TMath::Pi() / 2.}},
0035 {20, {0, shift_2, 3 * TMath::PiOver4()}},
0036 {21, {0, shift_2, 5 * TMath::PiOver4()}},
0037 {22, {0, shift_2, 7 * TMath::PiOver4()}},
0038 {23, {0, shift_3, 0}},
0039 {24, {0, shift_3, TMath::Pi() / 6.}},
0040 {25, {0, shift_3, TMath::PiOver4()}},
0041 {26, {0, shift_3, TMath::Pi() / 3.}},
0042 {27, {0, shift_3, TMath::Pi() / 2.}},
0043 {28, {0, shift_3, 3 * TMath::PiOver4()}},
0044 {29, {0, shift_3, 5 * TMath::PiOver4()}},
0045 {30, {0, shift_3, 7 * TMath::PiOver4()}},
0046 {31, {shift_1, shift_1, TMath::PiOver4()}},
0047 {32, {shift_1, shift_2, TMath::PiOver4()}},
0048 {33, {shift_1, shift_3, TMath::PiOver4()}},
0049 {34, {shift_2, shift_1, TMath::PiOver4()}},
0050 {35, {shift_2, shift_2, TMath::PiOver4()}},
0051 {36, {shift_2, shift_3, TMath::PiOver4()}},
0052 {37, {shift_3, shift_1, TMath::PiOver4()}},
0053 {38, {shift_3, shift_2, TMath::PiOver4()}},
0054 {39, {shift_3, shift_3, TMath::PiOver4()}},
0055
0056 {100, {float(TMath::ATan(0.7 / 604.59))}},
0057 {101, {float(TMath::ATan(1.0 / 604.59))}}};
0058
0059 return Map_MisliagnCase[c];
0060 }
0061
0062
0063
0064
0065
0066
0067 void UpdatePos_GapTwoHalves(vector<float> &hitpos, float gap_northend, float s, float g1)
0068 {
0069 float NorthEnd_to_StaveMid = 177.5;
0070 float StaveSouthEnd_to_StaveMid = 154.;
0071 float Clips_to_StaveSouthEnd = 273.09;
0072 float zshift = (Clips_to_StaveSouthEnd + StaveSouthEnd_to_StaveMid) / 10.;
0073 float gap_atClips = 1.5;
0074 float g2 = gap_northend - g1;
0075 float dalpha1_num = g1 - (gap_atClips / 2.);
0076 float dalpha2_num = g2 - (gap_atClips / 2.);
0077
0078 if (gap_northend != gap_atClips)
0079 {
0080
0081 float z0 = hitpos[2] + zshift;
0082 float x0 = hitpos[0];
0083 float l = z0;
0084 float alpha0 = TMath::ATan(x0 / z0);
0085 float dalpha1 = TMath::ATan(dalpha1_num / 604.59);
0086 float dalpha2 = TMath::ATan(dalpha2_num / 604.59);
0087
0088
0089 hitpos[2] = (x0 > 0) ? l * TMath::Cos(dalpha1) - zshift : l * TMath::Cos(dalpha2) - zshift;
0090 hitpos[0] = (x0 > 0) ? x0 + l * TMath::Sin(dalpha1) : x0 + l * TMath::Sin(-1 * dalpha2);
0091
0092 hitpos[0] = hitpos[0] + s;
0093 }
0094 }
0095
0096 #endif