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 **************************************************************************/
21 Old Logs: AliDrawVolume.cxx,v $
22 Revision 1.1 2000/07/13 16:19:10 fca
23 Mainly coding conventions + some small bug fixes
25 Revision 1.8 2000/07/12 08:56:32 fca
26 Coding convention correction and warning removal
28 Revision 1.7 2000/06/28 21:27:45 morsch
29 Most coding rule violations corrected.
30 Still to do: Split the file (on file per class) ? Avoid the global variables.
31 Copy constructors and assignment operators (dummy ?)
33 Revision 1.6 2000/04/14 11:07:46 morsch
34 Correct volume to medium assignment in case several media are asigned to the
37 Revision 1.5 2000/03/20 15:11:03 fca
38 Mods to make the code compile on HP
40 Revision 1.4 2000/01/18 16:12:08 morsch
41 Bug in calculation of number of volume divisions and number of positionings corrected
42 Browser for Material and Media properties added
44 Revision 1.3 1999/11/14 14:31:14 fca
45 Correct small error and remove compilation warnings on HP
47 Revision 1.2 1999/11/10 16:53:35 fca
48 The new geometry viewer from A.Morsch
54 * Written by Andreas Morsch
58 * For questions critics and suggestions to this part of the code
59 * contact andreas.morsch@cern.ch
61 **************************************************************************/
63 #include "AliG3Volume.h"
65 #include "TMaterial.h"
87 AliG3Volume::AliG3Volume(const char* name)
118 AliG3Volume::AliG3Volume(const AliG3Volume& volume)
143 fIdVolume = volume.GetIdVolume();
144 fIdCopy = volume.GetIdCopy();
145 fIdMedium = volume.Medium();
146 fIdMaterial = volume.Material();
147 fPosition = volume.Position(0);
148 fShape = volume.Shape();
149 fRotMatrix = volume.RotMatrix();
151 volume.Parameters(0, fParameters);
152 fNCopies = volume.NCopies();
153 fPosp = volume.Posp();
155 fNParam = volume.NParam();
156 fCopies = volume.Copies();
157 fRotMatrix = volume.RotMatrix();
158 volume.Division(fNdiv, fAxis, fStartC, fStep);
165 void AliG3Volume::Draw(Option_t *)
167 // Wraps the geant Gdraw
168 gMC->Gsatt(fName,"seen", fSeen);
171 gMC->Gdopt("hide", "on");
173 gMC->Gdopt("hide", "off");
177 gMC->Gdopt("shad", "on");
178 gMC->Gsatt("*", "fill", fFill);
180 gMC->Gdopt("shad", "off");
183 gMC->SetClipBox(".");
185 gMC->SetClipBox("*", fClipXmin, fClipXmax,
186 fClipYmin, fClipYmax, fClipZmin, fClipZmax);
188 gMC->SetClipBox(".");
192 gMC->Gdraw(fName, fTheta, fPhi, fPsi, fU, fV, fUscale, fVscale);
193 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
194 if (higz) higz->Update();
197 void AliG3Volume::DrawSpec()
199 // Wraps the Geant DrawSpec
200 gMC->Gsatt(fName,"seen", fSeen);
203 gMC->Gdopt("hide", "on");
205 gMC->Gdopt("hide", "off");
209 gMC->Gdopt("shad", "on");
210 gMC->Gsatt("*", "fill", fFill);
212 gMC->Gdopt("shad", "off");
215 gMC->SetClipBox(".");
217 gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
219 gMC->SetClipBox(".");
223 ((TGeant3*) gMC)->DrawOneSpec(fName);
224 THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
225 if (higz) higz->Update();
228 void AliG3Volume::SetParam(Int_t ip, Float_t param)
230 // Set drawing parameters
257 fShadow=Int_t(param);
289 Float_t AliG3Volume::GetParam(Int_t ip)
291 // Get drawing parameters
308 return Float_t(fHide);
310 return Float_t(fShadow);
312 return Float_t(fFill);
314 return Float_t(fSeen);
316 return Float_t(fClip);
335 void AliG3Volume::AddCopy(AliG3Volume* volume)
337 volume->SetIdMaterial(Material());
338 fCopies->Add(volume);
342 AliG3Volume* AliG3Volume::Copy(Int_t i)
344 return (AliG3Volume*) fCopies->At(i);
348 TArrayF AliG3Volume::Position(Int_t i) const
351 // Get position for volume copy i
356 return ((AliG3Volume*) fCopies->At(i-1))->Position(0);
360 void AliG3Volume::SetPosition(Float_t x, Float_t y, Float_t z)
371 void AliG3Volume::SetParameters(Int_t np, Float_t* param)
377 for (Int_t j=0; j<np; j++) fParameters[j]=param[j];
382 void AliG3Volume::Parameters(Int_t i, TArrayF& param) const
385 // Get parameters for volume copy i
391 ((AliG3Volume*) (fCopies->At(i-1)))->Parameters(0, p);
395 for (Int_t j=0; j<np; j++) {
401 void AliG3Volume::CreateTShape(char* nameV, TMaterial* mat)
404 // Create a root volume from G3 volume
408 Float_t kRadDeg = 180./TMath::Pi();
409 Float_t theta, phi, alpha1, alpha2;
413 const char* tmp = mat->GetName();
415 strncpy(nameM, tmp, 20);
421 nShape = new TBRIK(nameV,"BRIK",nameM,fParameters[0], fParameters[1], fParameters[2]);
426 nShape = new TTRD1(nameV, "TRD1", nameM, fParameters[0], fParameters[1], fParameters[2],
432 nShape = new TTRD2(nameV, "TRD2", nameM, fParameters[0], fParameters[1], fParameters[2],
433 fParameters[3], fParameters[4]);
441 theta = TMath::ATan(TMath::Sqrt(p1*p1+p2*p2))*kRadDeg;
442 phi = TMath::ATan2(p2,p1)*kRadDeg;
443 alpha1 = fParameters[6 ]*kRadDeg;
444 alpha2 = fParameters[10]*kRadDeg;
446 if (theta < 0.) theta+=180.;
448 nShape = new TTRAP(nameV, "TRAP", nameM, fParameters[0],
450 fParameters[3], fParameters[4], fParameters[5],
452 fParameters[7], fParameters[8], fParameters[9],
458 nShape = new TTUBE(nameV,"TUBE",nameM,fParameters[0], fParameters[1], fParameters[2]);
463 nShape = new TTUBS(nameV,"TUBS",nameM,fParameters[0], fParameters[1], fParameters[2],
464 fParameters[3], fParameters[4]);
469 nShape = new TCONE(nameV, "CONE", nameM, fParameters[0], fParameters[1], fParameters[2],
470 fParameters[3], fParameters[4]);
476 nShape = new TCONS(nameV, "CONS", nameM, fParameters[0], fParameters[1], fParameters[2],
477 fParameters[3], fParameters[4], fParameters[5], fParameters[6]);
483 nShape = new TSPHE(nameV, "SPHE", nameM, fParameters[0], fParameters[1], fParameters[2],
484 fParameters[3], fParameters[4], fParameters[5]);
489 alpha1 = fParameters[3]*kRadDeg;
492 theta = TMath::ATan(TMath::Sqrt(p1*p1+p2*p2))*kRadDeg;
493 phi = TMath::ATan2(p2,p1)*kRadDeg;
495 nShape = new TPARA(nameV, "PARA", nameM, fParameters[0], fParameters[1], fParameters[2],
501 nShape = new TPGON(nameV, "PGON", nameM, fParameters[0], fParameters[1], Int_t(fParameters[2]),
502 Int_t(fParameters[3]));
503 for (ip=0; ip<Int_t(fParameters[3]); ip++) {
504 ((TPGON*) nShape)->DefineSection(ip, fParameters[4+3*ip], fParameters[4+3*ip+1],
505 fParameters[4+3*ip+2]);
511 nShape = new TPCON(nameV, "PCON", nameM, fParameters[0], fParameters[1], Int_t(fParameters[2]));
512 for (ip=0; ip<Int_t(fParameters[2]); ip++) {
513 ((TPCON*) nShape)->DefineSection(ip, fParameters[3+3*ip], fParameters[3+3*ip+1],
514 fParameters[3+3*ip+2]);
520 nShape = new TELTU(nameV,"ELTU",nameM,fParameters[0], fParameters[1], fParameters[2]);
525 nShape = new THYPE(nameV,"HYPE",nameM,fParameters[0], fParameters[1], fParameters[2],
531 nShape = new TGTRA(nameV, "GTRA", nameM, fParameters[0], fParameters[1], fParameters[2],
532 fParameters[3], fParameters[4], fParameters[5], fParameters[6],
533 fParameters[7], fParameters[8], fParameters[9], fParameters[10],
539 nShape = new TCTUB(nameV, "CTUB", nameM, fParameters[0], fParameters[1], fParameters[2],
540 fParameters[3], fParameters[4], fParameters[5], fParameters[6],
541 fParameters[7], fParameters[8], fParameters[9], fParameters[10]);
547 Float_t density = mat->GetDensity();
548 if (density < 0.01) {
549 nShape->SetVisibility(0);
551 nShape->SetVisibility(1);
554 Int_t color = Int_t(density/20.*100.);
555 nShape->SetLineColor(color);
559 void AliG3Volume::SetDivision(Int_t ndiv, Int_t axis, Float_t start, Float_t step)
567 void AliG3Volume::Division(Int_t& ndiv, Int_t& axis, Float_t& start, Float_t& step) const