Logo ROOT   6.12/07
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 "Riostream.h"
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),
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 }
Double_t fParams[20]
Definition: TGeoMedium.h:32
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition: TObject.cxx:375
const char Option_t
Definition: RtypesCore.h:62
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Basic string class.
Definition: TString.h:125
Base class describing materials.
Definition: TGeoMaterial.h:29
int Int_t
Definition: RtypesCore.h:41
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
TList * GetListOfMaterials() const
Definition: TGeoManager.h:463
TList * GetListOfMedia() const
Definition: TGeoManager.h:464
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:2365
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
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".
Definition: TGeoMedium.cxx:137
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
char * GetPointerName() const
Provide a pointer name containing uid.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1080
TGeoMedium()
Default constructor.
Definition: TGeoMedium.cxx:36
TString fName
Definition: TNamed.h:32
#define ClassImp(name)
Definition: Rtypes.h:359
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:559
double Double_t
Definition: RtypesCore.h:55
virtual ~TGeoMedium()
Destructor.
Definition: TGeoMedium.cxx:120
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:23
TGeoMaterial * fMaterial
Definition: TGeoMedium.h:33
char * GetPointerName() const
Provide a pointer name containing uid.
Definition: TGeoMedium.cxx:127
virtual void Add(TObject *obj)
Definition: TList.h:87
TGeoMedium & operator=(const TGeoMedium &)
assignment operator
Definition: TGeoMedium.cxx:106
char name[80]
Definition: TGX11.cxx:109
const char * Data() const
Definition: TString.h:345