1 /* *************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
18 Revision 1.1 2001/07/09 11:41:46 morsch
19 AliGUIMedium, AliGUIMaterial and AliDrawVolume obselete. Development continues
20 on AliG3Material, AliG3Medium and AliG3Volume.
25 Old Logs: AliDrawVolume.cxx,v $
26 Revision 1.1 2000/07/13 16:19:10 fca
27 Mainly coding conventions + some small bug fixes
29 Revision 1.8 2000/07/12 08:56:32 fca
30 Coding convention correction and warning removal
32 Revision 1.7 2000/06/28 21:27:45 morsch
33 Most coding rule violations corrected.
34 Still to do: Split the file (on file per class) ? Avoid the global variables.
35 Copy constructors and assignment operators (dummy ?)
37 Revision 1.6 2000/04/14 11:07:46 morsch
38 Correct volume to medium assignment in case several media are asigned to the
41 Revision 1.5 2000/03/20 15:11:03 fca
42 Mods to make the code compile on HP
44 Revision 1.4 2000/01/18 16:12:08 morsch
45 Bug in calculation of number of volume divisions and number of positionings corrected
46 Browser for Material and Media properties added
48 Revision 1.3 1999/11/14 14:31:14 fca
49 Correct small error and remove compilation warnings on HP
51 Revision 1.2 1999/11/10 16:53:35 fca
52 The new geometry viewer from A.Morsch
58 * Written by Andreas Morsch
62 * For questions critics and suggestions to this part of the code
63 * contact andreas.morsch@cern.ch
65 **************************************************************************/
67 #include "AliG3Volume.h"
69 #include "TMaterial.h"
91 AliG3Volume::AliG3Volume(const char* name)
122 AliG3Volume::AliG3Volume(const AliG3Volume& volume)
147 fIdVolume = volume.GetIdVolume();
148 fIdCopy = volume.GetIdCopy();
149 fIdMedium = volume.Medium();
150 fIdMaterial = volume.Material();
151 fPosition = volume.Position(0);
152 fShape = volume.Shape();
153 fRotMatrix = volume.RotMatrix();
155 volume.Parameters(0, fParameters);
156 fNCopies = volume.NCopies();
157 fPosp = volume.Posp();
159 fNParam = volume.NParam();
160 fCopies = volume.Copies();
161 fRotMatrix = volume.RotMatrix();
162 volume.Division(fNdiv, fAxis, fStartC, fStep);
169 void AliG3Volume::Draw(Option_t *)
171 // Wraps the geant Gdraw
172 gMC->Gsatt(fName,"seen", fSeen);
175 gMC->Gdopt("hide", "on");
177 gMC->Gdopt("hide", "off");
181 gMC->Gdopt("shad", "on");
182 gMC->Gsatt("*", "fill", fFill);
184 gMC->Gdopt("shad", "off");
187 gMC->SetClipBox(".");
189 gMC->SetClipBox("*", fClipXmin, fClipXmax,
190 fClipYmin, fClipYmax, fClipZmin, fClipZmax);
192 gMC->SetClipBox(".");
196 gMC->Gdraw(fName, fTheta, fPhi, fPsi, fU, fV, fUscale, fVscale);
197 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
198 if (higz) higz->Update();
201 void AliG3Volume::DrawSpec()
203 // Wraps the Geant DrawSpec
204 gMC->Gsatt(fName,"seen", fSeen);
207 gMC->Gdopt("hide", "on");
209 gMC->Gdopt("hide", "off");
213 gMC->Gdopt("shad", "on");
214 gMC->Gsatt("*", "fill", fFill);
216 gMC->Gdopt("shad", "off");
219 gMC->SetClipBox(".");
221 gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
223 gMC->SetClipBox(".");
227 ((TGeant3*) gMC)->DrawOneSpec(fName);
228 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
229 if (higz) higz->Update();
232 void AliG3Volume::SetParam(Int_t ip, Float_t param)
234 // Set drawing parameters
261 fShadow=Int_t(param);
293 Float_t AliG3Volume::GetParam(Int_t ip)
295 // Get drawing parameters
312 return Float_t(fHide);
314 return Float_t(fShadow);
316 return Float_t(fFill);
318 return Float_t(fSeen);
320 return Float_t(fClip);
339 void AliG3Volume::AddCopy(AliG3Volume* volume)
341 volume->SetIdMaterial(Material());
342 fCopies->Add(volume);
346 AliG3Volume* AliG3Volume::Copy(Int_t i)
348 return (AliG3Volume*) fCopies->At(i);
352 TArrayF AliG3Volume::Position(Int_t i) const
355 // Get position for volume copy i
360 return ((AliG3Volume*) fCopies->At(i-1))->Position(0);
364 void AliG3Volume::SetPosition(Float_t x, Float_t y, Float_t z)
375 void AliG3Volume::SetParameters(Int_t np, Float_t* param)
381 for (Int_t j=0; j<np; j++) fParameters[j]=param[j];
386 void AliG3Volume::Parameters(Int_t i, TArrayF& param) const
389 // Get parameters for volume copy i
395 ((AliG3Volume*) (fCopies->At(i-1)))->Parameters(0, p);
399 for (Int_t j=0; j<np; j++) {
405 void AliG3Volume::CreateTShape(char* nameV, TMaterial* mat)
408 // Create a root volume from G3 volume
412 Float_t kRadDeg = 180./TMath::Pi();
413 Float_t theta, phi, alpha1, alpha2;
417 const char* tmp = mat->GetName();
419 strncpy(nameM, tmp, 20);
425 nShape = new TBRIK(nameV,"BRIK",nameM,fParameters[0], fParameters[1], fParameters[2]);
430 nShape = new TTRD1(nameV, "TRD1", nameM, fParameters[0], fParameters[1], fParameters[2],
436 nShape = new TTRD2(nameV, "TRD2", nameM, fParameters[0], fParameters[1], fParameters[2],
437 fParameters[3], fParameters[4]);
445 theta = TMath::ATan(TMath::Sqrt(p1*p1+p2*p2))*kRadDeg;
446 phi = TMath::ATan2(p2,p1)*kRadDeg;
447 alpha1 = fParameters[6 ]*kRadDeg;
448 alpha2 = fParameters[10]*kRadDeg;
450 if (theta < 0.) theta+=180.;
452 nShape = new TTRAP(nameV, "TRAP", nameM, fParameters[0],
454 fParameters[3], fParameters[4], fParameters[5],
456 fParameters[7], fParameters[8], fParameters[9],
462 nShape = new TTUBE(nameV,"TUBE",nameM,fParameters[0], fParameters[1], fParameters[2]);
467 nShape = new TTUBS(nameV,"TUBS",nameM,fParameters[0], fParameters[1], fParameters[2],
468 fParameters[3], fParameters[4]);
473 nShape = new TCONE(nameV, "CONE", nameM, fParameters[0], fParameters[1], fParameters[2],
474 fParameters[3], fParameters[4]);
480 nShape = new TCONS(nameV, "CONS", nameM, fParameters[0], fParameters[1], fParameters[2],
481 fParameters[3], fParameters[4], fParameters[5], fParameters[6]);
487 nShape = new TSPHE(nameV, "SPHE", nameM, fParameters[0], fParameters[1], fParameters[2],
488 fParameters[3], fParameters[4], fParameters[5]);
493 alpha1 = fParameters[3]*kRadDeg;
496 theta = TMath::ATan(TMath::Sqrt(p1*p1+p2*p2))*kRadDeg;
497 phi = TMath::ATan2(p2,p1)*kRadDeg;
499 nShape = new TPARA(nameV, "PARA", nameM, fParameters[0], fParameters[1], fParameters[2],
505 nShape = new TPGON(nameV, "PGON", nameM, fParameters[0], fParameters[1], Int_t(fParameters[2]),
506 Int_t(fParameters[3]));
507 for (ip=0; ip<Int_t(fParameters[3]); ip++) {
508 ((TPGON*) nShape)->DefineSection(ip, fParameters[4+3*ip], fParameters[4+3*ip+1],
509 fParameters[4+3*ip+2]);
515 nShape = new TPCON(nameV, "PCON", nameM, fParameters[0], fParameters[1], Int_t(fParameters[2]));
516 for (ip=0; ip<Int_t(fParameters[2]); ip++) {
517 ((TPCON*) nShape)->DefineSection(ip, fParameters[3+3*ip], fParameters[3+3*ip+1],
518 fParameters[3+3*ip+2]);
524 nShape = new TELTU(nameV,"ELTU",nameM,fParameters[0], fParameters[1], fParameters[2]);
529 nShape = new THYPE(nameV,"HYPE",nameM,fParameters[0], fParameters[1], fParameters[2],
535 nShape = new TGTRA(nameV, "GTRA", nameM, fParameters[0], fParameters[1], fParameters[2],
536 fParameters[3], fParameters[4], fParameters[5], fParameters[6],
537 fParameters[7], fParameters[8], fParameters[9], fParameters[10],
543 nShape = new TCTUB(nameV, "CTUB", nameM, fParameters[0], fParameters[1], fParameters[2],
544 fParameters[3], fParameters[4], fParameters[5], fParameters[6],
545 fParameters[7], fParameters[8], fParameters[9], fParameters[10]);
551 Float_t density = mat->GetDensity();
552 if (density < 0.01) {
553 nShape->SetVisibility(0);
555 nShape->SetVisibility(1);
558 Int_t color = Int_t(density/20.*100.);
559 nShape->SetLineColor(color);
563 void AliG3Volume::SetDivision(Int_t ndiv, Int_t axis, Float_t start, Float_t step)
571 void AliG3Volume::Division(Int_t& ndiv, Int_t& axis, Float_t& start, Float_t& step) const