-
Notifications
You must be signed in to change notification settings - Fork 4
/
mergeLHEfiles.cpp
57 lines (48 loc) · 1.52 KB
/
mergeLHEfiles.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// c++ -o mergeLHEfiles mergeLHEfiles.cpp
#include "LHEF.h"
#include <iomanip>
#include <vector>
#include <iostream>
#include <string>
using namespace std ;
int main(int argc, char ** argv) {
if(argc < 3)
{
cout << "Usage: " << argv[0]
<< " fileToAdd1.lhe [fileToAdd2.lhe [...]]" << endl ;
return -1;
}
vector<string> fileToAddNames;
for(int fileIt = 0; fileIt < argc-1; ++fileIt)
{
fileToAddNames.push_back( argv[1+fileIt] );
cout << "fileToAddName = " << fileToAddNames.at(fileIt) << endl ;
}
ofstream outputStream ("total.lhe") ;
LHEF::Writer writer (outputStream) ;
//PG loop over input files
for (int i = 0 ; i < fileToAddNames.size () ; ++i)
{
cout << "opening " << fileToAddNames.at (i) << endl ;
std::ifstream ifs(fileToAddNames.at (i).c_str ());
// Create the Reader object:
LHEF::Reader reader(ifs);
if (i == 0)
{
writer.headerBlock() << reader.headerBlock;
writer.initComments() << reader.initComments;
writer.heprup = reader.heprup;
writer.init();
}
//PG loop over events
while ( reader.readEvent() )
{
if ( reader.outsideBlock.length() ) std::cout << reader.outsideBlock;
writer.eventComments() << reader.eventComments;
writer.hepeup = reader.hepeup;
writer.writeEvent();
} //PG loop over events
} //PG loop over input files
cout << "output file : " << "total.lhe" << endl ;
return 0 ;
}