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
30
31////////////////////////////////////////////////////////////////////////////////
32/// Default constructor
33
35{
36 fId = 0;
37 for (Int_t i = 0; i < 20; i++)
38 fParams[i] = 0.;
39 fMaterial = nullptr;
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// constructor
44
46{
47 fName = fName.Strip();
48 fId = numed;
49 for (Int_t i = 0; i < 20; i++)
50 fParams[i] = 0.;
52 for (Int_t i = 0; i < 10; i++) {
53 if (params)
54 fParams[i] = params[i];
55 else
56 fParams[i] = 0;
57 }
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// constructor
63
66 : TNamed(name, "")
67{
68 fName = fName.Strip();
69 fId = numed;
70 for (Int_t i = 0; i < 20; i++)
71 fParams[i] = 0.;
74 while ((mat = (TGeoMaterial *)next())) {
75 if (mat->GetUniqueID() == (UInt_t)imat)
76 break;
77 }
78 if (!mat || (mat->GetUniqueID() != (UInt_t)imat)) {
79 fMaterial = nullptr;
80 Error("TGeoMedium", "%s, material number %d does not exist", name, imat);
81 return;
82 }
84 fParams[0] = isvol;
85 fParams[1] = ifield;
86 fParams[2] = fieldm;
87 fParams[3] = tmaxfd;
88 fParams[4] = stemax;
89 fParams[5] = deemax;
90 fParams[6] = epsil;
91 fParams[7] = stmin;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// copy constructor
97
98TGeoMedium::TGeoMedium(const TGeoMedium &gm) : TNamed(gm), fId(gm.fId), fMaterial(gm.fMaterial)
99{
100 for (Int_t i = 0; i < 20; i++)
101 fParams[i] = gm.fParams[i];
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// assignment operator
106
108{
109 if (this != &gm) {
111 fId = gm.fId;
112 for (Int_t i = 0; i < 20; i++)
113 fParams[i] = gm.fParams[i];
114 fMaterial = gm.fMaterial;
115 }
116 return *this;
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Destructor
121
123
124////////////////////////////////////////////////////////////////////////////////
125/// Provide a pointer name containing uid.
126
127const char *TGeoMedium::GetPointerName() const
128{
129 static TString name;
130 name.Form("pMed%d", GetUniqueID());
131 return name.Data();
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Save a primitive as a C++ statement(s) on output stream "out".
136
137void TGeoMedium::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
138{
140 return;
142 out << "// Medium: " << GetName() << std::endl;
143 out << " numed = " << fId << "; // medium number" << std::endl;
144 out << " par[0] = " << fParams[0] << "; // isvol" << std::endl;
145 out << " par[1] = " << fParams[1] << "; // ifield" << std::endl;
146 out << " par[2] = " << fParams[2] << "; // fieldm" << std::endl;
147 out << " par[3] = " << fParams[3] << "; // tmaxfd" << std::endl;
148 out << " par[4] = " << fParams[4] << "; // stemax" << std::endl;
149 out << " par[5] = " << fParams[5] << "; // deemax" << std::endl;
150 out << " par[6] = " << fParams[6] << "; // epsil" << std::endl;
151 out << " par[7] = " << fParams[7] << "; // stmin" << std::endl;
152
153 out << " auto " << GetPointerName() << " = new TGeoMedium(\"" << GetName() << "\", numed, "
154 << fMaterial->GetPointerName() << ", par);" << std::endl;
156}
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:49
TString fName
Definition TNamed.h:32
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:50
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:475
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Basic string class.
Definition TString.h:138
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1170