-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathHemisphere.h
249 lines (204 loc) · 6.76 KB
/
Hemisphere.h
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#pragma once
#define _USE_MATH_DEFINES
#include "Analysis/alp_analysis/interface/Event.h"
#include "Analysis/alp_analysis/interface/Utils.h"
#include "Math/GenVector/VectorUtil.h"
namespace alp {
class Hemisphere {
public:
std::vector<alp::Jet> jets_;
double p_phi_ = 0.;
bool sumPz_inv_ = false;
bool d_phi_inv_ = false;
unsigned int evtnum_ = 0;
unsigned int run_ = 0;
unsigned int lumiblock_ = 0;
double dist_ = -99.;
static constexpr const char* disc_ = "pfCombinedMVAV2BJetTags";;
static constexpr float disc_wp_ = 0.4432;
static constexpr float disc_minwp_ = 0.4432;
static constexpr float disc_maxwp_ = 99.;
Hemisphere() {}
Hemisphere(double p_phi, bool d_phi_inv, unsigned int evtnum = 0, unsigned int run = 0, unsigned int lumiblock = 0, double dist = -99. ) :
p_phi_(p_phi),
d_phi_inv_(d_phi_inv),
evtnum_(evtnum),
run_(run),
lumiblock_(lumiblock),
dist_(dist) {}
static double SumPz(const Hemisphere & hem) {
double sumPz = 0.0;
for (const auto & j : hem.jets_) {
sumPz += j.p4_.Pz();
}
return sumPz;
}
static double ThrustMayor(const Hemisphere & hem) {
double thrustMayor = 0.0;
for (const auto & j : hem.jets_) {
double d_phi = ROOT::Math::VectorUtil::Phi_mpi_pi(j.p4_.Phi()-M_PI/2.);
thrustMayor += std::abs(j.p4_.Pt()* std::cos(d_phi));
}
return thrustMayor;
}
static double ThrustMinor(const Hemisphere & hem) {
double thrustMinor = 0.0;
for (const auto & j : hem.jets_) {
double d_phi = ROOT::Math::VectorUtil::Phi_mpi_pi(j.p4_.Phi()-M_PI/2.);
thrustMinor += std::abs(j.p4_.Pt()* std::sin(d_phi));
}
return thrustMinor;
}
static double InvMass(const Hemisphere & hem) {
alp::PtEtaPhiEVector sum_v; // init null?
for (const auto & j : hem.jets_) {
sum_v += j.p4_;
}
return sum_v.M();
}
static int NJets(const Hemisphere & hem) {
return int(hem.jets_.size());
}
static int NTags(const Hemisphere & hem,
std::string disc,
float minwp=0., float maxwp=100000.) {
int nTags = 0;
for (const auto & j : hem.jets_) {
if (minwp < j.disc(disc) && j.disc(disc) < maxwp) nTags++;
}
return nTags;
}
static double MinPtBtag(const Hemisphere & hem,
std::string disc,
float wp) {
double minPtBtag = 999.0; //debug
for (const auto & j : hem.jets_) {
if (j.disc(disc) > wp){
double pt = j.p4_.Pt();
if(pt < minPtBtag) minPtBtag = pt;
}
}
return minPtBtag;
}
static double PtNBtag(const Hemisphere & hem,
std::string disc, float wp,
unsigned int nBtag) {
double pt = 0.;
std::vector<alp::Jet> tjets = hem.jets_;
if(tjets.size()>nBtag){
auto iter = remove_if(tjets.begin(),tjets.end(),
[&] (const alp::Jet & jet) {
return jet.disc(disc)>=wp; });
tjets.erase(iter, tjets.end());
if(tjets.size()>nBtag) {
order_jets_by_disc(tjets, disc);
pt = tjets.at(nBtag).p4_.Pt();
}
}
return pt;
}
static double Pt1Btag(const Hemisphere & hem,
std::string disc, float wp) {
return PtNBtag(hem,disc,wp,0);
}
static double Pt2Btag(const Hemisphere & hem,
std::string disc, float wp) {
return PtNBtag(hem,disc,wp,1);
}
static double Pt3Btag(const Hemisphere & hem,
std::string disc, float wp) {
return PtNBtag(hem,disc,wp,2);
}
static double Pt4Btag(const Hemisphere & hem,
std::string disc, float wp) {
return PtNBtag(hem,disc,wp,3);
}
static double PtMaxBtag(const Hemisphere & hem,
std::string disc) {
double maxBtag = 0.;
double pt = 0.;
for (const auto & j : hem.jets_) {
if (j.disc(disc) > maxBtag){
pt = j.p4_.Pt();
maxBtag = j.disc(disc);
}
}
return pt;
}
static double HtBtag(const Hemisphere & hem,
std::string disc,
float wp) {
double ht = 0.;
for (const auto & j : hem.jets_) {
if (j.disc(disc) > wp){
ht += j.p4_.Pt();
}
}
return ht;
}
static double Ht(const Hemisphere & hem) {
double ht = 0.;
for (const auto & j : hem.jets_) {
ht += j.p4_.Pt();
}
return ht;
}
// functions to call on branches
unsigned int lumiblock() const {
return lumiblock_;
}
unsigned int run() const {
return run_;
}
unsigned int evtnum() const {
return evtnum_;
}
double dist() const {
return dist_;
}
double sumPz() const {
return SumPz(*this);
}
double thrustMayor() const {
return ThrustMayor(*this);
}
double thrustMinor() const {
return ThrustMinor(*this);
}
double invMass() const {
return InvMass(*this);
}
int nJets() const {
return NJets(*this);
}
//default values to call function directly in branches -- WARNING
int nTags(std::string disc = disc_, float minwp = disc_minwp_, float maxwp = disc_maxwp_) const {
return NTags(*this,disc,minwp,maxwp);
}
double minPtBtag(std::string disc = disc_, float wp = disc_wp_) const {
return MinPtBtag(*this,disc,wp);
}
double ptMaxBtag(std::string disc = disc_) const {
return PtMaxBtag(*this,disc);
}
double htBtag(std::string disc = disc_, float wp = disc_wp_) const {
return HtBtag(*this,disc,wp);
}
double ht() const {
return Ht(*this);
}
double pt1Btag(std::string disc = disc_, float wp = disc_wp_) const {
return Pt1Btag(*this,disc,wp);
}
double pt2Btag(std::string disc = disc_, float wp = disc_wp_) const {
return Pt2Btag(*this,disc,wp);
}
double pt3Btag(std::string disc = disc_, float wp = disc_wp_) const {
return Pt3Btag(*this,disc,wp);
}
double pt4Btag(std::string disc = disc_, float wp = disc_wp_) const {
return Pt4Btag(*this,disc,wp);
}
virtual ~Hemisphere() {}
};
}