Belle II Software development
dqmmerge.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <string>
9#include <stdio.h>
10#include <stdlib.h>
11#include <sys/stat.h>
12
13#include <TFileMerger.h>
14
15using namespace std;
16
17int main(int argc, char** argv)
18{
19 if (argc < 6) {
20 printf("Usage : dqmmerge topdir histofile nnodes startnode outfile\n");
21 exit(-1);
22 }
23 string topdir = string(argv[1]);
24 string file = string(argv[2]);
25 int nnodes = atoi(argv[3]);
26 int startnode = atoi(argv[4]);
27 string outfile = string(argv[5]);
28
29 // Set up merger with output file
30 TFileMerger merger(false, false);
31 if (!merger.OutputFile(outfile.c_str())) {
32 printf("RbTupleManager:: error to open output file %s\n", file.c_str());
33 return -1;
34 }
35
36 // Make file list
37 for (int i = 0; i < nnodes; i++) {
38 char histofile[1024];
39 sprintf(histofile, "%s/evp_hltwk%2.2d/%s",
40 topdir.c_str(), startnode + i,
41 file.c_str());
42 struct stat statbuf;
43 if (stat(histofile, &statbuf) == 0)
44 merger.AddFile(histofile);
45 }
46
47 // Do Merge
48 if (!merger.Merge()) {
49 printf("RbTupleManager:: error to merge files\n");
50 return -1;
51 }
52}
53
54
STL namespace.