StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ReadPythia.C
1 // Author V.Fine 06/12/2001 BNL mailto:fine@bnl.gov
2 // This run Pythia using ROOT TPYthia6 interface
3 // Thanks Michael Bussmann <Michael.Bussmann@physik.uni-muenchen.de> for Pythia living example
4 void ReadPythia(const char *fileName="pythia.root")
5 {
6  struct pythia_particle {
7  Int_t status; // status of particle ( LUJETS K[1] )
8  Int_t pdg_id; // flavour code ( LUJETS K[2] )
9  Int_t parent; // parrent's id ( LUJETS K[3] )
10  Int_t firstChild; // id of first child ( LUJETS K[4] )
11  Int_t lastChild; // id of last child ( LUJETS K[5] )
12  Float_t momentum[4]; // X.Y,Z,energy momenta [GeV/c]( LUJETS P[1]=P[4] )
13  Float_t mass; // Mass [Gev/c^2] ( LUJETS P[5] )
14  Float_t vertex[4]; // X,Y,Z vertex [mm]; time of procuction [mm/c]( LUJETS V[1]-V[4] )
15  Float_t lifetime; // proper lifetime [mm/c] ( LUJETS V[5] )
16  };
17  TFileIter readEvents(fileName);
18  TObject *nextObject = 0;
19  // the number of the object available directly from "MyDataSet.root"
20  Int_t size = readEvents.TotalKeys();
21  printf(" The total number of the events: %d\n",size);
22 
23  //-----------------------------------------------------------------------
24  // Loop over all events, read them in to memory one by one
25 
26  printf(" -- > Loop over all events, read them in to memory one by one < -- \n");
27  for( readEvents = 0; int(readEvents) < size; readEvents.SkipObjects() ){
28  nextObject = *readEvents;
29  printf(" %d bytes of the object \"%s\" of class \"%s\" written with TKey \"%s\" has been read from file\n"
30  ,readEvents.GetObjlen()
31  ,nextObject->GetName()
32  ,nextObject->IsA()->GetName()
33  ,(const char *)readEvents
34  );
35  TDataSet *event = (TDataSet *)nextObject;
36  event->ls(9);
37  delete nextObject;
38  }
39 }
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495