Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
create_pythia_dummy.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file create_pythia_dummy.C
1 int
3 {
4  /* Open output for dummy file */
5  ofstream ofs("pythia_dummy_new.dat");
6 
7  /* Number of particles per event in dummy file */
8  unsigned npart = 100;
9 
10  /* Number of events */
11  unsigned nevents = 10000;
12 
13  /* first record after header and scattered electron */
14  unsigned I0 = 14;
15 
16  /* Add Pythia style header */
17  ofs << " PYTHIA EVENT FILE " << endl;
18  ofs << " ============================================" << endl;
19  ofs << " I, ievent, genevent, subprocess, nucleon, targetparton, xtargparton, beamparton, xbeamparton, thetabeamprtn, truey, trueQ2, truex, trueW2, trueNu, leptonphi, s_hat, t_hat, u_hat, pt2_hat, Q2_hat, F2, F1, R, sigma_rad, SigRadCor, EBrems, photonflux, t-diff, nrTracks" << endl;
20  ofs << " ============================================" << endl;
21  ofs << " I K(I,1) K(I,2) K(I,3) K(I,4) K(I,5) P(I,1) P(I,2) P(I,3) P(I,4) P(I,5) V(I,1) V(I,2) V(I,3)" << endl;
22  ofs << " ============================================" << endl;
23 
24 
25  /* Loop over events */
26  for ( unsigned event = 0; event < nevents; event++ )
27  {
28  ofs << " 0 " << event << " 1 28 2212 2 0.626588 21 0.021799 0.000606 0.11143372116 1.29649562992 0.00058761008 2205.97153388399 1175.77442684038 0.45626715567 30.13077585993 -6.512950687 -23.617825173 5.105136735 5.105136735 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.093679142 -6.512950687 " << npart << endl;
29  ofs << " ============================================" << endl;
30  ofs << " 1 21 11 0 3 4 0.000000 0.000000 -18.000000 18.000000 0.000510 0.000000 0.000000 0.000000" << endl;
31  ofs << " 2 21 2212 0 5 0 -0.000000 0.000000 275.000000 275.001601 0.938270 0.000000 0.000000 0.000000" << endl;
32  ofs << " 3 21 11 1 0 0 -0.963526 0.472906 -15.976186 16.012200 0.000510 0.000000 0.000000 0.000000" << endl;
33  ofs << " 4 21 22 1 0 0 0.963526 -0.472906 -2.023814 1.987800 -1.138638 0.000000 0.000000 0.000000" << endl;
34  ofs << " 5 21 2212 2 0 0 -0.000000 -0.000000 275.000000 275.001601 0.938270 0.000000 0.000000 0.000000" << endl;
35  ofs << " 6 21 -2 4 0 0 0.575223 -0.495057 -1.333090 1.533980 -0.000000 0.000000 0.000000 0.000000" << endl;
36  ofs << " 7 21 2 5 0 0 0.104280 -0.005342 172.232299 172.232331 -0.000000 0.000000 0.000000 0.000000" << endl;
37  ofs << " 8 21 21 6 0 0 -0.493961 -0.724549 3.813575 3.913096 0.000000 0.000000 0.000000 0.000000" << endl;
38  ofs << " 9 21 2 7 0 0 0.091399 -0.004682 150.957731 150.957759 0.000000 0.000000 0.000000 0.000000" << endl;
39  ofs << " 10 21 21 0 0 0 1.874941 -0.450971 23.470606 23.549694 0.000000 0.000000 0.000000 0.000000" << endl;
40  ofs << " 11 21 2 0 0 0 -2.277502 -0.278261 131.300700 131.321161 0.330000 0.000000 0.000000 0.000000" << endl;
41  ofs << " 12 11 213 4 25 26 0.233938 -0.337111 -0.113230 0.880819 0.771135 0.000000 0.000000 0.000000" << endl;
42  ofs << " 13 1 11 3 0 0 -0.963526 0.472906 -15.976186 16.012200 0.000510 0.000000 0.000000 0.000000" << endl;
43 
44  /* Add additional particles */
45  for ( unsigned I = I0; I <= npart; I++ )
46  {
47  /* Create random particle */
48  double mass = 0.000510;
49  double ptotal = (rand() % 4000 + 1) / 100.; // random from 1 to 40
50  double eta = (rand() % 900) / 100. - 4.5;
51  double phi = (rand() % 100) / 100. * 2 * TMath::Pi();
52 
53  // cout << eta << " " << ptotal << endl;
54 
55  double pt = ptotal / cosh(eta);
56 
57  /* Create Lorentz vector */
58  TLorentzVector v1;
59  v1.SetPtEtaPhiE(pt, eta, phi, ptotal);
60 
61  /* Pythia line format:
62  * I K(I,1) K(I,2) K(I,3) K(I,4) K(I,5) P(I,1) P(I,2) P(I,3) P(I,4) P(I,5) V(I,1) V(I,2) V(I,3)
63  *
64  * Scattered electron line example:
65  * 13 1 11 3 0 0 -0.963526 0.472906 -15.976186 16.012200 0.000510 0.000000 0.000000 0.000000
66  */
67 
68  /* New particle parameters for output */
69  unsigned status = 1;
70  int pid = 11;
71  unsigned parentI = 0;
72  unsigned daughterfirstI = 0;
73  unsigned daughterlastI = 0;
74  double px = v1.Px();
75  double py = v1.Py();
76  double pz = v1.Pz();
77  double E = v1.E();
78  double m = mass;
79  double vx = 0.0;
80  double vy = 0.0;
81  double vz = 0.0;
82 
83  ofs << "\t" << I
84  << "\t" << status << "\t" << pid << "\t" << parentI << "\t" << daughterfirstI << "\t" << daughterlastI << "\t"
85  << px << "\t" << py << "\t" << pz << "\t" << E << "\t" << m
86  << "\t" << vx << "\t" << vy << "\t" << vz << endl;
87  }
88 
89  /* Add Pythia style end-of-event record (footer) */
90  ofs << " =============== Event finished ===============" << endl;
91 
92  } // end event loop
93 
94  /* Close file */
95  ofs.close();
96  return 0;
97 }