VGM Version 5.3
Loading...
Searching...
No Matches
Medium.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The RootGM package of the Virtual Geometry Model
5// Copyright (C) 2007, Ivana Hrivnacova
6// All rights reserved.
7//
8// For the licensing terms see vgm/LICENSE.
9// Contact: ivana@ipno.in2p3.fr
10// -----------------------------------------------------------------------
11
12//
13// Class Medium
14// ---------------
15// VGM implementations for Root medium.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20
23
24#include "TGeoMedium.h"
25
26#include <cstdlib>
27
28const int RootGM::Medium::fgkParamSize = 20;
29
30//_____________________________________________________________________________
31RootGM::Medium::Medium(const std::string& name, int mediumId,
32 VGM::IMaterial* material, int nofParameters, double* parameters)
33 : VGM::IMedium(), BaseVGM::VMedium(material), fMedium(0)
34{
42
43 TGeoMaterial* geoMaterial =
45
46 Double_t* param = new Double_t[fgkParamSize];
47 for (Int_t i = 0; i < fgkParamSize; i++) {
48 if (i < nofParameters)
49 param[i] = parameters[i];
50 else
51 param[i] = 0;
52 }
53
54 fMedium = new TGeoMedium(name.data(), mediumId, geoMaterial, param);
55
56 delete[] param;
57}
58
59//_____________________________________________________________________________
60RootGM::Medium::Medium(TGeoMedium* medium)
61 : VGM::IMedium(),
62 BaseVGM::VMedium(
63 RootGM::MaterialMap::Instance()->GetMaterial(medium->GetMaterial())),
64 fMedium(medium)
65{
67}
68
69//_____________________________________________________________________________
70RootGM::Medium::Medium() : VGM::IMedium(), BaseVGM::VMedium()
71{
73}
74
75//_____________________________________________________________________________
77 : VGM::IMedium(rhs), BaseVGM::VMedium(rhs)
78{
80}
81
82//_____________________________________________________________________________
87
88//
89// private functions
90//
91//_____________________________________________________________________________
92void RootGM::Medium::CheckIndex(int i) const
93{
94 if (i < 0 || i >= NofParameters()) {
95 std::cerr << " RootGM::Medium::CheckIndex: " << std::endl;
96 std::cerr << " Index of parameter outside limits." << std::endl;
97 std::cerr << "*** Error: Aborting execution ***" << std::endl;
98 exit(1);
99 }
100}
101
102//
103// public functions
104//
105
106//_____________________________________________________________________________
107std::string RootGM::Medium::Name() const
108{
109 return std::string(fMedium->GetName());
110}
111
112//_____________________________________________________________________________
114{
115 //
116 return fMedium->GetId();
117}
118
119//_____________________________________________________________________________
120double RootGM::Medium::Parameter(int i) const
121{
122 CheckIndex(i);
123
124 return fMedium->GetParam(i);
125}
The map between VGM and Root material.
Definition MaterialMap.h:36
TGeoMaterial * GetMaterial(VGM::IMaterial *iMaterial) const
static MaterialMap * Instance()
VGM implementation for Root medium.
Definition Medium.h:32
virtual std::string Name() const
Return its name.
Definition Medium.cxx:107
virtual int Id() const
Return its unique identifier.
Definition Medium.cxx:113
virtual double Parameter(int i) const
Return the i-th parameter.
Definition Medium.cxx:120
virtual ~Medium()
Definition Medium.cxx:83
The VGM interface to materials.
Definition IMaterial.h:44
BaseVGM utilities.
Definition utilities.h:23
VGM implementation for Root.
Definition axis.h:28
VGM interfaces.
Definition VMedium.h:28