-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMCTruthOperator.h
59 lines (50 loc) · 1.79 KB
/
MCTruthOperator.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
#pragma once
#include "BaseOperator.h"
#include "Math/VectorUtil.h"
template <class EventClass> class MCTruthOperator : public BaseOperator<EventClass> {
public:
std::vector<int> matchId;
double max_DeltaR_;
size_t m_jets_loop_;
bool HHMatchedOnly_;
MCTruthOperator(double max_DeltaR = 0.5, size_t m_jets_loop = 0, bool HHMatchedOnly = false) :
max_DeltaR_(max_DeltaR),
m_jets_loop_(m_jets_loop),
HHMatchedOnly_(HHMatchedOnly) {}
virtual ~MCTruthOperator() {}
virtual bool process( EventClass & ev ) {
//find gen jets per each ev.jets
matchId.clear();
int n_matched=0;
double dR_min=99.;
size_t max_jets = ev.jets_.size();
if (m_jets_loop_ > 0) max_jets = m_jets_loop_;
//std::cout << max_jets << std::endl;
for (std::size_t j=0; j < max_jets; j++) {
matchId.push_back(-1);
for (std::size_t g=0; g < ev.genbfromhs_.size(); g++) {
double dR = ROOT::Math::VectorUtil::DeltaR( ev.jets_.at(j).p4_, ev.genbfromhs_.at(g).p4_);
if ( dR < max_DeltaR_ && dR < dR_min) {
matchId.at(j) = g;
n_matched++;
dR = dR_min;
}
}
}
for (std::size_t i=0; i < matchId.size(); i++){
int id = matchId.at(i);
for (std::size_t k=0; k < matchId.size(); k++){
// std::cout << matchId.at(k) << std::endl;
// if(id == matchId.at(k) && i!=k && matchId.at(k)>0) n_sameGenstd::cout<< "WARNING: same gen Jet for different reco jets" << std::endl;
}
}
// std::cout << std::endl;
if(HHMatchedOnly_ && n_matched<4) return false;
return true;
}
virtual std::string get_name() {
auto name = std::string{};
name+= "MCTruth";
return name;
}
};