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
80{
81 if (n > MAXCOLS) {
82 LOG(fatal) << "MAXCOLS exceeded " << n << " > " << MAXCOLS;
83 }
84 mNcols = n;
85};
86
88{
89 if (n > MAXROWS) {
90 LOG(fatal) << "MAXROWS exceeded " << n << " > " << MAXROWS;
91 }
92 mNrows = n;
93};
94
95double PadPlane::getPadRow(double z) const
96{
97 double lengthCorr = mLengthIPad * mInverseLengthOPad;
98
99 // calculate position based on inner pad length
100 double padrow = -z * mInverseLengthIPad + mNrows * 0.5;
101
102 // correct row for outer pad rows
103 if (padrow <= 1.0) {
104 padrow = 1.0 - (1.0 - padrow) * lengthCorr;
105 }
106
107 if (padrow >= double(mNrows - 1)) {
108 padrow = double(mNrows - 1) + (padrow - double(mNrows - 1)) * lengthCorr;
109 }
110
111 // sanity check: is the padrow coordinate reasonable?
112 // assert(!(padrow < 0.0 || padrow > double(mNrows)));
113 if (padrow < 0.0) {
114 padrow = 0;
115 } else {
116 if (padrow > double(mNrows)) {
117 padrow = mNrows;
118 }
119 }
120
121 return padrow;
122}
123
124double PadPlane::getPad(double y, double z) const
125{
126 int padrow = getPadRow(z);
127 double padrowOffset = getPadRowOffsetROC(padrow, z);
128 double tiltOffsetY = getTiltOffset(padrow, padrowOffset);
129
130 double pad = y * mInverseWidthIPad + mNcols * 0.5;
131
132 double lengthCorr = mWidthIPad * mInverseWidthOPad;
133 // correct row for outer pad rows
134 if (pad <= 1.0) {
135 pad = 1.0 - (1.0 - pad) * lengthCorr;
136 }
137
138 if (pad >= double(mNcols - 1)) {
139 pad = double(mNcols - 1) + (pad - double(mNcols - 1)) * lengthCorr;
140 }
141
142 double tiltOffsetPad;
143 if (pad <= 1.0 || pad >= double(mNcols - 1)) {
144 tiltOffsetPad = tiltOffsetY * mInverseWidthOPad;
145 pad += tiltOffsetPad;
146 } else {
147 tiltOffsetPad = tiltOffsetY * mInverseWidthIPad;
148 pad += tiltOffsetPad;
149 }
150
151 // TODO come back and find why this assert fails on mac arm.
152 // assert(!(pad < 0.0 || pad > double(mNcols)));
153 if (pad < 0.0) {
154 pad = 0;
155 } else {
156 if (pad > double(mNcols)) {
157 pad = mNcols;
158 }
159 }
160
161 return pad;
162}
Global TRD definitions and constants.
uint32_t padrow
Definition RawData.h:5
void setNrows(int n)
Definition PadPlane.cxx:87
void setNcols(int n)
Definition PadPlane.cxx:79
void setTiltingAngle(double t)
Definition PadPlane.cxx:34
GLdouble n
Definition glcorearb.h:1982
GLint y
Definition glcorearb.h:270
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row