StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PythiaTest.C
1 
2 #include <iostream>
3 
4 struct Pyjets_t {
5  int N;
6  int NPAD;
7  int K[5][4000];
8  double P[5][4000];
9  double V[5][4000];
10 };
11 
12 struct pythia_particle {
13  Int_t status; // status of particle ( LUJETS K[1] )
14  Int_t pdg_id; // flavour code ( LUJETS K[2] )
15  Int_t parent; // parrent's id ( LUJETS K[3] )
16  Int_t firstChild; // id of first child ( LUJETS K[4] )
17  Int_t lastChild; // id of last child ( LUJETS K[5] )
18  Float_t momentum[4]; // X.Y,Z,energy momenta [GeV/c]( LUJETS P[1]=P[4] )
19  Float_t mass; // Mass [Gev/c^2] ( LUJETS P[5] )
20  Float_t vertex[4]; // X,Y,Z vertex [mm]; time of procuction [mm/c]( LUJETS V[1]-V[4] )
21  Float_t lifetime; // proper lifetime [mm/c] ( LUJETS V[5] )
22 
23  void print() {
24  cout <<" --- New Particle --- "<<endl;
25  cout <<"status: "<<status<<" pdg_id: "<<pdg_id<<" parent: "
26  <<parent<<" fChild: "<<firstChild<<" lChild: "<<lastChild<<endl;
27  cout <<"px: "<<momentum[0]<<" py: "<<momentum[1]<<" pz: "<<momentum[2]<<" e: "
28  <<momentum[3]<<" mass: "<<mass<<endl;
29  cout <<"vX: "<<vertex[0]<<" vY: "<<vertex[1]<<" vZ: "<<vertex[2]<<" t: "
30  <<vertex[3]<<" tau: "<<lifetime<<endl;
31  }
32 
33 };
34 
35 void PythiaTest(int nEvents=1)
36 {
37  gSystem->Load("$PYTHIA/libPythia6.so");
38  gSystem->Load("libEG");
39  gSystem->Load("libEGPythia6.so");
40 
41  TPythia6* p6 = new TPythia6();
42  //p6->Dump();
43 
44  p6->SetMSEL(0); //set subprocesses by hand
45  p6->SetMSTP(48, 1); //t->W+b
46  p6->SetMSTJ(11, 3); //select fragmentation function "Bowler"
47  p6->SetPARJ(50+4, -0.07); //peterson parameter for charm
48  p6->SetPARJ(50+5, -0.006); //peterson parameter for bottom
49  p6->SetPARJ(50+5, -0.000001); //peterson parameter for top
50  p6->SetPMAS(6, 1, 174.3); //top mass
51  p6->SetPMAS(25, 1, 120.0); //higgs mass
52  p6->SetMSTP(61, 1); //ISR "on"
53  p6->SetMSTP(71, 1); //FSR "on"
54  p6->SetMSTP(81, 1); //multiple interactions "on"
55  p6->SetMSTP(111, 1); //fragmentation "on"
56  p6->SetMSTP(82, 3); //multiple interaction "vary impact param"
57  p6->SetPARP(82, 2.41); //cut-off pt for multiple interaction
58  p6->SetMRPY(1, 88158204); //random seed number
59 
60  p6->SetMSUB(26, 1); //set subprocess WH
61  p6->SetMDCY(24, 1, 1); //W decaying
62  p6->SetMDCY(25, 1, 1); //H decaying
63 
64  //close all W decay channels
65  int startdecay = p6->GetMDCY(24, 2);
66  int enddecay = p6->GetMDCY(24, 2) + p6->GetMDCY(24, 3);
67  for ( i=startdecay; i<enddecay; i++ ) p6->SetMDME(i, 1, 0);
68 
69  //close all H decay channels
70 
71  startdecay = p6->GetMDCY(25, 2);
72  enddecay = p6->GetMDCY(25, 2) + p6->GetMDCY(25, 3);
73  for ( i=startdecay; i<enddecay; i++ ) p6->SetMDME(i, 1, 0);
74 
75  //open wanted W decay channels
76 
77  p6->SetMDME(206, 1, 1); //W->e+nu
78  p6->SetMDME(207, 1, 1); //W->mu+nu
79  p6->SetMDME(208, 1, 1); //W->tau+nu
80 
81  //open wanted W decay channels
82 
83  p6->SetMDME(214, 1, 1); //H->b+bbar
84 
85  //initialize Pythia for D0
86 
87  p6->Initialize("CMS", "p", "pbar", 2000.0);
88 
89  for ( i=0; i<nEvents; i++ ) {
90 
91  if ( i%10 == 0 ) cout << "Event No.: " << i << endl;
92 
93  p6->GenerateEvent();
94 
95  Pyjets_t* pythiaParticle = p6->GetPyjets();
96 
97  Int_t nParticle = p6->GetN();
98 
99  for (int i=0;i<nParticle;i++) {
100  pythia_particle particle;
101  memset(&particle,0,sizeof(particle));
102 
103  particle.momentum[0] = pythiaParticle->P[0][i]; // px
104  particle.momentum[1] = pythiaParticle->P[1][i]; // px
105  particle.momentum[2] = pythiaParticle->P[2][i]; // px
106  particle.momentum[3] = pythiaParticle->P[3][i]; // energy
107  particle.mass = pythiaParticle->P[4][i]; // mass
108 
109  particle.status = pythiaParticle->K[0][i]; // kS
110  particle.pdg_id = pythiaParticle->K[1][i]; // kF
111  particle.parent = pythiaParticle->K[2][i]; // parent
112  particle.firstChild = pythiaParticle->K[3][i]; // firstchild
113  particle.lastChild = pythiaParticle->K[4][i]; // lastchild
114 
115  particle.vertex[0] = pythiaParticle->V[0][i]; // vx
116  particle.vertex[1] = pythiaParticle->V[1][i]; // vy
117  particle.vertex[2] = pythiaParticle->V[2][i]; // vz
118  particle.vertex[3] = pythiaParticle->V[3][i]; // time
119 
120  particle.lifetime = pythiaParticle->V[4][i]; // lifetime
121 
122  particle.print();
123  }
124 
125  }
126 
127 
128 }
129