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 double lorentzCorrection = TMath::Tan(exb) * mXAnode;
54
55 // assuming angle in Bailhache, fig. 4.17 would be positive in our calibration code
56 double calibratedDy = rawDy - lorentzCorrection;
57
58 return calibratedDy;
59}
60
62{
63 // Hard-coded value will be replaced once t0 calibration is available from CCDB
64 float t0Correction = -0.279;
65 return x += t0Correction;
66}
67
68std::array<float, 3> TrackletTransformer::transformL2T(int detector, std::array<double, 3> point) const
69{
70 auto transformationMatrix = mGeo->getMatrixT2L(detector);
71
72 ROOT::Math::Impl::Transform3D<double>::Point localPoint(point[0], point[1], point[2]);
73 auto gobalPoint = transformationMatrix ^ localPoint;
74
75 return {(float)gobalPoint.x(), (float)gobalPoint.y(), (float)gobalPoint.z()};
76}
77
79{
80 auto detector = tracklet.getDetector();
81 auto hcid = tracklet.getHCID();
82 auto padrow = tracklet.getPadRow();
83 auto column = tracklet.getColumn();
84 int position;
85 int slope;
86 if (mApplyXOR) {
87 position = tracklet.getPosition() ^ 0x80;
88 if (position & (1 << (constants::NBITSTRKLPOS - 1))) {
89 position = -((~(position - 1)) & ((1 << constants::NBITSTRKLPOS) - 1));
90 }
91 slope = tracklet.getSlope() ^ 0x80;
92 if (slope & (1 << (constants::NBITSTRKLSLOPE - 1))) {
93 slope = -((~(slope - 1)) & ((1 << constants::NBITSTRKLSLOPE) - 1));
94 }
95 } else {
96 position = tracklet.getPositionBinSigned();
97 slope = tracklet.getSlopeBinSigned();
98 }
99
100 // calculate raw local chamber space point
101 const auto padPlane = mGeo->getPadPlane(detector);
102
103 // 5mm below cathode plane to reduce error propogation from tracklet fit and driftV
104 float x = mGeo->cdrHght() - 0.5;
105 float y = tracklet.getUncalibratedY(mApplyShift);
106 float z = calculateZ(padrow, padPlane);
107
108 float dy = calculateDy(detector, slope, padPlane);
109
110 float calibratedX = calibrateX(x);
111
112 // NOTE: Correction to y position based on x calibration NOT YET implemented. Need t0.
113 if (trackingFrame) {
114 std::array<float, 3> sectorSpacePoint = transformL2T(detector, std::array<double, 3>{calibratedX, y, z});
115 LOG(debug) << "x: " << sectorSpacePoint[0] << " | "
116 << "y: " << sectorSpacePoint[1] << " | "
117 << "z: " << sectorSpacePoint[2];
118 return CalibratedTracklet(sectorSpacePoint[0], sectorSpacePoint[1], sectorSpacePoint[2], dy);
119 } else {
120 return CalibratedTracklet(calibratedX, y, z, dy); // local frame
121 }
122}
123
124double TrackletTransformer::getTimebin(int detector, double x) const
125{
126 // calculate timebin from x position within chamber
127 float vDrift = mCalVdriftExB->getVdrift(detector);
128 double t0 = 4.0; // time (in timebins) of start of drift region
129
130 double timebin;
131 // x = 0 at anode plane and points toward pad plane.
132 if (x < -mGeo->camHght() / 2) {
133 // drift region
134 timebin = t0 - (x + mGeo->camHght() / 2) / (vDrift * 0.1);
135 } else {
136 // anode region: very rough guess
137 timebin = t0 - 1.0 + fabs(x);
138 }
139
140 return timebin;
141}
Global TRD definitions and constants.
Definition of the GeometryManager class.
uint16_t slope
Definition RawData.h:1
uint32_t padrow
Definition RawData.h:5
std::ostringstream debug
const Mat3D & getMatrixT2L(int sensID) const
float getExB(int iDet) const
float getVdrift(int iDet) 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"