00001 #include "iostream.h"
00002
00003 class StChain;
00004 StChain *chain=0;
00005 class St_db_Maker;
00006 St_db_Maker *dbMk =0;
00007 class StFileI;
00008 StFileI *setFiles =0;
00009
00010 Int_t iEvt=0,istat=0,nEvents=0;
00011
00012
00013 void doEvents(const Char_t *file="StRoot/StTofPool/StVpdAnalysisMaker/macros/test.lis", const Char_t *outputname="test.root");
00014
00015
00016
00017 void doEvents(const Char_t *fileList, const Char_t *outputname)
00018 {
00019 Int_t nEvents = 1000;
00020 Int_t nfiles = 100;
00021
00022
00023
00024
00025 if (gClassTable->GetID("TTable") < 0) {
00026 gSystem->Load("libStar");
00027 gSystem->Load("libPhysics");
00028 }
00029 gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
00030 loadSharedLibraries();
00031 gSystem->Load("StarMagField");
00032 gSystem->Load("StMagF");
00033 gSystem->Load("StTpcDb");
00034
00035 gSystem->Load("StDaqLib");
00036 gSystem->Load("StDbBroker");
00037 gSystem->Load("StDetectorDbMaker");
00038 gSystem->Load("StDbUtilities");
00039 gSystem->Load("St_db_Maker");
00040
00041 gSystem->Load("StEvent");
00042 gSystem->Load("StEventMaker");
00043 gSystem->Load("StarMagField");
00044 gSystem->Load("StTofUtil");
00045
00046 gSystem->Load("StVpdAnalysisMaker");
00047
00048
00049
00050 chain = new StChain("StChain");
00051
00052
00053 delete setFiles; setFiles =0;
00054 if (fileList) {
00055 setFiles= new StFile();
00056 } else {
00057 return;
00058 }
00059 ifstream* inputStream = new ifstream;
00060 inputStream->open(fileList);
00061 if (!(inputStream)) {
00062 cout << "can not open list file" << endl;
00063 return;
00064 }
00065 cout<<"Open file list: --- "<<fileList<<endl;
00066
00067 char line[512];
00068 for (;inputStream->good();) {
00069 inputStream->getline(line,512);
00070 if ( inputStream->good() ) {
00071
00072 TFile *ftmp = new TFile(line);
00073
00074 if (!(ftmp->IsOpen())) {
00075 cout<<line<<" open failed ! not chained"<<endl;
00076 continue;
00077 }
00078 if (ftmp->IsZombie()) {
00079 cout<<"sth. very wrong with "<<line<<", not chained "<<endl;
00080 continue;
00081 }
00082 if (ftmp->TestBit(1024)) {
00083 cout<<"revocer procedure applied to "<<line<<endl;
00084 continue;
00085 }
00086
00087 if( ftmp && ftmp->IsOpen() && ftmp->GetNkeys()) {
00088 cout << "add file " << line << endl;
00089 setFiles->AddFile(line);
00090 } else {
00091 cout << " cannot open file " << line << endl;
00092 }
00093 delete ftmp;
00094 }
00095 }
00096
00097
00098 StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList,"MuDst.root",nfiles);
00099 muDstMaker->SetStatus("*",0);
00100 muDstMaker->SetStatus("MuEvent",1);
00101 muDstMaker->SetStatus("TofRawData",1);
00102
00103 cout<<endl<<"============ Data Base ========="<<endl;
00104 dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
00105
00106 StVpdAnalysisMaker *vpdAna = new StVpdAnalysisMaker();
00107 vpdAna->SetDebug();
00108
00109
00110
00111
00112 Int_t iInit = chain->Init();
00113 if (iInit) chain->Fatal(iInit,"on init");
00114 chain->PrintInfo();
00115
00116
00117
00118
00119 int istat = 0, i = 1;
00120 EventLoop: if (i <= nEvents && istat != 2) {
00121
00122 cout << endl << "============================ Event " << i
00123 << " start ============================" << endl;
00124
00125 chain->Clear();
00126 istat = chain->Make(i);
00127 if (istat == 2)
00128 {cout << "Last event processed. Status = " << istat << endl;}
00129 if (istat == 3)
00130 {cout << "Error event processed. Status = " << istat << endl;}
00131
00132
00133 i++;
00134 goto EventLoop;
00135 }
00136
00137 i--;
00138 cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;
00139
00140
00141
00142
00143 if (nEvents > 1) {
00144 chain->Finish();
00145 }
00146
00147
00148 }
00149
00150
00151
00152
00153