]>
Commit | Line | Data |
---|---|---|
b7943f00 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
17 | //************************************************************************* | |
18 | // Class for flat cables | |
19 | // | |
20 | // Ludovic Gaudichet gaudichet@to.infn.it | |
21 | //************************************************************************* | |
22 | ||
23 | ||
24 | ||
25 | // General Root includes | |
26 | //#include <Riostream.h> | |
27 | #include <TMath.h> | |
28 | #include <TVectorD.h> | |
29 | ||
30 | // Root Geometry includes | |
31 | #include <TGeoManager.h> | |
32 | #include <TGeoVolume.h> | |
33 | #include <TGeoArb8.h> | |
34 | #include <TGeoMatrix.h> | |
35 | #include <TGeoNode.h> | |
36 | ||
37 | #include "AliITSv11GeomCableFlat.h" | |
38 | ||
39 | ||
40 | ClassImp(AliITSv11GeomCableFlat) | |
41 | ||
42 | //________________________________________________________________________ | |
43 | AliITSv11GeomCableFlat::AliITSv11GeomCableFlat() : AliITSv11GeomCable() | |
44 | { | |
45 | // constructor | |
46 | fWidth = 0; | |
47 | fThick = 0; | |
48 | fNlayer = 0; | |
49 | for (Int_t i=0; i<fgkCableMaxLayer ; i++) { | |
50 | fLayThickness[i] = 0; | |
51 | fTranslation[i] = 0; | |
52 | fLayColor[i] = 0; | |
53 | fLayMedia[i] = 0; | |
54 | }; | |
5d7a6c6d | 55 | } |
b7943f00 | 56 | |
57 | //________________________________________________________________________ | |
58 | AliITSv11GeomCableFlat:: | |
59 | AliITSv11GeomCableFlat(const char* name, Double_t width, Double_t thick) : | |
60 | AliITSv11GeomCable(name) { | |
61 | // standard constructor | |
62 | fWidth = width; | |
63 | fThick = thick; | |
64 | fNlayer = 0; | |
65 | for (Int_t i=0; i<fgkCableMaxLayer ; i++) { | |
66 | fLayThickness[i] = 0; | |
67 | fTranslation[i] = 0; | |
68 | fLayColor[i] = 0; | |
69 | fLayMedia[i] = 0; | |
70 | }; | |
5d7a6c6d | 71 | } |
b7943f00 | 72 | |
73 | //________________________________________________________________________ | |
74 | AliITSv11GeomCableFlat::AliITSv11GeomCableFlat(const AliITSv11GeomCableFlat &s) : | |
75 | AliITSv11GeomCable(s),fWidth(s.fWidth),fThick(s.fThick),fNlayer(s.fNlayer) | |
76 | { | |
77 | // Copy Constructor | |
78 | for (Int_t i=0; i<s.fNlayer; i++) { | |
79 | fLayThickness[i] = s.fLayThickness[i]; | |
80 | fTranslation[i] = s.fTranslation[i]; | |
81 | fLayMedia[i] = s.fLayMedia[i]; | |
82 | fLayColor[i] = s.fLayColor[i]; | |
83 | } | |
84 | } | |
85 | ||
86 | //________________________________________________________________________ | |
87 | AliITSv11GeomCableFlat& AliITSv11GeomCableFlat:: | |
88 | operator=(const AliITSv11GeomCableFlat &s) { | |
89 | // Assignment operator | |
90 | // Not fully inplemented yet !!! | |
91 | ||
92 | if(&s == this) return *this; | |
93 | *this = s; | |
94 | fWidth = s.fWidth; | |
95 | fThick = s.fThick; | |
96 | fNlayer = s.fNlayer; | |
97 | for (Int_t i=0; i<s.fNlayer; i++) { | |
98 | fLayThickness[i] = s.fLayThickness[i]; | |
99 | fTranslation[i] = s.fTranslation[i]; | |
100 | fLayMedia[i] = s.fLayMedia[i]; | |
101 | fLayColor[i] = s.fLayColor[i]; | |
102 | }; | |
103 | return *this; | |
104 | } | |
105 | ||
106 | //________________________________________________________________________ | |
107 | Int_t AliITSv11GeomCableFlat::GetPoint( Int_t iCheckPt, Double_t *coord) | |
108 | const { | |
109 | // Get the correct point #iCheckPt | |
110 | TVectorD *coordVector =(TVectorD *)fPointArray.At(2*iCheckPt); | |
111 | if (coordVector) { | |
5d7a6c6d | 112 | #if ROOT_VERSION_CODE < ROOT_VERSION(4,0,0) |
113 | CopyFrom(coord, coordVector->GetElements()); | |
114 | #else | |
b7943f00 | 115 | CopyFrom(coord, coordVector->GetMatrixArray()); |
5d7a6c6d | 116 | #endif |
b7943f00 | 117 | return kTRUE; |
118 | } else { | |
119 | return kFALSE; | |
120 | }; | |
5d7a6c6d | 121 | } |
b7943f00 | 122 | |
123 | ||
124 | //________________________________________________________________________ | |
125 | Int_t AliITSv11GeomCableFlat::GetVect( Int_t iCheckPt, Double_t *coord) | |
126 | const { | |
127 | // Get the correct vect corresponding to point #iCheckPt | |
128 | ||
129 | TVectorD *coordVector =(TVectorD *)fPointArray.At(2*iCheckPt+1); | |
130 | if (coordVector) { | |
5d7a6c6d | 131 | #if ROOT_VERSION_CODE < ROOT_VERSION(4,0,0) |
132 | CopyFrom(coord, coordVector->GetElements()); | |
133 | #else | |
b7943f00 | 134 | CopyFrom(coord, coordVector->GetMatrixArray()); |
5d7a6c6d | 135 | #endif |
b7943f00 | 136 | return kTRUE; |
137 | } else { | |
138 | return kFALSE; | |
139 | }; | |
5d7a6c6d | 140 | } |
b7943f00 | 141 | |
142 | ||
143 | //________________________________________________________________________ | |
144 | void AliITSv11GeomCableFlat::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt, | |
145 | Double_t *coord, Double_t *orthVect) | |
146 | { | |
147 | // | |
148 | // Add a check point. In the fPointArray, the point is at i and its vector | |
149 | // is at i+1. | |
150 | // | |
151 | ||
152 | // if (iCheckPt>=fVolumeArray.GetEntriesFast()) { | |
153 | // fVolumeArray.AddLast(vol); | |
154 | // TVectorD *point = new TVectorD(3,coord); | |
155 | // TVectorD *vect = new TVectorD(3,orthVect); | |
156 | // fPointArray.AddLast(point); | |
157 | // fPointArray.AddLast(vect); | |
158 | ||
159 | // } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) { | |
160 | // fVolumeArray.AddAt(vol, iCheckPt); | |
161 | // TVectorD *point = new TVectorD(3,coord); | |
162 | // TVectorD *vect = new TVectorD(3,orthVect); | |
163 | // fPointArray.AddAt(point, iCheckPt*2 ); | |
164 | // fPointArray.AddAt(vect, iCheckPt*2+1); | |
165 | // }; | |
166 | fVolumeArray.AddAtAndExpand(vol, iCheckPt); | |
167 | TVectorD *point = new TVectorD(3,coord); | |
168 | TVectorD *vect = new TVectorD(3,orthVect); | |
169 | fPointArray.AddAtAndExpand(point, iCheckPt*2 ); | |
170 | fPointArray.AddAtAndExpand(vect, iCheckPt*2+1); | |
5d7a6c6d | 171 | } |
b7943f00 | 172 | |
173 | //________________________________________________________________________ | |
174 | void AliITSv11GeomCableFlat::PrintCheckPoints() const { | |
175 | // print all check points of the cable | |
176 | printf(" ---\n Printing all check points of the flat cable\n"); | |
177 | for (Int_t i = 0; i<fVolumeArray.GetEntriesFast(); i++) { | |
178 | Double_t coord[3]; | |
179 | if (GetPoint( i, coord)) | |
180 | printf(" ( %.2f, %.2f, %.2f )\n", coord[0], coord[1], coord[2]); | |
181 | }; | |
5d7a6c6d | 182 | } |
b7943f00 | 183 | |
184 | //________________________________________________________________________ | |
185 | Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, | |
186 | Double_t rotation) | |
187 | { | |
188 | // Creates a cable segment between points p1 and p2. | |
189 | // Rotation is the eventual rotation of the flat cable | |
190 | // along its length axis | |
191 | // | |
192 | // The segment volume is created inside the volume containing point2 | |
193 | // Therefore this segment should be defined in this volume only. | |
194 | // I mean here that, if the previous point is in another volume, | |
195 | // it should be just at the border between the 2 volumes. Also the | |
196 | // orientation vector of the previous point should be orthogonal to | |
197 | // the surface between the 2 volumes. | |
198 | ||
199 | TGeoNode *mainNode; | |
200 | if (fInitialNode==0) { | |
201 | TObjArray *nodes = gGeoManager->GetListOfNodes(); | |
202 | if (nodes->GetEntriesFast()==0) return kFALSE; | |
203 | mainNode = (TGeoNode *) nodes->UncheckedAt(0); | |
204 | } else { | |
205 | mainNode = fInitialNode; | |
206 | }; | |
207 | ||
208 | Int_t p1 = p2 - 1; | |
209 | TGeoVolume *p2Vol = GetVolume(p2); | |
210 | TGeoVolume *p1Vol = GetVolume(p1); | |
211 | ||
212 | ResetCheckDaughter(); | |
213 | fCurrentVol = p1Vol; | |
214 | if (! CheckDaughter(mainNode)) { | |
215 | printf("Error::volume containing point is not visible in node tree!\n"); | |
216 | return kFALSE; | |
217 | }; | |
218 | ||
219 | Double_t coord1[3], coord2[3], vect1[3], vect2[3]; | |
220 | //================================================= | |
221 | // Get p1 position in the systeme of p2 | |
222 | if (p1Vol!=p2Vol) { | |
223 | ||
224 | Int_t p1nodeInd[fgkCableMaxNodeLevel]; | |
225 | for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p1nodeInd[i]=fNodeInd[i]; | |
226 | Int_t p1volLevel = 0; | |
227 | while (p1nodeInd[p1volLevel]!=-1) p1volLevel++; | |
228 | p1volLevel--; | |
229 | ||
230 | ResetCheckDaughter(); | |
231 | fCurrentVol = p2Vol; | |
232 | if (! CheckDaughter(mainNode)) { | |
233 | printf("Error::volume containing point is not visible in node tree!\n"); | |
234 | return kFALSE; | |
235 | }; | |
236 | Int_t p2nodeInd[fgkCableMaxNodeLevel]; | |
237 | for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p2nodeInd[i]=fNodeInd[i]; | |
238 | Int_t commonMotherLevel = 0; | |
239 | while (p1nodeInd[commonMotherLevel]==fNodeInd[commonMotherLevel]) | |
240 | commonMotherLevel++; | |
241 | commonMotherLevel--; | |
242 | Int_t p2volLevel = 0; | |
243 | while (fNodeInd[p2volLevel]!=-1) p2volLevel++; | |
244 | p2volLevel--; | |
245 | ||
246 | // Get coord and vect of p1 in the common mother reference system | |
247 | if (! GetCheckPoint(p1, 0, p1volLevel-commonMotherLevel, coord1) ) | |
248 | return kFALSE; | |
249 | if (! GetCheckVect( p1, 0, p1volLevel-commonMotherLevel, vect1) ) | |
250 | return kFALSE; | |
251 | ||
252 | // Translate them in the reference system of the volume containing p2 | |
253 | TGeoNode *pathNode[fgkCableMaxNodeLevel]; | |
254 | pathNode[0] = mainNode; | |
255 | for (Int_t i=0; i<=p2volLevel; i++) { | |
256 | pathNode[i+1] = pathNode[i]->GetDaughter(p2nodeInd[i]); | |
257 | }; | |
258 | Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]}; | |
259 | Double_t globalVect1[3] = {vect1[0], vect1[1], vect1[2]}; | |
260 | ||
261 | for (Int_t i = commonMotherLevel+1; i <= p2volLevel; i++) { | |
262 | pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1); | |
263 | pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1); | |
264 | CopyFrom(globalCoord1, coord1); | |
265 | CopyFrom(globalVect1, vect1); | |
266 | }; | |
267 | } else { | |
268 | if (! GetCheckPoint(p1, 0, 0, coord1) ) return kFALSE; | |
269 | if (! GetCheckVect(p1, 0, 0, vect1) ) return kFALSE; | |
270 | }; | |
271 | ||
272 | //================================================= | |
273 | // Get p2 position in the systeme of p2 | |
274 | if (! GetCheckPoint(p2, 0, 0, coord2) ) return kFALSE; | |
275 | if (! GetCheckVect(p2, 0, 0, vect2) ) return kFALSE; | |
276 | ||
277 | Double_t cx = (coord1[0]+coord2[0])/2; | |
278 | Double_t cy = (coord1[1]+coord2[1])/2; | |
279 | Double_t cz = (coord1[2]+coord2[2])/2; | |
280 | Double_t dx = coord2[0]-coord1[0]; | |
281 | Double_t dy = coord2[1]-coord1[1]; | |
282 | Double_t dz = coord2[2]-coord1[2]; | |
283 | ||
284 | //================================================= | |
285 | // Positionning of the segment between the 2 points | |
286 | if (TMath::Abs(dy)<1e-231) dy = 1e-231; | |
287 | if (TMath::Abs(dz)<1e-231) dz = 1e-231; | |
288 | //Double_t angleRot1 = -TMath::ATan(dx/dy); | |
289 | //Double_t planDiagL = -TMath::Sqrt(dy*dy+dx*dx); | |
290 | //if (dy<0) planDiagL = -planDiagL; | |
291 | //Double_t angleRotDiag = TMath::ATan(planDiagL/dz); | |
292 | ||
293 | Double_t angleRot1 = -TMath::ATan2(dx,dy); | |
294 | Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx); | |
295 | Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz); | |
296 | //--- (Calculate rotation of segment on the Z axis) | |
297 | //-- Here I'm trying to calculate the rotation to be applied in | |
298 | //-- order to match as closer as possible this segment and the | |
299 | //-- previous one. | |
300 | //-- It seems that some times it doesn't work ... | |
301 | Double_t angleRotZ = 0; | |
302 | TGeoRotation rotTemp("",angleRot1*TMath::RadToDeg(), | |
303 | angleRotDiag*TMath::RadToDeg(), rotation); | |
304 | Double_t localX[3] = {0,1,0}; | |
305 | Double_t globalX[3]; | |
306 | rotTemp.LocalToMasterVect(localX, globalX); | |
307 | CopyFrom(localX, globalX); | |
308 | GetCheckVect(localX, p2Vol, 0, fgkCableMaxNodeLevel+1, globalX); | |
309 | Double_t orthVect[3]; | |
310 | GetCheckVect(vect1, p2Vol, 0, fgkCableMaxNodeLevel+1, orthVect); | |
311 | if (p2>1) { | |
312 | Double_t orthVectNorm2 = ScalProd(orthVect,orthVect); | |
313 | Double_t alpha1 = ScalProd(fPreviousX,orthVect)/orthVectNorm2; | |
314 | Double_t alpha2 = ScalProd(globalX,orthVect)/orthVectNorm2; | |
315 | Double_t globalX1p[3], globalX2p[3]; | |
316 | globalX1p[0] = fPreviousX[0] - alpha1*orthVect[0]; | |
317 | globalX1p[1] = fPreviousX[1] - alpha1*orthVect[1]; | |
318 | globalX1p[2] = fPreviousX[2] - alpha1*orthVect[2]; | |
319 | globalX2p[0] = globalX[0] - alpha2*orthVect[0]; | |
320 | globalX2p[1] = globalX[1] - alpha2*orthVect[1]; | |
321 | globalX2p[2] = globalX[2] - alpha2*orthVect[2]; | |
322 | //-- now I'm searching the 3th vect which makes an orthogonal base | |
323 | //-- with orthVect and globalX1p ... | |
324 | Double_t nulVect[3] = {0,0,0}; | |
325 | Double_t axis3[3]; | |
326 | TMath::Normal2Plane(nulVect, orthVect, globalX1p, axis3); | |
327 | Double_t globalX1pNorm2 = ScalProd(globalX1p, globalX1p); | |
328 | Double_t beta = ScalProd(globalX2p, globalX1p)/globalX1pNorm2; | |
329 | Double_t gamma = ScalProd(globalX2p, axis3); | |
330 | angleRotZ = (TMath::ATan2(1,0) - TMath::ATan2(beta, gamma)) | |
331 | *TMath::RadToDeg(); | |
332 | }; | |
333 | // cout << "!!!!!!!!!!!!!!!!!!! angle = " <<angleRotZ << endl; | |
334 | CopyFrom(fPreviousX, globalX); | |
335 | //--- | |
336 | Double_t localVect1[3], localVect2[3]; | |
337 | TGeoRotation rot("",angleRot1*TMath::RadToDeg(), | |
338 | angleRotDiag*TMath::RadToDeg(), | |
339 | rotation); | |
340 | // rotation-angleRotZ); | |
341 | // since angleRotZ doesn't always work, I won't use it ... | |
342 | ||
343 | rot.MasterToLocalVect(vect1, localVect1); | |
344 | rot.MasterToLocalVect(vect2, localVect2); | |
345 | ||
346 | //================================================= | |
347 | // Create the segment and add it to the mother volume | |
348 | TGeoVolume *vCableSegB = CreateSegment(coord1, coord2, | |
349 | localVect1, localVect2); | |
350 | ||
351 | TGeoRotation rotArbSeg("", 0, 90, 0); | |
352 | rotArbSeg.MultiplyBy(&rot, kFALSE); | |
353 | TGeoTranslation trans("",cx, cy, cz); | |
354 | TGeoCombiTrans *combiB = new TGeoCombiTrans(trans, rotArbSeg); | |
355 | p2Vol->AddNode(vCableSegB, p2, combiB); | |
356 | //=================================================; | |
357 | ||
358 | if (fDebug) { | |
359 | printf("---\n Cable segment points : "); | |
360 | printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]); | |
361 | printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]); | |
362 | }; | |
363 | ||
364 | // #include <TGeoSphere.h> | |
365 | // TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir"); | |
366 | // TGeoSphere *sphere = new TGeoSphere(0, 0.05); | |
367 | // TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD); | |
368 | // TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz); | |
369 | // TGeoTranslation *tr1 = new TGeoTranslation("",coord1[0], | |
370 | // coord1[1],coord1[2]); | |
371 | // TGeoTranslation *tr2 = new TGeoTranslation("",coord2[0], | |
372 | // coord2[1],coord2[2]); | |
373 | // p2Vol->AddNode(vSphere, p2*3-2, trC); | |
374 | // p2Vol->AddNode(vSphere, p2*3-1, tr1); | |
375 | // p2Vol->AddNode(vSphere, p2*3 , tr2); | |
376 | ||
377 | return kTRUE; | |
5d7a6c6d | 378 | } |
b7943f00 | 379 | |
380 | //________________________________________________________________________ | |
381 | TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1, | |
382 | Double_t *coord2, | |
383 | Double_t *localVect1, | |
384 | Double_t *localVect2 ) | |
385 | { | |
386 | ||
387 | //================================================= | |
388 | // Calculate segment "deformation" | |
389 | Double_t dx = coord2[0]-coord1[0]; | |
390 | Double_t dy = coord2[1]-coord1[1]; | |
391 | Double_t dz = coord2[2]-coord1[2]; | |
392 | Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz); | |
393 | ||
394 | Double_t cosTheta1 = -1./TMath::Sqrt( 1 + localVect1[0]*localVect1[0] | |
395 | /localVect1[2]/localVect1[2] ); | |
396 | Double_t cosTheta2 = 1./TMath::Sqrt( 1 + localVect2[0]*localVect2[0] | |
397 | /localVect2[2]/localVect2[2] ); | |
398 | if (localVect1[2]<0) cosTheta1 = -cosTheta1; | |
399 | if (localVect2[2]<0) cosTheta2 = -cosTheta2; | |
400 | ||
401 | Double_t dL1 = 0.5*fWidth*TMath::Tan(TMath::ACos(cosTheta1)); | |
402 | Double_t dL2 = 0.5*fWidth*TMath::Tan(TMath::ACos(cosTheta2)); | |
403 | if (localVect1[0]<0) dL1 = - dL1; | |
404 | if (localVect2[0]<0) dL2 = - dL2; | |
405 | //--- | |
406 | Double_t cosPhi1 = -1./TMath::Sqrt( 1 + localVect1[1]*localVect1[1] | |
407 | /localVect1[2]/localVect1[2] ); | |
408 | Double_t cosPhi2 = 1./TMath::Sqrt( 1 + localVect2[1]*localVect2[1] | |
409 | /localVect2[2]/localVect2[2] ); | |
410 | if (localVect1[2]<0) cosPhi1 = -cosPhi1; | |
411 | if (localVect2[2]<0) cosPhi2 = -cosPhi2; | |
412 | ||
413 | Double_t tanACosCosPhi1 = TMath::Tan(TMath::ACos(cosPhi1)); | |
414 | Double_t tanACosCosPhi2 = TMath::Tan(TMath::ACos(cosPhi2)); | |
415 | if (localVect1[1]<0) tanACosCosPhi1 = -tanACosCosPhi1; | |
416 | if (localVect2[1]<0) tanACosCosPhi2 = -tanACosCosPhi2; | |
417 | ||
418 | Double_t dl1 = 0.5*fThick*tanACosCosPhi1; | |
419 | Double_t dl2 = 0.5*fThick*tanACosCosPhi2; | |
420 | ||
421 | //================================================= | |
422 | // Create the segment | |
423 | TGeoArb8 *cableSeg = new TGeoArb8(fThick/2); | |
424 | cableSeg->SetVertex( 0, -fWidth/2, -length/2 - dL1 + dl1); | |
425 | cableSeg->SetVertex( 1, fWidth/2, -length/2 + dL1 + dl1); | |
426 | cableSeg->SetVertex( 2, fWidth/2, length/2 - dL2 - dl2); | |
427 | cableSeg->SetVertex( 3, -fWidth/2, length/2 + dL2 - dl2); | |
428 | cableSeg->SetVertex( 4, -fWidth/2, -length/2 - dL1 - dl1); | |
429 | cableSeg->SetVertex( 5, fWidth/2, -length/2 + dL1 - dl1); | |
430 | cableSeg->SetVertex( 6, fWidth/2, length/2 - dL2 + dl2); | |
431 | cableSeg->SetVertex( 7, -fWidth/2, length/2 + dL2 + dl2); | |
432 | ||
433 | TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair"); | |
434 | TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD); | |
435 | ||
436 | // add all cable layers | |
437 | for (Int_t iLay=0; iLay<fNlayer; iLay++) { | |
438 | ||
439 | Double_t dl1Lay = 0.5*fLayThickness[iLay]*tanACosCosPhi1; | |
440 | Double_t dl2Lay = 0.5*fLayThickness[iLay]*tanACosCosPhi2; | |
441 | ||
442 | Double_t ztr = -fThick/2; | |
443 | for (Int_t i=0;i<iLay; i++) ztr+= fLayThickness[i]; | |
444 | ztr+= fLayThickness[iLay]/2; | |
445 | ||
446 | Double_t dl1LayS = ztr*tanACosCosPhi1; | |
447 | Double_t dl2LayS = ztr*tanACosCosPhi2; | |
448 | ||
449 | TGeoArb8 *lay = new TGeoArb8(fLayThickness[iLay]/2); | |
450 | lay->SetVertex( 0, -fWidth/2, -length/2 - dL1 + dl1Lay - dl1LayS); | |
451 | lay->SetVertex( 1, fWidth/2, -length/2 + dL1 + dl1Lay - dl1LayS); | |
452 | lay->SetVertex( 2, fWidth/2, length/2 - dL2 - dl2Lay + dl2LayS); | |
453 | lay->SetVertex( 3, -fWidth/2, length/2 + dL2 - dl2Lay + dl2LayS); | |
454 | lay->SetVertex( 4, -fWidth/2, -length/2 - dL1 - dl1Lay - dl1LayS); | |
455 | lay->SetVertex( 5, fWidth/2, -length/2 + dL1 - dl1Lay - dl1LayS); | |
456 | lay->SetVertex( 6, fWidth/2, length/2 - dL2 + dl2Lay + dl2LayS); | |
457 | lay->SetVertex( 7, -fWidth/2, length/2 + dL2 + dl2Lay + dl2LayS); | |
458 | TGeoVolume *vLay = new TGeoVolume("vCableSegLay", lay, fLayMedia[iLay]); | |
459 | vLay->SetLineColor(fLayColor[iLay]); | |
460 | ||
461 | if (fTranslation[iLay]==0) | |
462 | fTranslation[iLay] = new TGeoTranslation(0, 0, ztr); | |
463 | vCableSeg->AddNode(vLay, iLay+1, fTranslation[iLay]); | |
464 | }; | |
465 | ||
466 | vCableSeg->SetVisibility(kFALSE); | |
467 | return vCableSeg; | |
5d7a6c6d | 468 | } |
b7943f00 | 469 | |
470 | ||
471 | //________________________________________________________________________ | |
472 | void AliITSv11GeomCableFlat::SetNLayers(Int_t nLayers) { | |
473 | // Set the number of layers | |
474 | if((nLayers>0) &&(nLayers<=fgkCableMaxLayer)) { | |
475 | ||
476 | fNlayer = nLayers; | |
477 | for (Int_t i=0; i<fgkCableMaxLayer ; i++) { | |
478 | fLayThickness[i] = 0; | |
479 | fTranslation[i] = 0; | |
480 | fLayColor[i] = 0; | |
481 | fLayMedia[i] = 0; | |
482 | }; | |
483 | }; | |
5d7a6c6d | 484 | } |
b7943f00 | 485 | |
486 | //________________________________________________________________________ | |
487 | Int_t AliITSv11GeomCableFlat::SetLayer(Int_t nLayer, Double_t thick, | |
488 | TGeoMedium *medium, Int_t color) { | |
489 | // Set the layer number nLayer | |
490 | if ((nLayer<0)||(nLayer>=fNlayer)) { | |
491 | printf("Set wrong layer number of the cable\n"); | |
492 | return kFALSE; | |
493 | }; | |
494 | if (nLayer>0) | |
495 | if (fLayThickness[nLayer-1]<=0) { | |
496 | printf("AliITSv11GeomCableFlat::SetLayer():" | |
497 | " You must define cable layer %i first !",nLayer-1); | |
498 | return kFALSE; | |
499 | }; | |
500 | ||
501 | Double_t thickTot = 0; | |
502 | for (Int_t i=0; i<nLayer; i++) thickTot += fLayThickness[i]; | |
503 | thickTot += thick; | |
504 | if (thickTot-1e-10>fThick) { | |
505 | printf("Can't add this layer, cable thickness would be higher than total\n"); | |
506 | return kFALSE; | |
507 | }; | |
508 | ||
509 | fLayThickness[nLayer] = thick; | |
510 | fLayMedia[nLayer] = medium; | |
511 | fLayColor[nLayer] = color; | |
512 | fTranslation[nLayer] = 0; | |
513 | return kTRUE; | |
5d7a6c6d | 514 | } |