Project
Loading...
Searching...
No Matches
HitFinder.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
16
17#include "MIDBase/HitFinder.h"
18
19#include <cmath>
22
23namespace o2
24{
25namespace mid
26{
27//______________________________________________________________________________
29 : mGeometryTransformer(geoTrans),
30 mTanTheta(std::tan((90. - geoparams::BeamAngle) * std::atan(1) / 45.)),
31 mCosTheta(std::cos(geoparams::BeamAngle * std::atan(1) / 45.))
32{
34}
35
36//______________________________________________________________________________
37math_utils::Point3D<double> HitFinder::getIntersectInDefaultPlane(const Track& track, int chamber) const
38{
39 double defaultZ = geoparams::DefaultChamberZ[chamber];
40 double linePar = ((track.getPositionZ() - defaultZ) * mTanTheta - track.getPositionY()) /
41 (track.getDirectionY() - track.getDirectionZ() * mTanTheta);
43 point.SetX(track.getPositionX() + linePar * track.getDirectionX());
44 point.SetY(track.getPositionY() + linePar * track.getDirectionY());
45 point.SetZ(track.getPositionZ() + linePar * track.getDirectionZ());
46 return point;
47}
48
49//______________________________________________________________________________
50Cluster HitFinder::getIntersect(const Track& track, int deId) const
51{
52 math_utils::Point3D<float> localPoint = mGeometryTransformer.globalToLocal(deId, track.getPositionX(), track.getPositionY(), track.getPositionZ());
53
54 math_utils::Vector3D<float> localDirection = mGeometryTransformer.globalToLocal(deId, math_utils::Vector3D<float>(track.getDirectionX(), track.getDirectionY(), track.getDirectionZ()));
55 Track localTrack;
56 localTrack.setPosition(localPoint.x(), localPoint.y(), localPoint.z());
57 localTrack.setDirection(localDirection.x() / localDirection.z(), localDirection.y() / localDirection.z(), 1.);
58
59 localTrack.propagateToZ(0);
60 Cluster cluster;
61 cluster.deId = deId;
62 cluster.xCoor = localTrack.getPositionX();
63 cluster.yCoor = localTrack.getPositionY();
64 return cluster;
65}
66
67//______________________________________________________________________________
68int HitFinder::guessRPC(double yPos, int chamber) const
69{
70 return (int)(yPos / (2. * geoparams::getRPCHalfHeight(chamber)) + 4.5);
71}
72
73//______________________________________________________________________________
74std::vector<int> HitFinder::getFiredDE(const Track& track, int chamber) const
75{
76 std::vector<int> deIdList;
77 math_utils::Point3D<double> defPos = getIntersectInDefaultPlane(track, chamber);
78 double xPos = defPos.x();
79 double xErr = std::sqrt(track.getCovarianceParameter(Track::CovarianceParamIndex::VarX));
80 double yPos = defPos.y() / mCosTheta;
81 double yErr = std::sqrt(track.getCovarianceParameter(Track::CovarianceParamIndex::VarY));
82 double positions[3] = {yPos, yPos - yErr, yPos + yErr};
83 int centerRpc = -1;
84 for (int ipos = 0; ipos < 3; ++ipos) {
85 int rpc = guessRPC(positions[ipos], chamber);
86 if (rpc < 0 || rpc > 8) {
87 continue;
88 }
89 if (ipos == 0) {
90 centerRpc = rpc;
91 } else if (rpc == centerRpc) {
92 continue;
93 }
94 if (xPos > 0) {
95 deIdList.push_back(detparams::getDEId(true, chamber, rpc));
96 if (xPos - xErr < 0) {
97 deIdList.push_back(detparams::getDEId(false, chamber, rpc));
98 }
99 } else {
100 deIdList.push_back(detparams::getDEId(false, chamber, rpc));
101 if (xPos + xErr > 0) {
102 deIdList.push_back(detparams::getDEId(true, chamber, rpc));
103 }
104 }
105 }
106
107 return deIdList;
108}
109
110//______________________________________________________________________________
111std::vector<Cluster> HitFinder::getLocalPositions(const Track& track, int chamber, bool withUncertainties) const
112{
113 std::vector<int> deIdList = getFiredDE(track, chamber);
114
115 std::vector<Cluster> points;
116 for (auto& deId : deIdList) {
117 Cluster cl = getIntersect(track, deId);
118 int rpc = detparams::getRPCLine(deId);
119 double hl = geoparams::getRPCHalfLength(chamber, rpc);
120 double hh = geoparams::getRPCHalfHeight(chamber);
121 if (cl.xCoor < -hl || cl.xCoor > hl) {
122 continue;
123 }
124 if (cl.yCoor < -hh || cl.yCoor > hh) {
125 continue;
126 }
127 if (withUncertainties) {
128 addUncertainty(cl, track);
129 }
130 points.emplace_back(cl);
131 }
132
133 return points;
134}
135
136//______________________________________________________________________________
137void HitFinder::addUncertainty(Cluster& cl, Track track) const
138{
139 auto globalPos = mGeometryTransformer.localToGlobal(cl.deId, cl.xCoor, cl.yCoor);
140 track.propagateToZ(globalPos.z());
143}
144
145} // namespace mid
146} // namespace o2
Useful detector parameters for MID.
Useful geometrical parameters for MID.
Hit finder for MID.
HMPID cluster implementation.
Definition Cluster.h:27
math_utils::Point3D< T > localToGlobal(int deId, const math_utils::Point3D< T > &position) const
math_utils::Point3D< T > globalToLocal(int deId, const math_utils::Point3D< T > &position) const
std::vector< int > getFiredDE(const Track &track, int chamber) const
Definition HitFinder.cxx:74
std::vector< Cluster > getLocalPositions(const Track &track, int chamber, bool withUncertainties=false) const
HitFinder(const GeometryTransformer &geoTrans)
Definition HitFinder.cxx:28
This class defines the MID track.
Definition Track.h:30
float getDirectionY() const
Gets the track y direction.
Definition Track.h:48
bool propagateToZ(float zPosition)
Definition Track.cxx:65
float getDirectionX() const
Gets the track x direction.
Definition Track.h:46
@ VarX
Variance on X position.
@ VarY
Variance on Y position.
float getDirectionZ() const
Gets the track z direction.
Definition Track.h:50
float getPositionY() const
Gets the track y position.
Definition Track.h:35
float getCovarianceParameter(CovarianceParamIndex covParam) const
returns the covariance parameter covParam
Definition Track.h:70
float getPositionX() const
Gets the track x position.
Definition Track.h:33
float getPositionZ() const
Gets the track z position.
Definition Track.h:37
int getDEId(bool isRight, int chamber, int rpc)
constexpr std::array< const double, 4 > DefaultChamberZ
Array of default z position of the chamber.
double getRPCHalfHeight(int chamber)
double getRPCHalfLength(int chamber, int rpc)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
cluster structure for MID
Definition Cluster.h:30
float yErr
Cluster resolution along y.
Definition Cluster.h:35
float yCoor
y coordinate
Definition Cluster.h:32
float xErr
Cluster resolution along x.
Definition Cluster.h:34
float xCoor
x coordinate
Definition Cluster.h:31
uint8_t deId
Detection element ID.
Definition Cluster.h:36