-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAngleCalc.h
More file actions
54 lines (42 loc) · 1.44 KB
/
AngleCalc.h
File metadata and controls
54 lines (42 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <cmath>
#include <iostream>
#include <vector>
#include "ConfigTopDir.cpp"
double CalcdPhi(double dPhiTemp) {
double dPhi;
if (dPhiTemp > 180.0) {
dPhi = dPhiTemp - 360.0;
} else if (dPhiTemp < -180.0) {
dPhi = dPhiTemp + 360.0;
} else {
dPhi = dPhiTemp;
}
return dPhi;
}
// Function to find the angle closest to 180 degrees away from phi_N
double getPhi_e(TString OutPutFolder, double phi_N) {
double phi_e_offset = 0.; // Electron phi_e offset due to the solenoid field
string OutPutFolder0(OutPutFolder.Data());
if (findSubstring(OutPutFolder0, "2070MeV")) {
phi_e_offset = 16.;
} else if (findSubstring(OutPutFolder0, "4029MeV")) {
phi_e_offset = 7.;
} else if (findSubstring(OutPutFolder0, "5986MeV")) {
phi_e_offset = 5.;
}
std::vector<double> possible_angles = {-120, -60, 0, 60, 120, 180};
// Calculate the target angle (180 degrees away from phi_N)
double target_angle = CalcdPhi(phi_N + 180);
// Find the closest possible angle
double closest_angle = possible_angles[0];
double min_diff = std::abs(CalcdPhi(target_angle - closest_angle));
for (double angle : possible_angles) {
double diff = std::abs(CalcdPhi(target_angle - angle));
if (diff < min_diff) {
min_diff = diff;
closest_angle = angle;
}
}
return closest_angle + phi_e_offset;
// return closest_angle;
}