//2004.9.20 updated #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 box object // one can change these parameters, make sure your box is inside the // scanned eta-phi region. double xmin = -10.; double ymin = 20.; double zmin = -20.; double xmax = 15.0; double ymax = 30.0; double zmax = 50.0; double volume = (xmax-xmin)*(ymax-ymin)*(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 for randum number generator 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; // repeat nmax times for(int i=0; i