1 #include "TFileMerger.h"
9 std::map<int, int> runToFill; // maps: run -> fill
10 std::map<int, TFileMerger*> fillToMerger;
16 void FillMerge(const TString filelist="filelist.txt",
17 const TString runlist="runlist.txt",
18 const TString runFillFile = "run_fill.txt")
20 // Use to merge run files to fill files
21 // For some reason, it does not work without compiling:
25 // run_fill.txt must be a two column txt file,
26 // column 1 being run and column 2 being fill.
28 //TGrid::Connect("alien://");
33 rfin.open(runFillFile.Data());
38 if (!rfin.good()) break;
39 runToFill[run] = fill;
43 // Make FillMergers and add run files to them.
45 in.open(filelist.Data());
47 inRuns.open(runlist.Data());
48 char rootFileName[256];
52 if (!in.good()) break;
54 if (!inRuns.good()) break;
56 if(169094 == runNumber )
59 if( ! runToFill.count(runNumber) ) {
60 Printf("can't map run %d to fill, not in file %s", runNumber, runFillFile.Data());
64 int fill = runToFill[runNumber];
66 if( ! fillToMerger.count( fill ) ) { // if no merger for fill
67 fillToMerger[fill] = new TFileMerger(); // create merger
68 gSystem->mkdir("fillMerge");
69 fillToMerger[fill]->OutputFile(Form("fillMerge/%d.root", fill));
72 fillToMerger[fill]->AddFile(rootFileName);
75 std::ofstream fls("fillList.txt");
76 std::ofstream ffls("fillFileList.txt");
80 std::map<int, TFileMerger*>::iterator it;
81 for( it = fillToMerger.begin(); it != fillToMerger.end(); ++it ) {
82 TFileMerger* fm = (*it).second;
83 Printf("merging %s", fm->GetOutputFileName());
85 fls << (*it).first << std::endl;
86 ffls << fm->GetOutputFileName() << std::endl;