Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefaultHoughFunctions.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DefaultHoughFunctions.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020-2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
11 #pragma once
12 
13 enum class HoughError {
14  Failure = 1,
15  SomethingElse,
16 };
17 std::error_code make_error_code(HoughError e) {
18  return {static_cast<int>(e), std::generic_category()};
19 }
20 
21 namespace std {
22 // register with STL
23 template <>
24 struct is_error_code_enum<HoughError> : std::true_type {};
25 } // namespace std
26 
27 namespace ActsExamples {
28 namespace DefaultHoughFunctions {
32 
33 ResultDouble fieldCorrectionDefault(unsigned region, double y, double r) {
34  if (region == 999) {
35  return y + r; // this should not be found, for now this is a dummy to show
36  // what one *could* do
37  }
38  return ResultDouble::success(0.0);
39 }
40 
42  if (r < 50) {
43  return ResultUnsigned::success(0);
44  } else if (r < 100) {
45  return ResultUnsigned::success(1);
46  } else if (r < 150) {
47  return ResultUnsigned::success(2);
48  } else if (r < 200) {
49  return ResultUnsigned::success(3);
50  } else if (r < 300) {
51  return ResultUnsigned::success(4);
52  } else if (r < 400) {
53  return ResultUnsigned::success(5);
54  } else if (r < 550) {
55  return ResultUnsigned::success(6);
56  } else if (r < 700) {
57  return ResultUnsigned::success(7);
58  } else if (r < 900) {
59  return ResultUnsigned::success(8);
60  } else if (r < 1100) {
61  return ResultUnsigned::success(9);
62  }
63  return ResultUnsigned::failure(
64  HoughError::Failure);
65 }
66 
67 // default with two slices, one for negative and one for positive z, counting
68 // some small overlaps, and -1 means "just take everything"
69 ResultBool inSliceDefault(double z, unsigned layer, int slice) {
70  if (slice == -1) {
71  return ResultBool::success(true);
72  }
73 
74  double absz = abs(z);
75  if (slice == 0 && z > 50) {
76  return ResultBool::success(false);
77  } else if (slice == 1 && z < -50) {
78  return ResultBool::success(false);
79  } else {
80  if (layer <= 3) {
81  if (absz < 200) {
82  return ResultBool::success(true);
83  } else {
84  return ResultBool::success(false);
85  }
86  } else if (layer == 4) {
87  if (absz < 300) {
88  return ResultBool::success(true);
89  } else {
90  return ResultBool::success(false);
91  }
92  } else if (layer == 5) {
93  if (absz < 400) {
94  return ResultBool::success(true);
95  } else {
96  return ResultBool::success(false);
97  }
98  } else if (layer == 6) {
99  if (absz < 600) {
100  return ResultBool::success(true);
101  } else {
102  return ResultBool::success(false);
103  }
104  } else if (layer == 7) {
105  if (absz < 700) {
106  return ResultBool::success(true);
107  } else {
108  return ResultBool::success(false);
109  }
110  } else if (layer == 8) {
111  if (absz < 800) {
112  return ResultBool::success(true);
113  } else {
114  return ResultBool::success(false);
115  }
116  } else if (layer == 9) {
117  if (absz < 1100) {
118  return ResultBool::success(true);
119  } else {
120  return ResultBool::success(false);
121  }
122  } else {
123  return ResultBool::success(false);
124  }
125  }
126 }
127 } // namespace DefaultHoughFunctions
128 } // namespace ActsExamples