]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDRing.cxx
Setting raw digits flag
[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   SetBondingWidth();
48   SetWaferRadius();
49   SetSiThickness();
50   SetLegRadius();
51   SetLegLength();
52   SetLegOffset();
53   SetModuleSpacing();
54   SetPrintboardThickness();
55   
56   if (fId == 'I' || fId == 'i') {
57     SetLowR(4.3);
58     SetHighR(17.2);
59     SetTheta(36/2);
60     SetNStrips(512);
61   }
62   else if (fId == 'O' || fId == 'o') {
63     SetLowR(15.6);
64     SetHighR(28.0);
65     SetTheta(18/2);
66     SetNStrips(256);
67   }
68 }
69
70 //____________________________________________________________________
71 void
72 AliFMDRing::Init()
73 {
74   Double_t tanTheta  = TMath::Tan(fTheta * TMath::Pi() / 180.);
75   Double_t tanTheta2 = TMath::Power(tanTheta,2);
76   Double_t r2        = TMath::Power(fWaferRadius,2);
77   Double_t yA        = tanTheta * fLowR;
78   Double_t lr2       = TMath::Power(fLowR, 2);
79   Double_t hr2       = TMath::Power(fHighR,2);
80   Double_t xD        = fLowR + TMath::Sqrt(r2 - tanTheta2 * lr2);
81   Double_t xD2       = TMath::Power(xD,2);
82   Double_t yB        = TMath::Sqrt(r2 - hr2 + 2 * fHighR * xD - xD2);
83   Double_t xC        = ((xD + TMath::Sqrt(-tanTheta2 * xD2 + r2
84                                           + r2 * tanTheta2)) 
85                         / (1 + tanTheta2));
86   Double_t yC        = tanTheta * xC;
87   
88   fVerticies.Expand(6);
89   fVerticies.AddAt(new TVector2(fLowR,  -yA), 0);
90   fVerticies.AddAt(new TVector2(xC,     -yC), 1);
91   fVerticies.AddAt(new TVector2(fHighR, -yB), 2);
92   fVerticies.AddAt(new TVector2(fHighR,  yB), 3);
93   fVerticies.AddAt(new TVector2(xC,      yC), 4);
94   fVerticies.AddAt(new TVector2(fLowR,   yA), 5);  
95
96   fRingDepth = (fSiThickness + fPrintboardThickness 
97                 + fLegLength + fModuleSpacing);
98 }
99
100 //____________________________________________________________________
101 TVector2*
102 AliFMDRing::GetVertex(Int_t i) const
103 {
104   return static_cast<TVector2*>(fVerticies.At(i));
105 }
106
107 //____________________________________________________________________
108 void
109 AliFMDRing::Detector2XYZ(UShort_t sector,
110                          UShort_t strip, 
111                          Double_t& x, 
112                          Double_t& y, 
113                          Double_t& z) const
114 {
115   if (sector >= GetNSectors()) {
116     Error("Detector2XYZ", "Invalid sector number %d (>=%d) in ring %c", 
117           sector, GetNSectors(), fId);
118     return;
119   }
120   if (strip >= GetNStrips()) {
121     Error("Detector2XYZ", "Invalid strip number %d (>=%d)", 
122           strip, GetNStrips(), fId);
123     return;
124   }
125   Double_t phi = Float_t(sector + .5) / GetNSectors() * 2 * TMath::Pi();
126   Double_t r   = Float_t(strip + .5) / GetNStrips() * (fHighR - fLowR) + fLowR;
127   x = r * TMath::Cos(phi);
128   y = r * TMath::Sin(phi);
129   if (((sector / 2) % 2) == 1) 
130     z += TMath::Sign(fModuleSpacing, z);
131 }
132
133 //
134 // EOF
135 //