Moving the destructor to the implementation file
[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
1a1fdef7 24// rings. This is used by AliFMDDetector and AliFMDGeometry.
4347b38f 25//
1a1fdef7 26// The AliFMDGeometry object owns the AliFMDRing objects, and the
27// AliFMDDetector objects reference these. That is, the AliFMDRing
28// objects are share amoung the AliFMDDetector objects.
4347b38f 29//
30// Latest changes by Christian Holm Christensen
31//
5edc364e 32
02a27b50 33// #include <AliLog.h> // ALILOG_H
e802be3e 34#include "AliFMDRing.h" // ALIFMDRING_H
02a27b50 35// #include <TMath.h> // ROOT_TMath
56b1929b 36#include <TVector2.h> // ROOT_TVector2
4347b38f 37
1a1fdef7 38//====================================================================
e6a0eb08 39ClassImp(AliFMDRing)
1a1fdef7 40#if 0
41 ; // This is here to keep Emacs for indenting the next line
42#endif
4347b38f 43
44//____________________________________________________________________
1a1fdef7 45AliFMDRing::AliFMDRing(Char_t id)
46 : TNamed(Form("FMD%c", id), "Forward multiplicity ring"),
47 fId(id),
48 fVerticies(0)
4347b38f 49{
088f8e79 50 // CTOR
1a1fdef7 51 SetBondingWidth();
52 SetWaferRadius();
53 SetSiThickness();
54 SetLegRadius();
55 SetLegLength();
56 SetLegOffset();
57 SetModuleSpacing();
58 SetPrintboardThickness();
4ac75127 59 SetCopperThickness();
60 SetChipThickness();
a1f80595 61 SetSpacing();
4347b38f 62
1a1fdef7 63 if (fId == 'I' || fId == 'i') {
64 SetLowR(4.3);
65 SetHighR(17.2);
66 SetTheta(36/2);
67 SetNStrips(512);
68 }
69 else if (fId == 'O' || fId == 'o') {
70 SetLowR(15.6);
71 SetHighR(28.0);
72 SetTheta(18/2);
73 SetNStrips(256);
4347b38f 74 }
4347b38f 75}
76
4347b38f 77//____________________________________________________________________
78void
1a1fdef7 79AliFMDRing::Init()
4347b38f 80{
088f8e79 81 // Initialize
1a1fdef7 82 Double_t tanTheta = TMath::Tan(fTheta * TMath::Pi() / 180.);
83 Double_t tanTheta2 = TMath::Power(tanTheta,2);
84 Double_t r2 = TMath::Power(fWaferRadius,2);
85 Double_t yA = tanTheta * fLowR;
86 Double_t lr2 = TMath::Power(fLowR, 2);
87 Double_t hr2 = TMath::Power(fHighR,2);
88 Double_t xD = fLowR + TMath::Sqrt(r2 - tanTheta2 * lr2);
89 Double_t xD2 = TMath::Power(xD,2);
90 Double_t yB = TMath::Sqrt(r2 - hr2 + 2 * fHighR * xD - xD2);
91 Double_t xC = ((xD + TMath::Sqrt(-tanTheta2 * xD2 + r2
92 + r2 * tanTheta2))
93 / (1 + tanTheta2));
94 Double_t yC = tanTheta * xC;
4347b38f 95
1a1fdef7 96 fVerticies.Expand(6);
97 fVerticies.AddAt(new TVector2(fLowR, -yA), 0);
98 fVerticies.AddAt(new TVector2(xC, -yC), 1);
99 fVerticies.AddAt(new TVector2(fHighR, -yB), 2);
100 fVerticies.AddAt(new TVector2(fHighR, yB), 3);
101 fVerticies.AddAt(new TVector2(xC, yC), 4);
102 fVerticies.AddAt(new TVector2(fLowR, yA), 5);
103
54e415a8 104 // A's length. Corresponds to distance from nominal beam line to the
105 // cornor of the active silicon element.
106 fMinR = GetVertex(5)->Mod();
107 // A's length. Corresponds to distance from nominal beam line to the
108 // cornor of the active silicon element.
109 fMaxR = fHighR;
110
1a1fdef7 111 fRingDepth = (fSiThickness + fPrintboardThickness
4ac75127 112 + fCopperThickness + fChipThickness
113 + fLegLength + fModuleSpacing + fSpacing);
4347b38f 114}
115
116//____________________________________________________________________
1a1fdef7 117TVector2*
118AliFMDRing::GetVertex(Int_t i) const
4347b38f 119{
088f8e79 120 // Get the i'th vertex of polygon shape
1a1fdef7 121 return static_cast<TVector2*>(fVerticies.At(i));
4347b38f 122}
123
124//____________________________________________________________________
bf000c32 125Double_t
126AliFMDRing::GetStripRadius(UShort_t strip) const
127{
128 // Return the nominal strip radius
129 Double_t rmax = GetMaxR();
130 Double_t stripoff = GetMinR();
131 Double_t dstrip = (rmax - stripoff) / GetNStrips();
132 return (strip + .5) * dstrip + stripoff; // fLowR
133}
134
135//____________________________________________________________________
1a1fdef7 136void
137AliFMDRing::Detector2XYZ(UShort_t sector,
138 UShort_t strip,
139 Double_t& x,
140 Double_t& y,
141 Double_t& z) const
4347b38f 142{
088f8e79 143 // Translate detector coordinates (this,sector,strip) to global
144 // coordinates (x,y,z)
1a1fdef7 145 if (sector >= GetNSectors()) {
146 Error("Detector2XYZ", "Invalid sector number %d (>=%d) in ring %c",
147 sector, GetNSectors(), fId);
148 return;
4347b38f 149 }
1a1fdef7 150 if (strip >= GetNStrips()) {
151 Error("Detector2XYZ", "Invalid strip number %d (>=%d)",
152 strip, GetNStrips(), fId);
153 return;
4347b38f 154 }
1a1fdef7 155 Double_t phi = Float_t(sector + .5) / GetNSectors() * 2 * TMath::Pi();
156 Double_t r = Float_t(strip + .5) / GetNStrips() * (fHighR - fLowR) + fLowR;
157 x = r * TMath::Cos(phi);
158 y = r * TMath::Sin(phi);
159 if (((sector / 2) % 2) == 1)
160 z += TMath::Sign(fModuleSpacing, z);
4347b38f 161}
162
54e415a8 163//____________________________________________________________________
164Bool_t
165AliFMDRing::XYZ2Detector(Double_t x,
166 Double_t y,
167 Double_t z,
168 UShort_t& sector,
169 UShort_t& strip) const
170{
088f8e79 171 // Translate global coordinates (x,y,z) to detector coordinates
172 // (this,sector,strip)
54e415a8 173 sector = strip = 0;
174 Double_t r = TMath::Sqrt(x * x + y * y);
175 Int_t str = Int_t((r - fMinR) / GetPitch());
176 if (str < 0 || str >= GetNStrips()) return kFALSE;
177
178 Double_t phi = TMath::ATan2(y, x) * 180. / TMath::Pi();
179 if (phi < 0) phi = 360. + phi;
180 Int_t sec = Int_t(phi / fTheta);
181 if (sec < 0 || sec >= GetNSectors()) return kFALSE;
182 if ((sec / 2) % 2 == 1) {
183 if (TMath::Abs(z - TMath::Sign(fModuleSpacing, z)) >= 0.01)
184 return kFALSE;
185 }
186 else if (TMath::Abs(z) >= 0.01) return kFALSE;
187
188 strip = str;
189 sector = sec;
190 return kTRUE;
191}
192
193
4347b38f 194//
195// EOF
196//