ATLAS Offline Software
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 
6 namespace {
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 }
VRJetOverlapDecorator::VRJetOverlapDecorator
VRJetOverlapDecorator(const VRJetOverlapConfig &=VRJetOverlapConfig())
Definition: VRJetOverlapDecorator.cxx:68
max
#define max(a, b)
Definition: cfImp.cxx:41
VRJetOverlapDecorator::decorate
void decorate(const xAOD::JetContainer &jets) const
Definition: VRJetOverlapDecorator.cxx:78
plotting.yearwise_luminosity.absolute
absolute
Definition: yearwise_luminosity.py:32
VRJetParameters::EDM
@ EDM
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
VRJetOverlapDecorator.h
VRJetOverlapConfig::VRJetOverlapConfig
VRJetOverlapConfig(VRJetParameters=VRJetParameters::RHO30MIN02MAX4)
Definition: VRJetOverlapDecorator.cxx:61
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
doubleTestComp.j1
j1
Definition: doubleTestComp.py:21
VRJetParameters
VRJetParameters
Definition: VRJetOverlapDecorator.h:9
VRJetOverlapDecorator::m_max_radius
SG::AuxElement::ConstAccessor< float > m_max_radius
Definition: VRJetOverlapDecorator.h:28
PyAlgorithmExample.min_dr
def min_dr(p, l)
Definition: PyAlgorithmExample.py:57
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
VRJetOverlapDecorator::m_rel_decorator
SG::AuxElement::Decorator< float > m_rel_decorator
Definition: VRJetOverlapDecorator.h:25
min
#define min(a, b)
Definition: cfImp.cxx:40
VRJetOverlapDecorator::m_abs_decorator
SG::AuxElement::Decorator< float > m_abs_decorator
Definition: VRJetOverlapDecorator.h:26
VRJetOverlapDecorator::m_mass_scale
SG::AuxElement::ConstAccessor< float > m_mass_scale
Definition: VRJetOverlapDecorator.h:29
VRJetOverlapDecorator::m_param_source
VRJetParameters m_param_source
Definition: VRJetOverlapDecorator.h:24
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
VRJetOverlapDecorator::m_min_radius
SG::AuxElement::ConstAccessor< float > m_min_radius
Definition: VRJetOverlapDecorator.h:27
VRJetParameters::RHO30MIN02MAX4
@ RHO30MIN02MAX4
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
VRJetOverlapConfig
Definition: VRJetOverlapDecorator.h:11
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
doubleTestComp.j2
j2
Definition: doubleTestComp.py:22