StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
exampleMuDstFilter.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 class StMuDstFilterMaker;
13 StMuDstMaker* maker;
15 
16 void exampleMuDstFilter(const char* in="/star/u/laue/afsWork/dAu200.lis", const char* out="test.MuDst.root") {
17  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
18  loadSharedLibraries();
19 
20  int counter=0;
21  int iret=0;
22  StMuTimer timer;
23  timer.start();
24  // switch of debug messages
26  // for faster chain building
27  StMuDbReader* dbReader = StMuDbReader::instance();
28  dbReader->addDb("dAu200.db");
29  // create maker
30  maker = new StMuDstMaker(0,0,"",in,"st_physics:MuDst.root",10000); // set up maker in read mode
31  cout << "time to load chain: " << timer.elapsedTime() <<endl;
32 
33  filter = new StMuDstFilterMaker("filter");
34  filter->setMuDstMaker(maker);
35  filter->setOutputFileName(out);
36  filter->Init();
37 
38  timer.reset();
39  timer.start();
40  cout << maker->chain()->GetEntries() << " events in chain" << endl;
41  TMemStat memStat("exampleMuDstFilter");
42  int iret = maker->Make(); // get first event
43  while ( iret==0 ) { // read an event
44  filter->Make();
45  cout << " #" << counter;
46  cout << " used= "<< memStat.Used();
47  cout << " size= "<< memStat.ProgSize();
48  cout << endl;
49  counter++;
50  iret = maker->Make();
51  }
52  cout << endl;
53  if (counter) cout << "time/event " << timer.elapsedTime()/counter <<endl;
54  cout << " # of events:" << counter << endl;
55  filter->Finish(); // Make sure that output file is written
56 }
57 
58 
59 
virtual int Make()
int addDb(const char *dbFile)
add entries in dbFile to internal data base ( mDb ), will call sortDb(), returns number of entries in...
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
int Make()
Filters the muDst and writes the filtered version.
StMuDstFilterMaker(const char *name="muDstFilter")
Default constructor; get pointer to StMuDstMaker.
int Finish()
Writes and closes the output file.
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
bool filter(T *t)
specialize this function to apply filters to the individual branches