-
Notifications
You must be signed in to change notification settings - Fork 0
/
anom_vs_sm_distributions.cpp
192 lines (154 loc) · 6.17 KB
/
anom_vs_sm_distributions.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
// c++ -o checkMomentum_00 `root-config --glibs --cflags` -lm checkMomentum_00.cpp
#include "LHEF.h"
#include <iomanip>
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
#include "TH1.h"
#include "TFile.h"
#include "TLorentzVector.h"
// CINT does not understand some files included by LorentzVector
#include "Math/Vector3D.h"
#include "Math/Vector4D.h"
using namespace ROOT::Math;
using namespace std ;
double DeltaPhi(double phi1, double phi2)
{
// Compute DeltaPhi between two given angles. Results is in [-pi/2,pi/2].
double dphi = TMath::Abs(phi1-phi2);
while (dphi>TMath::Pi())
dphi = TMath::Abs(dphi - TMath::TwoPi());
return(dphi);
}
TLorentzVector buildP (const LHEF::HEPEUP & event, int iPart)
{
TLorentzVector dummy ;
dummy.SetPxPyPzE (
event.PUP.at (iPart).at (0), // px
event.PUP.at (iPart).at (1), // py
event.PUP.at (iPart).at (2), // pz
event.PUP.at (iPart).at (3) // E
) ;
return dummy ;
}
int main(int argc, char ** argv)
{
if(argc < 2)
{
cout << "Usage: " << argv[0]
<< " input1.lhe input2.lhe" << endl ;
return -1;
}
std::ifstream ifs1 (argv[1]) ;
LHEF::Reader reader1 (ifs1) ;
std::ifstream ifs2 (argv[2]) ;
LHEF::Reader reader2 (ifs2) ;
TH1F mjjll_1 ("mjjll_1", "mjjll_1", 10, 500, 3000) ;
TH1F mjjll_2 ("mjjll_2", "mjjll_2", 10, 500, 3000) ;
TH1F mt_1 ("mt_1", "mt_1", 10, 000, 600) ;
TH1F mt_2 ("mt_2", "mt_2", 10, 000, 600) ;
TH1F mll_1 ("mll_1", "mll_1", 10, 0, 300) ;
TH1F mll_2 ("mll_2", "mll_2", 10, 0, 300) ;
TH1F mjj_1 ("mjj_1", "mjj_1", 10, 500, 3000) ;
TH1F mjj_2 ("mjj_2", "mjj_2", 10, 500, 3000) ;
//PG loop over input events
while (reader1.readEvent ())
{
std::vector<TLorentzVector> electrons;
std::vector<TLorentzVector> quarks;
std::vector<TLorentzVector> electron_neutrinos;
if ( reader1.outsideBlock.length() ) std::cout << reader1.outsideBlock;
// loop over particles in the event
for (int iPart = 0 ; iPart < reader1.hepeup.IDUP.size (); ++iPart)
{
// outgoing particles
if (reader1.hepeup.ISTUP.at (iPart) == 1)
{
if (abs (reader1.hepeup.IDUP.at (iPart)) == 11)
{
TLorentzVector vec = buildP (reader1.hepeup, iPart) ;
electrons.push_back(vec);
}
if(abs (reader1.hepeup.IDUP.at (iPart)) == 5 || abs (reader1.hepeup.IDUP.at (iPart)) == 6)
std::cout << "abs (reader1.hepeup.IDUP.at (iPart)) = " << abs (reader1.hepeup.IDUP.at (iPart)) << std::endl;
if(abs (reader1.hepeup.IDUP.at (iPart)) == 12 ){
TLorentzVector vec = buildP(reader1.hepeup,iPart);
electron_neutrinos.push_back(vec);
}
if (abs (reader1.hepeup.IDUP.at (iPart)) == 1 || abs (reader1.hepeup.IDUP.at (iPart)) == 2 || abs (reader1.hepeup.IDUP.at (iPart)) == 3 || abs (reader1.hepeup.IDUP.at (iPart)) == 4)
{
TLorentzVector vec = buildP (reader1.hepeup, iPart) ;
quarks.push_back(vec);
}
} // outgoing particles
} // loop over particles in the event
if(quarks.size() != 2){
std::cout << "found event without exactly two quarks 1" << std::endl;
continue;
}
if(electrons.size() != 2)
continue;
assert(electron_neutrinos.size() == 2);
mjjll_1.Fill( (quarks[0] + quarks[1]+electrons[0]+electrons[1]).M() );
mjj_1.Fill( (quarks[0] + quarks[1]).M() );
mll_1.Fill( (electrons[0]+electrons[1]).M() );
mt_1.Fill( sqrt(2 * (electrons[0]+electrons[1]).Pt() * (electron_neutrinos[0] + electron_neutrinos[1]).Et()
* (1-cos(DeltaPhi((electrons[0]+electrons[1]).Phi(),(electron_neutrinos[0] + electron_neutrinos[1]).Phi())))) );
} //PG loop over input events
//PG loop over input events
while (reader2.readEvent ())
{
std::vector<TLorentzVector> electrons;
std::vector<TLorentzVector> quarks;
std::vector<TLorentzVector> electron_neutrinos;
if ( reader2.outsideBlock.length() ) std::cout << reader2.outsideBlock;
// loop over particles in the event
for (int iPart = 0 ; iPart < reader2.hepeup.IDUP.size (); ++iPart)
{
// outgoing particles
if (reader2.hepeup.ISTUP.at (iPart) == 1)
{
if (abs (reader2.hepeup.IDUP.at (iPart)) == 11)
{
TLorentzVector vec = buildP (reader2.hepeup, iPart) ;
electrons.push_back(vec);
}
if(abs (reader2.hepeup.IDUP.at (iPart)) == 12 ){
TLorentzVector vec = buildP(reader2.hepeup,iPart);
electron_neutrinos.push_back(vec);
}
if(abs (reader2.hepeup.IDUP.at (iPart)) == 5 || abs (reader2.hepeup.IDUP.at (iPart)) == 6)
std::cout << "abs (reader2.hepeup.IDUP.at (iPart)) = " << abs (reader2.hepeup.IDUP.at (iPart)) << std::endl;
if (abs (reader2.hepeup.IDUP.at (iPart)) == 1 || abs (reader2.hepeup.IDUP.at (iPart)) == 2 || abs (reader2.hepeup.IDUP.at (iPart)) == 3 || abs (reader2.hepeup.IDUP.at (iPart)) == 4)
{
TLorentzVector vec = buildP (reader2.hepeup, iPart) ;
quarks.push_back(vec);
}
} // outgoing particles
} // loop over particles in the event
if(quarks.size() != 2){
std::cout << "found event without exactly two quarks 2" << std::endl;
continue;
}
if(electrons.size() != 2)
continue;
assert(electron_neutrinos.size() == 2);
mjjll_2.Fill( (quarks[0] + quarks[1]+electrons[0]+electrons[1]).M() );
mjj_2.Fill( (quarks[0] + quarks[1]).M() );
mll_2.Fill( (electrons[0]+electrons[1]).M() );
mt_2.Fill( sqrt(2 * (electrons[0]+electrons[1]).Pt() * (electron_neutrinos[0] + electron_neutrinos[1]).Et()
* (1-cos(DeltaPhi((electrons[0]+electrons[1]).Phi(),(electron_neutrinos[0] + electron_neutrinos[1]).Phi())))) );
} //PG loop over input events
TFile f ("output_distributions.root", "recreate") ;
mjjll_2.Write();
mjjll_1.Write();
mjj_1.Write();
mjj_2.Write();
mll_1.Write();
mll_2.Write();
mt_1.Write();
mt_2.Write();
f.Close () ;
return 0 ;
}