00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 void bfcread_hist_files_add(
00085 int nevents=3,
00086 const Char_t *fileName="fileList.txt",
00087 const Char_t *outHistFile="kathy",
00088 const Char_t *TopDirTree="bfcTree")
00089 {
00090 cout << "bfcread_hist_files_add.C, input file list = "
00091 << fileName << endl;
00092 cout << "bfcread_hist_files_add.C, output file list = "
00093 << outHistFile << endl;
00094 cout << "bfcread_hist_files_add.C, top level directory in hist file = "
00095 << TopDirTree << endl;
00096
00097 gSystem->Load("St_base");
00098 gSystem->Load("StChain");
00099 gSystem->Load("StIOMaker");
00100 gSystem->Load("StarClassLibrary");
00101 gSystem->Load("StUtilities");
00102 gSystem->Load("StAnalysisUtilities");
00103 gSystem->Load("libglobal_Tables");
00104 gSystem->Load("libStDb_Tables");
00105 gSystem->Load("StDetectorDbMaker");
00106 gSystem->Load("libtpc_Tables");
00107 gSystem->Load("libStDb_Tables.so");
00108 gSystem->Load("StTpcDb");
00109 gSystem->Load("StEvent");
00110 gSystem->Load("StPmdUtil");
00111 gSystem->Load("St_QA_Maker");
00112 gSystem->Load("StTreeMaker");
00113
00114
00115 char **fList = new char[8192][256];
00116 ifstream fin(fileName);
00117 if (fin) {
00118 int j=0;
00119 cout << "Input file " << fileName << " found." << endl;
00120 for (Int_t i=0;i<nevents;i++){
00121 char *line = new char[256];
00122 fin >> line;
00123 if (fin.eof()) break;
00124 fList[j] = line;
00125 cout << " Added file : " << fList[j] << endl;
00126 j++;
00127 }
00128 }
00129 fin.close();
00130
00131
00132 StChain* chainW = new StChain("writeChain");
00133 char *MakerHistDir= new char[256];
00134
00135
00136 StTreeMaker* treeMk = new StTreeMaker("outTree",outHistFile,TopDirTree);
00137 treeMk->SetIOMode("w");
00138 treeMk->SetBranch("histBranch");
00139 treeMk->Init();
00140
00141
00142 Int_t istat=0;
00143 Int_t ifl=0;
00144 Int_t hCCount=0;
00145
00146 StFile* fff = new StFile(fList);
00147 StIOMaker *IOMk = new StIOMaker("IO","r",fff,TopDirTree);
00148 IOMk->SetIOMode("r");
00149 IOMk->SetBranch("*",0,"0");
00150 IOMk->SetBranch("histBranch",0,"r");
00151 IOMk->Init();
00152
00153 IOMk->Shunt();
00154
00155
00156 StHistMaker* HM[128];
00157 StHistUtil* HU[128];
00158 int nbranch=0;
00159
00160 EventLoop: if (ifl<nevents && istat==0) {
00161
00162 cout << endl << "Now processing file : " << ifl+1 << endl << endl;
00163
00164
00165
00166 IOMk->Clear();
00167 istat = IOMk->Open();
00168 istat = IOMk->Make();
00169
00170 Event = IOMk->GetDataSet("hist");
00171 if (!Event) {
00172 cout << " No histogram branch found in file!" << endl;
00173 }
00174
00175
00176 TDataSetIter nextHistList(Event);
00177 St_ObjectSet *histContainer = 0;
00178 TList *dirList = 0;
00179 while (histContainer = (St_ObjectSet *)nextHistList.Next()) {
00180 dirList = (TList *) histContainer->GetObject();
00181 strcpy(MakerHistDir,histContainer->GetName());
00182 MakerHistDir[strlen(MakerHistDir)-4] = 0;
00183
00184
00185
00186
00187 cout << endl << " --- MakerHistDir : " << MakerHistDir << endl;
00188
00189
00190 int bnum=-1;
00191 for (int l=0; l<nbranch; l++) {
00192 if (!strcmp(MakerHistDir,HM[l]->GetName())) {
00193 bnum = l;
00194 break;
00195 }
00196 }
00197
00198 if (bnum==-1) {
00199 bnum = nbranch++;
00200 HM[bnum] = new StHistMaker(MakerHistDir);
00201 HM[bnum]->Init();
00202 HU[bnum] = new StHistUtil();
00203 HU[bnum]->SetPntrToMaker(IOMk);
00204
00205
00206 dirList = HU[bnum]->FindHists(MakerHistDir);
00207
00208
00209 hCCount = HU[bnum]->CopyHists(dirList);
00210
00211 cout << "bfcread_hist_files_add.C, # histograms copied = " <<
00212 hCCount << endl;
00213
00214 HM[bnum]->SetHArraySize(HU[bnum]->getNewHistSize());
00215 HM[bnum]->SetHArray(HU[bnum]->getNewHist());
00216 HM[bnum]->Make();
00217 }
00218
00219 else {
00220 dirList = HU[bnum]->FindHists(MakerHistDir);
00221
00222
00223 hCCount = HU[bnum]->AddHists(dirList);
00224
00225 cout << "bfcread_hist_files_add.C, # histograms added = " <<
00226 hCCount << endl;
00227
00228 HM[bnum]->SetHArraySize(HU[bnum]->getNewHistSize());
00229 HM[bnum]->SetHArray(HU[bnum]->getNewHist());
00230 HM[bnum]->Make();
00231
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 }
00243
00244 ifl++;
00245 istat = IOMk->Close();
00246 goto EventLoop;
00247 }
00248
00249 treeMk->Make();
00250 treeMk->Finish();
00251 IOMk->Finish();
00252 }