Logo ROOT  
Reference Guide
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 
16 Media are used to store properties related to tracking and which are useful
17 only when using geometry with a particle transport MC package (via VMC). One
18 may define several tracking media for a given material. The media ID are user
19 defined values that are not used by the geometry package. In case geometry
20 is used via VMC (in GEANT) these numbers are overwritten, so one can only
21 rely on these values after gMC->FinishGeometry() is called.
22 The media parameters are inspired from GEANT3 and the values defined make sense
23 in 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 
46 TGeoMedium::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  }
57  gGeoManager->GetListOfMedia()->Add(this);
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// constructor
62 
63 TGeoMedium::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;
89  gGeoManager->GetListOfMedia()->Add(this);
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) {
109  TNamed::operator=(gm);
110  fId=gm.fId;
111  for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
112  fMaterial=gm.fMaterial;
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 
137 void 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 }
TGeoMedium::kMedSavePrimitive
@ kMedSavePrimitive
Definition: TGeoMedium.h:27
TGeoMedium.h
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
TGeoMedium::GetPointerName
char * GetPointerName() const
Provide a pointer name containing uid.
Definition: TGeoMedium.cxx:127
Option_t
const char Option_t
Definition: RtypesCore.h:66
TString::Strip
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1131
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
TNamed::operator=
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
TGeoMedium::fMaterial
TGeoMaterial * fMaterial
Definition: TGeoMedium.h:33
TGeoMedium::fId
Int_t fId
Definition: TGeoMedium.h:31
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
TGeoMedium::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGeoMedium.cxx:137
TObject::GetUniqueID
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition: TObject.cxx:377
TNamed::fName
TString fName
Definition: TNamed.h:32
TGeoMedium::fParams
Double_t fParams[20]
Definition: TGeoMedium.h:32
TList.h
TGeoMaterial::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGeoMaterial.cxx:537
TString::Format
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:2336
TString
Basic string class.
Definition: TString.h:136
TGeoMaterial
Base class describing materials.
Definition: TGeoMaterial.h:36
TGeoManager::GetListOfMaterials
TList * GetListOfMaterials() const
Definition: TGeoManager.h:491
TGeoMaterial::GetPointerName
char * GetPointerName() const
Provide a pointer name containing uid.
Definition: TGeoMaterial.cxx:419
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TGeoMedium::operator=
TGeoMedium & operator=(const TGeoMedium &)
assignment operator
Definition: TGeoMedium.cxx:106
unsigned int
TGeoMedium::~TGeoMedium
virtual ~TGeoMedium()
Destructor.
Definition: TGeoMedium.cxx:120
TGeoManager.h
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeoManager::GetListOfMedia
TList * GetListOfMedia() const
Definition: TGeoManager.h:492
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
name
char name[80]
Definition: TGX11.cxx:110
TIter
Definition: TCollection.h:233
TGeoMedium::TGeoMedium
TGeoMedium()
Default constructor.
Definition: TGeoMedium.cxx:36
TGeoMedium
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:24
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
int