StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMuDst_Geant2print.C
1 // read muDst & geant.root in sync
2 
3 class StChain;
4 StChain *chain=0;
5 
6 int rdMuDst_Geant2print( int maxEve=2){
7  char * muDstPath="/star/data26/reco/pp200/pythia_6.203/default/minbias/year2003/hadronic_on/trs_ic/";
8  char * muDstFile="rcf1200_2723_2000evts.MuDst.root";
9 
10  TString geantFile = "/star/data26/reco/pp200/pythia_6.203/default/minbias/year2003/hadronic_on/trs_ic/rcf1200_2723_2000evts.geant.root";
11 
12 
13  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
14  loadSharedLibraries();
15  cout << " loading done " << endl;
16 
17 
18  // create chain
19  chain = new StChain("StChain");
20  //chain->SetDebug();
21  //chain->PrintInfo();
22 
23  // set up maker in read mode
24  StIOMaker* IOMk = new StIOMaker("IO","r",geantFile,"bfcTree");
25  IOMk->SetDebug();
26  IOMk->SetIOMode("r");
27  IOMk->SetBranch("*",0,"0");
28  IOMk->SetBranch("geantBranch",0,"r");
29 
30 
31  int maxList=1;
32  muMk = new StMuDstMaker(0,0,muDstPath,muDstFile,"MuDst.root",maxList); // set up maker in read mode
33 
34  chain->Init();
35  chain->ls(3);
36 
37  // StMuDebug::setLevel(1); // switch of some debug output
38 
39  int eventCounter=0;
40 
41  printf(" requested maxEve=%d\n",maxEve);
42  //---------------------------------------------------
43  while ( 1) {// loop over events
44  eventCounter++;;
45  if(eventCounter >maxEve) break;
46  chain->Clear();
47  int stat = chain->Make();
48  if(stat) break;
49 
50  // Access to muDst .......................
51  StMuEvent* muEve = muMk->muDst()->event();
52  int n = muMk->muDst()->primaryTracks()->GetEntries(); // get number of primary tracks
53  StEventInfo &info=muEve->eventInfo();
54 
55  printf("eve=%d Nprim=%d ID=%d\n",eventCounter,n,info.id());
56 
57 
58  // Access to geant-tables .......................
59 
60  St_DataSet* Event = chain->GetDataSet("geant");
61  //Event->ls(3);
62  St_DataSetIter geantDstI(Event);
63 
64  // Event generator info ........................
65  St_g2t_event *Pg2t_event=(St_g2t_event *) geantDstI("g2t_event");
66  //Pg2t_event->Print();
67  g2t_event_st *g2t_event1=Pg2t_event->GetTable();
68  printf("nr=%d %p\n",Pg2t_event->GetNRows(),g2t_event1);
69  int k1= g2t_event1->eg_label;
70  int k2= g2t_event1->n_event;
71  int k3= g2t_event1->subprocess_id;
72 
73  printf("eg_label=%d n_event=%d subprocess_id=%d\n", k1,k2,k3);
74  assert(info.id()==g2t_event1->n_event);
75 
76 
77  // This is an example to access the particle table directly.
78  St_particle *particleTabPtr = (St_particle *) geantDstI("particle");
79  particle_st* particleTable = particleTabPtr->GetTable();
80 
81  for (int i=0; i<particleTabPtr->GetNRows();++i) {
82  if(i>10) break;
83  cout << "track " << i << endl;
84  cout << " id = " << particleTable[i].idhep << endl;
85  cout << " px = " << particleTable[i].phep[0] << endl;
86  cout << " py = " << particleTable[i].phep[1] << endl;
87  cout << " pz = " << particleTable[i].phep[2] << endl;
88  cout << " e = " << particleTable[i].phep[3] << endl;
89  cout << " m = " << particleTable[i].phep[4] << endl;
90  cout << " moth1 = " << particleTable[i].jmohep[0] << endl;
91  cout << " moth2 = " << particleTable[i].jmohep[1] << endl;
92  }
93 
94  }
95 
96 
97 
98 }
99 
100 
101 
102 
103 
104 // /star/data31/reco/ppMinBias/FullField/P03if/2002/...
105 // /star/data31/reco/ppMinBias/ReversedFullField/P03if/2002/...
106 
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
virtual Int_t Make()
Definition: StChain.cxx:110
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Definition: AgUStep.h:26