StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEvents.C
1 #include "iostream.h"
2 
3 class StChain;
4 StChain *chain=0;
5 class St_db_Maker;
6 St_db_Maker *dbMk =0;
7 class StFileI;
8 StFileI *setFiles =0;
9 
10 Int_t iEvt=0,istat=0,nEvents=0;
11 // ProtoTypes
12 
13 void doEvents(const Char_t *file="StRoot/StTofPool/StVpdAnalysisMaker/macros/test.lis", const Char_t *outputname="test.root");
14 
15 
16 // ------------------ Here is the actual method -----------------------------------------
17 void doEvents(const Char_t *fileList, const Char_t *outputname)
18 {
19  Int_t nEvents = 1000;
20  Int_t nfiles = 100;
21 
22  //
23  // First load some shared libraries we need
24  //
25  if (gClassTable->GetID("TTable") < 0) {
26  gSystem->Load("libStar");
27  gSystem->Load("libPhysics");
28  }
29  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
30  loadSharedLibraries();
31  gSystem->Load("StarMagField");
32  gSystem->Load("StMagF");
33  gSystem->Load("StTpcDb");
34 // gSystem->Load("StDbUtilities");
35  gSystem->Load("StDaqLib");
36  gSystem->Load("StDbBroker");
37  gSystem->Load("StDetectorDbMaker");
38  gSystem->Load("StDbUtilities");
39  gSystem->Load("St_db_Maker");
40 
41  gSystem->Load("StEvent");
42  gSystem->Load("StEventMaker");
43  gSystem->Load("StarMagField");
44  gSystem->Load("StTofUtil");
45 
46  gSystem->Load("StVpdAnalysisMaker");
47  //
48  // Handling depends on whether file is a ROOT file or XDF file
49  //
50  chain = new StChain("StChain");
51 
52 
53  delete setFiles; setFiles =0;
54  if (fileList) { //Normal case
55  setFiles= new StFile();
56  } else { //
57  return;
58  }
59  ifstream* inputStream = new ifstream;
60  inputStream->open(fileList);
61  if (!(inputStream)) {
62  cout << "can not open list file" << endl;
63  return;
64  }
65  cout<<"Open file list: --- "<<fileList<<endl;
66 
67  char line[512];
68  for (;inputStream->good();) {
69  inputStream->getline(line,512);
70  if ( inputStream->good() ) {
71  //cout<<" root file "<<line<<endl;
72  TFile *ftmp = new TFile(line);
73  //----------
74  if (!(ftmp->IsOpen())) {
75  cout<<line<<" open failed ! not chained"<<endl;
76  continue;
77  }
78  if (ftmp->IsZombie()) {
79  cout<<"sth. very wrong with "<<line<<", not chained "<<endl;
80  continue;
81  }
82  if (ftmp->TestBit(1024)) {
83  cout<<"revocer procedure applied to "<<line<<endl;
84  continue;
85  }
86  //--------------------------
87  if( ftmp && ftmp->IsOpen() && ftmp->GetNkeys()) {
88  cout << "add file " << line << endl;
89  setFiles->AddFile(line);
90  } else {
91  cout << " cannot open file " << line << endl;
92  }
93  delete ftmp;
94  }
95  }
96 
97 
98  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList,"MuDst.root",nfiles);
99  muDstMaker->SetStatus("*",0);
100  muDstMaker->SetStatus("MuEvent",1);
101  muDstMaker->SetStatus("TofRawData",1);
102 
103  cout<<endl<<"============ Data Base ========="<<endl;
104  dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
105 
106  StVpdAnalysisMaker *vpdAna = new StVpdAnalysisMaker();
107  vpdAna->SetDebug();
108 
109  //
110  // Initialize chain
111  //
112  Int_t iInit = chain->Init();
113  if (iInit) chain->Fatal(iInit,"on init");
114  chain->PrintInfo();
115 
116  //
117  // Event loop
118  //
119  int istat = 0, i = 1;
120 EventLoop: if (i <= nEvents && istat != 2) {
121 
122  cout << endl << "============================ Event " << i
123  << " start ============================" << endl;
124 
125  chain->Clear();
126  istat = chain->Make(i);
127  if (istat == 2)
128  {cout << "Last event processed. Status = " << istat << endl;}
129  if (istat == 3)
130  {cout << "Error event processed. Status = " << istat << endl;}
131 
132  // gObjectTable->Print();
133  i++;
134  goto EventLoop;
135  }
136 
137  i--;
138  cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;
139 
140  //
141  // Chain Finish
142  //
143  if (nEvents > 1) {
144  chain->Finish();
145  }
146 
147 
148 }
149 
150 
151 
152 
153 
Definition: StTree.h:125
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
void SetStatus(const char *arrType, int status)