StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
exampleRefMult.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 TH1D refMult("refMult","refMult",100,0.,100.);
15 
16 void exampleRefMult(const char* dir="", const char* file="/star/u/laue/afsWork/dAu200.lis",const char* filter="st:MuDst.root", const
17 char* outFile="test.root") {
18  gROOT->LoadMacro("StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
19  loadSharedLibraries();
20 
21  int counter=0;
22  int iret=0;
23  StMuTimer timer;
24  timer.start();
26  maker = new StMuDstMaker(0,0,dir,file,filter,1); // set up maker in read mode
27  // 0,0 this mean read mode
28  // dir read all files in this directory
29  // file bla.lis real all file in this list, if (file!="") dir is ignored
30  // filter apply filter to filenames, multiple filters are separated by ':'
31  // 10 maximum number of file to read
32  cout << "time to load chain: " << timer.elapsedTime() <<endl;
34  timer.reset();
35  timer.start();
36  cout << maker->chain()->GetEntries() << " events in chain" << endl;
37  TMemStat memStat("exampleRefMult");
38  while ( !(iret=maker->Make()) ) { // read an event
39  StMuDst* mu = maker->muDst(); // get a pointer to the StMuDst class, the class that points to all the data
40  StMuEvent* muEvent = mu->event(); // get a pointer to the class holding event-wise information
41  int referenceMultiplicity = muEvent->refMult(); // get the reference multiplicity
42  refMult->Fill(referenceMultiplicity); // fill histogram
43  cout << " #" << counter;
44  cout << " refMult= "<< referenceMultiplicity;
45  cout << " used= "<< memStat.Used();
46  cout << " size= "<< memStat.ProgSize();
47  cout << endl;
48  counter++;
49  }
50  cout << endl;
51  if (counter) cout << "time/event " << timer.elapsedTime()/counter <<endl;
52  cout << " # of events:" << counter << endl;
53 
54  refMult.Draw();
55 
56  TFile f(outFile,"RECREATE");
57  refMult.Write();
58  f.Close();
59 }
60 
61 
62 
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
unsigned short refMult(int vtx_id=-1)
Reference multiplicity of charged particles as defined in StEventUtilities/StuRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)
Definition: StMuEvent.cxx:195
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426