ATLAS Offline Software
Loading...
Searching...
No Matches
LArSamplesMerge.cxx File Reference
#include "LArCafJobs/PersistentAccessor.h"
#include <vector>
#include <string>
#include <iostream>
#include "TROOT.h"
#include "TApplication.h"
#include "TSystem.h"
#include "TFile.h"
#include "CxxUtils/checker_macros.h"
Include dependency graph for LArSamplesMerge.cxx:

Go to the source code of this file.

Functions

int main ATLAS_NOT_THREAD_SAFE (int argc, char **argv)

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

int main ATLAS_NOT_THREAD_SAFE ( int argc,
char ** argv )

Definition at line 21 of file LArSamplesMerge.cxx.

21 {
22
23 if (argc<3 || (argc>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help")))) {
24 std::cout << "Syntax:" << std::endl;
25 std::cout << "LArSamplesMerge file1 file2 ... outFile" << std::endl;
26 return -1;
27 }
28
29
30 TROOT root ("root", "root");
31 gSystem->Load("libLArCafJobsDict.so");
32
33 std::vector<TString> inFileNames;
34 std::string outFileName(argv[argc-1]);
35
36 int result=0;
37
38 for (int i=1;i<argc-1;++i)
39 inFileNames.emplace_back(argv[i]);
40
41
42 std::vector<const PersistentAccessor*> accessors;
43
44 for (const TString& fileName : inFileNames) {
46 if (!acc) {
47 std::cout << "ERROR failed to open " << fileName << std::endl;
48 result=-1;
49 }
50 else {
51 std::cout << "Open file " << fileName << " with " << acc->nEvents() << " events." << std::endl;
52 accessors.push_back(acc);
53 }
54 }
55
56 const PersistentAccessor* output=PersistentAccessor::merge(accessors,outFileName);
57 if (!output) {
58 std::cout << "ERROR: Failed to merge files" << std::endl;
59 result=-2;
60 }
61 else {
62 std::cout << "Wrote output file " << outFileName << " with " << output->nEvents() << " events." << std::endl;
63 output->file()->Close();
64 std::cout << "Out file closed"<<std::endl;
65 }
66
67 return result;
68}
static PersistentAccessor * open(const TString &fileName)
static PersistentAccessor * merge(const std::vector< const PersistentAccessor * > &accessors, const TString &fileName)
output
Definition merge.py:16