Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SPForSeed.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SPForSeed.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 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 // SPForSeed.hpp Acts project
12 
13 #pragma once
14 #include <cmath>
15 
16 // COLLECTION OF MAGIC NUMBERS IN HERE:
17 //
18 //
19 // m_q = 100000.;
20 //
21 // float cov = wid*wid*.08333;
22 //
23 // Pixel Case
24 // if(de->isBarrel()) {m_covz = 9.*cov; m_covr = .06;}
25 // else {m_covr = 9.*cov; m_covz = .06;}
26 //
27 // SCT Case
28 // if(de->isBarrel()) {m_covz = 8.*f22; m_covr = .1;}
29 // else {m_covr = 8.*f22; m_covz = .1;}
30 
31 namespace Acts {
32 namespace Legacy {
33 
34 template <typename SpacePoint>
35 class SPForSeed {
37  // Public methods:
39 
40  public:
41  SPForSeed();
42  SPForSeed(SpacePoint* const& /*sp*/, const float* /*r*/);
43  SPForSeed(SpacePoint* const& /*sp*/, const float* /*r*/, const float* /*sc*/);
44  SPForSeed(const SPForSeed& /*sp*/);
45  virtual ~SPForSeed();
46  SPForSeed& operator=(const SPForSeed& /*sp*/);
47 
48  void set(SpacePoint* const& /*sp*/, const float* /*r*/);
49  void set(SpacePoint* const& /*sp*/, const float* /*r*/, const float* /*sc*/);
50  void setQuality(float /*q*/);
51  void setParam(const float& /*p*/);
52 
53  const SpacePoint* spacepoint = nullptr;
54  const float& x() const { return m_x; }
55  const float& y() const { return m_y; }
56  const float& z() const { return m_z; }
57  const float& radius() const { return m_r; }
58  float phi() const { return atan2(m_y, m_x); }
59  const float& covr() const { return m_covr; }
60  const float& covz() const { return m_covz; }
61  const float& param() const { return m_param; }
62  const float& quality() const { return m_q; }
63 
64  const int& surface() const { return m_surface; }
65 
66  protected:
67  float m_x = 0; // x-coordinate in beam system coordinates
68  float m_y = 0; // y-coordinate in beam system coordinates
69  float m_z = 0; // z-coordinate in beam system coordinetes
70  float m_r = 0; // radius in beam system coordinates
71  float m_covr = 0; //
72  float m_covz = 0; //
73  float m_param = 0;
74  float m_q = 0;
75 
76  int m_surface = 0; // surface identifier
77 };
78 
80 // Inline methods
82 
83 template <typename SpacePoint>
85  spacepoint = 0;
86  m_x = 0.;
87  m_y = 0.;
88  m_z = 0.;
89  m_r = 0.;
90  m_covr = 0.;
91  m_covz = 0.;
92  m_param = 0.;
93  m_q = 0.;
94 }
95 
96 template <typename SpacePoint>
98  const SPForSeed<SpacePoint>& sp) {
99  if (&sp != this) {
100  spacepoint = sp.spacepoint;
101  m_x = sp.m_x;
102  m_y = sp.m_y;
103  m_z = sp.m_z;
104  m_r = sp.m_r;
105  m_covr = sp.m_covr;
106  m_covz = sp.m_covz;
107  m_q = sp.m_q;
108  }
109  return (*this);
110 }
111 
112 template <typename SpacePoint>
113 inline SPForSeed<SpacePoint>::SPForSeed(SpacePoint* const& sp, const float* r) {
114  set(sp, r);
115  m_param = 0.;
116 }
117 
118 template <typename SpacePoint>
119 inline SPForSeed<SpacePoint>::SPForSeed(SpacePoint* const& sp, const float* r,
120  const float* sc) {
121  set(sp, r, sc);
122  m_param = 0.;
123 }
124 
126 // Copy constructor
128 
129 template <typename SpacePoint>
131  *this = sp;
132 }
133 
135 // Destructor
137 
138 template <typename SpacePoint>
139 inline SPForSeed<SpacePoint>::~SPForSeed() = default;
140 
142 // Set
144 
145 template <typename SpacePoint>
146 inline void SPForSeed<SpacePoint>::set(SpacePoint* const& sp, const float* r) {
147  spacepoint = sp;
148  m_x = r[0];
149  m_y = r[1];
150  m_z = r[2];
151  m_r = std::hypot(m_x, m_y);
152  m_surface = sp->surface;
153  m_q = 100000.;
154 
155  if (!sp->clusterList().second) {
156  m_covr = sp->covr * 9.;
157  m_covz = sp->covz * 9.;
158  if (m_covr < 0.06) {
159  m_covr = 0.06;
160  }
161  if (m_covz < 0.06) {
162  m_covz = 0.06;
163  }
164  } else {
165  m_covr = sp->covr * 8.;
166  m_covz = sp->covz * 8.;
167  if (m_covr < 0.1) {
168  m_covr = 0.1;
169  }
170  if (m_covz < 0.1) {
171  m_covz = 0.1;
172  }
173  }
174 }
175 
177 // Set with error correction
178 // sc[0] - barrel pixels error correction
179 // sc[1] - endcap pixels
180 // sc[2] - barrel sct
181 // sc[3] - endcap sct
183 
184 template <typename SpacePoint>
185 inline void SPForSeed<SpacePoint>::set(SpacePoint* const& sp, const float* r,
186  const float* sc) {
187  spacepoint = sp;
188  m_x = r[0];
189  m_y = r[1];
190  m_z = r[2];
191  m_r = std::hypot(m_x, m_y);
192  m_q = 100000.;
193  if (!sp->clusterList().second) {
194  m_covr = sp->covr * 9. * sc[0];
195  m_covz = sp->covz * 9. * sc[1];
196  if (m_covr < 0.06) {
197  m_covr = 0.06;
198  }
199  if (m_covz < 0.06) {
200  m_covz = 0.06;
201  }
202  } else {
203  m_covr = sp->covr * 8. * sc[2];
204  m_covz = sp->covz * 8. * sc[3];
205  if (m_covr < 0.1) {
206  m_covr = 0.1;
207  }
208  if (m_covz < 0.1) {
209  m_covz = 0.1;
210  }
211  }
212 
213  // old code:
214  // const InDet::SiCluster* c = static_cast<const
215  // InDet::SiCluster*>(sp->clusterList().first);
216  // if( de->isPixel() ) {
217  //
218  // const Amg::MatrixX& v = sp->localCovariance();
219  // //ATTENTION: v(1,1) contains error for z in barrel, error for r in
220  // endcaps
221  // float f22 = float(v(1,1));
222  // //ATTENTION: Variable Z contains width of R in the endcaps.
223  // float wid = float(c->width().z());
224  // float cov = wid*wid*.08333; if(cov < f22) cov = f22;
225  // // Set error of low uncertainty dimension (i.e. r for barrel, z for
226  // EC)
227  // to "small"
228  // if(sp->isBarrel()) {m_covz = 9.*cov*sc[0]; m_covr = .06;}
229  // else {m_covr = 9.*cov*sc[1]; m_covz = .06;}
230  // }
231  // else {
232  //
233  // const Amg::MatrixX& v = sp->localCovariance();
234  // float f22 = float(v(1,1));
235  // if(sp->isBarrel()) {m_covz = 8.*f22*sc[2]; m_covr = .1;}
236  // else {m_covr = 8.*f22*sc[3]; m_covz = .1;}
237  // }
238 }
239 template <typename SpacePoint>
240 inline void SPForSeed<SpacePoint>::setParam(const float& p) {
241  m_param = p;
242 }
243 template <typename SpacePoint>
244 inline void SPForSeed<SpacePoint>::setQuality(float q) {
245  if (q <= m_q) {
246  m_q = q;
247  }
248 }
249 
250 } // namespace Legacy
251 } // namespace Acts