ATLAS Offline Software
Loading...
Searching...
No Matches
VRJetOverlapDecorator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
5
6namespace {
7
8 struct VRConfig {
9 VRConfig();
10 double min;
11 double max;
12 double scale;
13 };
14 VRConfig::VRConfig():
15 min(NAN),
16 max(NAN),
17 scale(NAN)
18 {}
19
20
21 double getRadius(const TLorentzVector& vec, const VRConfig& cfg) {
22 return std::max(cfg.min, std::min(cfg.max, cfg.scale / vec.Pt()));
23 }
24 struct VRJetDR {
25 double relative;
26 double absolute;
27 };
28
29 std::vector<VRJetDR> getMinimumRelativeDR(const xAOD::JetContainer& jets,
30 const VRConfig& cfg) {
31 const size_t n_jets = jets.size();
32 std::vector<VRJetDR> min_dr(n_jets, {INFINITY,INFINITY});
33 for (size_t iii = 0; iii < n_jets; iii++) {
34 const xAOD::Jet* j1 = jets.at(iii);
35 const TLorentzVector j1p4 = j1->p4();
36 const double j1_radius = getRadius(j1p4, cfg);
37 for (size_t jjj = iii+1; jjj < n_jets; jjj++) {
38 const xAOD::Jet* j2 = jets.at(jjj);
39 const TLorentzVector j2p4 = j2->p4();
40 const double j2_radius = getRadius(j2p4, cfg);
41 const double min_radius = std::min(j1_radius, j2_radius);
42 const double dR = j1p4.DeltaR(j2p4);
43 const double rel_dR = dR / min_radius;
44 // check both jets, if the relative dR is less than whatever
45 // we have recorded, save this relative dR and absolute dR
46 for (const size_t idx: {iii,jjj}) {
47 if (rel_dR < min_dr.at(idx).relative) {
48 VRJetDR vrstruct;
49 vrstruct.relative = rel_dR;
50 vrstruct.absolute = dR;
51 min_dr.at(idx) = vrstruct;
52 }
53 }
54 }
55 }
56 return min_dr;
57 }
58
59}
60
62 relative_name("relativeDeltaRToVRJet"),
63 absolute_name("deltaRToVRJet"),
64 jet_parameters_source(param_source)
65{}
66
67
69 m_param_source(cfg.jet_parameters_source),
70 m_rel_decorator(cfg.relative_name),
71 m_abs_decorator(cfg.absolute_name),
72 m_min_radius("VariableRMinRadius"),
73 m_max_radius("SizeParameter"),
74 m_mass_scale("VariableRMassScale")
75{
76}
77
79 // if no jet is present, do nothing
80 if (jets.empty() && m_param_source == VRJetParameters::EDM) return;
81
82 VRConfig cfg;
84 // we'll assume all the jets have the same parameters, I don't
85 // know of counterexamples but if they exist we'd have to rethink
86 // all the code here.
87 const xAOD::Jet* jet = jets.at(0);
88 cfg.min = m_min_radius(*jet);
89 cfg.max = m_max_radius(*jet);
90 cfg.scale = m_mass_scale(*jet);
92 // right now we only have one set of VR jets where we'd use this
93 // tool thus the hardcoded numbers here.
94 cfg.min = 0.02;
95 cfg.max = 0.4;
96 cfg.scale = 30e3;
97 } else {
98 throw std::logic_error("unknown jet parameter lookup");
99 }
100 auto min_dr = getMinimumRelativeDR(jets, cfg);
101 for (size_t iii = 0; iii < jets.size(); iii++) {
102 const xAOD::Jet* jet = jets.at(iii);
103 const auto drs = min_dr.at(iii);
104 m_rel_decorator(*jet) = drs.relative;
105 m_abs_decorator(*jet) = drs.absolute;
106 }
107}
std::vector< size_t > vec
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
SG::AuxElement::Decorator< float > m_rel_decorator
SG::AuxElement::ConstAccessor< float > m_mass_scale
SG::AuxElement::ConstAccessor< float > m_min_radius
SG::AuxElement::Decorator< float > m_abs_decorator
SG::AuxElement::ConstAccessor< float > m_max_radius
VRJetOverlapDecorator(const VRJetOverlapConfig &=VRJetOverlapConfig())
void decorate(const xAOD::JetContainer &jets) const
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
VRJetOverlapConfig(VRJetParameters=VRJetParameters::RHO30MIN02MAX4)
VRJetParameters jet_parameters_source