ATLAS Offline Software
JetPartonTruthLabel.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 using namespace std;
10 using namespace Analysis;
11 
12 int JetPartonTruthLabel::modifyJet(xAOD::Jet &jet) const {
13  ATH_MSG_VERBOSE("In " << name() << "::modifyJet()");
14 
15  int label = -1;
16  double e_max = 0;
17  double pt_max = 0;
18  double dr_max = 0;
19 
20  vector<const xAOD::TruthParticle*> partons;
21  bool success = jet.getAssociatedObjects("GhostPartons", partons);
22  if(success) {
23  for(auto it = partons.begin(); it != partons.end(); it++) {
24  if(MC::isTop(*it)) continue; // Skip top
25 
26  if((*it)->e() > e_max) {
27  label = (*it)->absPdgId();
28  e_max = (*it)->e();
29  pt_max = (*it)->pt();
30  dr_max = (*it)->p4().DeltaR(jet.p4());
31  }
32  }
33  }
34 
35  jet.setAttribute("PartonTruthLabelID", label);
36  jet.setAttribute("PartonTruthLabelPt", pt_max);
37  jet.setAttribute("PartonTruthLabelEnergy", e_max);
38  jet.setAttribute("PartonTruthLabelDR", dr_max);
39 
40  return 0;
41 }
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
skel.it
it
Definition: skel.GENtoEVGEN.py:396
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
isTop
bool isTop(const T &p)
Definition: AtlasPID.h:151
JetPartonTruthLabel.h
TruthParticle.h
HepMCHelpers.h