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