StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ReadPythia.C
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 20 July 2010
5 //
6 // Simple macro to read Pythia record saved in .pythia.root files
7 // by the BFC trigger filter. The Pythia tree simply contains
8 // a StPythiaEvent object for each event.
9 //
10 
11 void ReadPythia(int nevents = 10, const char* pythiafile = "jet_pp200_pythia_6422_perugia_0_pt2_3gev_2000evts_185.pythia.root")
12 {
13  // Load shared library for StythiaEvent
14  gSystem->Load("StJetSkimEvent");
15 
16  // Open pythia file(s)
17  TChain* chain = new TChain("PythiaTree");
18  chain->Add(pythiafile);
19 
20  // Set Pythia event buffer
21  StPythiaEvent* pythiaEvent = 0;
22  chain->SetBranchAddress("PythiaBranch",&pythiaEvent);
23 
24  // Event loop
25  for (int iEvent = 0; iEvent < nevents; ++iEvent) {
26  // Read event and exit event loop if end-of-file or error encountered
27  if (chain->GetEvent(iEvent) <= 0) break;
28 
29  // Print Pythia event
30  cout << "iEvent = " << iEvent << endl;
31  cout << "runId = " << pythiaEvent->runId() << endl;
32  cout << "eventId = " << pythiaEvent->eventId() << endl;
33  cout << "processId = " << pythiaEvent->processId() << endl;
34  const TVector3& v = pythiaEvent->vertex();
35  cout << "vx = " << v.x() << ", vy = " << v.y() << ", vz = " << v.z() << endl;
36  cout << "s = " << pythiaEvent->s() << endl;
37  cout << "t = " << pythiaEvent->t() << endl;
38  cout << "u = " << pythiaEvent->u() << endl;
39  cout << "pt = " << pythiaEvent->pt() << endl;
40  cout << "cosTheta = " << pythiaEvent->cosTheta() << endl;
41  cout << endl;
42  } // End event loop
43 }