Functions to add up all histogram files.
137{
138
140
141 return 0;
142 }
143
144 B2INFO("RbTupleManager: hadd started.");
145
146
147 TFileMerger merger(false, false);
149 B2ERROR("RbTupleManager: error on opening the output file."
151 return -1;
152 }
153
154
155
157 DIR* dp;
158 struct dirent* dirp;
159 if ((dp = opendir(dir.c_str())) == nullptr) {
160 B2ERROR("RbTubleManager: error on opening the directory."
161 <<
LogVar(
"directory", dir));
162 return errno;
163 }
164
165 std::vector<std::string> filenames;
166
167
169 B2INFO(
LogVar(
"compfile", compfile));
170 while ((dirp = readdir(dp)) != nullptr) {
171 std::string curfile = std::string(dirp->d_name);
172
173 if (curfile.compare(0, compfile.size(), compfile) == 0) {
174 printf("RbTupleManager:: adding file =%s\n", curfile.c_str());
175 merger.AddFile((
m_workdir +
"/" + curfile).c_str());
176 filenames.push_back(
m_workdir +
"/" + curfile);
177 }
178 }
179 closedir(dp);
180
181
182 if (!merger.Merge()) {
183
184 B2ERROR("RbTupleManager: error on merging files.");
185 return -1;
186 }
187
188 if (deleteflag) {
189
190 vector<string>::iterator it;
191 for (it = filenames.begin(); it != filenames.end(); ++it) {
192 string& hfile = *it;
193 unlink(hfile.c_str());
194 }
195 }
196
197 B2INFO("RbTupleManager: histogram files are added.");
198
199 return 0;
200}