Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoMedium.cxx
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Rene Brun 26/12/02
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoMedium
13\ingroup Materials_classes
14
15Media are used to store properties related to tracking and which are useful
16only when using geometry with a particle transport MC package (via VMC). One
17may define several tracking media for a given material. The media ID are user
18defined values that are not used by the geometry package. In case geometry
19is used via VMC (in GEANT) these numbers are overwritten, so one can only
20rely on these values after gMC->FinishGeometry() is called.
21The media parameters are inspired from GEANT3 and the values defined make sense
22in context of GEANT (3 but also 4) or FLUKA interfaces.
23*/
24
25#include <iostream>
26#include "TGeoManager.h"
27#include "TGeoMedium.h"
28#include "TList.h"
29
31
32////////////////////////////////////////////////////////////////////////////////
33/// Default constructor
34
36{
37 fId = 0;
38 for (Int_t i = 0; i < 20; i++)
39 fParams[i] = 0.;
40 fMaterial = nullptr;
41}
42
43////////////////////////////////////////////////////////////////////////////////
44/// constructor
45
46TGeoMedium::TGeoMedium(const char *name, Int_t numed, const TGeoMaterial *mat, Double_t *params) : TNamed(name, "")
47{
48 fName = fName.Strip();
49 fId = numed;
50 for (Int_t i = 0; i < 20; i++)
51 fParams[i] = 0.;
52 fMaterial = (TGeoMaterial *)mat;
53 for (Int_t i = 0; i < 10; i++) {
54 if (params)
55 fParams[i] = params[i];
56 else
57 fParams[i] = 0;
58 }
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// constructor
64
65TGeoMedium::TGeoMedium(const char *name, Int_t numed, Int_t imat, Int_t isvol, Int_t ifield, Double_t fieldm,
66 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
67 : TNamed(name, "")
68{
69 fName = fName.Strip();
70 fId = numed;
71 for (Int_t i = 0; i < 20; i++)
72 fParams[i] = 0.;
74 TGeoMaterial *mat;
75 while ((mat = (TGeoMaterial *)next())) {
76 if (mat->GetUniqueID() == (UInt_t)imat)
77 break;
78 }
79 if (!mat || (mat->GetUniqueID() != (UInt_t)imat)) {
80 fMaterial = nullptr;
81 Error("TGeoMedium", "%s, material number %d does not exist", name, imat);
82 return;
83 }
84 fMaterial = (TGeoMaterial *)mat;
85 fParams[0] = isvol;
86 fParams[1] = ifield;
87 fParams[2] = fieldm;
88 fParams[3] = tmaxfd;
89 fParams[4] = stemax;
90 fParams[5] = deemax;
91 fParams[6] = epsil;
92 fParams[7] = stmin;
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// copy constructor
98
99TGeoMedium::TGeoMedium(const TGeoMedium &gm) : TNamed(gm), fId(gm.fId), fMaterial(gm.fMaterial)
100{
101 for (Int_t i = 0; i < 20; i++)
102 fParams[i] = gm.fParams[i];
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// assignment operator
107
109{
110 if (this != &gm) {
112 fId = gm.fId;
113 for (Int_t i = 0; i < 20; i++)
114 fParams[i] = gm.fParams[i];
115 fMaterial = gm.fMaterial;
116 }
117 return *this;
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Destructor
122
124
125////////////////////////////////////////////////////////////////////////////////
126/// Provide a pointer name containing uid.
127
128const char *TGeoMedium::GetPointerName() const
129{
130 static TString name;
131 name.Form("pMed%d", GetUniqueID());
132 return name.Data();
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Save a primitive as a C++ statement(s) on output stream "out".
137
138void TGeoMedium::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
139{
141 return;
143 out << "// Medium: " << GetName() << std::endl;
144 out << " numed = " << fId << "; // medium number" << std::endl;
145 out << " par[0] = " << fParams[0] << "; // isvol" << std::endl;
146 out << " par[1] = " << fParams[1] << "; // ifield" << std::endl;
147 out << " par[2] = " << fParams[2] << "; // fieldm" << std::endl;
148 out << " par[3] = " << fParams[3] << "; // tmaxfd" << std::endl;
149 out << " par[4] = " << fParams[4] << "; // stemax" << std::endl;
150 out << " par[5] = " << fParams[5] << "; // deemax" << std::endl;
151 out << " par[6] = " << fParams[6] << "; // epsil" << std::endl;
152 out << " par[7] = " << fParams[7] << "; // stmin" << std::endl;
153
154 out << " auto " << GetPointerName() << " = new TGeoMedium(\"" << GetName() << "\", numed, "
155 << fMaterial->GetPointerName() << ", par);" << std::endl;
157}
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
TList * GetListOfMedia() const
TList * GetListOfMaterials() const
Base class describing materials.
const char * GetPointerName() const
Provide a pointer name containing uid.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
TGeoMaterial * fMaterial
Definition TGeoMedium.h:30
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Double_t fParams[20]
Definition TGeoMedium.h:29
@ kMedSavePrimitive
Definition TGeoMedium.h:25
TGeoMedium & operator=(const TGeoMedium &)
assignment operator
Int_t fId
Definition TGeoMedium.h:28
const char * GetPointerName() const
Provide a pointer name containing uid.
TGeoMedium()
Default constructor.
~TGeoMedium() override
Destructor.
void Add(TObject *obj) override
Definition TList.h:81
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
TString fName
Definition TNamed.h:32
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:51
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:457
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
Basic string class.
Definition TString.h:139
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1163
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356