Project
Loading...
Searching...
No Matches
TPCFastTransformGeo.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 "TPCFastTransformGeo.h"
18#include "FlatObject.h"
19#include "GPUCommonMath.h"
20#include "GPUCommonLogger.h"
21
22#include <iostream>
23
24using namespace o2::gpu;
25
27{
28 // Default Constructor: creates an empty uninitialized object
29 for (int32_t i = 0; i < NumberOfSectors; i++) {
30 double angle = (i + 0.5) * 2. * M_PI / NumberOfSectorsA;
31 mSectorInfos[i].sinAlpha = sin(angle);
32 mSectorInfos[i].cosAlpha = cos(angle);
33 }
34 mSectorInfos[NumberOfSectors] = SectorInfo{};
35
36 for (int32_t i = 0; i < MaxNumberOfRows + 1; i++) {
37 mRowInfos[i] = RowInfo{};
38 }
39}
40
42{
44
45 assert(numberOfRows >= 0 && numberOfRows < MaxNumberOfRows);
46
47 mConstructionMask = ConstructionState::InProgress;
48 mNumberOfRows = numberOfRows;
49
50 mTPCzLength = 0.f;
51
52 for (int32_t i = 0; i < MaxNumberOfRows; i++) {
53 mRowInfos[i] = RowInfo{};
54 }
55}
56
58{
60
61 assert(mConstructionMask & ConstructionState::InProgress);
62 assert(tpcZlength > 0.f);
63
64 mTPCzLength = tpcZlength;
65
66 mConstructionMask |= ConstructionState::GeometryIsSet;
67}
68
69void TPCFastTransformGeo::setTPCrow(int32_t iRow, float x, int32_t nPads, float padWidth)
70{
72 assert(mConstructionMask & ConstructionState::InProgress);
73 assert(iRow >= 0 && iRow < mNumberOfRows);
74 assert(nPads > 1);
75 assert(padWidth > 0.);
76
77 // Make scaled U = area between centers of the first and the last pad
78
79 // double uWidth = (nPads - 1) * padWidth;
80
81 // Make scaled U = area between the geometrical sector borders
82
83 const double sectorAngle = 2. * M_PI / NumberOfSectorsA;
84 const double scaleXtoRowWidth = 2. * tan(0.5 * sectorAngle);
85 double uWidth = x * scaleXtoRowWidth; // distance to the sector border
86
87 RowInfo& row = mRowInfos[iRow];
88 row.x = x;
89 row.maxPad = nPads - 1;
90 row.padWidth = padWidth;
91 row.yMin = -uWidth / 2.;
92}
93
95{
97
98 assert(mConstructionMask & ConstructionState::InProgress); // construction in process
99 assert(mConstructionMask & ConstructionState::GeometryIsSet); // geometry is set
100
101 for (int32_t i = 0; i < mNumberOfRows; i++) { // all TPC rows are initialized
102 assert(getRowInfo(i).maxPad > 0);
103 }
104
105 mConstructionMask = (uint32_t)ConstructionState::Constructed; // clear all other construction flags
106}
107
109{
111 LOG(info) << "TPC Fast Transformation Geometry: ";
112 LOG(info) << "mNumberOfRows = " << mNumberOfRows;
113 LOG(info) << "mTPCzLength = " << mTPCzLength;
114 LOG(info) << "TPC Rows : ";
115 for (int32_t i = 0; i < mNumberOfRows; i++) {
116 LOG(info) << " tpc row " << i << ": x = " << mRowInfos[i].x << " maxPad = " << mRowInfos[i].maxPad << " padWidth = " << mRowInfos[i].padWidth;
117 }
118}
119
120int32_t TPCFastTransformGeo::test(int32_t sector, int32_t row, float ly, float lz) const
121{
123
124 int32_t error = 0;
125
126 if (!isConstructed()) {
127 error = -1;
128 }
129 if (mNumberOfRows <= 0 || mNumberOfRows >= MaxNumberOfRows) {
130 error = -2;
131 }
132 float lx = getRowInfo(row).x;
133 float lx1 = 0.f, ly1 = 0.f, lz1 = 0.f;
134 float gx = 0.f, gy = 0.f, gz = 0.f;
135
136 convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
137 convGlobalToLocal(sector, gx, gy, gz, lx1, ly1, lz1);
138
139 if (fabs(lx1 - lx) > 1.e-4 || fabs(ly1 - ly) > 1.e-4 || fabs(lz1 - lz) > 1.e-7) {
140 LOG(info) << "Error local <-> global: x " << lx << " dx " << lx1 - lx << " y " << ly << " dy " << ly1 - ly << " z " << lz << " dz " << lz1 - lz;
141 error = -3;
142 }
143
144 float pad, length;
145 convLocalToPadDriftLength(sector, 10, ly, lz, pad, length);
146 float ly2, lz2;
147 convPadDriftLengthToLocal(sector, 10, pad, length, ly2, lz2);
148
149 if (fabs(ly2 - ly) + fabs(lz2 - lz) > 1.e-6) {
150 LOG(info) << "Error local <-> UV: y " << ly << " dy " << ly2 - ly << " z " << lz << " dz " << lz2 - lz;
151 error = -4;
152 }
153
154 if (error != 0) {
155 LOG(info) << "TPC Fast Transformation Geometry: Internal ERROR " << error;
156 }
157 return error;
158}
159
161{
163
164 return test(2, 5, 10., 10.); // test at an arbitrary position
165}
Definition of FlatObject class.
int32_t i
Definition of TPCFastTransformGeo class.
void finishConstruction()
Finishes initialization: puts everything to the flat buffer, releases temporary memory.
void setTPCzLength(float tpcZlength)
int32_t test() const
Method for testing consistency.
float float float float float & gy
TPCFastTransformGeo()
_____________ Constructors / destructors __________________________
void startConstruction(int32_t numberOfRows)
_______________ Construction interface ________________________
void setTPCrow(int32_t iRow, float x, int32_t nPads, float padWidth)
Initializes a TPC row.
bool isConstructed() const
Is the object constructed.
void print() const
Print method.
float float float float & gx
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLfloat angle
Definition glcorearb.h:4071
The struct contains necessary info about TPC padrow.
float x
nominal X coordinate of the padrow [cm]
int32_t maxPad
maximal pad number = n pads - 1
The struct contains necessary info for TPC sector.
float cosAlpha
cos of the angle between the local x and the global x
float sinAlpha
sin of the angle between the local x and the global x
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row