TGeoMedium.cxx

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoMedium.cxx 36535 2010-11-08 14:41:54Z agheata $
00002 // Author: Rene Brun   26/12/02
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 ////////////////////////////////////////////////////////////////////////////////
00013 // Full description with examples and pictures
00014 //
00015 //
00016 #include "Riostream.h"
00017 #include "TGeoManager.h"
00018 #include "TGeoMedium.h"
00019 #include "TList.h"
00020 
00021 ClassImp(TGeoMedium)
00022 
00023 //-----------------------------------------------------------------------------
00024 TGeoMedium::TGeoMedium()
00025 {
00026 // Default constructor
00027    fId      = 0;
00028    for (Int_t i=0; i<20; i++) fParams[i] = 0.;
00029    fMaterial= 0;
00030 }
00031 
00032 //-----------------------------------------------------------------------------
00033 TGeoMedium::TGeoMedium(const char *name, Int_t numed, const TGeoMaterial *mat, Double_t *params)
00034              :TNamed(name,"")
00035 {
00036 // constructor
00037    fName = fName.Strip();
00038    fId    = numed;
00039    for (Int_t i=0; i<20; i++) fParams[i] = 0.;
00040    fMaterial = (TGeoMaterial*)mat;
00041    for (Int_t i=0;i<10;i++) {
00042       if (params) fParams[i] = params[i];
00043       else        fParams[i] = 0;
00044    }
00045    gGeoManager->GetListOfMedia()->Add(this);
00046 }
00047 
00048 //-----------------------------------------------------------------------------
00049 TGeoMedium::TGeoMedium(const char *name, Int_t numed, Int_t imat, Int_t isvol, Int_t ifield,
00050               Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
00051              :TNamed(name,"")
00052 {
00053 // constructor
00054    fName = fName.Strip();
00055    fId    = numed;
00056    for (Int_t i=0; i<20; i++) fParams[i] = 0.;
00057    TIter next (gGeoManager->GetListOfMaterials());
00058    TGeoMaterial *mat;
00059    while ((mat = (TGeoMaterial*)next())) {
00060       if (mat->GetUniqueID() == (UInt_t)imat) break;
00061    }
00062    if (!mat || (mat->GetUniqueID() != (UInt_t)imat)) {
00063       fMaterial = 0;
00064       Error("TGeoMedium", "%s, material number %d does not exist",name,imat);
00065       return;
00066    }
00067    fMaterial = (TGeoMaterial*)mat;
00068    fParams[0] = isvol;
00069    fParams[1] = ifield;
00070    fParams[2] = fieldm;
00071    fParams[3] = tmaxfd;
00072    fParams[4] = stemax;
00073    fParams[5] = deemax;
00074    fParams[6] = epsil;
00075    fParams[7] = stmin;
00076    gGeoManager->GetListOfMedia()->Add(this);
00077 }
00078 
00079 //-----------------------------------------------------------------------------
00080 TGeoMedium::TGeoMedium(const TGeoMedium& gm) : 
00081   TNamed(gm),
00082   fId(gm.fId),
00083   fMaterial(gm.fMaterial)
00084 {
00085    //copy constructor
00086    for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
00087 }
00088  
00089 //-----------------------------------------------------------------------------
00090 TGeoMedium& TGeoMedium::operator=(const TGeoMedium& gm) 
00091 {
00092    //assignment operator
00093    if(this!=&gm) {
00094       TNamed::operator=(gm);
00095       fId=gm.fId;
00096       for(Int_t i=0; i<20; i++) fParams[i]=gm.fParams[i];
00097       fMaterial=gm.fMaterial;
00098    } 
00099    return *this;
00100 }
00101  
00102 //-----------------------------------------------------------------------------
00103 TGeoMedium::~TGeoMedium()
00104 {
00105 // Destructor
00106 }
00107 
00108 //_____________________________________________________________________________
00109 char *TGeoMedium::GetPointerName() const
00110 {
00111 // Provide a pointer name containing uid.
00112    static TString name;
00113    name = TString::Format("pMed%d", GetUniqueID());
00114    return (char*)name.Data();
00115 }    
00116 
00117 //_____________________________________________________________________________
00118 void TGeoMedium::SavePrimitive(ostream &out, Option_t *option /*= ""*/)
00119 {
00120 // Save a primitive as a C++ statement(s) on output stream "out".
00121    if (TestBit(TGeoMedium::kMedSavePrimitive)) return;
00122    fMaterial->SavePrimitive(out,option);
00123    out << "// Medium: " << GetName() << endl;
00124    out << "   numed   = " << fId << ";  // medium number" << endl;
00125    out << "   par[0]  = " << fParams[0] << "; // isvol" << endl;
00126    out << "   par[1]  = " << fParams[1] << "; // ifield" << endl;
00127    out << "   par[2]  = " << fParams[2] << "; // fieldm" << endl;
00128    out << "   par[3]  = " << fParams[3] << "; // tmaxfd" << endl;
00129    out << "   par[4]  = " << fParams[4] << "; // stemax" << endl;
00130    out << "   par[5]  = " << fParams[5] << "; // deemax" << endl;
00131    out << "   par[6]  = " << fParams[6] << "; // epsil" << endl;
00132    out << "   par[7]  = " << fParams[7] << "; // stmin" << endl;
00133    
00134    out << "   " << GetPointerName() << " = new TGeoMedium(\"" << GetName() << "\", numed," << fMaterial->GetPointerName() << ", par);" << endl;
00135    SetBit(TGeoMedium::kMedSavePrimitive);
00136 }

Generated on Tue Jul 5 14:12:56 2011 for ROOT_528-00b_version by  doxygen 1.5.1