StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runTree.C
1 // forward declarations
2 class StChain;
3 class StMuDstMaker;
4 
5 // global variables
6 StChain *analysisChain = 0;
7 
8 void runTree(char* dir="hist_pAu2", char* filter="16142010", unsigned int neventsIn = 0){
9  // If nEvents is negative, reset to the maximum possible value for an Int_t
10  if( neventsIn <= 0 ) neventsIn = 1<<31-1;
11 
12  TSystemDirectory DIR(dir, dir);
13  TList *files = DIR.GetListOfFiles();
14  TChain* trees = new TChain();
15  int nfile=0;
16  if (files) {
17  TSystemFile *file;
18  TString fname;
19  TIter next(files);
20  while ((file=(TSystemFile*)next())) {
21  fname = file->GetName();
22  if (!file->IsDirectory() && fname.BeginsWith(filter) && fname.EndsWith("tree.root")) {
23  cout << Form("Adding %s/%s to TChain",dir,fname.Data())<<endl;
24  trees->AddFile(Form("%s/%s/dipi0",dir,fname.Data()));
25  nfile++;
26  }
27  }
28  }
29  cout << Form("%d files added",nfile) << endl;
30 
31  // load the shared libraries
32  std::cout << "***** Loading libraries *****" << endl;
33  LoadLibs();
34 
35  // Create the analysis chain
36  analysisChain = new StChain("dipi0Chain");
37 
38  //cout << "Constructing StFmsDbMaker" << endl;
39  //StFmsDbMaker* fmsDbMkr = new StFmsDbMaker( "fmsDb" );
40  //fmsDbMkrName = fgtDbMkr->GetName();
41 
42  gSystem->Load("StFmsDiPi0");
43  StFmsDiPi0* dipi0=new StFmsDiPi0;
44  TString filenameDiPi0(Form("%s/%s.dipi0.root",dir,filter));
45  cout << "DiPi0 outfile name = " << filenameDiPi0.Data()<<endl;
46  dipi0->setFileName(filenameDiPi0.Data());
47  dipi0->setReadTree(trees);
48 
49  analysisChain->Init();
50 
51  Int_t ierr = kStOK; // err flag
52  Int_t nevents = 0; // cumulative number of events in
53  for( ; nevents < neventsIn && !ierr; ++nevents ){
54  if(nevents%10000==0) cout <<"event: "<< nevents <<endl;
55  analysisChain->Clear();
56  ierr = analysisChain->Make();
57  }
58  analysisChain->Finish();
59 
60  analysisChain->Delete();
61  return;
62 };
63 
64 
65 void LoadLibs() {
66  // commong shared libraries
67  gROOT->Macro("loadMuDst.C");
68  gSystem->Load("StStarLogger");
69  //gSystem->Load("StTpcDb");
70  //gSystem->Load("StDbUtilities");
71  //gSystem->Load("StDetectorDbMaker");
72  //gSystem->Load("StMagF");
73  //gSystem->Load("StFmsUtil");
74  //gSystem->Load("StFmsDbMaker");
75 };
virtual void Delete(Option_t *opt="")
Definition: TDataSet.cxx:320
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: Stypes.h:40