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