-
Notifications
You must be signed in to change notification settings - Fork 4
/
checkMomentum_01.cpp
118 lines (96 loc) · 4.04 KB
/
checkMomentum_01.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
// c++ -o checkMomentum_01 `root-config --glibs --cflags` -lm checkMomentum_01.cpp
#include "LHEF.h"
#include <iomanip>
#include <vector>
#include <map>
#include <iostream>
#include <string>
#include <sstream>
#include "TLorentzVector.h"
using namespace std ;
// find daughters for a particle
vector<int> daughters (const LHEF::HEPEUP & event, int PID)
{
vector<int> result ;
for (int iPart = 0 ; iPart < event.IDUP.size () ; ++iPart)
{
pair <int, int> mothers = event.MOTHUP.at (iPart) ;
if (mothers.first != mothers.second) continue ;
if (mothers.first == PID) result.push_back (iPart) ;
}
return result ;
}
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
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 < 3)
{
cout << "Usage: " << argv[0]
<< " input.lhe lepton_ID" << endl ;
return -1;
}
int lepton_ID = atoi (argv[2]) ;
std::ifstream ifs (argv[1]) ;
LHEF::Reader reader (ifs) ;
//PG loop over input events
while (reader.readEvent ())
{
if ( reader.outsideBlock.length() ) std::cout << reader.outsideBlock;
// loop over particles in the event
for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size () ; ++iPart)
{
// outgoing particles
if (reader.hepeup.ISTUP.at (iPart) == 1)
{
if (abs (reader.hepeup.IDUP.at (iPart)) == lepton_ID)
{
// find mother
pair <int, int> mothers = reader.hepeup.MOTHUP.at (iPart) ;
cout << "----- " << reader.hepeup.IDUP.at (iPart) << " " << iPart << " \n" ;
cout << " m1 : " << mothers.first << ": " << reader.hepeup.IDUP.at (mothers.first) << endl ;
cout << " m2 : " << mothers.second << ": " << reader.hepeup.IDUP.at (mothers.second) << endl ;
if (mothers.first == mothers.second)
{
if (abs (reader.hepeup.IDUP.at (mothers.first)) != 24) continue ;
vector<int> daugh = daughters (reader.hepeup, mothers.first) ;
cout << " d1 : " << daugh.at (0) << " " << reader.hepeup.IDUP.at (daugh.at (0)) << "\n" ;
cout << " d2 : " << daugh.at (1) << " " << reader.hepeup.IDUP.at (daugh.at (1)) << "\n" ;
TLorentzVector moth = buildP (reader.hepeup, mothers.first) ;
TLorentzVector daugh1 = buildP (reader.hepeup, daugh.at (0)) ;
TLorentzVector daugh2 = buildP (reader.hepeup, daugh.at (1)) ;
TLorentzVector daughSum = daugh1 + daugh2 ;
// daughSum = daughSum - moth ;
cout << daughSum.Mag () << " " << moth.Mag () << endl ;
}
else
{
cout << " the two mothers differ\n" ;
}
// find mother's daughters
// check momentum conservation
// TLorentzVector dummy
// (
// reader.hepeup.PUP.at (iPart).at (0), // px
// reader.hepeup.PUP.at (iPart).at (1), // py
// reader.hepeup.PUP.at (iPart).at (2), // pz
// reader.hepeup.PUP.at (iPart).at (3) // E
// ) ;
// float p2 = dummy.Vect ().Mag2 () ;
}
} // outgoing particles
} // loop over particles in the event
} //PG loop over input events
return 0 ;
}