ATLAS Offline Software
JetMSVAugmentation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "xAODJet/JetContainer.h"
9 
11 #include "xAODTracking/Vertex.h"
12 #include "xAODBTagging/BTagging.h"
14 
15 
16 namespace DerivationFramework {
17 
18 
19 JetMSVAugmentation::JetMSVAugmentation(const std::string& t, const std::string& n, const IInterface* p):
20  base_class(t,n,p)
21 {
22 
23 
24  declareProperty("JetCollectionName",m_jetCollectionName="AntiKt4EMTopoJets");
25  declareProperty("vertexAlgName",m_vtxAlgName="MSV");
26 
27 }
28 
29 
30 
32 
33 
34 
36 
37  ATH_MSG_INFO("Initialize " );
38 
39 
40  return StatusCode::SUCCESS;
41 
42 }
43 
44 
45 
47 
48  return StatusCode::SUCCESS;
49 
50 }
51 
52 
53 
55 
56 
57  const xAOD::JetContainer* jets;
58  if( evtStore()->retrieve( jets, m_jetCollectionName ).isFailure() ) {
59  ATH_MSG_ERROR ("Couldn't retrieve jets with key: " << m_jetCollectionName );
60  return StatusCode::FAILURE;
61  }
62 
63 
64  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxmass(m_vtxAlgName+"_vtxmass");
65  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxpt(m_vtxAlgName+"_vtxpt");
66  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxeta(m_vtxAlgName+"_vtxeta");
67  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxphi(m_vtxAlgName+"_vtxphi");
68  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxefrac(m_vtxAlgName+"_vtxefrac");
69 
70  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxx(m_vtxAlgName+"_vtxx");
71  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxy(m_vtxAlgName+"_vtxy");
72  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxz(m_vtxAlgName+"_vtxz");
73 
74  static const SG::AuxElement::Decorator<std::vector<int> > dec_vtxntrk(m_vtxAlgName+"_vtxntrk");
75  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxdls(m_vtxAlgName+"_vtxdls");
76 
77 
78  for(auto jet : *jets){
80 
81  if(!bjet){
82  ATH_MSG_WARNING("btagging information not available" );
83  continue;
84  }
85 
86  std::vector< ElementLink< xAOD::VertexContainer > > msvVertices;
87  bjet->variable<std::vector<ElementLink<xAOD::VertexContainer> > >(m_vtxAlgName, "vertices", msvVertices);
88 
89  std::vector<float> vtx_mass;
90  std::vector<float> vtx_pt;
91  std::vector<float> vtx_eta;
92  std::vector<float> vtx_phi;
93  std::vector<float> vtx_efrac;
94  std::vector<float> vtx_x;
95  std::vector<float> vtx_y;
96  std::vector<float> vtx_z;
97  std::vector<int> vtx_ntrk;
98  std::vector<float> vtx_dls;
99 
100 
101  for(auto vtx : msvVertices){//loop in vertices
102 
103  int ntrk = xAOD::SecVtxHelper::VtxNtrk(*vtx);
104  float mass = xAOD::SecVtxHelper::VertexMass(*vtx);
105  float efrc = xAOD::SecVtxHelper::EnergyFraction(*vtx);
106  float pt = xAOD::SecVtxHelper::Vtxpt(*vtx);
107  float eta = xAOD::SecVtxHelper::Vtxeta(*vtx);
108  float phi = xAOD::SecVtxHelper::Vtxphi(*vtx);
109  float dls = xAOD::SecVtxHelper::VtxnormDist(*vtx);
110  float xp = (*vtx)->x();
111  float yp = (*vtx)->y();
112  float zp = (*vtx)->z();
113  // float chi = (*vtx)->chiSquared();
114  // float ndf = (*vtx)->numberDoF();
115 
116  TLorentzVector p;
117  p.SetPtEtaPhiM(pt,eta,phi,mass);
118 
119  vtx_mass.push_back(mass);
120  vtx_pt.push_back(pt);
121  vtx_eta.push_back(eta);
122  vtx_phi.push_back(phi);
123  vtx_efrac.push_back(efrc);
124  vtx_x.push_back(xp);
125  vtx_y.push_back(yp);
126  vtx_z.push_back(zp);
127  vtx_ntrk.push_back(ntrk);
128  vtx_dls.push_back(dls);
129  }
130 
131  dec_vtxmass(*bjet)=vtx_mass;
132  dec_vtxpt(*bjet)=vtx_pt;
133  dec_vtxeta(*bjet)=vtx_eta;
134  dec_vtxphi(*bjet)=vtx_phi;
135  dec_vtxefrac(*bjet)=vtx_efrac;
136  dec_vtxx(*bjet)=vtx_x;
137  dec_vtxy(*bjet)=vtx_y;
138  dec_vtxz(*bjet)=vtx_z;
139  dec_vtxdls(*bjet)=vtx_dls;
140  dec_vtxntrk(*bjet)=vtx_ntrk;
141 
142  }
143 
144  return StatusCode::SUCCESS;
145 
146 }
147 
148 
149 
150 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
BTaggingUtilities.h
python.BuildSignatureFlags.bjet
AthConfigFlags bjet(AthConfigFlags flags, str instanceName, str recoMode)
Definition: BuildSignatureFlags.py:359
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
BTagging.h
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
test_pyathena.pt
pt
Definition: test_pyathena.py:11
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::SecVtxHelper::VtxNtrk
int VtxNtrk(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:39
DerivationFramework::JetMSVAugmentation::initialize
StatusCode initialize()
Definition: JetMSVAugmentation.cxx:35
SecVtxHelper.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::SecVtxHelper::VertexMass
float VertexMass(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:9
DerivationFramework::JetMSVAugmentation::addBranches
virtual StatusCode addBranches() const
Definition: JetMSVAugmentation.cxx:54
xAOD::SecVtxHelper::VtxnormDist
float VtxnormDist(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:95
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
TTbarPlusHeavyFlavorFilterTool.h
tool to compute filter flag for ttbar+HF
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
DerivationFramework::JetMSVAugmentation::JetMSVAugmentation
JetMSVAugmentation(const std::string &t, const std::string &n, const IInterface *p)
Definition: JetMSVAugmentation.cxx:19
beamspotman.n
n
Definition: beamspotman.py:729
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
DerivationFramework::JetMSVAugmentation::~JetMSVAugmentation
~JetMSVAugmentation()
Definition: JetMSVAugmentation.cxx:31
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Vertex.h
DerivationFramework::JetMSVAugmentation::m_jetCollectionName
std::string m_jetCollectionName
Definition: JetMSVAugmentation.h:39
xAOD::BTaggingUtilities::getBTagging
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Definition: BTaggingUtilities.cxx:37
JetContainer.h
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_vtxAlgName
std::string m_vtxAlgName
Definition: JetMSVAugmentation.h:40
xAOD::SecVtxHelper::Vtxeta
float Vtxeta(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:67
DerivationFramework::JetMSVAugmentation::finalize
StatusCode finalize()
Definition: JetMSVAugmentation.cxx:46
JetMSVAugmentation.h
tool to add some MSV variables to jets