00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 TCanvas *QACanvas = 0;
00025 TBrowser *QABrowser = 0;
00026 class StChain;
00027 class St_DataSet;
00028 StChain *chain=0;
00029
00030 void Analysis(St_DataSet *set);
00031
00032
00033 void Load()
00034 {
00035 gSystem->Load("St_base");
00036 gSystem->Load("StChain");
00037
00038 gSystem->Load("libglobal_Tables");
00039 gSystem->Load("libgen_Tables");
00040 gSystem->Load("libsim_Tables");
00041
00042 gSystem->Load("St_io_Maker");
00043 };
00044
00045
00046 void MakeCustomMacro(const Char_t *fileName){
00047
00048 FILE *f = fopen(fileName,"w");
00049 if (!f) return;
00050 const Char_t *codePatter[] = {
00051 "void Analysis(St_DataSet *set){ "
00052 , " printf(\" Found \\\"void Analysis(St_DataSet *set)\\\" and put in there \\n\");"
00053 , " printf(\" your favourite analysis\\n\"); "
00054 , " set->ls(\"*\"); "
00055 , "}"
00056 };
00057 Int_t lenOfPatter = sizeof(codePatter)/4;
00058 printf("\n %s:\n",fileName);
00059 for (int i=0;i<lenOfPatter;i++) {
00060 fprintf(f,"%s\n",codePatter[i]);
00061 printf("\t%s\n", codePatter[i]);
00062 }
00063 fclose(f);
00064 printf(" Please find \"%s\" file with function \n\n",fileName);
00065 printf("\t void Analysis(St_DataSet *set)\n\n");
00066 printf(" and put in there your favourite analysis code\n");
00067 printf(" or just call LoopOverDst() function again \"AS IS\":\n");
00068 printf(" root[1] LoopOverDst()\n");
00069 }
00070
00071
00072 void LoopOverDst(
00073
00074 const Char_t *fileName="/disk00001/star/auau200/venus412/default/b0_3/year_1b/hadronic_on/tss",
00075 const Char_t *customMacroFile = "Analysis.C"
00076 )
00077 {
00078 cout << endl
00079 << " TURN the ROOT/CINT optimization OFF FIRST !!!" << endl
00080 << " with root[0] .O0 " << endl
00081 << " command: \"dot\"-\"Ou\"-\"ZERO\" " << endl << endl
00082 << " Usage: LoopOverDst( const Char_t *fileName =\"" << fileName << "\"," << endl
00083 << " const Char_t *customMacroFile =\"" << customMacroFile << "\"," << endl
00084 << " Note: fileName - may define either file or entire directory tree." << endl
00085 << " ----- For the directory all files from that will be used." << endl
00086 << endl ;
00087 if (gClassTable->GetID("StChain") < 0) Load();
00088
00089 if (gSystem->AccessPathName(customMacroFile) == 0)
00090 gROOT->LoadMacro(customMacroFile);
00091 else {
00092 MakeCustomMacro(customMacroFile);
00093 return;
00094 }
00095
00096 Long_t id;
00097 Long_t size;
00098 Long_t flags;
00099 Long_t modtime;
00100 Char_t *exFileName = gSystem->ExpandPathName(fileName);
00101 if (gSystem->GetPathInfo(exFileName, &id, &size, &flags, &modtime))
00102 {
00103 cerr << " *** Error *** Can not find file: \"" << fileName << "\"" << endl;
00104 delete [] exFileName;
00105 exFileName=0;
00106 return;
00107 }
00108
00109 if (!chain) {
00110 chain = new StChain("bfc");
00111 St_io_Maker *in = new St_io_Maker("Input","all");
00112 Int_t nFile = 0;
00113 if ((flags & 2)) {
00114
00115
00116
00117 St_FileSet dstDirs(exFileName);
00118 St_DataSetIter nextDataSet(&dstDirs,0);
00119 St_DataSet *set = 0;
00120 while ( (set = nextDataSet()) ) {
00121 if (strcmp(set->GetTitle(),"file") || !(strstr(set->GetName(),"evts.root"))) continue;
00122 TString p = set->Path();
00123 Char_t *rootfilename = gSystem->ConcatFileName(exFileName,p.Data());
00124 cout << "Including file " << rootfilename << " into list of the files " << endl;
00125 in->AddFile(rootfilename);
00126 nFile++;
00127 }
00128 } else {
00129 in->AddFile(exFileName);
00130 nFile++;
00131 }
00132 cout << "Total: " << nFile << " files will be analysed" << endl ;
00133
00134 in->SetMaxEvent(4);
00135 }
00136
00137 chain->Init();
00138 chain->PrintInfo();
00139 int i;
00140 for (i=1;i<11111111;i++) {
00141 if (!chain->Make(i)) {
00142 St_DataSet *ds = chain.DataSet("dst");
00143 if (ds) Analysis(ds);
00144 chain->Clear();
00145 }
00146 else break;
00147 }
00148 chain->Finish();
00149 if (QABrowser) delete QABrowser;
00150
00151 delete [] exFileName;
00152 delete [] exPsFile;
00153 }