]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDDetector.cxx
Updated with modifications in AliMUONGeometryTransformer
[u/mrichter/AliRoot.git] / FMD / AliFMDDetector.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 the FMD geometry.  This provides
21 // the interface for the concrete geometry implementations of the FMD
22 // sub-detectors. 
23 //
24 // The AliFMDGeometry object owns the AliFMDDetector objects
25 //
26 // Latest changes by Christian Holm Christensen
27 //
28 #include "AliFMDDetector.h"     // ALIFMDSUBDETECTOR_H
29 #include "AliFMDRing.h"         // ALIFMDRING_H
30
31 //====================================================================
32 ClassImp(AliFMDDetector)
33 #if 0
34   ; // This is here to keep Emacs for indenting the next line
35 #endif
36
37 //____________________________________________________________________
38 AliFMDDetector::AliFMDDetector(Int_t id, AliFMDRing* inner, AliFMDRing* outer) 
39   : TNamed(Form("FMD%d", id), "Forward multiplicity ring"), 
40     fId(id), 
41     fInner(inner),
42     fOuter(outer)
43 {
44   // Constructor
45   // 
46   //   ID         Id of detector (1,2, or 3)
47   //   INNER      Inner ring geometry 
48   //   OUTER      Outer ring geometry (if any)
49   // 
50   SetHoneycombThickness();
51   SetAlThickness();
52   SetInnerHoneyLowR(0);
53   SetInnerHoneyHighR(0);
54   SetInnerZ(0);
55   SetOuterZ(0);
56   SetOuterHoneyLowR(0);
57   SetOuterHoneyHighR(0);
58 }
59
60 //____________________________________________________________________
61 AliFMDDetector::AliFMDDetector(const AliFMDDetector& other)
62   : TNamed(other), 
63     fId(other.fId),
64     fInner(other.fInner),
65     fOuter(other.fOuter)
66 {
67   // Copy constructor 
68   SetHoneycombThickness(other.GetHoneycombThickness());
69   SetAlThickness(other.GetAlThickness());
70   SetInnerHoneyLowR(other.GetInnerHoneyLowR());
71   SetInnerHoneyHighR(other.GetInnerHoneyHighR());
72   SetInnerZ(other.GetInnerZ());
73   SetOuterZ(other.GetOuterZ());
74   SetOuterHoneyLowR(other.GetOuterHoneyLowR());
75   SetOuterHoneyHighR(other.GetOuterHoneyHighR());
76 }
77
78 //____________________________________________________________________
79 AliFMDDetector&
80 AliFMDDetector::operator=(const AliFMDDetector& other)
81 {
82   // Assignment operator
83   SetName(other.GetName());
84   SetTitle(other.GetTitle());
85   fId    = other.fId;
86   fInner = other.fInner;
87   fOuter = other.fOuter;
88   SetHoneycombThickness(other.GetHoneycombThickness());
89   SetAlThickness(other.GetAlThickness());
90   SetInnerHoneyLowR(other.GetInnerHoneyLowR());
91   SetInnerHoneyHighR(other.GetInnerHoneyHighR());
92   SetInnerZ(other.GetInnerZ());
93   SetOuterZ(other.GetOuterZ());
94   SetOuterHoneyLowR(other.GetOuterHoneyLowR());
95   SetOuterHoneyHighR(other.GetOuterHoneyHighR());
96   return *this;
97 }
98
99 //____________________________________________________________________
100 void
101 AliFMDDetector::Init()
102 {
103   // Initialize. 
104   if (fInner) {
105     SetInnerHoneyLowR(fInner->GetLowR() + 1.);
106     SetInnerHoneyHighR(fInner->GetHighR() + 1.);
107   }
108   if (fOuter) {
109     SetOuterHoneyLowR(fOuter->GetLowR() + 1.);
110     SetOuterHoneyHighR(fOuter->GetHighR() + 1.);
111   }
112     
113 }
114
115 //____________________________________________________________________
116 AliFMDRing*
117 AliFMDDetector::GetRing(Char_t id) const
118 {
119   // Get the specified ring 
120   // 
121   //   ID      Id of ring ('I' or 'O')
122   // 
123   switch (id) {
124   case 'i':
125   case 'I': return GetInner();
126   case 'o':
127   case 'O': return GetOuter();
128   }
129   return 0;
130 }
131
132 //____________________________________________________________________
133 Double_t
134 AliFMDDetector::GetRingZ(Char_t id) const
135 {
136   // Get the z-coordinate specified ring 
137   // 
138   //   ID      Id of ring ('I' or 'O')
139   // 
140   switch (id) {
141   case 'i':
142   case 'I': return GetInnerZ();
143   case 'o':
144   case 'O': return GetOuterZ();
145   }
146   return 0;
147 }
148 //____________________________________________________________________
149 void
150 AliFMDDetector::Detector2XYZ(Char_t ring, 
151                              UShort_t sector,
152                              UShort_t strip, 
153                              Double_t& x, 
154                              Double_t& y, 
155                              Double_t& z) const
156 {
157   // Translate detector coordinates (this,ring,sector,strip) into
158   // (x,y,z) coordinates (in global reference frame)
159   AliFMDRing* r = GetRing(ring);
160   if (!r) return;
161   z = GetRingZ(ring);
162   r->Detector2XYZ(sector, strip, x, y, z);
163 }
164
165 //____________________________________________________________________
166 Bool_t
167 AliFMDDetector::XYZ2Detector(Double_t  x,
168                              Double_t  y,
169                              Double_t  z,
170                              Char_t&   ring, 
171                              UShort_t& sector,
172                              UShort_t& strip) const
173 {
174   // Translate (x,y,z) coordinates (in global reference frame) into 
175   // detector coordinates (this,ring,sector,strip).
176   AliFMDRing* rng = 0;
177   ring = -1;
178   for (int j = 0; j < 2; j++) {
179     rng = GetRing(j == 0 ? 'I'  : 'O');
180     if (!rng) continue;
181     Double_t ringZ    = GetRingZ(j == 0 ? 'I'  : 'O');
182     Double_t modSpace = TMath::Sign(rng->GetModuleSpacing(), ringZ);
183     if (TMath::Abs(z - ringZ) < 0.01 || 
184         TMath::Abs(z - ringZ + modSpace) < 0.01) break;
185     rng = 0;
186   }
187   if (rng && rng->XYZ2Detector(x, y, z - GetRingZ(rng->GetId()),
188                                sector, strip)) {
189     ring = rng->GetId();
190     return kTRUE;
191   }
192   return kFALSE;
193 }
194
195   
196
197 //____________________________________________________________________
198 // 
199 // EOF
200 //