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/StTofMuDstReader/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 = 100;
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 gSystem->Load("StTofMaker");
00046
00047 gSystem->Load("libtpc_Tables");
00048 gSystem->Load("libGeom");
00049 gSystem->Load("St_g2t");
00050 gSystem->Load("geometry");
00051 gSystem->Load("St_geant_Maker");
00052
00053 gSystem->Load("StTofMuDstReader");
00054
00055
00056
00057 chain = new StChain("StChain");
00058
00059
00060 int NwGeant=5000000, IwType=0, NwPaw=0;
00061 St_geant_Maker *geantMk = new St_geant_Maker("geant",NwGeant,NwPaw,IwType);
00062 geantMk->LoadGeometry("detp geometry y2005F");
00063 geantMk->SetActive(kFALSE);
00064
00065
00066 delete setFiles; setFiles =0;
00067 if (fileList) {
00068 setFiles= new StFile();
00069 } else {
00070 return;
00071 }
00072 ifstream* inputStream = new ifstream;
00073 inputStream->open(fileList);
00074 if (!(inputStream)) {
00075 cout << "can not open list file" << endl;
00076 return;
00077 }
00078 cout<<"Open file list: --- "<<fileList<<endl;
00079
00080 char line[512];
00081 for (;inputStream->good();) {
00082 inputStream->getline(line,512);
00083 if ( inputStream->good() ) {
00084
00085 TFile *ftmp = new TFile(line);
00086
00087 if (!(ftmp->IsOpen())) {
00088 cout<<line<<" open failed ! not chained"<<endl;
00089 continue;
00090 }
00091 if (ftmp->IsZombie()) {
00092 cout<<"sth. very wrong with "<<line<<", not chained "<<endl;
00093 continue;
00094 }
00095 if (ftmp->TestBit(1024)) {
00096 cout<<"revocer procedure applied to "<<line<<endl;
00097 continue;
00098 }
00099
00100 if( ftmp && ftmp->IsOpen() && ftmp->GetNkeys()) {
00101 cout << "add file " << line << endl;
00102 setFiles->AddFile(line);
00103 } else {
00104 cout << " cannot open file " << line << endl;
00105 }
00106 delete ftmp;
00107 }
00108 }
00109
00110 StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList,"MuDst.root",nfiles);
00111 muDstMaker->SetStatus("*",0);
00112 muDstMaker->SetStatus("MuEvent",1);
00113 muDstMaker->SetStatus("PrimaryVertices",1);
00114 muDstMaker->SetStatus("PrimaryTracks",1);
00115 muDstMaker->SetStatus("TofRawData",1);
00116 muDstMaker->SetStatus("TofData",1);
00117 muDstMaker->SetStatus("TofHit",1);
00118
00119 gSystem->Load("StTofMuDstReader");
00120
00121 StTofMuDstEval *tofEval = new StTofMuDstEval("tofMuDstEval",muDstMaker);
00122 StTofMuDstReader *tofMaker = new StTofMuDstReader("tofMaker",outputname,muDstMaker);
00123
00124
00125
00126
00127
00128 Int_t iInit = chain->Init();
00129 if (iInit) chain->Fatal(iInit,"on init");
00130 chain->PrintInfo();
00131
00132
00133
00134
00135 int istat = 0, i = 1;
00136 EventLoop: if (i <= nEvents && istat != 2) {
00137
00138 cout << endl << "============================ Event " << i
00139 << " start ============================" << endl;
00140
00141 chain->Clear();
00142 istat = chain->Make(i);
00143 if (istat == 2)
00144 {cout << "Last event processed. Status = " << istat << endl;}
00145 if (istat == 3)
00146 {cout << "Error event processed. Status = " << istat << endl;}
00147
00148
00149 i++;
00150 goto EventLoop;
00151 }
00152
00153 i--;
00154 cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;
00155
00156
00157
00158
00159 if (nEvents > 1) {
00160 chain->Finish();
00161 }
00162
00163
00164 }
00165
00166
00167
00168
00169