-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.cpp
194 lines (165 loc) · 7.61 KB
/
calc.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//example hepmc reader
#include "utils.h"
#include "jetSelector.h"
#include "calcDeltaPhiDist.h"
#include "distCalculator.h"
#include <HepMC/IO_GenEvent.h>
#include <HepMC/GenEvent.h>
#include <HepMC/GenVertex.h>
#include <fastjet/PseudoJet.hh>
#include <fastjet/ClusterSequence.hh>
#include <fastjet/Selector.hh>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
using namespace fastjet;
const static double PI = 3.1415926;
const static double R_jet = 0.3;
JetDefinition jet_def(antikt_algorithm, R_jet);
Selector select_akt = SelectorAbsEtaMax(1.6) && SelectorPtMin(30.);
double weight_total = 0.;
double phi_bin[10] = {0, 0.31, 0.94, 1.25, 1.72, 2.20, 2.51, 2.82, 2.98, 3.14};
double weight_for_bin[10] = {0.};
double x_bin[10] = {0.10, 0.30, 0.50, 0.70, 0.90, 1.10, 1.30, 1.50, 1.70, 1.90};
double weight_for_bin_for_x_jz[10] = {0.};
int main(int argc, char *argv[]) {
if (argc == 1) {
cout << " " << "ERROR: Please supply HepMC file as argument..." << endl;
return 1;
}
ifstream in_file(argv[1]);
if (!in_file.is_open()) {
cout << "Can't open file." << endl;
exit(EXIT_FAILURE);
}
while (!in_file.eof()) {
int event_id, pdg_code, partons_num, Z_daughter_pdg_code;
double Z_daughter_1_x, Z_daughter_1_y, Z_daughter_1_z, Z_daughter_1_energy;
double Z_daughter_2_x, Z_daughter_2_y, Z_daughter_2_z, Z_daughter_2_energy;
double px, py, pz, energy, temp;
double weight0, weight1, weight2, weight3, weight4;
double eta, pT;
bool isContinueFind = false;
in_file >> event_id >> partons_num >> weight0 >> weight1
>> weight2 >> weight3 >> weight4;
in_file >> Z_daughter_pdg_code >> Z_daughter_1_x >> Z_daughter_1_y
>> Z_daughter_1_z >> Z_daughter_1_energy >> temp;
in_file >> Z_daughter_pdg_code >> Z_daughter_2_x >> Z_daughter_2_y
>> Z_daughter_2_z >> Z_daughter_2_energy >> temp;
double Z_daughter1_pT = sqrt(pow(Z_daughter_1_x, 2) + pow(Z_daughter_1_y, 2));
double Z_daughter1_p = sqrt(pow(Z_daughter_1_x, 2) + pow(Z_daughter_1_y, 2)
+ pow(Z_daughter_1_z, 2));
double Z_daught1_eta = (1.0 / 2.0) * log((Z_daughter1_p + Z_daughter_1_z) / (
Z_daughter1_p - Z_daughter_1_z
) );
double Z_daughter1_phi = acos(Z_daughter_1_x / Z_daughter1_pT );
if (Z_daughter_1_y < 0) Z_daughter1_phi = 2 * PI - Z_daughter1_phi;
double Z_daughter2_pT = sqrt(pow(Z_daughter_2_x, 2) + pow(Z_daughter_2_y, 2));
double Z_daughter2_p = sqrt(pow(Z_daughter_2_x, 2) + pow(Z_daughter_2_y, 2)
+ pow(Z_daughter_2_z, 2));
double Z_daught2_eta = (1.0 / 2.0) * log((Z_daughter2_p + Z_daughter_2_z) / (
Z_daughter2_p - Z_daughter_2_z
) );
double Z_daughter2_phi = acos(Z_daughter_2_x / Z_daughter2_pT );
if (Z_daughter_2_y < 0) Z_daughter2_phi = 2 * PI - Z_daughter2_phi;
double Z_pT = sqrt(pow(Z_daughter_1_x + Z_daughter_2_x, 2) + pow(
Z_daughter_1_y + Z_daughter_2_y, 2
));
double Z_p = sqrt(pow(Z_daughter_1_x + Z_daughter_2_x, 2) + pow(
Z_daughter_1_y + Z_daughter_2_y, 2
) + pow(Z_daughter_1_z + Z_daughter_2_z, 2));
double Z_rap = (1.0 / 2.0) * log(
(Z_daughter_1_energy + Z_daughter_2_energy + Z_daughter_1_z + Z_daughter_2_z) / (
Z_daughter_1_energy + Z_daughter_2_energy - Z_daughter_1_z - Z_daughter_2_z
)
);
double Z_mass = sqrt(pow(Z_daughter_1_energy + Z_daughter_2_energy, 2) -
pow(Z_p, 2));
double Z_eta = (1.0 / 2.0) * log(
(Z_p + Z_daughter_1_z + Z_daughter_2_z) / (
Z_p - Z_daughter_1_z - Z_daughter_2_z
)
);
double Z_phi = acos((Z_daughter_1_x + Z_daughter_2_x) / Z_pT);
if ((Z_daughter_2_y + Z_daughter_1_y) < 0) Z_phi = 2 * PI - Z_phi;
// if (abs(Z_daughter_pdg_code) == 11 || abs(Z_daughter_pdg_code) == 13) {
// if (Z_mass >= 70.0 && Z_mass <=110 && Z_pT >= 60 ) {
// weight_total += weight0 / weight2;
// isContinueFind = true;
// }
// }
if (abs(Z_daughter_pdg_code) == 11) {
if (fabs(Z_daught1_eta) < 1.44 || (fabs(Z_daught1_eta) > 1.57 &&
fabs(Z_daught1_eta) < 2.5) ) {
//
if (fabs(Z_daught2_eta) < 1.44 || (fabs(Z_daught2_eta) > 1.57 &&
fabs(Z_daught2_eta) < 2.5) ) {
if (Z_daughter1_pT > 20. && Z_daughter2_pT > 20 && Z_mass > 70 &&
Z_mass < 110 && Z_pT > 60 && fabs(Z_rap) < 2.5 ) {
//
weight_total += weight0 / weight2;
isContinueFind = true;
}
}
}
}
if (abs(Z_daughter_pdg_code) == 13) {
if (fabs(Z_daught1_eta) < 2.4) {
if (fabs(Z_daught2_eta) < 2.4) {
if (Z_daughter1_pT > 10. && Z_daughter2_pT > 10 && Z_mass > 70 &&
Z_mass < 110 && Z_pT > 60 && fabs(Z_rap) < 2.5 ) {
//
weight_total += weight0 / weight2;
isContinueFind = true;
}
}
}
}
vector<PseudoJet> pseudo_jets;
for ( unsigned i = 0; i < partons_num - 2; i++) {
in_file >> pdg_code >> px >> py >> pz >> energy >> temp;
PseudoJet tmp(px, py, pz, energy);
pseudo_jets.emplace_back(tmp);
}
if (isContinueFind) {
ClusterSequence cluster(pseudo_jets, jet_def);
vector<PseudoJet> jets = sorted_by_pt(select_akt(cluster.inclusive_jets()));
if (jets.size() > 0) {
for (const auto jet : jets) {
double delta_phi = fabs(jet.phi() - Z_phi);
delta_phi = delta_phi > PI ? 2 * PI - delta_phi : delta_phi;
for (unsigned i = 0; i < 9; i++) {
if (delta_phi >= phi_bin[i] && delta_phi < phi_bin[i + 1]) {
weight_for_bin[i + 1] += weight0 / weight2;
}
if (delta_phi > 7 * PI / 8.0) {
double x_jZ = jet.perp() / Z_pT;
// cout << "Found!: " << x_jZ << endl;
if (x_jZ >= x_bin[i] && x_jZ < x_bin[i + 1]) {
weight_for_bin_for_x_jz[i + 1] += weight0 / weight2;
}
}
}
}
}
isContinueFind = false;
}
}
std::ofstream delta_phi_dist_file;
const char *out_delta_phi_dist_file = "deltaPhiDist.dat";
delta_phi_dist_file.open(out_delta_phi_dist_file);
std::ofstream transverse_momentum_dist_file;
const char *out_trans_mome_dist_file = "transverse_momentum_dist_file.dat";
transverse_momentum_dist_file.open(out_trans_mome_dist_file);
for(unsigned i = 1; i < 10; i++) {
// cout << "weight_for_bin: " << weight_for_bin[i]
// << ", phi_bin[i]: " << phi_bin[i] << ", "
// << "phi_bin[i - 1]: " << phi_bin[i - 1] << endl;
delta_phi_dist_file << phi_bin[i]
<< ", " << weight_for_bin[i] / weight_total / (phi_bin[i] - phi_bin[i - 1]) << endl;
transverse_momentum_dist_file << x_bin[i] << ", "
<< weight_for_bin_for_x_jz[i] / weight_total / (x_bin[i] - x_bin[i - 1]) << endl;
}
return 0;
} //end main