Project
Loading...
Searching...
No Matches
GeometryTransformer.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
18
19#include <fstream>
20#include <string>
21#include "TMath.h"
22#include "TGeoVolume.h"
23#include "TGeoManager.h"
24#include "Math/GenVector/RotationX.h"
25#include "Math/GenVector/RotationY.h"
27
28namespace o2
29{
30namespace mid
31{
32
34{
37 mTransformations[deId] = matrix;
38}
39
41{
43 const double degToRad = TMath::DegToRad();
44 ROOT::Math::Rotation3D planeRot(ROOT::Math::RotationX(geoparams::BeamAngle * degToRad));
45 ROOT::Math::Translation3D planeTrans(0., 0., geoparams::DefaultChamberZ[ichamber]);
46 return planeTrans * planeRot;
47}
48
49ROOT::Math::Transform3D getDefaultRPCTransform(bool isRight, int chamber, int rpc)
50{
52 const double degToRad = TMath::DegToRad();
53 double angle = isRight ? 0. : 180.;
54 ROOT::Math::Rotation3D rot(ROOT::Math::RotationY(angle * degToRad));
55 double xSign = isRight ? 1. : -1.;
56 double xPos = xSign * geoparams::getRPCCenterPosX(chamber, rpc);
57 double sign = (rpc % 2 == 0) ? 1. : -1;
58 if (!isRight) {
59 sign *= -1.;
60 }
61 double zPos = sign * geoparams::RPCZShift;
62 double newZ = geoparams::DefaultChamberZ[0] + zPos;
63 double oldZ = geoparams::DefaultChamberZ[0] - zPos;
64 double yPos = geoparams::getRPCHalfHeight(chamber) * (rpc - 4) * (1. + newZ / oldZ);
65 ROOT::Math::Translation3D trans(xPos, yPos, zPos);
66 return trans * rot;
67}
68
70{
72 GeometryTransformer geoTrans;
73 for (int ich = 0; ich < detparams::NChambers; ++ich) {
74 for (int iside = 0; iside < 2; ++iside) {
75 bool isRight = (iside == 0);
76 for (int irpc = 0; irpc < detparams::NRPCLines; ++irpc) {
77 int deId = detparams::getDEId(isRight, ich, irpc);
79 geoTrans.setMatrix(deId, matrix);
80 }
81 }
82 }
83 return geoTrans;
84}
85
87{
89 GeometryTransformer geoTrans;
90 TGeoNavigator* navig = geoManager->GetCurrentNavigator();
91 for (int ide = 0; ide < detparams::NDetectionElements; ++ide) {
92 int ichamber = detparams::getChamber(ide);
93 std::stringstream volPath;
94 volPath << geoManager->GetTopVolume()->GetName() << "/";
95 if (geoManager->GetVolume("YOUT2")) {
96 volPath << "YOUT2_1/";
97 }
98 volPath << geoparams::getChamberVolumeName(ichamber) << "_1/" << geoparams::getRPCVolumeName(geoparams::getRPCType(ide), ichamber) << "_" << std::to_string(ide);
99 if (!navig->cd(volPath.str().c_str())) {
100 throw std::runtime_error("Could not get to volPathName=" + volPath.str());
101 }
102 geoTrans.setMatrix(ide, o2::math_utils::Transform3D{*(navig->GetCurrentMatrix())});
103 }
104 return geoTrans;
105}
106
107} // namespace mid
108} // namespace o2
Useful geometrical parameters for MID.
Geometry transformer for MID.
void setMatrix(int deId, const ROOT::Math::Transform3D &matrix)
GLfloat angle
Definition glcorearb.h:4071
constexpr int NDetectionElements
Number of RPCs.
constexpr int NChambers
Number of chambers.
constexpr int NRPCLines
Number of RPC lines.
int getDEId(bool isRight, int chamber, int rpc)
std::string getChamberVolumeName(int chamber)
constexpr double BeamAngle
Angle between beam position and horizontal.
std::string getRPCVolumeName(RPCtype type, int iChamber)
RPCtype getRPCType(int deId)
constexpr double RPCZShift
Default shift of the RPC z position with respect to the average chamber position.
constexpr std::array< const double, 4 > DefaultChamberZ
Array of default z position of the chamber.
double getRPCHalfHeight(int chamber)
double getRPCCenterPosX(int chamber, int rpc)
GeometryTransformer createTransformationFromManager(const TGeoManager *geoManager)
ROOT::Math::Transform3D getDefaultChamberTransform(int ichamber)
ROOT::Math::Transform3D getDefaultRPCTransform(bool isRight, int chamber, int rpc)
GeometryTransformer createDefaultTransformer()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52