Project
Loading...
Searching...
No Matches
PadPlane.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
13// //
14// Describes a pad plane of a TRD ROC //
15// //
16// Contains the information on pad postions, pad dimensions, //
17// tilting angle, etc. //
18// It also provides methods to identify the current pad number from //
19// global coordinates. //
20// The numbering and coordinates should follow the official convention //
21// (see David Emschermanns note on TRD convention) //
22// //
24
25#include "TRDBase/PadPlane.h"
26#include <TMath.h>
27#include <fairlogger/Logger.h>
29
30using namespace o2::trd;
31using namespace o2::trd::constants;
32
33//_____________________________________________________________________________
35{
36 //
37 // Set the tilting angle of the pads
38 //
39
40 mTiltingAngle = t;
41 mTiltingTan = TMath::Tan(TMath::DegToRad() * mTiltingAngle);
42}
43
44//_____________________________________________________________________________
45int PadPlane::getPadRowNumberROC(double z) const
46{
47 //
48 // Finds the pad row number for a given z-position in local ROC system
49 //
50
51 int row = 0;
52 int nabove = 0;
53 int nbelow = 0;
54 int middle = 0;
55
56 if ((z > getRow0ROC()) || (z < getRowEndROC())) {
57 row = -1;
58
59 } else {
60 nabove = mNrows + 1;
61 nbelow = 0;
62 while (nabove - nbelow > 1) {
63 middle = (nabove + nbelow) / 2;
64 if (z == mPadRow[middle - 1]) {
65 row = middle;
66 }
67 if (z > mPadRow[middle - 1]) {
68 nabove = middle;
69 } else {
70 nbelow = middle;
71 }
72 }
73 row = nbelow - 1;
74 }
75
76 return row;
77}
78
79//_____________________________________________________________________________
80int PadPlane::getPadColNumber(double rphi) const
81{
82 //
83 // Finds the pad column number for a given rphi-position
84 //
85
86 int col = 0;
87 int nabove = 0;
88 int nbelow = 0;
89 int middle = 0;
90
91 if ((rphi < getCol0()) || (rphi > getColEnd())) {
92 col = -1;
93
94 } else {
95 nabove = mNcols;
96 nbelow = 0;
97 while (nabove - nbelow > 1) {
98 middle = (nabove + nbelow) / 2;
99 if (rphi == mPadCol[middle]) {
100 col = middle;
101 }
102 if (rphi > mPadCol[middle]) {
103 nbelow = middle;
104 } else {
105 nabove = middle;
106 }
107 }
108 col = nbelow;
109 }
110
111 return col;
112}
113
115{
116 if (n > MAXCOLS) {
117 LOG(fatal) << "MAXCOLS exceeded " << n << " > " << MAXCOLS;
118 }
119 mNcols = n;
120};
121
123{
124 if (n > MAXROWS) {
125 LOG(fatal) << "MAXROWS exceeded " << n << " > " << MAXROWS;
126 }
127 mNrows = n;
128};
129
130double PadPlane::getPadRow(double z) const
131{
132 double lengthCorr = mLengthIPad * mInverseLengthOPad;
133
134 // calculate position based on inner pad length
135 double padrow = -z * mInverseLengthIPad + mNrows * 0.5;
136
137 // correct row for outer pad rows
138 if (padrow <= 1.0) {
139 padrow = 1.0 - (1.0 - padrow) * lengthCorr;
140 }
141
142 if (padrow >= double(mNrows - 1)) {
143 padrow = double(mNrows - 1) + (padrow - double(mNrows - 1)) * lengthCorr;
144 }
145
146 // sanity check: is the padrow coordinate reasonable?
147 // assert(!(padrow < 0.0 || padrow > double(mNrows)));
148 if (padrow < 0.0) {
149 padrow = 0;
150 } else {
151 if (padrow > double(mNrows)) {
152 padrow = mNrows;
153 }
154 }
155
156 return padrow;
157}
158
159double PadPlane::getPad(double y, double z) const
160{
161 int padrow = getPadRow(z);
162 double padrowOffset = getPadRowOffsetROC(padrow, z);
163 double tiltOffsetY = getTiltOffset(padrow, padrowOffset);
164
165 double pad = y * mInverseWidthIPad + mNcols * 0.5;
166
167 double lengthCorr = mWidthIPad * mInverseWidthOPad;
168 // correct row for outer pad rows
169 if (pad <= 1.0) {
170 pad = 1.0 - (1.0 - pad) * lengthCorr;
171 }
172
173 if (pad >= double(mNcols - 1)) {
174 pad = double(mNcols - 1) + (pad - double(mNcols - 1)) * lengthCorr;
175 }
176
177 double tiltOffsetPad;
178 if (pad <= 1.0 || pad >= double(mNcols - 1)) {
179 tiltOffsetPad = tiltOffsetY * mInverseWidthOPad;
180 pad += tiltOffsetPad;
181 } else {
182 tiltOffsetPad = tiltOffsetY * mInverseWidthIPad;
183 pad += tiltOffsetPad;
184 }
185
186 // TODO come back and find why this assert fails on mac arm.
187 // assert(!(pad < 0.0 || pad > double(mNcols)));
188 if (pad < 0.0) {
189 pad = 0;
190 } else {
191 if (pad > double(mNcols)) {
192 pad = mNcols;
193 }
194 }
195
196 return pad;
197}
Global TRD definitions and constants.
uint32_t col
Definition RawData.h:4
uint32_t padrow
Definition RawData.h:5
void setNrows(int n)
Definition PadPlane.cxx:122
void setNcols(int n)
Definition PadPlane.cxx:114
void setTiltingAngle(double t)
Definition PadPlane.cxx:34
GLdouble n
Definition glcorearb.h:1982
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row