#include #include #include using namespace std; const double pi = 3.141592; const double twopi = 2.0 * pi; const double eta_min = -5.0; const double eta_max = 5.0; const double phi_min = 0.0; const double phi_max = twopi; int main() { // define a cylinder double rmin = 50.0; double rmax = 55.0; double zmin = -500.0; double zmax = 500.0; double volume = pi*(rmax*rmax-rmin*rmin)*(zmax-zmin); double density = 2.70; double weight_expected = density * volume; cout << "Monte Carlo program to calculate weight"<< endl; cout << "weight expected = " << weight_expected << " gram" << endl; // set seed number long zzz=12459888; srand48(zzz); cout << "set seed number to : " << zzz << endl; // strat start Monte Carlo double total_weight = 0.0; int itry = 0; for (int n=0; n<30; n++){ int nmax = 10000; double step = 0.1; // step length = 0.1 cm // repeat nmax times for(int i=0; i