Updates (N. Bastid)
[u/mrichter/AliRoot.git] / FMD / AliFMDRing.cxx
CommitLineData
4347b38f 1/**************************************************************************
c4bcfd14 2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4347b38f 3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
4347b38f 15/* $Id$ */
c2fc1258 16/** @file AliFMDRing.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:47:43 2006
19 @brief FMD ring geometry parameters
20*/
c4bcfd14 21//__________________________________________________________________
4347b38f 22//
23// Utility class to help implement collection of FMD modules into
6169f936 24// rings. This is used by AliFMDDetector and AliFMDGeometry.
1a1fdef7 25// The AliFMDGeometry object owns the AliFMDRing objects, and the
26// AliFMDDetector objects reference these. That is, the AliFMDRing
27// objects are share amoung the AliFMDDetector objects.
4347b38f 28//
29// Latest changes by Christian Holm Christensen
30//
5edc364e 31
02a27b50 32// #include <AliLog.h> // ALILOG_H
e802be3e 33#include "AliFMDRing.h" // ALIFMDRING_H
02a27b50 34// #include <TMath.h> // ROOT_TMath
56b1929b 35#include <TVector2.h> // ROOT_TVector2
4347b38f 36
1a1fdef7 37//====================================================================
e6a0eb08 38ClassImp(AliFMDRing)
1a1fdef7 39#if 0
40 ; // This is here to keep Emacs for indenting the next line
41#endif
4347b38f 42
43//____________________________________________________________________
1a1fdef7 44AliFMDRing::AliFMDRing(Char_t id)
45 : TNamed(Form("FMD%c", id), "Forward multiplicity ring"),
46 fId(id),
47 fVerticies(0)
4347b38f 48{
088f8e79 49 // CTOR
1a1fdef7 50 SetBondingWidth();
51 SetWaferRadius();
52 SetSiThickness();
53 SetLegRadius();
54 SetLegLength();
55 SetLegOffset();
56 SetModuleSpacing();
57 SetPrintboardThickness();
4ac75127 58 SetCopperThickness();
59 SetChipThickness();
a1f80595 60 SetSpacing();
4347b38f 61
1a1fdef7 62 if (fId == 'I' || fId == 'i') {
63 SetLowR(4.3);
64 SetHighR(17.2);
65 SetTheta(36/2);
66 SetNStrips(512);
67 }
68 else if (fId == 'O' || fId == 'o') {
69 SetLowR(15.6);
70 SetHighR(28.0);
71 SetTheta(18/2);
72 SetNStrips(256);
4347b38f 73 }
4347b38f 74}
75
4347b38f 76//____________________________________________________________________
77void
1a1fdef7 78AliFMDRing::Init()
4347b38f 79{
088f8e79 80 // Initialize
1a1fdef7 81 Double_t tanTheta = TMath::Tan(fTheta * TMath::Pi() / 180.);
82 Double_t tanTheta2 = TMath::Power(tanTheta,2);
83 Double_t r2 = TMath::Power(fWaferRadius,2);
84 Double_t yA = tanTheta * fLowR;
85 Double_t lr2 = TMath::Power(fLowR, 2);
86 Double_t hr2 = TMath::Power(fHighR,2);
87 Double_t xD = fLowR + TMath::Sqrt(r2 - tanTheta2 * lr2);
88 Double_t xD2 = TMath::Power(xD,2);
89 Double_t yB = TMath::Sqrt(r2 - hr2 + 2 * fHighR * xD - xD2);
90 Double_t xC = ((xD + TMath::Sqrt(-tanTheta2 * xD2 + r2
91 + r2 * tanTheta2))
92 / (1 + tanTheta2));
93 Double_t yC = tanTheta * xC;
4347b38f 94
1a1fdef7 95 fVerticies.Expand(6);
96 fVerticies.AddAt(new TVector2(fLowR, -yA), 0);
97 fVerticies.AddAt(new TVector2(xC, -yC), 1);
98 fVerticies.AddAt(new TVector2(fHighR, -yB), 2);
99 fVerticies.AddAt(new TVector2(fHighR, yB), 3);
100 fVerticies.AddAt(new TVector2(xC, yC), 4);
101 fVerticies.AddAt(new TVector2(fLowR, yA), 5);
102
54e415a8 103 // A's length. Corresponds to distance from nominal beam line to the
104 // cornor of the active silicon element.
105 fMinR = GetVertex(5)->Mod();
106 // A's length. Corresponds to distance from nominal beam line to the
107 // cornor of the active silicon element.
108 fMaxR = fHighR;
109
1a1fdef7 110 fRingDepth = (fSiThickness + fPrintboardThickness
4ac75127 111 + fCopperThickness + fChipThickness
112 + fLegLength + fModuleSpacing + fSpacing);
4347b38f 113}
114
115//____________________________________________________________________
1a1fdef7 116TVector2*
117AliFMDRing::GetVertex(Int_t i) const
4347b38f 118{
088f8e79 119 // Get the i'th vertex of polygon shape
1a1fdef7 120 return static_cast<TVector2*>(fVerticies.At(i));
4347b38f 121}
122
123//____________________________________________________________________
bf000c32 124Double_t
125AliFMDRing::GetStripRadius(UShort_t strip) const
126{
127 // Return the nominal strip radius
128 Double_t rmax = GetMaxR();
129 Double_t stripoff = GetMinR();
130 Double_t dstrip = (rmax - stripoff) / GetNStrips();
131 return (strip + .5) * dstrip + stripoff; // fLowR
132}
133
134//____________________________________________________________________
1a1fdef7 135void
136AliFMDRing::Detector2XYZ(UShort_t sector,
137 UShort_t strip,
138 Double_t& x,
139 Double_t& y,
140 Double_t& z) const
4347b38f 141{
088f8e79 142 // Translate detector coordinates (this,sector,strip) to global
143 // coordinates (x,y,z)
1a1fdef7 144 if (sector >= GetNSectors()) {
145 Error("Detector2XYZ", "Invalid sector number %d (>=%d) in ring %c",
146 sector, GetNSectors(), fId);
147 return;
4347b38f 148 }
1a1fdef7 149 if (strip >= GetNStrips()) {
150 Error("Detector2XYZ", "Invalid strip number %d (>=%d)",
151 strip, GetNStrips(), fId);
152 return;
4347b38f 153 }
1a1fdef7 154 Double_t phi = Float_t(sector + .5) / GetNSectors() * 2 * TMath::Pi();
155 Double_t r = Float_t(strip + .5) / GetNStrips() * (fHighR - fLowR) + fLowR;
156 x = r * TMath::Cos(phi);
157 y = r * TMath::Sin(phi);
158 if (((sector / 2) % 2) == 1)
159 z += TMath::Sign(fModuleSpacing, z);
4347b38f 160}
161
54e415a8 162//____________________________________________________________________
163Bool_t
164AliFMDRing::XYZ2Detector(Double_t x,
165 Double_t y,
166 Double_t z,
167 UShort_t& sector,
168 UShort_t& strip) const
169{
088f8e79 170 // Translate global coordinates (x,y,z) to detector coordinates
171 // (this,sector,strip)
54e415a8 172 sector = strip = 0;
173 Double_t r = TMath::Sqrt(x * x + y * y);
174 Int_t str = Int_t((r - fMinR) / GetPitch());
175 if (str < 0 || str >= GetNStrips()) return kFALSE;
176
177 Double_t phi = TMath::ATan2(y, x) * 180. / TMath::Pi();
178 if (phi < 0) phi = 360. + phi;
179 Int_t sec = Int_t(phi / fTheta);
180 if (sec < 0 || sec >= GetNSectors()) return kFALSE;
181 if ((sec / 2) % 2 == 1) {
182 if (TMath::Abs(z - TMath::Sign(fModuleSpacing, z)) >= 0.01)
183 return kFALSE;
184 }
185 else if (TMath::Abs(z) >= 0.01) return kFALSE;
186
187 strip = str;
188 sector = sec;
189 return kTRUE;
190}
191
192
4347b38f 193//
194// EOF
195//