Project
Loading...
Searching...
No Matches
FairGeoTrap.cxx
Go to the documentation of this file.
1/********************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3 * *
4 * This software is distributed under the terms of the *
5 * GNU Lesser General Public Licence (LGPL) version 3, *
6 * copied verbatim in the file "LICENSE" *
7 ********************************************************************************/
8//*-- AUTHOR : Ilse Koenig
9//*-- Modified : 11/11/2003 by Ilse Koenig
10//*-- Modified : 16/05/99 by Ilse Koenig
11
13//
14// FairGeoTrap
15//
16// class for the GEANT shape TRAP
17//
18// The technical coordinate system of a TRAP, which sits in
19// CAVE and is not rotated, is the laboratory system.
20// The y-axis points from the smaller side to the larger one.
21// That's the same definitition as for a TRAP and different from
22// the Geant or ROOT definition for a TRAP.
23// Therefore a transformation is needed:
24// x-technical = - (x-Geant)
25// y-technical = - (y-Geant)
26// z-technical = z-Geant
27// This is stored in the data element intrinsicRot which is
28// created in the function calcVoluPosition(...)
29//
31#include "FairGeoTrap.h"
32
33#include "FairGeoTransform.h" // for FairGeoTransform
34#include "FairGeoVector.h" // for FairGeoVector
35#include "FairGeoVolume.h" // for FairGeoVolume
36
37#include <TArrayD.h> // for TArrayD
38#include <TMath.h> // for ATan, Pi, Sqrt, atan
39#include <TMathBase.h> // for Abs
40#include <TString.h> // for TString
41#include <iostream> // for operator<<, cout, etc
42
43using std::cout;
44
46
49 , intrinsicRot(FairGeoRotation())
50{
51 // constructor
52 fName = "TRAP";
53 nPoints = 8;
54 nParam = 11;
55 param = new TArrayD(nParam);
56 intrinsicRot.setElement(-1., 0);
57 intrinsicRot.setElement(-1., 4);
58}
59
61{
62 // destructor
63 delete param;
64 param = 0;
65 delete center;
66 center = 0;
67 delete position;
68 position = 0;
69}
70
72{
73 // calculates the parameters needed to create the shape
74 const Double_t fac = 20.;
75 const Double_t raddeg = 180. / TMath::Pi();
76 Double_t alpha, beta;
77 FairGeoVector cb, ct, dc;
78 for (Int_t i = 0; i < 4; i++) {
79 cb += *(volu->getPoint(i));
80 } // bottom plane
81 for (Int_t j = 4; j < 8; j++) {
82 ct += *(volu->getPoint(j));
83 } // top plane
84 dc = (ct - cb);
85 // cout << dc <<" "<< ct <<" "<< cb <<" "<< endl;
86 dc *= 0.25; // vector from bottom to top plane
87 dc.setX(-dc(0)); // GEANT coordinate system
88 dc.setY(-dc(1));
89 param->AddAt(TMath::Abs(dc(2)) / fac, 0);
90 alpha = TMath::ATan(TMath::Sqrt(dc(0) * dc(0) + dc(1) * dc(1)) / dc(2)) * raddeg;
91 if (TMath::Abs(alpha) < 0.0001) {
92 alpha = 0.0;
93 beta = 0.0;
94 } else {
95 if (TMath::Abs(dc(0)) < 0.0001) {
96 if (dc(1) > 0) {
97 beta = 90.0;
98 } else {
99 beta = 270.0;
100 }
101 } else {
102 beta = atan(dc(1) / dc(0)) * raddeg;
103 if (dc(0) < 0) {
104 beta = 180.0 + beta;
105 }
106 if (beta < 0) {
107 beta = 360.0 + beta;
108 }
109 }
110 }
111 param->AddAt(alpha, 1);
112 param->AddAt(beta, 2);
113 param->AddAt(((*(volu->getPoint(1)))(1) - (*(volu->getPoint(0)))(1)) / fac, 3);
114 param->AddAt(((*(volu->getPoint(1)))(0) - (*(volu->getPoint(2)))(0)) / fac, 4);
115 param->AddAt(((*(volu->getPoint(0)))(0) - (*(volu->getPoint(3)))(0)) / fac, 5);
116
117 Double_t a = TMath::ATan(((*(volu->getPoint(1)))(0) - (*(volu->getPoint(0)))(0) + (*(volu->getPoint(2)))(0)
118 - (*(volu->getPoint(3)))(0))
119 / 40. / param->At(3))
120 * raddeg;
121 if (TMath::Abs(a) <= 0.0001) {
122 param->AddAt(0., 6);
123 } else {
124 param->AddAt(a, 6);
125 }
126 param->AddAt(((*(volu->getPoint(5)))(1) - (*(volu->getPoint(4)))(1)) / fac, 7);
127 param->AddAt(((*(volu->getPoint(5)))(0) - (*(volu->getPoint(6)))(0)) / fac, 8);
128 param->AddAt(((*(volu->getPoint(4)))(0) - (*(volu->getPoint(7)))(0)) / fac, 9);
129 a = TMath::ATan(((*(volu->getPoint(5)))(0) - (*(volu->getPoint(4)))(0) + (*(volu->getPoint(6)))(0)
130 - (*(volu->getPoint(7)))(0))
131 / 40. / param->At(7))
132 * raddeg;
133 if (TMath::Abs(a) <= 0.0001) {
134 param->AddAt(0., 10);
135 } else {
136 param->AddAt(a, 10);
137 }
138 // check if coplanar
139 Double_t dx = (param->At(4) - param->At(5)) / param->At(3) * param->At(7) - (param->At(8) - param->At(9));
140 if (TMath::Abs(dx) >= 0.001) {
141 cout << "top and bottom plane are not coplanar for shape TRAP\n";
142 cout << "lenght in x-direction of top plane is changed\n";
143 cout << "old values: " << param->At(8) << " " << param->At(9) << "\n";
144 param->AddAt(param->At(8) + dx / 2., 8);
145 param->AddAt(param->At(9) - dx / 2., 9);
146 cout << "new values: " << param->At(8) << " " << param->At(9) << "\n";
147 }
148 return param;
149}
150
152{
153 // calls the function posInMother(...) to calculate the position of the
154 // volume in its mother
155 Double_t t[3] = {0., 0., 0.};
156 for (Int_t i = 0; i < 8; i++) {
157 t[0] += (*(volu->getPoint(i)))(0);
158 }
159 t[0] /= 8.;
160 t[1] =
161 ((*(volu->getPoint(1)))(1) + (*(volu->getPoint(0)))(1) + (*(volu->getPoint(5)))(1) + (*(volu->getPoint(4)))(1))
162 / 4.;
163 t[2] = ((*(volu->getPoint(4)))(2) + (*(volu->getPoint(0)))(2)) / 2.;
165 center->setRotMatrix(intrinsicRot);
166 posInMother(dTC, mTR);
167}
ClassImp(FairGeoTrap)
int32_t i
uint32_t j
Definition RawData.h:0
FairGeoTransform * center
void posInMother(const FairGeoTransform &, const FairGeoTransform &)
FairGeoTransform * position
void setElement(const Double_t, const Int_t)
void setTransVector(const FairGeoVector &t)
void setRotMatrix(const FairGeoRotation &r)
TArrayD * calcVoluParam(FairGeoVolume *)
void calcVoluPosition(FairGeoVolume *, const FairGeoTransform &, const FairGeoTransform &)
void setY(const Double_t a)
void setX(const Double_t a)
FairGeoVector * getPoint(const Int_t n)
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLenum GLfloat param
Definition glcorearb.h:271
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233