// Author: David Lawrence June 19, 2009 // // // mkMaterialMap.cc // #include #include "DANA/DApplication.h" using namespace std; #include #include #include #include #include void ParseCommandLineArguments(int narg, char *argv[], JApplication &app); void Usage(JApplication &app); class Material{ public: double A; double Z; double Density; double RadLen; double rhoZ_overA; // density*Z/A double rhoZ_overA_logI; // density*Z/A * log(mean excitation energy) }; // Table dimensions int Nr = 500; int Nz = 1500; double rmin = 0.0; double rmax = 9.75; double zmin = 15.0; double zmax = 100.0; int n_r = 3; int n_z = 3; int n_phi = 60; //----------- // main //----------- int main(int narg, char *argv[]) { DApplication *dapp = new DApplication(narg, argv); ParseCommandLineArguments(narg, argv, *dapp); DRootGeom *g = new DRootGeom(dapp); // Fill average materials table cout<<"Filling material table ..."; cout.flush(); double r0 = rmin; double z0 = zmin; double dr = (rmax-rmin)/(double)(Nr); double dz = (zmax-zmin)/(double)(Nz); Material **MatTable = new Material*[Nr]; Material *buff = new Material[Nr*Nz]; for(int ir=0; irFindMatLL(pos, density, A, Z, radlen); if(err==NOERROR){ rhoZ_overA = density*Z/A; double I = (Z*12.0 + 7.0)*1.0E-9; // From Leo 2nd ed. pg 25. rhoZ_overA_logI = rhoZ_overA*log(I); }else{ A = Z = density = radlen = rhoZ_overA = rhoZ_overA_logI = 0.0; } avg_mat.A += A; avg_mat.Z += Z; avg_mat.Density += density; avg_mat.RadLen += 1.0/radlen; // use this to keep proper sum (will be flipped and normalized below) avg_mat.rhoZ_overA += rhoZ_overA; avg_mat.rhoZ_overA_logI += rhoZ_overA_logI; } } } // Divide by number of points to get averages double N = (double)(n_r*n_z*n_phi); avg_mat.A /= N; avg_mat.Z /= N; avg_mat.RadLen = N/avg_mat.RadLen; // see eq. 27.23 pg 273 of 2008 PDG (note: we implicitly converted to g cm^-2 and back) avg_mat.Density /= N; avg_mat.rhoZ_overA /= N; avg_mat.rhoZ_overA_logI /= N; if(!finite(avg_mat.RadLen))avg_mat.RadLen = 0.0; MatTable[ir][iz] = avg_mat; } cout<<"\r Filling Material table ... "<<100.0*(double)ir/(double)Nr<<"% ";cout.flush(); } cout <<"Done"<=narg){ cout<<"option \""<