Project
Loading...
Searching...
No Matches
Ray.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "DetectorsBase/Ray.h"
16#include "GPUCommonMath.h"
17
18using namespace o2::base;
19using namespace o2::gpu;
20
21//______________________________________________________
22GPUd() int Ray::crossLayer(const MatLayerCyl& lr)
23{
24 // Calculate parameters t of intersection with cyl.layer
25 // Calculated as solution of equation for ray crossing with circles of r (rmin and rmax)
26 // t^2*mDistXY2 +- sqrt( mXDxPlusYDy^2 - mDistXY2*(mR02 - r^2) )
27 // Region of valid t is 0:1.
28 // Straigh line may have 2 crossings with cyl. layer
29 float detMax = mXDxPlusYDy2 - mDistXY2 * (mR02 - lr.getRMax2());
30 if (detMax < 0) {
31 return 0; // does not reach outer R, hence inner also
32 }
33 float detMaxRed = CAMath::Sqrt(detMax) * mDistXY2i;
34 float tCross0Max = mXDxPlusYDyRed + detMaxRed; // largest possible t
35
36 if (tCross0Max < 0) { // max t is outside of the limiting point -> other t's also
37 return 0;
38 }
39
40 float tCross0Min = mXDxPlusYDyRed - detMaxRed; // smallest possible t
41 if (tCross0Min > 1.f) { // min t is outside of the limiting point -> other t's also
42 return 0;
43 }
44 float detMin = mXDxPlusYDy2 - mDistXY2 * (mR02 - lr.getRMin2());
45 if (detMin < 0) { // does not reach inner R -> just 1 tangential crossing
46 mCrossParams1[0] = tCross0Min > 0.f ? tCross0Min : 0.f;
47 mCrossParams2[0] = tCross0Max < 1.f ? tCross0Max : 1.f;
48 return validateZRange(mCrossParams1[0], mCrossParams2[0], lr);
49 }
50 int nCross = 0;
51 float detMinRed = CAMath::Sqrt(detMin) * mDistXY2i;
52 float tCross1Max = mXDxPlusYDyRed + detMinRed;
53 float tCross1Min = mXDxPlusYDyRed - detMinRed;
54
55 if (tCross1Max < 1.f) {
56 mCrossParams1[0] = tCross0Max < 1.f ? tCross0Max : 1.f;
57 mCrossParams2[0] = tCross1Max > 0.f ? tCross1Max : 0.f;
58 if (validateZRange(mCrossParams1[nCross], mCrossParams2[nCross], lr)) {
59 nCross++;
60 }
61 }
62
63 if (tCross1Min > -0.f) {
64 mCrossParams1[nCross] = tCross1Min < 1.f ? tCross1Min : 1.f;
65 mCrossParams2[nCross] = tCross0Min > 0.f ? tCross0Min : 0.f;
66 if (validateZRange(mCrossParams1[nCross], mCrossParams2[nCross], lr)) {
67 nCross++;
68 }
69 }
70 return nCross;
71}
GPUd() int Ray
Definition Ray.cxx:22