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
45TGeoMedium::TGeoMedium(const char *name, Int_t numed, const TGeoMaterial *mat, Double_t *params) : TNamed(name, "")
46{
47 fName = fName.Strip();
48 fId = numed;
49 for (Int_t i = 0; i < 20; i++)
50 fParams[i] = 0.;
51 fMaterial = (TGeoMaterial *)mat;
52 for (Int_t i = 0; i < 10; i++) {
53 if (params)
54 fParams[i] = params[i];
55 else
56 fParams[i] = 0;
57 }
58 gGeoManager->GetListOfMedia()->Add(this);
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// constructor
63
64TGeoMedium::TGeoMedium(const char *name, Int_t numed, Int_t imat, Int_t isvol, Int_t ifield, Double_t fieldm,
65 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
66 : TNamed(name, "")
67{
68 fName = fName.Strip();
69 fId = numed;
70 for (Int_t i = 0; i < 20; i++)
71 fParams[i] = 0.;
72 TIter next(gGeoManager->GetListOfMaterials());
73 TGeoMaterial *mat;
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 }
83 fMaterial = (TGeoMaterial *)mat;
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;
92 gGeoManager->GetListOfMedia()->Add(this);
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// copy constructor
97
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;
141 fMaterial->SavePrimitive(out, option);
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}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
char name[80]
Definition TGX11.cxx:148
externTGeoManager * gGeoManager
Base class describing materials.
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(const TGeoMedium &)
copy constructor
~TGeoMedium() override
Destructor.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
TNamed()
Definition TNamed.h:38
TString fName
Definition TNamed.h:32
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:50
Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:480
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
Basic string class.
Definition TString.h:138
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.