//*-- รถ : Ilse Koenig //*-- Modified : 10/11/2003 by Ilse Koenig //////////////////////////////////////////////////////////////////////////////// // // Class for tracking medium ( includes also material ) // //////////////////////////////////////////////////////////////////////////////// #include "FairGeoMedium.h" #include #include #include "stdlib.h" using std::cout; using std::log; using std::pow; ClassImp(FairGeoMedium) FairGeoMedium::FairGeoMedium(const char* name) : TNamed(name,""), medId(0), autoflag(1), nComponents(0), weightFac(0), ca(NULL), cz(NULL), cw(NULL), density(0), radLen(0), sensFlag(0), fldFlag(0), fld(0), epsil(0), madfld(-1), maxstep(-1), maxde(-1), minstep(-1), npckov(0), ppckov(NULL), absco(NULL), effic(NULL), rindex(NULL) { // Constructor for a medium with name and index id // SetName(name); }; FairGeoMedium::~FairGeoMedium() { // Destructor if (nComponents>0) { delete [] ca; ca=0; delete [] cz; cz=0; delete [] cw; cw=0; nComponents=0; } if (npckov>0) { delete [] ppckov; ppckov=0; delete [] absco; absco=0; delete [] effic; effic=0; delete [] rindex; rindex=0; npckov=0; } } void FairGeoMedium::setNComponents(Int_t n) { // Sets the number of components in the material if (n==0) { return; } Int_t k=abs(n); if (nComponents!=0 && k!=nComponents) { delete [] ca; delete [] cz; delete [] cw; nComponents=0; } if (nComponents==0) { nComponents=k; ca=new Double_t[k]; cz=new Double_t[k]; cw=new Double_t[k]; } weightFac=(Int_t)(n/nComponents); } Bool_t FairGeoMedium::setComponent (Int_t i,Double_t a,Double_t z,Double_t weight) { // Defines the ith material component if (i<0||i>=nComponents) { Error("setNComponents","Wrong index"); return kFALSE; } ca[i]=a; cz[i]=z; cw[i]=weight; return kTRUE; } void FairGeoMedium::getComponent(Int_t i,Double_t* p) { // Returns the ith material component if (i>=0&&i0) { delete [] ppckov; delete [] absco; delete [] effic; delete [] rindex; } npckov=n; if (n>0) { ppckov=new Double_t[npckov]; absco=new Double_t[npckov]; effic=new Double_t[npckov]; rindex=new Double_t[npckov]; } } Bool_t FairGeoMedium::setCerenkovPar(Int_t i,Double_t p,Double_t a,Double_t e ,Double_t r) { // Defines the ith parameter set of the optical parameters if (i<0 || i>=npckov) { Error("setNpckov","Wrong index"); return kFALSE; } ppckov[i]=p; absco[i]=a; effic[i]=e; rindex[i]=r; return kTRUE; } void FairGeoMedium::getCerenkovPar(Int_t i,Double_t* p) { // returns the ith parameter set of the optical parameters if (i>=0&&i>n; setNComponents(n); for(Int_t ik=0; ik>ca[ik]; } for(Int_t i=0; i>cz[i]; } fin>>density; if (nComponents==1) { cw[0]=1.; calcRadiationLength(); } else { for(Int_t i=0; i>cw[i]; } } fin>>sensFlag>>fldFlag>>fld>>epsil ; if (autoflag<1) { fin>>madfld>>maxstep>>maxde>>minstep; } else { //to use this feature one has to set TGeant3::SetAUTO(0), thus if the media does not // defined these values one can force Geant3 to calculate them by given them a value // of -1 madfld=-1; maxstep=-1; maxde=-1; minstep=-1; } fin>>n; setNpckov(n); if (n>0) { for(Int_t i=0; i>ppckov[i]>>absco[i]>>effic[i]>>rindex[i]; } } } void FairGeoMedium::print() { // Prints the medium definition const char* bl=" "; cout<0) { for(Int_t i=0; i0) { for(Int_t i=0; i0) { amol=1.; } else { for (int i=0; i0) { w=cw[i]/amol; } else { w=a*cw[i]/amol; } az2=alpha*alpha*z*z; fc=az2 * (1./(1.+az2) + 0.20206 - 0.0369*az2 + 0.0083*az2*az2 - .002F*az2*az2*az2); y=log(183./pow(z,1./3.)) - fc; xi=(float)(log(1440./pow(z,2./3.)) / y); x0i=fac*alpha/a*z*(z+xi)*y; x0itot+=(x0i*w); } if (x0itot==0. || density==0.) { Error("calcRadiationLength()","x0itot=0 or density=0 for medium %s",fName.Data()); return kFALSE; } radLen=1/density/x0itot; return kTRUE; }