Project
Loading...
Searching...
No Matches
TrackletTransformer.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
15#include "TMath.h"
16
17using namespace o2::trd;
18using namespace o2::trd::constants;
19
21{
22 mGeo = Geometry::instance();
23 mGeo->createPadPlaneArray();
25
26 // 3.35 cm
27 mXAnode = mGeo->cdrHght() + mGeo->camHght() / 2;
28}
29
30float TrackletTransformer::calculateZ(int padrow, const PadPlane* padPlane) const
31{
32 double rowPos = padPlane->getRowPos(padrow);
33 double rowSize = padPlane->getRowSize(padrow);
34 double middleRowPos = padPlane->getRowPos(padPlane->getNrows() / 2);
35
36 return rowPos - rowSize / 2. - middleRowPos;
37}
38
39float TrackletTransformer::calculateDy(int detector, int slope, const PadPlane* padPlane) const
40{
41 double padWidth = padPlane->getWidthIPad();
42
43 float vDrift = mCalVdriftExB->getVdrift(detector);
44 float exb = mCalVdriftExB->getExB(detector);
45
46 // dy = slope * nTimeBins * padWidth * GRANULARITYTRKLSLOPE;
47 // nTimeBins should be number of timebins in drift region. 1 timebin is 100 nanosecond
48 double rawDy = slope * ((mGeo->cdrHght() / vDrift) * 10.) * padWidth * GRANULARITYTRKLSLOPE / ADDBITSHIFTSLOPE;
49
50 // NOTE: check what drift height is used in calibration code to ensure consistency
51 // NOTE: check sign convention of Lorentz angle
52 // NOTE: confirm the direction in which vDrift is measured/determined. Is it in x or in direction of drift?
53 // The Lorentz correction have to be applied both at the point of entrance and at the end of the drift region
54 double lorentzCorrection = TMath::Tan(exb) * mGeo->cdrHght();
55
56 // assuming angle in Bailhache, fig. 4.17 would be positive in our calibration code
57 double calibratedDy = rawDy - lorentzCorrection;
58
59 return calibratedDy;
60}
61
63{
64 // Hard-coded value will be replaced once t0 calibration is available from CCDB
65 float t0Correction = -0.279;
66 return x += t0Correction;
67}
68
69std::array<float, 3> TrackletTransformer::transformL2T(int detector, std::array<double, 3> point) const
70{
71 auto transformationMatrix = mGeo->getMatrixT2L(detector);
72
73 ROOT::Math::Impl::Transform3D<double>::Point localPoint(point[0], point[1], point[2]);
74 auto gobalPoint = transformationMatrix ^ localPoint;
75
76 return {(float)gobalPoint.x(), (float)gobalPoint.y(), (float)gobalPoint.z()};
77}
78
80{
81 auto detector = tracklet.getDetector();
82 auto hcid = tracklet.getHCID();
83 auto padrow = tracklet.getPadRow();
84 auto column = tracklet.getColumn();
85 int position;
86 int slope;
87 if (mApplyXOR) {
88 position = tracklet.getPosition() ^ 0x80;
89 if (position & (1 << (constants::NBITSTRKLPOS - 1))) {
90 position = -((~(position - 1)) & ((1 << constants::NBITSTRKLPOS) - 1));
91 }
92 slope = tracklet.getSlope() ^ 0x80;
93 if (slope & (1 << (constants::NBITSTRKLSLOPE - 1))) {
94 slope = -((~(slope - 1)) & ((1 << constants::NBITSTRKLSLOPE) - 1));
95 }
96 } else {
97 position = tracklet.getPositionBinSigned();
98 slope = tracklet.getSlopeBinSigned();
99 }
100
101 // calculate raw local chamber space point
102 const auto padPlane = mGeo->getPadPlane(detector);
103
104 // 5mm below cathode plane to reduce error propogation from tracklet fit and driftV
105 float x = mGeo->cdrHght() - 0.5;
106 float y = tracklet.getUncalibratedY(mApplyShift);
107 float z = calculateZ(padrow, padPlane);
108
109 float dy = calculateDy(detector, slope, padPlane);
110
111 float calibratedX = calibrateX(x);
112
113 // NOTE: Correction to y position based on x calibration NOT YET implemented. Need t0.
114 if (trackingFrame) {
115 std::array<float, 3> sectorSpacePoint = transformL2T(detector, std::array<double, 3>{calibratedX, y, z});
116 LOG(debug) << "x: " << sectorSpacePoint[0] << " | "
117 << "y: " << sectorSpacePoint[1] << " | "
118 << "z: " << sectorSpacePoint[2];
119 return CalibratedTracklet(sectorSpacePoint[0], sectorSpacePoint[1], sectorSpacePoint[2], dy);
120 } else {
121 return CalibratedTracklet(calibratedX, y, z, dy); // local frame
122 }
123}
124
125double TrackletTransformer::getTimebin(int detector, double x) const
126{
127 // calculate timebin from x position within chamber
128 float vDrift = mCalVdriftExB->getVdrift(detector);
129 double t0 = 4.0; // time (in timebins) of start of drift region
130
131 double timebin;
132 // x = 0 at anode plane and points toward pad plane.
133 if (x < -mGeo->camHght() / 2) {
134 // drift region
135 timebin = t0 - (x + mGeo->camHght() / 2) / (vDrift * 0.1);
136 } else {
137 // anode region: very rough guess
138 timebin = t0 - 1.0 + fabs(x);
139 }
140
141 return timebin;
142}
Global TRD definitions and constants.
Definition of the GeometryManager class.
std::ostringstream debug
uint16_t slope
Definition RawData.h:1
uint32_t padrow
Definition RawData.h:5
const Mat3D & getMatrixT2L(int sensID) const
float getExB(int iDet, bool defaultAvg=true) const
float getVdrift(int iDet, bool defaultAvg=true) const
void createPadPlaneArray()
Definition Geometry.cxx:55
bool createClusterMatrixArray()
static Geometry * instance()
Definition Geometry.h:33
CalibratedTracklet transformTracklet(Tracklet64 tracklet, bool trackingFrame=true) const
double getTimebin(int detector, double x) const
float calculateZ(int padrow, const PadPlane *padPlane) const
std::array< float, 3 > transformL2T(int hcid, std::array< double, 3 > spacePoint) const
float calculateDy(int hcid, int slope, const PadPlane *padPlane) const
GLint GLenum GLint x
Definition glcorearb.h:403
GLint y
Definition glcorearb.h:270
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr int NBITSTRKLSLOPE
number of bits for slope in tracklet64 word
Definition Constants.h:65
constexpr float GRANULARITYTRKLSLOPE
granularity of slope in tracklet64 word in pads/timebin
Definition Constants.h:70
constexpr int NBITSTRKLPOS
number of bits for position in tracklet64 word
Definition Constants.h:64
constexpr int ADDBITSHIFTSLOPE
in the TRAP the slope is shifted by 3 additional bits compared to the position
Definition Constants.h:66
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"