#include #include #include #include #include #include #include using namespace std; double PI_ZERO_MASS = 0.13497; uint MAX_EVENTS=10000; int NUM_TO_GEN=1; double E_BEAM_MIN=PI_ZERO_MASS; double E_BEAM_MAX=1.0; int RUN_NUMBER=100; string OUTPUT_FILENAME="genpi0.ascii"; double FORCE_THETA = -1000.0; double FORCE_PHI = -1000.0; double THETA_PHOTON_MIN = 0.0; // minimum angle for photons in radians double THETA_PHOTON_MAX = M_PI; // minimum angle for photons in radians #define GAMMA_TYPE 1 #define PI_TYPE 7 class pi0{ public: double px,py,pz,E; // pi0 double px1, py1, pz1, E1; // decay photon 1 double px2, py2, pz2, E2; // decay photon 2 }; void ParseCommandLineArguments(int narg, char* argv[]); void Usage(void); //---------------------------- // main //---------------------------- int main(int narg, char* argv[]) { // Parse the command line ParseCommandLineArguments(narg, argv); // Open file for output ofstream of(OUTPUT_FILENAME.c_str()); if(!of.is_open()){ cout<<"Unable to open \""< pi0s; for(int i=0; i-1000.0)theta_pi0=FORCE_THETA; if(FORCE_PHI>-1000.0)phi_pi0=FORCE_PHI; pi0 p; p.E = E_pi0; p.px = p_pi0*sin(theta_pi0)*cos(phi_pi0); p.py = p_pi0*sin(theta_pi0)*sin(phi_pi0); p.pz = p_pi0*cos(theta_pi0); // 4-vectors of 2 decay photons in rest frame of pi0 // where they are isotropic and back to back. double phi = 2.0*M_PI*((double)random()/(double)RAND_MAX); double theta = M_PI*((double)random()/(double)RAND_MAX); p.E1 = PI_ZERO_MASS/2.0; p.px1 = p.E1*sin(theta)*cos(phi); p.py1 = p.E1*sin(theta)*sin(phi); p.pz1 = p.E1*cos(theta); p.E2 = p.E1; p.px2 = -p.px1; p.py2 = -p.py1; p.pz2 = -p.pz1; // Boost photons into lab frame using 4-vector of pi0 // (http://rd11.web.cern.ch/RD11/rkb/PH14pp/node105.html) p.E1 = (p.E1*p.E + p.px1*p.px + p.py1*p.py + p.pz1*p.pz)/PI_ZERO_MASS; p.px1 += p.px*(PI_ZERO_MASS/2.0 + p.E1)/(p.E + PI_ZERO_MASS); p.py1 += p.py*(PI_ZERO_MASS/2.0 + p.E1)/(p.E + PI_ZERO_MASS); p.pz1 += p.pz*(PI_ZERO_MASS/2.0 + p.E1)/(p.E + PI_ZERO_MASS); p.E2 = (p.E2*p.E + p.px2*p.px + p.py2*p.py + p.pz2*p.pz)/PI_ZERO_MASS; p.px2 += p.px*(PI_ZERO_MASS/2.0 + p.E2)/(p.E + PI_ZERO_MASS); p.py2 += p.py*(PI_ZERO_MASS/2.0 + p.E2)/(p.E + PI_ZERO_MASS); p.pz2 += p.pz*(PI_ZERO_MASS/2.0 + p.E2)/(p.E + PI_ZERO_MASS); // Check that photons are within limits set by user double gtheta1 = acos(p.pz1/p.E1); double gtheta2 = acos(p.pz2/p.E2); if(gtheta1THETA_PHOTON_MAX || gtheta2THETA_PHOTON_MAX){ i--; continue; } pi0s.push_back(p); Etot -= E_pi0; // subtract this from beam energy available } // Write event to file of<