#include "Riostream.h"
#include "TGeoManager.h"
#include "TGeoMedium.h"
#include "TList.h"
ClassImp(TGeoMedium)
TGeoMedium::TGeoMedium()
{
fId = 0;
fMaterial= 0;
}
TGeoMedium::TGeoMedium(const char *name, Int_t numed, const TGeoMaterial *mat, Double_t *params)
:TNamed(name,"")
{
fName = fName.Strip();
fId = numed;
fMaterial = (TGeoMaterial*)mat;
for (Int_t i=0;i<10;i++) {
if (params) fParams[i] = params[i];
else fParams[i] = 0;
}
gGeoManager->GetListOfMedia()->Add(this);
}
TGeoMedium::TGeoMedium(const char *name, Int_t numed, Int_t imat, Int_t isvol, Int_t ifield,
Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
:TNamed(name,"")
{
fName = fName.Strip();
fId = numed;
TIter next (gGeoManager->GetListOfMaterials());
TGeoMaterial *mat;
while ((mat = (TGeoMaterial*)next())) {
if (mat->GetUniqueID() == (UInt_t)imat) break;
}
if (!mat || (mat->GetUniqueID() != (UInt_t)imat)) {
fMaterial = 0;
Error("TGeoMedium", "%s, material number %d does not exist",name,imat);
return;
}
fMaterial = (TGeoMaterial*)mat;
fParams[0] = isvol;
fParams[1] = ifield;
fParams[2] = fieldm;
fParams[3] = tmaxfd;
fParams[4] = stemax;
fParams[5] = deemax;
fParams[6] = epsil;
fParams[7] = stmin;
for (Int_t i=8;i<20;i++) fParams[i] = 0;
gGeoManager->GetListOfMedia()->Add(this);
}
TGeoMedium::TGeoMedium(const TGeoMedium& gm) :
TNamed(gm),
fId(gm.fId),
fMaterial(gm.fMaterial)
{
for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
}
TGeoMedium& TGeoMedium::operator=(const TGeoMedium& gm)
{
if(this!=&gm) {
TNamed::operator=(gm);
fId=gm.fId;
for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
fMaterial=gm.fMaterial;
}
return *this;
}
TGeoMedium::~TGeoMedium()
{
}
char *TGeoMedium::GetPointerName() const
{
static char name[20];
sprintf(name,"pMed%d", GetUniqueID());
return name;
}
void TGeoMedium::SavePrimitive(ostream &out, Option_t *option )
{
if (TestBit(TGeoMedium::kMedSavePrimitive)) return;
fMaterial->SavePrimitive(out,option);
out << "// Medium: " << GetName() << endl;
out << " numed = " << fId << "; // medium number" << endl;
out << " par[0] = " << fParams[0] << "; // isvol" << endl;
out << " par[1] = " << fParams[1] << "; // ifield" << endl;
out << " par[2] = " << fParams[2] << "; // fieldm" << endl;
out << " par[3] = " << fParams[3] << "; // tmaxfd" << endl;
out << " par[4] = " << fParams[4] << "; // stemax" << endl;
out << " par[5] = " << fParams[5] << "; // deemax" << endl;
out << " par[6] = " << fParams[6] << "; // epsil" << endl;
out << " par[7] = " << fParams[7] << "; // stmin" << endl;
out << " " << GetPointerName() << " = new TGeoMedium(\"" << GetName() << "\", numed," << fMaterial->GetPointerName() << ", par);" << endl;
SetBit(TGeoMedium::kMedSavePrimitive);
}
Last change: Wed Jun 25 08:44:48 2008
Last generated: 2008-06-25 08:44
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.