ATLAS Offline Software
JetMSVAugmentation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 #include "xAODTracking/Vertex.h"
12 
13 
14 namespace DerivationFramework {
15 
16 
17 JetMSVAugmentation::JetMSVAugmentation(const std::string& t, const std::string& n, const IInterface* p):
18  base_class(t,n,p)
19 {
20 }
21 
22 
23 
25 
26 
27 
29  ATH_MSG_DEBUG("Initialize " );
31 
32  return StatusCode::SUCCESS;
33 
34 }
35 
36 
37 
38 StatusCode JetMSVAugmentation::addBranches(const EventContext& ctx) const{
39 
41  if ( !jets.isValid() ) {
42  ATH_MSG_ERROR ("Couldn't retrieve jets with key: " << m_jetCollectionName );
43  return StatusCode::FAILURE;
44  }
45 
46 
52 
56 
59 
60 
61  for (auto jet : *jets) {
63  if (!bjet) {
64  ATH_MSG_WARNING("btagging information not available" );
65  continue;
66  }
67 
68  std::vector< ElementLink< xAOD::VertexContainer > > msvVertices;
69  bjet->variable<std::vector<ElementLink<xAOD::VertexContainer> > >(m_vtxAlgName, "vertices", msvVertices);
70 
71  std::vector<float> vtx_mass;
72  std::vector<float> vtx_pt;
73  std::vector<float> vtx_eta;
74  std::vector<float> vtx_phi;
75  std::vector<float> vtx_efrac;
76  std::vector<float> vtx_x;
77  std::vector<float> vtx_y;
78  std::vector<float> vtx_z;
79  std::vector<int> vtx_ntrk;
80  std::vector<float> vtx_dls;
81 
82 
83  for (auto vtx : msvVertices) {//loop in vertices
84 
85  int ntrk = xAOD::SecVtxHelper::VtxNtrk(*vtx);
87  float efrc = xAOD::SecVtxHelper::EnergyFraction(*vtx);
88  float pt = xAOD::SecVtxHelper::Vtxpt(*vtx);
89  float eta = xAOD::SecVtxHelper::Vtxeta(*vtx);
90  float phi = xAOD::SecVtxHelper::Vtxphi(*vtx);
91  float dls = xAOD::SecVtxHelper::VtxnormDist(*vtx);
92  float xp = (*vtx)->x();
93  float yp = (*vtx)->y();
94  float zp = (*vtx)->z();
95  // float chi = (*vtx)->chiSquared();
96  // float ndf = (*vtx)->numberDoF();
97 
98  TLorentzVector p;
99  p.SetPtEtaPhiM(pt,eta,phi,mass);
100 
101  vtx_mass.push_back(mass);
102  vtx_pt.push_back(pt);
103  vtx_eta.push_back(eta);
104  vtx_phi.push_back(phi);
105  vtx_efrac.push_back(efrc);
106  vtx_x.push_back(xp);
107  vtx_y.push_back(yp);
108  vtx_z.push_back(zp);
109  vtx_ntrk.push_back(ntrk);
110  vtx_dls.push_back(dls);
111  }
112 
113  dec_vtxmass(*bjet)=vtx_mass;
114  dec_vtxpt(*bjet)=vtx_pt;
115  dec_vtxeta(*bjet)=vtx_eta;
116  dec_vtxphi(*bjet)=vtx_phi;
117  dec_vtxefrac(*bjet)=vtx_efrac;
118  dec_vtxx(*bjet)=vtx_x;
119  dec_vtxy(*bjet)=vtx_y;
120  dec_vtxz(*bjet)=vtx_z;
121  dec_vtxdls(*bjet)=vtx_dls;
122  dec_vtxntrk(*bjet)=vtx_ntrk;
123 
124  }
125 
126  return StatusCode::SUCCESS;
127 
128 }
129 
130 
131 
132 }
BTaggingUtilities.h
python.BuildSignatureFlags.bjet
AthConfigFlags bjet(AthConfigFlags flags, str instanceName, str recoMode)
Definition: BuildSignatureFlags.py:375
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
BTagging.h
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
test_pyathena.pt
pt
Definition: test_pyathena.py:11
DerivationFramework::JetMSVAugmentation::m_jetCollectionName
SG::ReadHandleKey< xAOD::JetContainer > m_jetCollectionName
Definition: JetMSVAugmentation.h:37
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
DerivationFramework::JetMSVAugmentation::initialize
virtual StatusCode initialize() override final
Definition: JetMSVAugmentation.cxx:28
xAOD::SecVtxHelper::VtxNtrk
int VtxNtrk(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:39
DerivationFramework::JetMSVAugmentation::m_vtxAlgName
Gaudi::Property< std::string > m_vtxAlgName
Definition: JetMSVAugmentation.h:52
DerivationFramework::JetMSVAugmentation::m_dec_vtxz
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxz
Definition: JetMSVAugmentation.h:47
SecVtxHelper.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::JetMSVAugmentation::m_dec_vtxpt
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxpt
Definition: JetMSVAugmentation.h:40
xAOD::SecVtxHelper::VertexMass
float VertexMass(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:9
DerivationFramework::JetMSVAugmentation::m_dec_vtxphi
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxphi
Definition: JetMSVAugmentation.h:42
DerivationFramework::JetMSVAugmentation::m_dec_vtxntrk
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxntrk
Definition: JetMSVAugmentation.h:49
xAOD::SecVtxHelper::VtxnormDist
float VtxnormDist(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:95
DerivationFramework::JetMSVAugmentation::m_dec_vtxefrac
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxefrac
Definition: JetMSVAugmentation.h:43
DerivationFramework::JetMSVAugmentation::m_dec_vtxy
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxy
Definition: JetMSVAugmentation.h:46
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::JetMSVAugmentation::JetMSVAugmentation
JetMSVAugmentation(const std::string &t, const std::string &n, const IInterface *p)
Definition: JetMSVAugmentation.cxx:17
beamspotman.n
n
Definition: beamspotman.py:727
xAOD::SecVtxHelper::Vtxphi
float Vtxphi(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:81
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DerivationFramework::JetMSVAugmentation::~JetMSVAugmentation
~JetMSVAugmentation()
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework::JetMSVAugmentation::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: JetMSVAugmentation.cxx:38
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::JetMSVAugmentation::m_dec_vtxeta
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxeta
Definition: JetMSVAugmentation.h:41
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DerivationFramework::JetMSVAugmentation::m_dec_vtxdls
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxdls
Definition: JetMSVAugmentation.h:50
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
Vertex.h
DerivationFramework::JetMSVAugmentation::m_dec_vtxx
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxx
Definition: JetMSVAugmentation.h:45
xAOD::BTaggingUtilities::getBTagging
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Definition: BTaggingUtilities.cxx:37
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::SecVtxHelper::EnergyFraction
float EnergyFraction(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:24
xAOD::SecVtxHelper::Vtxpt
float Vtxpt(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:53
DerivationFramework::JetMSVAugmentation::m_dec_vtxmass
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_vtxmass
Definition: JetMSVAugmentation.h:39
xAOD::SecVtxHelper::Vtxeta
float Vtxeta(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:67
JetMSVAugmentation.h
tool to add some MSV variables to jets