forked from mverwe/JetToyHI
-
Notifications
You must be signed in to change notification settings - Fork 2
/
runConversionQPYTHIA.cc
85 lines (59 loc) · 1.9 KB
/
runConversionQPYTHIA.cc
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
//#include <fstream>
#include "TFile.h"
#include "TTree.h"
#include "fastjet/PseudoJet.hh"
#include "fastjet/ClusterSequenceArea.hh"
#include "include/ProgressBar.h"
#include "include/pythiaEvent.hh"
#include "include/extraInfo.hh"
#include "PU14/CmdLine.hh"
using namespace std;
using namespace fastjet;
int main(int argc, char *argv[])
{
if(argc != 2)
{
cerr << "Usage: " << argv[0] << " RootFileName" << endl;
return -1;
}
TFile File(argv[1]);
TTree *T = (TTree *)File.Get("Tdata");
vector<double> *px = NULL; T->SetBranchAddress("px", &px);
vector<double> *py = NULL; T->SetBranchAddress("py", &py);
vector<double> *pz = NULL; T->SetBranchAddress("pz", &pz);
vector<double> *m = NULL; T->SetBranchAddress("m", &m);
vector<int> *id = NULL; T->SetBranchAddress("id", &id);
double w; T->SetBranchAddress("xSec", &w);
ProgressBar Bar(cerr, T->GetEntries());
Bar.SetStyle(3);
//output text file
std::ofstream fout;
TString outFileName = Form("%s",argv[1]);
outFileName.ReplaceAll("pthat120","pu14/pthat120");
outFileName.ReplaceAll(".root",".pu14");
std::cout << "outFileName: " << outFileName << std::endl;
fout.open(outFileName.Data());
int EntryCount = T->GetEntries();
for(int iE = 0; iE < EntryCount; iE++)
{
T->GetEntry(iE);
Bar.Update(iE);
Bar.PrintWithMod(EntryCount / 300);
//cout << px << " " << id << endl;
fout << "# event " << iE << "\n";
fout << "weight " << w << "\n";
for(int i = 0; i < (int)id->size(); i++)
fout << (*px)[i] << " " << (*py)[i] << " " << (*pz)[i] << " " << (*m)[i]
<< " " << (*id)[i] << " " << 0 << "\n";
fout << "end" << "\n";
}
fout.close();
Bar.Update(EntryCount);
Bar.Print();
Bar.PrintLine();
File.Close();
return 0;
}