00001
00002
00003
00004 class StChain;
00005 StChain *chain;
00006 int total=0;
00007
00008 void RunPythiaReader(int nevents=10,
00009 const char* jetInFile = "processed/pds1214_23_5000evts.jet.root"
00010 )
00011 {
00012 cout <<"read jet file:\t"<<jetInFile<<endl;
00013
00014 string basename = firstHalf(jetInFile,"/processed/",".jet.root");
00015 cout <<"basename:\t"<<basename<<endl;
00016 TString ofn = TString("./assoc/") + TString(basename) + TString(".assoc.root");
00017 const char* outfile = ofn.Data();
00018 cout <<"write assoc file:\t"<<outfile<<endl;
00019
00020 if (gClassTable->GetID("TTable") < 0) {
00021 gSystem->Load("libStar");
00022 gSystem->Load("libPhysics");
00023 }
00024 gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
00025 loadSharedLibraries();
00026 gSystem->Load("StMagF");
00027 gSystem->Load("StTpcDb");
00028 gSystem->Load("StDbUtilities");
00029 gSystem->Load("StMcEvent");
00030 gSystem->Load("StMcEventMaker");
00031 gSystem->Load("StDaqLib");
00032 gSystem->Load("StEmcRawMaker");
00033 gSystem->Load("StEmcADCtoEMaker");
00034 gSystem->Load("StEmcUtil");
00035 gSystem->Load("StDbLib");
00036 gSystem->Load("StDbBroker");
00037 gSystem->Load("St_db_Maker");
00038 gSystem->Load("StEEmcUtil");
00039 gSystem->Load("StEEmcDbMaker");
00040 gSystem->Load("StJetFinder");
00041 gSystem->Load("StJetMaker");
00042
00043 double pi = atan(1.0)*4.0;
00044 cout << " loading done " << endl;
00045
00046 chain= new StChain("StChain");
00047 chain->SetDebug(1);
00048
00049
00050 StJetReader* jetReader = new StJetReader("JetReader",0);
00051
00052 StPythiaAssociator* jetAssoc = new StPythiaAssociator("JetAssoc", outfile, jetReader);
00053
00054 chain->PrintInfo();
00055 chain->Init();
00056
00057 jetReader->InitFile(jetInFile);
00058
00059 int ntotal = jetReader->tree()->GetEntries();
00060
00061 chain->PrintInfo();
00062
00063 for (Int_t iev=0;iev<nevents && iev<ntotal; iev++) {
00064 cout << "****************************************** " << endl;
00065 cout << "Working on eventNumber " << iev << endl;
00066 cout << "*************************1***************** " << endl;
00067 chain->Clear();
00068 int iret = chain->Make(iev);
00069 total++;
00070 if (iret) {
00071 cout << "Bad return code!" << endl;
00072 break;
00073 }
00074 }
00075
00076 chain->Finish();
00077 cout << "****************************************** " << endl;
00078 cout << "total number of events " << total << endl;
00079 cout << "****************************************** " << endl;
00080 }
00081
00082 string firstHalf(string infile, string begin, string end, int offset=0)
00083 {
00084 cout <<"look for:\t"<<begin<<"\tin:\t"<<infile<<endl;
00085 unsigned int where1 = infile.find(begin);
00086 cout <<"look for:\t"<<end<<"\tin:\t"<<infile<<endl;
00087 unsigned int where2 = infile.find(end);
00088 if (where2==infile.npos) {
00089 return 0;
00090 }
00091
00092 int start=where1+begin.size()+offset;
00093 int stop=where2;
00094 if (stop<=start) {
00095 cout <<"error, mismatch.abort()"<<endl; abort();
00096 }
00097
00098 string number;
00099 for (int i=start; i<stop; ++i) {
00100
00101 number += infile[i];
00102 }
00103 return number;
00104 }
00105