ATLAS Offline Software
ITkSiSpacePointsProSeed.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 #include <cmath>
11 
12 namespace ITk
13 {
14 
16  {
17  m_s0 = nullptr ;
18  m_s1 = nullptr ;
19  m_s2 = nullptr ;
20  m_z = 0.;
21  m_q = 0.;
22  }
23 
24  SiSpacePointsProSeed& SiSpacePointsProSeed::operator =
25  (const SiSpacePointsProSeed& sp)
26  {
27  if(&sp!=this) {
28 
29  m_z = sp.m_z ;
30  m_q = sp.m_q ;
31  m_s0 = sp.m_s0;
32  m_s1 = sp.m_s1;
33  m_s2 = sp.m_s2;
34  }
35  return(*this);
36  }
37 
40  {
41  set(s0,s1,s2,z); m_q = 0.;
42  }
43 
45  // Copy constructor
47 
48  SiSpacePointsProSeed::SiSpacePointsProSeed (const SiSpacePointsProSeed& sp): m_s0(sp.m_s0),m_s1(sp.m_s1),m_s2(sp.m_s2)
49  {
50  *this = sp;
51  }
52 
53 
55  // Set
57 
60  {
61  m_z = z ;
62  m_s0 = s0;
63  m_s1 = s1;
64  m_s2 = s2;
65  }
66 
68  // Set two space points seed
70 
72  {
73  s.erase();
74  s.add(m_s0->spacepoint);
75  s.add(m_s1->spacepoint);
76  s.setZVertex(double(m_z));
77  }
78 
80  // Set three space points seed
82 
83  bool SiSpacePointsProSeed::set3(InDet::SiSpacePointsSeed& s, float pTPerHelixRadius)
84  {
85  bool pixt = !m_s2->spacepoint->clusterList().second;
86 
87  if(pixt) {
88  if(m_q > m_s0->quality() && m_q > m_s1->quality() && m_q > m_s2->quality()) return false;
89  }
90 
94 
95  s.erase();
96  s.add(m_s0->spacepoint);
97  s.add(m_s1->spacepoint);
98  s.add(m_s2->spacepoint);
99  s.setZVertex(double(m_z));
100  s.setX1(m_s0->x());
101  s.setX2(m_s1->x());
102  s.setX3(m_s2->x());
103  s.setY1(m_s0->y());
104  s.setY2(m_s1->y());
105  s.setY3(m_s2->y());
106  s.setZ1(m_s0->z());
107  s.setZ2(m_s1->z());
108  s.setZ3(m_s2->z());
109  s.setR1(m_s0->radius());
110  s.setR2(m_s1->radius());
111  s.setR3(m_s2->radius());
112 
113  estimateParameters(pTPerHelixRadius);
114  s.setD0(m_s2->param());
115  s.setEta(m_s2->eta());
116  s.setDZDR_B(m_s0->dzdr());
117  s.setDZDR_T(m_s2->dzdr());
118  s.setPt(m_s2->pt());
119 
120  return true;
121  }
122 
123  void SiSpacePointsProSeed::estimateParameters(float pTPerHelixRadius)
124  {
125 
126  ITk::SiSpacePointForSeed& bottom = *m_s0;
127  ITk::SiSpacePointForSeed& medium = *m_s1;
129 
130  bool isPixel = !m_s2->spacepoint->clusterList().second;
131 
132  auto extractCoordinates =
133  [] (const ITk::SiSpacePointForSeed& sp) -> std::array<float,4>
134  {
135  std::array<float, 4> coordinates {sp.x(), sp.y(), sp.z(), sp.radius()};
136  return coordinates;
137  };
138 
139  auto extractQuantities =
140  [] (const std::array<float, 4>& sp,
141  const std::array<float, 4>& spM,
142  bool isBottom) -> std::array<float, 5>
143  {
144  const auto& [xM, yM, zM, rM] = spM;
145  const auto& [xO, yO, zO, rO] = sp;
146 
147  float cosPhiM = xM / rM;
148  float sinPhiM = yM / rM;
149  float deltaX = xO - xM;
150  float deltaY = yO - yM;
151  float deltaZ = zO - zM;
152  float x = deltaX * cosPhiM + deltaY * sinPhiM;
153  float y = deltaY * cosPhiM - deltaX * sinPhiM;
154  float iDeltaR2 = 1. / (deltaX * deltaX + deltaY * deltaY);
155  float iDeltaR = std::sqrt(iDeltaR2);
156  int bottomFactor = 1 * (int(not isBottom)) - 1 * (int(isBottom));
157  float cot_theta = deltaZ * iDeltaR * bottomFactor;
158 
159  // cotTheta, Zo, iDeltaR, U, V
160  std::array<float, 5> params =
161  {
162  cot_theta,
163  zM - rM * cot_theta,
164  iDeltaR,
165  x * iDeltaR2,
166  y * iDeltaR2
167  };
168 
169  return params;
170  };
171 
172  auto coo_b = extractCoordinates(bottom);
173  auto coo_m = extractCoordinates(medium);
174  auto coo_t = extractCoordinates(top);
175 
176  // Compute the variables we need
177  auto [cotThetaB, Zob, iDeltaRB, Ub, Vb] = extractQuantities(coo_b, coo_m, true);
178  auto [cotThetaT, Zot, iDeltaRT, Ut, Vt] = extractQuantities(coo_t, coo_m, false);
179 
180  float squarediDeltaR2B = iDeltaRB*iDeltaRB;
181  float squarediDeltaR2T = iDeltaRB*iDeltaRT;
182  float squarediDeltaR = std::min(squarediDeltaR2B, squarediDeltaR2T);
183 
184  auto& [xB, yB, zB, rB] = coo_b;
185  auto& [xM, yM, zM, rM] = coo_m;
186  auto& [xT, yT, zT, rT] = coo_t;
187 
188  float ax = xM / rM;
189  float ay = yM/ rM;
190 
191  float dxb = xM - xB;
192  float dyb = yM - yB;
193  float dzb = zM - zB;
194  float xb = dxb * ax + dyb *ay;
195  float yb = dyb * ax - dxb * ay;
196  float dxyb = xb * xb + yb * yb;
197  float drb = std::sqrt( xb*xb + yb*yb + dzb*dzb );
198 
199  float dxt = xT - xM;
200  float dyt = yT - yM;
201  float dzt = zT - zM;
202  float xt = dxt * ax + dyt *ay;
203  float yt = dyt * ax - dxt * ay;
204  float dxyt = xt * xt + yt * yt;
205  float drt = std::sqrt( xt*xt + yt*yt + dzt*dzt );
206 
207  float tzb = dzb * std::sqrt( 1./dxyb );
208  float tzt = dzt * std::sqrt( 1./dxyt );
209 
210  float sTzb2 = std::sqrt(1 + tzb*tzb);
211 
212  float dU = Ut - Ub;
213  if (dU == 0.) {
214  return;
215  }
216 
217  float A = (Vt - Vb) / dU;
218  float S2 = 1. + A * A;
219  float B = Vb - A * Ub;
220  if (B==0)
221  return;
222  float B2 = B * B;
223 
224  // dzdr
225  float dzdr_b = (zM - zB) / (rM - rB);
226  float dzdr_t = (zT - zM) / (rT - rM);
227 
228  // eta
229  float meanOneOverTanThetaSquare = isPixel ? (cotThetaB * cotThetaT) :
230  std::pow((cotThetaB + cotThetaT) / 2.,2);
231  if (meanOneOverTanThetaSquare <= 0) {
232  return;
233  }
234  float theta = std::atan(1. / std::sqrt(meanOneOverTanThetaSquare)); // [0, pi/2)
235  if (top.z()<0) {theta = -theta;} // (-pi/2, pi/2)
236  if (theta < 0.) {theta = theta + M_PI;} // [0, pi)
237  float eta = -std::log(std::tan(0.5 * theta));
238 
239  // pt
240  float pt = pTPerHelixRadius*std::sqrt(S2 / B2);
241 
242  // d0
243  float d0 = std::abs((A - B * rM) * rM);
244 
245  // Attach variables to SPs
246  top.setDR(drt);
247  top.setDZDR(dzdr_t);
248  top.setScorePenalty( std::abs((tzb - tzt) / (squarediDeltaR * sTzb2)) );
249  top.setParam(d0);
250  top.setEta(eta);
251  top.setPt(pt);
252 
253  bottom.setDR(drb);
254  bottom.setDZDR(dzdr_b);
255 
256  }
257 
259  // Set quality in pro seed
261 
263  {
264  m_q = q;
265 
266  if(!m_s2->spacepoint->clusterList().second) {
267  if(q > m_s0->quality() && q > m_s1->quality() && q > m_s2->quality()) return false;
268  }
269  m_s0->setQuality(m_q);
270  m_s1->setQuality(m_q);
271  m_s2->setQuality(m_q);
272  return true;
273  }
274 
275 } // end of name space ITk
Trk::SpacePoint::clusterList
const std::pair< const PrepRawData *, const PrepRawData * > & clusterList() const
return the pair of cluster pointers by reference
Definition: Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePoint.h:127
ITkSiSpacePointsProSeed.h
ITk::SiSpacePointForSeed::param
const float & param() const
Definition: ITkSiSpacePointForSeed.h:69
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ITk::SiSpacePointsProSeed::z
const float & z() const
Definition: ITkSiSpacePointsProSeed.h:48
yt
#define yt
fitman.ax
ax
Definition: fitman.py:522
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ITk::SiSpacePointForSeed::pt
const float & pt() const
Definition: ITkSiSpacePointForSeed.h:73
makeComparison.deltaY
int deltaY
Definition: makeComparison.py:44
ITk::SiSpacePointsProSeed::set
void set(SiSpacePointForSeed *&, SiSpacePointForSeed *&, SiSpacePointForSeed *&, float)
Definition: ITkSiSpacePointsProSeed.cxx:59
SiSpacePointsSeed.h
ITk::SiSpacePointsProSeed::m_q
float m_q
Definition: ITkSiSpacePointsProSeed.h:63
ITk::SiSpacePointsProSeed::setQuality
bool setQuality(float)
Definition: ITkSiSpacePointsProSeed.cxx:262
ITkSiSpacePointForSeed.h
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
ITk::SiSpacePointForSeed::y
const float & y() const
Definition: ITkSiSpacePointForSeed.h:63
test_pyathena.pt
pt
Definition: test_pyathena.py:11
ITk::SiSpacePointForSeed::z
const float & z() const
Definition: ITkSiSpacePointForSeed.h:64
M_PI
#define M_PI
Definition: ActiveFraction.h:11
ITk::SiSpacePointsProSeed::set3
bool set3(InDet::SiSpacePointsSeed &, float pTPerHelixRadius)
Definition: ITkSiSpacePointsProSeed.cxx:83
x
#define x
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
ITk::SiSpacePointForSeed::quality
const float & quality() const
Definition: ITkSiSpacePointForSeed.h:70
A
xt
#define xt
ITk::SiSpacePointForSeed::spacepoint
const Trk::SpacePoint * spacepoint
Definition: ITkSiSpacePointForSeed.h:61
isBottom
bool isBottom(const T &p)
Definition: AtlasPID.h:132
ITk::SiSpacePointsProSeed::m_s0
SiSpacePointForSeed * m_s0
Definition: ITkSiSpacePointsProSeed.h:59
InDet::SiSpacePointsSeed
Definition: SiSpacePointsSeed.h:30
z
#define z
ITk::SiSpacePointsProSeed::m_s1
SiSpacePointForSeed * m_s1
Definition: ITkSiSpacePointsProSeed.h:60
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
ITk::SiSpacePointsProSeed::estimateParameters
void estimateParameters(float pTPerHelixRadius)
Definition: ITkSiSpacePointsProSeed.cxx:123
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
ITk::SiSpacePointForSeed::eta
const float & eta() const
Definition: ITkSiSpacePointForSeed.h:72
compareGeometries.deltaX
float deltaX
Definition: compareGeometries.py:32
min
#define min(a, b)
Definition: cfImp.cxx:40
ITk::SiSpacePointForSeed::radius
const float & radius() const
Definition: ITkSiSpacePointForSeed.h:65
ITk
Definition: ITkPixelOfflineCalibCondAlg.cxx:14
ITk::SiSpacePointForSeed::setDZDR
void setDZDR(const float &)
Definition: ITkSiSpacePointForSeed.cxx:85
ITk::SiSpacePointsProSeed::m_z
float m_z
Definition: ITkSiSpacePointsProSeed.h:62
DataModelTestDataCommonDict::xb
DMTest::CView::Pers_t xb
Definition: DataModelTestDataCommonDict.h:55
ITk::SiSpacePointsProSeed
Definition: ITkSiSpacePointsProSeed.h:28
ITk::SiSpacePointsProSeed::m_s2
SiSpacePointForSeed * m_s2
Definition: ITkSiSpacePointsProSeed.h:61
y
#define y
ITk::SiSpacePointForSeed::setQuality
void setQuality(float)
Definition: ITkSiSpacePointForSeed.cxx:145
ITk::SiSpacePointsProSeed::SiSpacePointsProSeed
SiSpacePointsProSeed()
Definition: ITkSiSpacePointsProSeed.cxx:15
ITk::SiSpacePointForSeed::x
const float & x() const
Definition: ITkSiSpacePointForSeed.h:62
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
S2
struct TBPatternUnitContext S2
ITk::SiSpacePointsProSeed::set2
void set2(InDet::SiSpacePointsSeed &)
Definition: ITkSiSpacePointsProSeed.cxx:71
extractSporadic.q
list q
Definition: extractSporadic.py:98
ITk::SiSpacePointForSeed::dzdr
const float & dzdr() const
Definition: ITkSiSpacePointForSeed.h:71
top
@ top
Definition: TruthClasses.h:64
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
makeComparison.deltaZ
int deltaZ
Definition: makeComparison.py:46
ITk::SiSpacePointForSeed::setDR
void setDR(const float &)
Definition: ITkSiSpacePointForSeed.cxx:75
ITk::SiSpacePointForSeed
Definition: ITkSiSpacePointForSeed.h:33
fitman.ay
ay
Definition: fitman.py:525