36 TGeoMedium::TGeoMedium()
39 for (Int_t i=0; i<20; i++) fParams[i] = 0.;
46 TGeoMedium::TGeoMedium(
const char *name, Int_t numed,
const TGeoMaterial *mat, Double_t *params)
49 fName = fName.Strip();
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];
57 gGeoManager->GetListOfMedia()->Add(
this);
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)
67 fName = fName.Strip();
69 for (Int_t i=0; i<20; i++) fParams[i] = 0.;
70 TIter next (gGeoManager->GetListOfMaterials());
72 while ((mat = (TGeoMaterial*)next())) {
73 if (mat->GetUniqueID() == (UInt_t)imat)
break;
75 if (!mat || (mat->GetUniqueID() != (UInt_t)imat)) {
77 Error(
"TGeoMedium",
"%s, material number %d does not exist",name,imat);
80 fMaterial = (TGeoMaterial*)mat;
89 gGeoManager->GetListOfMedia()->Add(
this);
95 TGeoMedium::TGeoMedium(
const TGeoMedium& gm) :
98 fMaterial(gm.fMaterial)
100 for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
106 TGeoMedium& TGeoMedium::operator=(
const TGeoMedium& gm)
109 TNamed::operator=(gm);
111 for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
112 fMaterial=gm.fMaterial;
120 TGeoMedium::~TGeoMedium()
127 char *TGeoMedium::GetPointerName()
const
130 name = TString::Format(
"pMed%d", GetUniqueID());
131 return (
char*)name.Data();
137 void TGeoMedium::SavePrimitive(std::ostream &out, Option_t *option )
139 if (TestBit(TGeoMedium::kMedSavePrimitive))
return;
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;
152 out <<
" " << GetPointerName() <<
" = new TGeoMedium(\"" << GetName() <<
"\", numed," << fMaterial->GetPointerName() <<
", par);" << std::endl;
153 SetBit(TGeoMedium::kMedSavePrimitive);