ATLAS Offline Software
LArSamplesMerge.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 //Dear emacs, this is -*-c++-*-
7 
9 #include <vector>
10 #include <string>
11 #include <iostream>
12 
13 #include "TROOT.h"
14 #include "TApplication.h"
15 #include "TSystem.h"
16 #include "TFile.h"
18 
19 using namespace LArSamples;
20 
21 int main ATLAS_NOT_THREAD_SAFE (int argc, char** argv) {
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 
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 }
69 
70 
71 
get_generator_info.result
result
Definition: get_generator_info.py:21
LArSamples::PersistentAccessor
Definition: PersistentAccessor.h:24
LArSamples
Definition: AbsShape.h:24
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
CombineRootFiles.inFileNames
inFileNames
Definition: CombineRootFiles.py:22
PersistentAccessor.h
DumpGeoConfig.outFileName
string outFileName
Definition: DumpGeoConfig.py:238
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition: CppUnit_SGtestdriver.cxx:141
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
lumiFormat.i
int i
Definition: lumiFormat.py:92
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
LArSamples::PersistentAccessor::open
static PersistentAccessor * open(const TString &fileName)
Definition: PersistentAccessor.cxx:65
merge.output
output
Definition: merge.py:17
ATLAS_NOT_THREAD_SAFE
int main ATLAS_NOT_THREAD_SAFE(int argc, char **argv)
Definition: LArSamplesMerge.cxx:21
xAODRootTest.accessors
dictionary accessors
Definition: xAODRootTest.py:67
checker_macros.h
Define macros for attributes used to control the static checker.
LArSamples::PersistentAccessor::merge
static PersistentAccessor * merge(const std::vector< const PersistentAccessor * > &accessors, const TString &fileName)
Definition: PersistentAccessor.cxx:181