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 void bfcread_hist_prefixes_add(
00040 const Char_t *fileName="",
00041 const Char_t *outHistFile="summed",
00042 const Char_t *TopDirTree="bfcTree")
00043 {
00044 cout << "bfcread_hist_prefixes_add.C, input file = "
00045 << fileName << endl;
00046 cout << "bfcread_hist_prefixes_add.C, output file = "
00047 << outHistFile << endl;
00048 cout << "bfcread_hist_prefixes_add.C, top level directory in hist file = "
00049 << TopDirTree << endl;
00050
00051 gSystem->Load("St_base");
00052 gSystem->Load("StChain");
00053 gSystem->Load("StIOMaker");
00054 gSystem->Load("StUtilities");
00055 gSystem->Load("StAnalysisUtilities");
00056 gSystem->Load("libglobal_Tables");
00057 gSystem->Load("libtpc_Tables");
00058 gSystem->Load("libStDb_Tables.so");
00059 gSystem->Load("StDetectorDbMaker");
00060 gSystem->Load("StTpcDb");
00061 gSystem->Load("StEvent");
00062 gSystem->Load("StPmdUtil");
00063 gSystem->Load("St_QA_Maker");
00064 gSystem->Load("StTreeMaker");
00065
00066
00067 StChain* chainW = new StChain("writeChain");
00068 char *MakerHistDir= new char[256];
00069
00070
00071 StTreeMaker* treeMk = new StTreeMaker("outTree",outHistFile,TopDirTree);
00072 treeMk->SetIOMode("w");
00073 treeMk->SetBranch("histBranch");
00074 treeMk->Init();
00075
00076
00077 Int_t istat=0;
00078 Int_t hCCount=0;
00079
00080 StIOMaker *IOMk = new StIOMaker("IO","r",fileName,TopDirTree);
00081 IOMk->SetIOMode("r");
00082 IOMk->SetBranch("*",0,"0");
00083 IOMk->SetBranch("histBranch",0,"r");
00084 IOMk->Init();
00085
00086 IOMk->Shunt();
00087
00088
00089 StHistMaker* HM[128];
00090 StHistUtil* HU[128];
00091 int nbranch=0;
00092
00093
00094
00095
00096
00097 IOMk->Clear();
00098 istat = IOMk->Open();
00099 istat = IOMk->Make();
00100
00101 Event = IOMk->GetDataSet("hist");
00102 if (!Event) {
00103 cout << " No histogram branch found in file!" << endl;
00104 }
00105
00106
00107 TDataSetIter nextHistList(Event);
00108 St_ObjectSet *histContainer = 0;
00109
00110 TList *dirList = 0;
00111 while (histContainer = (St_ObjectSet *)nextHistList.Next()) {
00112 dirList = (TList *) histContainer->GetObject();
00113 strcpy(MakerHistDir,histContainer->GetName());
00114 MakerHistDir[strlen(MakerHistDir)-4] = 0;
00115
00116
00117
00118
00119 cout << endl << " --- MakerHistDir : " << MakerHistDir << endl;
00120
00121 HU[nbranch] = new StHistUtil();
00122 HU[nbranch]->SetPntrToMaker(IOMk);
00123 HU[nbranch]->IgnorePrefixes();
00124 HM[nbranch]=0;
00125
00126 int prefixNum;
00127 int nPrefixes = HU[nbranch]->GetNumOfPosPrefixes();
00128 Bool_t firstSet = kTRUE;
00129 for (prefixNum=0; prefixNum < nPrefixes; prefixNum++) {
00130
00131
00132 dirList = HU[nbranch]->FindHists(MakerHistDir,HU[nbranch]->GetPrefix(prefixNum));
00133 if (dirList->GetSize()) {
00134
00135 if (firstSet) {
00136 firstSet = kFALSE;
00137
00138
00139 hCCount = HU[nbranch]->CopyHists(dirList);
00140 cout << "bfcread_hist_prefixes_add.C, # histograms copied with prefix " <<
00141 HU[nbranch]->GetPrefix(prefixNum) << " = " << hCCount << endl;
00142
00143 if (HM[nbranch]==0) {
00144 HM[nbranch] = new StHistMaker(MakerHistDir);
00145 HM[nbranch]->Init();
00146 }
00147 HM[nbranch]->SetHArraySize(HU[nbranch]->getNewHistSize());
00148 HM[nbranch]->SetHArray(HU[nbranch]->getNewHist());
00149 HM[nbranch]->Make();
00150 } else {
00151 hCCount = HU[nbranch]->AddHists(dirList);
00152 cout << "bfcread_hist_prefixes_add.C, # histograms added with prefix " <<
00153 HU[nbranch]->GetPrefix(prefixNum) << " = " << hCCount << endl;
00154 }
00155 }
00156
00157 }
00158
00159 nbranch++;
00160
00161 }
00162 istat = IOMk->Close();
00163
00164 treeMk->Make();
00165 treeMk->Finish();
00166 IOMk->Finish();
00167 }