ATLAS Offline Software
ConeJetMaker.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include "./Jet.h"
6 #include "./ConeJetMaker.h"
7 
8 #include <sstream>
9 
10 #include <cassert>
11 #include <algorithm>
12 
14  const xAOD::jFexSRJetRoIContainer& seeds,
15  float seedEtThreshold,
16  const std::string& scheme) :
17  m_jetR{jetR},
18  m_seeds{seeds},
19  m_seedEtThreshold{seedEtThreshold},
20  m_recombScheme{string2RecombScheme(scheme)}{
21 }
22 
23 
26  auto schemeMatches =
27  [&scheme](const std::pair<std::string, RecombScheme>& p){return (p.first) == scheme;};
28 
29  auto scheme_it = std::find_if(m_knownSchemes.cbegin(),
30  m_knownSchemes.cend(),
31  schemeMatches);
32 
33  if (scheme_it == m_knownSchemes.end()){
34  throw std::runtime_error("GEP ConeJetMaker unknown recombinaton scheme " +
35  scheme);
36  }
37 
38  return scheme_it->second;
39 }
40 
41 std::string
43  auto schemeMatches =
44  [&scheme=m_recombScheme](const std::pair<std::string, RecombScheme>& p){
45  return (p.second) == scheme;};
46 
47  auto scheme_it = std::find_if(m_knownSchemes.cbegin(),
48  m_knownSchemes.cend(),
49  schemeMatches);
50 
51  if (scheme_it == m_knownSchemes.end()){
52  throw std::runtime_error("GEP ConeJetMaker unknown recombinaton scheme " +
53  recombSchemeAsString());
54  }
55 
56  return scheme_it->first;
57 }
58 
59 double deltaR (double eta_1, double eta_2, double phi_1, double phi_2);
60 
61 std::vector<Gep::Jet>
62 Gep::ConeJetMaker::makeJets( const std::vector<Gep::Cluster> &clusters) const
63 {
64  std::vector<Gep::Jet> jets;
65 
66  for (const auto seed: m_seeds) {
67 
68  float seedEt = seed->et();
69 
70  // skip seeds with Et below threshold
71  if(seedEt < m_seedEtThreshold) continue;
72  float seedEta = seed->eta();
73  float seedPhi = seed->phi();
74 
75  Gep::Jet jet;
76 
77  jet.radius = m_jetR;
78  jet.seedEta = seedEta;
79  jet.seedPhi = seedPhi;
80  jet.seedEt = seedEt;
81 
82  TLorentzVector jetVec;
83  float px{0}, py{0};
84  int clusterIndex {0};
85 
86  //build jet with clusters within dR from seed
87  for (const auto &cl: clusters) {
88  float dR_seed_cl = deltaR(seedEta, cl.vec.Eta(), seedPhi, cl.vec.Phi());
89 
90  if (dR_seed_cl < m_jetR) {
91  jetVec += cl.vec;
92  px += cl.vec.Px();
93  py += cl.vec.Py();
94 
95  jet.constituentsIndices.push_back(clusterIndex);
96  }
97  clusterIndex++;
98  }
99 
100 
101  // skip cone jets with 0 constituents
102  if (jet.constituentsIndices.empty()) {continue;}
103 
104 
105  // recombination scheme
106  if (m_recombScheme == RecombScheme::EScheme) {
107  // default option: add four-vectors of constituents
108  jet.vec = jetVec;
109  } else if (m_recombScheme == RecombScheme::SeedScheme) {
110  // massless jet, correct pt, re-using seed (eta,phi)
111  float m = 0;
112  float pt = std::sqrt(px*px + py*py);
113  jet.vec.SetPtEtaPhiM(pt, seedEta, seedPhi, m);
114  } else {
115  throw std::runtime_error("GEP ConeJetMaker recombinaton scheme error");
116  }
117  jets.push_back(jet);
118  }
119 
120  return jets;
121 }
122 
123 
124 std::string Gep::ConeJetMaker::toString() const {
125  std::stringstream ss;
126  ss << "ConeJetMaker. seed thresholds: " << m_seedEtThreshold
127  << " rad: " << m_jetR << " recombinaton scheme: " << recombSchemeAsString();
128  return ss.str();
129 }
130 
131 
132 double deltaR (double eta1, double eta2, double phi1, double phi2) {
133  double deltaPhi = TVector2::Phi_mpi_pi(phi1 - phi2);
134  double deltaEta = eta1 - eta2;
135  return std::sqrt( deltaEta*deltaEta + deltaPhi*deltaPhi );
136 }
137 
138 
Gep::ConeJetMaker::string2RecombScheme
RecombScheme string2RecombScheme(const std::string &) const
Definition: ConeJetMaker.cxx:25
test_pyathena.px
px
Definition: test_pyathena.py:18
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
Gep::ConeJetMaker::ConeJetMaker
ConeJetMaker(float jetR, const xAOD::jFexSRJetRoIContainer &seeds, float seedEtThreshold=5.e3, const std::string &recombScheme="EScheme")
Definition: ConeJetMaker.cxx:13
Jet.h
Gep::ConeJetMaker::makeJets
virtual std::vector< Gep::Jet > makeJets(const std::vector< Gep::Cluster > &clusters) const override
Definition: ConeJetMaker.cxx:62
test_pyathena.pt
pt
Definition: test_pyathena.py:11
deltaR
double deltaR(double eta_1, double eta_2, double phi_1, double phi_2)
Definition: ConeJetMaker.cxx:132
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
Phi_mpi_pi
__HOSTDEV__ double Phi_mpi_pi(double)
Definition: GeoRegion.cxx:7
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:66
JetTagCalibConfig.scheme
scheme
Definition: JetTagCalibConfig.py:16
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Gep::Jet
Definition: Trigger/TrigT1/TrigGepPerf/src/Jet.h:12
Gep::ConeJetMaker::toString
std::string toString() const override
Definition: ConeJetMaker.cxx:124
Amg::py
@ py
Definition: GeoPrimitives.h:39
Gep::ConeJetMaker::RecombScheme
RecombScheme
Definition: ConeJetMaker.h:44
ConeJetMaker.h
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
Gep::ConeJetMaker::recombSchemeAsString
std::string recombSchemeAsString() const
Definition: ConeJetMaker.cxx:42