1 /**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /** @file AliFMDDetector.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:36:27 2006
19 @brief Sub-detector base class implementation
23 //____________________________________________________________________
27 // Base class for concrete FMD detectors, like AliFMD1, AliFMD2,
29 // Utility class to help implement the FMD geometry. This provides
30 // the interface for the concrete geometry implementations of the FMD
33 // The AliFMDGeometry object owns the AliFMDDetector objects
35 // Latest changes by Christian Holm Christensen
37 #include "AliFMDDetector.h" // ALIFMDSUBDETECTOR_H
38 #include "AliFMDRing.h" // ALIFMDRING_H
39 #include "AliLog.h" // ALILOG_H
40 #include <TGeoManager.h> // ROOT_TGeoManager
41 #include <TGeoMatrix.h> // ROOT_TGeoMatrix
42 // #include <TMath.h> // ROOT_TMath
44 //====================================================================
45 ClassImp(AliFMDDetector)
47 ; // This is here to keep Emacs for indenting the next line
50 //____________________________________________________________________
51 AliFMDDetector::AliFMDDetector(Int_t id, AliFMDRing* inner, AliFMDRing* outer)
52 : TNamed(Form("FMD%d", id), "Forward multiplicity ring"),
56 fHoneycombThickness(0.),
69 // ID Id of detector (1,2, or 3)
70 // INNER Inner ring geometry
71 // OUTER Outer ring geometry (if any)
73 SetHoneycombThickness();
76 SetInnerHoneyHighR(0);
80 SetOuterHoneyHighR(0);
83 //____________________________________________________________________
84 AliFMDDetector::AliFMDDetector(const AliFMDDetector& other)
89 fHoneycombThickness(0.),
97 fInnerTransforms(other.fInnerTransforms),
98 fOuterTransforms(other.fOuterTransforms)
101 SetHoneycombThickness(other.GetHoneycombThickness());
102 SetAlThickness(other.GetAlThickness());
103 SetInnerHoneyLowR(other.GetInnerHoneyLowR());
104 SetInnerHoneyHighR(other.GetInnerHoneyHighR());
105 SetInnerZ(other.GetInnerZ());
106 SetOuterZ(other.GetOuterZ());
107 SetOuterHoneyLowR(other.GetOuterHoneyLowR());
108 SetOuterHoneyHighR(other.GetOuterHoneyHighR());
111 //____________________________________________________________________
113 AliFMDDetector::operator=(const AliFMDDetector& other)
115 // Assignment operator
116 SetName(other.GetName());
117 SetTitle(other.GetTitle());
119 fInner = other.fInner;
120 fOuter = other.fOuter;
121 fInnerTransforms = other.fInnerTransforms;
122 fOuterTransforms = other.fOuterTransforms;
123 SetHoneycombThickness(other.GetHoneycombThickness());
124 SetAlThickness(other.GetAlThickness());
125 SetInnerHoneyLowR(other.GetInnerHoneyLowR());
126 SetInnerHoneyHighR(other.GetInnerHoneyHighR());
127 SetInnerZ(other.GetInnerZ());
128 SetOuterZ(other.GetOuterZ());
129 SetOuterHoneyLowR(other.GetOuterHoneyLowR());
130 SetOuterHoneyHighR(other.GetOuterHoneyHighR());
134 //____________________________________________________________________
136 AliFMDDetector::Init()
140 SetInnerHoneyLowR(fInner->GetLowR() + 1.);
141 SetInnerHoneyHighR(fInner->GetHighR() + 1.);
144 SetOuterHoneyLowR(fOuter->GetLowR() + 1.);
145 SetOuterHoneyHighR(fOuter->GetHighR() + 1.);
149 //____________________________________________________________________
151 AliFMDDetector::HasAllTransforms(Char_t ring) const
153 // Check if we got all transformations for a given ring. Return
154 // true in that case.
155 AliFMDRing* r = GetRing(ring);
156 if (!r) return kTRUE;
157 TObjArray* matricies = (r == fInner ? fInnerTransforms : fOuterTransforms);
158 if (!matricies) return kTRUE;
159 if (matricies->GetEntries() == r->GetNModules()) return kTRUE;
163 #define IS_NODE_THIS(name) \
164 (name[0] == 'F' && name[2] == 'M' && name[1] == Char_t(48+fId) && \
165 (name[3] == 'T' || name[3] == 'B'))
166 #define IS_NODE_SENSOR(name) \
167 (name[0] == 'F' && name[2] == 'S' && name[3] == 'E')
169 //____________________________________________________________________
171 AliFMDDetector::InitTransformations()
173 // Find all local<->global transformations for this detector.
174 if ((!fInner || (fInner && fInnerTransforms)) &&
175 (!fOuter || (fOuter && fOuterTransforms))) {
176 AliDebug(5, Form("Transforms for FMD%d already registered", fId));
179 AliDebug(5, Form("Initializing transforms for FMD%d", fId));
181 AliFatal("No TGeoManager defined");
184 TGeoVolume* topVolume = gGeoManager->GetTopVolume();
186 AliFatal("No top-level volume defined");
189 // Make container of transforms
190 if (fInner && !fInnerTransforms)
191 fInnerTransforms = new TObjArray(fInner->GetNModules());
192 if (fOuter && !fOuterTransforms)
193 fOuterTransforms = new TObjArray(fOuter->GetNModules());
196 TGeoIterator next(topVolume);
199 // Find the node corresponding to this detector, and then find the
201 Bool_t thisNodeFound = kFALSE;
202 Bool_t allInners = HasAllTransforms('I');
203 Bool_t allOuters = HasAllTransforms('O');
205 while ((node = static_cast<TGeoNode*>(next()))
206 && !(allInners && allOuters)) {
208 const Char_t* name = node->GetName();
210 AliDebug(50, Form("Got volume %s", name));
211 // Check if this node is this detector
212 // The base offset for numbers in the ASCII table is 48
213 if (IS_NODE_THIS(name)) {
214 AliDebug(20, Form("Found detector node '%s' for FMD%d", name, fId));
215 thisNodeFound = kTRUE;
217 // if the detector was found, then we're on that branch, and we
218 // check if this node represents a module in that branch.
219 if (thisNodeFound && IS_NODE_SENSOR(name)) {
220 AliDebug(20, Form("Found sensor node '%s' for FMD%d", name, fId));
222 Char_t ringid = name[1];
224 // Get the approprate ring
225 AliFMDRing* ring = GetRing(ringid);
228 // Check whether we have all the modules we need for this ring,
229 // and if so, go on to the next node.
230 Bool_t& done = (ring == fInner ? allInners : allOuters);
231 if ((done = HasAllTransforms(ringid))) {
232 AliDebug(20, Form("Already has all module transforms for ring %c",
237 // Get the approprate container
238 TObjArray* matricies = (ringid == 'i' || ringid == 'I'
239 ? fInnerTransforms : fOuterTransforms);
241 // Get the copy (module) number, and check that it hasn't
242 // already been added to the container.
243 Int_t copy = node->GetNumber();
244 if (matricies->At(copy)) {
245 AliWarning(Form("Have a transformation for module %d in ring %c",
250 // Get the global transformation matrix, and store it.
251 TGeoMatrix* trans = new TGeoHMatrix(*(next.GetCurrentMatrix()));
252 matricies->AddAt(trans, copy);
258 //____________________________________________________________________
260 AliFMDDetector::GetRing(Char_t id) const
262 // Get the specified ring
264 // ID Id of ring ('I' or 'O')
268 case 'I': return GetInner();
270 case 'O': return GetOuter();
275 //____________________________________________________________________
277 AliFMDDetector::GetRingZ(Char_t id) const
279 // Get the z-coordinate specified ring
281 // ID Id of ring ('I' or 'O')
285 case 'I': return GetInnerZ();
287 case 'O': return GetOuterZ();
292 //____________________________________________________________________
294 AliFMDDetector::FindTransform(Char_t ring, UShort_t sector) const
296 // Find the transformation that corresponds to sector sector in ring
298 TObjArray* matricies = 0;
300 case 'i': case 'I': matricies = fInnerTransforms; break;
301 case 'o': case 'O': matricies = fOuterTransforms; break;
304 AliWarning(Form("Unknown ring %c of FMD%d", ring, fId));
307 UInt_t module = sector / 2;
308 TGeoMatrix* m = static_cast<TGeoMatrix*>(matricies->At(module));
310 AliWarning(Form("No matrix found for sector %d in FMD%d%c",
318 //____________________________________________________________________
320 AliFMDDetector::Detector2XYZ(Char_t ring,
327 // Translate detector coordinates (this,ring,sector,strip) into
328 // (x,y,z) coordinates (in global reference frame)
329 AliFMDRing* r = GetRing(ring);
331 TGeoMatrix* m = FindTransform(ring, sector);
333 Double_t rho = r->GetStripRadius(strip);
334 Double_t phi = ((sector % 2) - .5) * r->GetTheta();
335 Double_t siThick = r->GetSiThickness();
336 Double_t modThick = (siThick
337 + r->GetPrintboardThickness()
338 + r->GetCopperThickness()
339 + r->GetChipThickness()
341 AliDebug(30,Form("Rho %7.3f, angle %7.3f", rho, phi));
342 # define DEGRAD TMath::Pi() / 180.
343 Double_t local[] = { rho * TMath::Cos(phi * DEGRAD),
344 rho * TMath::Sin(phi * DEGRAD),
345 -modThick + siThick / 2 };
347 AliDebug(30, Form("Local (%7.3f,%7.3f,%7.3f)",local[0], local[1], local[2]));
348 m->LocalToMaster(local, master);
349 AliDebug(30, Form("Master (%7.3f,%7.3f,%7.3f)",
350 master[0],master[1],master[2]));
356 //____________________________________________________________________
358 AliFMDDetector::XYZ2Detector(Double_t x,
363 UShort_t& strip) const
365 // Translate (x,y,z) coordinates (in global reference frame) into
366 // detector coordinates (this,ring,sector,strip).
369 for (int j = 0; j < 2; j++) {
370 rng = GetRing(j == 0 ? 'I' : 'O');
372 Double_t ringZ = GetRingZ(j == 0 ? 'I' : 'O');
373 Double_t modSpace = TMath::Sign(rng->GetModuleSpacing(), ringZ);
374 if (TMath::Abs(z - ringZ) < 0.01 ||
375 TMath::Abs(z - ringZ + modSpace) < 0.01) break;
378 if (rng && rng->XYZ2Detector(x, y, z - GetRingZ(rng->GetId()),
388 //____________________________________________________________________