// Author: David Lawrence June 19, 2009 // // // mkMaterialMap.cc // #include #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) double chi2c_factor; double chi2a_factor; double chi2a_corr; }; // 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; //----------- // mkstr //----------- template string mkstr(const T &val, unsigned int width) { stringstream ssval; ssval<0)ss<FindMatLL(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; avg_mat.chi2c_factor += 0.157*rhoZ_overA*(Z+1); avg_mat.chi2a_factor += 2.007e-5*cbrt(Z*Z); avg_mat.chi2a_corr += 3.34*Z*Z*5.32513e-05; } } } // 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; avg_mat.chi2c_factor/=N; avg_mat.chi2a_factor/=N; avg_mat.chi2a_corr/=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"< cols; cols.push_back("r"); cols.push_back("z"); cols.push_back("A"); cols.push_back("Z"); cols.push_back("density"); cols.push_back("radlen"); cols.push_back("rhoZ_overA"); cols.push_back("rhoZ_overA_logI"); cols.push_back("chi2c_factor"); cols.push_back("chi2a_factor"); cols.push_back("chi2a_corr"); // Find max width of each column so we can print these in file with aligned columns vector max_width; for(unsigned int i=0; i strs; stringstream ss; ss.str(""); ss< max_width[i])max_width[i] = strs[i].size()+2; } } } // Make colheader string as a comment that can be placed at the top and then periodically // in the file to make it easier to read stringstream colheader; colheader<<"#"; for(unsigned int i=0; i=narg){ cout<<"option \""<