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
13/** \class TGeoMedium
14\ingroup Geometry_classes
15
16Media are used to store properties related to tracking and which are useful
17only when using geometry with a particle transport MC package (via VMC). One
18may define several tracking media for a given material. The media ID are user
19defined values that are not used by the geometry package. In case geometry
20is used via VMC (in GEANT) these numbers are overwritten, so one can only
21rely on these values after gMC->FinishGeometry() is called.
22The media parameters are inspired from GEANT3 and the values defined make sense
23in context of GEANT (3 but also 4) or FLUKA interfaces.
24*/
25
26#include <iostream>
27#include "TGeoManager.h"
28#include "TGeoMedium.h"
29#include "TList.h"
30
32
33////////////////////////////////////////////////////////////////////////////////
34/// Default constructor
35
37{
38 fId = 0;
39 for (Int_t i=0; i<20; i++) fParams[i] = 0.;
40 fMaterial= 0;
41}
42
43////////////////////////////////////////////////////////////////////////////////
44/// constructor
45
46TGeoMedium::TGeoMedium(const char *name, Int_t numed, const TGeoMaterial *mat, Double_t *params)
47 :TNamed(name,"")
48{
49 fName = fName.Strip();
50 fId = numed;
51 for (Int_t i=0; i<20; i++) fParams[i] = 0.;
52 fMaterial = (TGeoMaterial*)mat;
53 for (Int_t i=0;i<10;i++) {
54 if (params) fParams[i] = params[i];
55 else fParams[i] = 0;
56 }
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// constructor
62
63TGeoMedium::TGeoMedium(const char *name, Int_t numed, Int_t imat, Int_t isvol, Int_t ifield,
64 Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
65 :TNamed(name,"")
66{
67 fName = fName.Strip();
68 fId = numed;
69 for (Int_t i=0; i<20; i++) fParams[i] = 0.;
71 TGeoMaterial *mat;
72 while ((mat = (TGeoMaterial*)next())) {
73 if (mat->GetUniqueID() == (UInt_t)imat) break;
74 }
75 if (!mat || (mat->GetUniqueID() != (UInt_t)imat)) {
76 fMaterial = 0;
77 Error("TGeoMedium", "%s, material number %d does not exist",name,imat);
78 return;
79 }
80 fMaterial = (TGeoMaterial*)mat;
81 fParams[0] = isvol;
82 fParams[1] = ifield;
83 fParams[2] = fieldm;
84 fParams[3] = tmaxfd;
85 fParams[4] = stemax;
86 fParams[5] = deemax;
87 fParams[6] = epsil;
88 fParams[7] = stmin;
90}
91
92////////////////////////////////////////////////////////////////////////////////
93///copy constructor
94
96 TNamed(gm),
97 fId(gm.fId),
98 fMaterial(gm.fMaterial)
99{
100 for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
101}
102
103////////////////////////////////////////////////////////////////////////////////
104///assignment operator
105
107{
108 if(this!=&gm) {
110 fId=gm.fId;
111 for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
113 }
114 return *this;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Destructor
119
121{
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Provide a pointer name containing uid.
126
128{
129 static TString name;
130 name = TString::Format("pMed%d", GetUniqueID());
131 return (char*)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 fMaterial->SavePrimitive(out,option);
141 out << "// Medium: " << GetName() << std::endl;
142 out << " numed = " << fId << "; // medium number" << std::endl;
143 out << " par[0] = " << fParams[0] << "; // isvol" << std::endl;
144 out << " par[1] = " << fParams[1] << "; // ifield" << std::endl;
145 out << " par[2] = " << fParams[2] << "; // fieldm" << std::endl;
146 out << " par[3] = " << fParams[3] << "; // tmaxfd" << std::endl;
147 out << " par[4] = " << fParams[4] << "; // stemax" << std::endl;
148 out << " par[5] = " << fParams[5] << "; // deemax" << std::endl;
149 out << " par[6] = " << fParams[6] << "; // epsil" << std::endl;
150 out << " par[7] = " << fParams[7] << "; // stmin" << std::endl;
151
152 out << " " << GetPointerName() << " = new TGeoMedium(\"" << GetName() << "\", numed," << fMaterial->GetPointerName() << ", par);" << std::endl;
154}
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
TList * GetListOfMedia() const
TList * GetListOfMaterials() const
Base class describing materials.
char * GetPointerName() const
Provide a pointer name containing uid.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
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:24
TGeoMaterial * fMaterial
Definition TGeoMedium.h:33
Double_t fParams[20]
Definition TGeoMedium.h:32
@ kMedSavePrimitive
Definition TGeoMedium.h:27
TGeoMedium & operator=(const TGeoMedium &)
assignment operator
virtual ~TGeoMedium()
Destructor.
Int_t fId
Definition TGeoMedium.h:31
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TGeoMedium()
Default constructor.
char * GetPointerName() const
Provide a pointer name containing uid.
virtual void Add(TObject *obj)
Definition TList.h:87
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
TString fName
Definition TNamed.h:32
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:51
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:187
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:377
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:696
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:893
Basic string class.
Definition TString.h:136
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1126
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2331