// class Box, 2004.9.16 T. Kondo #include #include #include using namespace std; const double pi = 3.141592; const double twopi = 2.0 * pi; class Box { private: double xcenter[3] ; double xHalfLength[3] ; double density ; public: Box(double xh, double yh, double zh, double density0); void locateBox(double *x0); void showBox(); double xLowEdge(int i); double xHighEdge(int i); double getDensity(){return density;} }; class Particle { private: double ptotal; double mass; double x[3] ; double p[3] ; public: Particle(double *x0, double *p0, double mass); void showParticle(); void stepParticle(double delta); int checkBox(Box thisbox); double getRxy2(){return x[0]*x[0]+x[1]*x[1];} }; int main() { // define a box object double xmin = -10.; double ymin = 20.; double zmin = -20.; double xmax = 15.0; double ymax = 30.0; double zmax = 50.0; double x0[3] ; x0[0] = xmax - xmin; x0[1] = ymax - ymin; x0[2] = zmax - zmin; double density = 2.70; Box mybox(0.5*x0[0], 0.5*x0[1], 0.5*x0[2], density); double xc[3] ; xc[0] = xmin + 0.5*x0[0]; xc[1] = ymin + 0.5*x0[1]; xc[2] = zmin + 0.5*x0[2]; mybox.locateBox(xc); mybox.showBox(); double volume = x0[0] * x0[1] * x0[2]; double weight_expected = density * volume; cout << "Monte Carlo program to calculate weight"<< endl; cout << "weight expected = " << weight_expected << " gram" << endl; //----- start Monte Carlo---------- // one can change these parameters, make sure your box is inside the // scanned eta-phi region. const double eta_min = -5.0; const double eta_max = 5.0; const double phi_min = 0.0; const double phi_max = twopi; cout << "eta_min, eta_max = " << eta_min << " , "<< eta_max<