StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
examplePt.C
1 // NOTE - chain needs to be declared global so for StHbtEventReader
2 //==========================================================================================
3 //#include "StRoot/StMuDSTMaker/COMMON/StMuTypes.hh"
4 
5 #include "TH1.h"
6 #include "TChain.h"
7 #include "TSystem.h"
8 #include "TFile.h"
9 #include <iostream>
10 
11 class StMuDstMaker;
12 StMuDstMaker* maker;
13 
14 
15 TH1D globalPt("globalPt","globalPt",100,0.,3.);
16 TH1D primaryPt("primaryPt","primaryPt",100,0.,3.);
17 TH1D l3Pt("l3Pt","l3Pt",100,0.,3.);
18 
19 TH2D etaLength("etaLength","etaLength",20,-1,+1,200,0.,200.);
20 
21 
22 void examplePt(const char* dir="", const char* file="/star/u/laue/afsWork/test.list",const char* filter="st:MuDst.root", const
23 char* outFile="test.root") {
24  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
25  loadSharedLibraries();
26 
28 // StMuDbReader* db = StMuDbReader::instance();
29 // db->addDb("/star/u/laue/afsWork/P02gc.db");
30 // db->addDb("/star/u/laue/afsWork/P02gd.db");
31 
32  int counter=0;
33  int iret=0;
34  StMuTimer timer;
35  timer.start();
36  maker = new StMuDstMaker(0,0,dir,file,filter,10); // set up maker in read mode
37  cout << "time to load chain: " << timer.elapsedTime() <<endl;
38  timer.reset();
39  timer.start();
40  cout << maker->chain()->GetEntries() << " events in chain" << endl;
41  TMemStat memStat("examplePt");
42  while ( !(iret=maker->Make()) ) {
43  // iret = maker->Make(); // read an event
44  StMuDst* mu = maker->muDst();
45  int n;
46  n= mu->globalTracks()->GetEntries();
47  for (int l=0; l<n; l++) globalPt.Fill( mu->globalTracks(l)->pt() );
48  n= mu->primaryTracks()->GetEntries();
49  for (int l=0; l<n; l++) primaryPt.Fill( mu->primaryTracks(l)->pt() );
50  n= mu->l3Tracks()->GetEntries();
51  for (int l=0; l<n; l++) l3Pt.Fill( mu->l3Tracks(l)->pt() );
52  if (maker->chain()->GetEntries()) cout << "event# " << counter << " " << counter++/maker->chain()->GetEntries() << "%";
53  cout << " used= "<< memStat.Used();
54  cout << " size= "<< memStat.ProgSize();
55  cout << endl;
56 
57  }
58  cout << endl;
59  if (counter) cout << "time/event " << timer.elapsedTime()/counter <<endl;
60  cout << " # of events:" << counter << endl;
61 
62  globalPt.Draw();
63  primaryPt.Draw("same");
64  l3Pt.Draw("same");
65 
66  TFile f(outFile,"RECREATE");
67  globalPt.Write();
68  primaryPt.Write();
69  l3Pt.Write();
70  f.Close();
71 }
72 
73 
74 
static TObjArray * globalTracks()
returns pointer to the global tracks list
Definition: StMuDst.h:303
virtual int Make()
StMuDst * muDst()
Definition: StMuDstMaker.h:425
StMuDstMaker(const char *name="MuDst")
Default constructor.
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
static TClonesArray * l3Tracks()
returns pointer to the l3Tracks list
Definition: StMuDst.h:307
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426