Project
Loading...
Searching...
No Matches
testCoordinateTransforms.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
16#define BOOST_TEST_MODULE Test CoordinateTransforms
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
20#include <iostream>
21#include <numeric>
22
25
26#include "TRDBase/PadPlane.h"
28#include "TRDBase/Geometry.h"
29
30namespace o2
31{
32namespace trd
33{
34
35using namespace o2::trd::constants;
36using namespace std;
37
38void testRCPoint(double calculatedPoint, double predictedPoint)
39{
40 float e = 0.000001;
41 BOOST_CHECK(fabs(predictedPoint - calculatedPoint) <= e);
42}
43
45{
46 auto mGeo = o2::trd::Geometry::instance();
47 mGeo->createPadPlaneArray();
48
49 int hcid = 776;
50 // This C1 chamber has 16 pad rows with I pad length = 90mm and O pad length = 75mm
51 int detector = hcid / 2;
52 int stack = mGeo->getStack(detector);
53 int layer = mGeo->getLayer(detector);
54
55 auto padPlane = mGeo->getPadPlane(layer, stack);
56 double lengthIPad = padPlane->getLengthIPad();
57 double lengthOPad = padPlane->getLengthOPad();
58
59 double padIWidth = padPlane->getWidthIPad();
60 double padOWidth = padPlane->getWidthOPad();
61
62 double tiltingAngle = padPlane->getTiltingAngle();
63
64 // Test padrows
65 auto p1 = padPlane->getPadRow(0);
66 // Center of the chamber. This should return the lower edge of padrow 8.
67 // Since we are using float values, the lower edge of padrow 8 correspond with float value 8.0.
68 testRCPoint(p1, 8.);
69
70 auto p2 = padPlane->getPadRow(lengthIPad / 2.);
71 // With an I pad length of 9 cm, 9. / 2. should put us half way into the preceeding pad (pad 7) since padrow number
72 // decreses in positive z direction.
73 testRCPoint(p2, 7.5);
74
75 auto p3 = padPlane->getPadRow(-lengthIPad / 2.);
76 // Same as above but in the other direction.
77 testRCPoint(p3, 8.5);
78
79 auto p4 = padPlane->getPadRow(lengthIPad * 4.2);
80 // Arbitrary distance in z.
81 testRCPoint(p4, 8 - 4.2);
82
83 auto p5 = padPlane->getPadRow(lengthIPad * 7 + lengthOPad);
84 // Lower border case. Take center and add 7 pads * 9 cm + 1 pad * 7.5 cm.
85 testRCPoint(p5, 0);
86
87 auto p6 = padPlane->getPadRow(-lengthIPad * 7 - lengthOPad);
88 // Upper border case. Take center and subtract 7 pads * 9 cm - 1 pad * 7.5 cm.
89 testRCPoint(p6, 16);
90
91 // Test pads with pad tilting
92 double p13 = padPlane->getPad(0, 0.01);
93 // Center of chamber plus epsilon (in z). Note the discontinuity in pad vs. z at z=0. This puts us at a point on the lower
94 // (in z direction) end of padrow 7. Since we have a pad tilt of -2 deg (pads tilted clockwise for particle coming
95 // from interaction vertex). After a lot thought and doodles on Miro (https://miro.com/app/board/o9J_lKgybMc=/) we
96 // find that we expect a small negative offset which would place us in the upper half of pad 71.
97 // To calculate that offset, we multiply the tangent of the tilting angle by the distance that our point is away
98 // from the center of its local padrow. Some unit conversions are also neccessary...
99 testRCPoint(p13, 72 + TMath::Tan(TMath::DegToRad() * tiltingAngle) * (0.5 * lengthIPad - 0.01) / padIWidth);
100
101 double p14 = padPlane->getPad(0, -lengthIPad / 2.);
102 // Move from center of chamber to to center of padrow 8 = 8.5.
103 // This should now place us as edge of pad 72 = 72.0 since no offset is applied from pad tilt.
104 testRCPoint(p14, 72);
105
106 double p15 = padPlane->getPad(0, lengthIPad / 2.);
107 // Should be the same in the other direction at padrow = 7.5
108 testRCPoint(p15, 72);
109
110 double p16 = padPlane->getPad(padIWidth * 42, lengthIPad / 2.);
111 // Adding an arbitrary number of pads should just increase position by same number
112 testRCPoint(p16, 72 + 42);
113
114 double p17 = padPlane->getPad(padIWidth * 42, -lengthIPad * 4 - 2.3);
115 // Moving to arbitrary point in both y and z. In y, we are 42 pads from the center which would be 72 + 42 = 114
116 // if we were in the center of the padrow and no pad tilting is considered. However, we are not in the center of
117 // a padrow, but rather 2.3 cm into padrow 8 + 4 = 12. This puts us below the center which is at 4.5 cm
118 // into the padrow and therefore, we expect a small postiive offset since the pad tilting angle is -2 deg.
119 testRCPoint(p17, 72 + 42 + TMath::Tan(TMath::DegToRad() * tiltingAngle) * (2.3 - 0.5 * lengthIPad) / padIWidth);
120
121 double p18 = padPlane->getPad(padIWidth * 71 + padOWidth, lengthIPad / 2.);
122 // Border case right on the upper edge of the padrow in y direction and at the center of the padrow in z
123 testRCPoint(p18, 144);
124
125 double p19 = padPlane->getPad(-padIWidth * 71 - padOWidth, lengthIPad / 2.);
126 // Border case right on the lower edge of the padrow in y direction and at the center of the padrow in z
127 testRCPoint(p19, 0);
128
129 double p20 = padPlane->getPad(0, lengthIPad * 7 + 1.5);
130 // Ensure that shorter length of outer padrows is considered correctly
131 testRCPoint(p20, 72 + TMath::Tan(TMath::DegToRad() * tiltingAngle) * (0.5 * lengthOPad - 1.5) / padIWidth);
132}
133
134} // namespace trd
135} // namespace o2
Global TRD definitions and constants.
Definition of the GeometryManager class.
constexpr int p2()
constexpr int p1()
constexpr to accelerate the coordinates changing
uint32_t stack
Definition RawData.h:1
static Geometry * instance()
Definition Geometry.h:33
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
void testRCPoint(double calculatedPoint, double predictedPoint)
BOOST_AUTO_TEST_CASE(TRDDigit_test)
Definition testDigit.cxx:48
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
BOOST_CHECK(tree)