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  AthAlgTool(t,n,p)
21 {
22 
23  declareInterface<DerivationFramework::IAugmentationTool>(this);
24 
25  declareProperty("JetCollectionName",m_jetCollectionName="AntiKt4EMTopoJets");
26  declareProperty("vertexAlgName",m_vtxAlgName="MSV");
27 
28 }
29 
30 
31 
33 
34 
35 
37 
38  ATH_MSG_INFO("Initialize " );
39 
40 
41  return StatusCode::SUCCESS;
42 
43 }
44 
45 
46 
48 
49  return StatusCode::SUCCESS;
50 
51 }
52 
53 
54 
56 
57 
58  const xAOD::JetContainer* jets;
59  if( evtStore()->retrieve( jets, m_jetCollectionName ).isFailure() ) {
60  ATH_MSG_ERROR ("Couldn't retrieve jets with key: " << m_jetCollectionName );
61  return StatusCode::FAILURE;
62  }
63 
64 
65  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxmass(m_vtxAlgName+"_vtxmass");
66  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxpt(m_vtxAlgName+"_vtxpt");
67  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxeta(m_vtxAlgName+"_vtxeta");
68  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxphi(m_vtxAlgName+"_vtxphi");
69  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxefrac(m_vtxAlgName+"_vtxefrac");
70 
71  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxx(m_vtxAlgName+"_vtxx");
72  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxy(m_vtxAlgName+"_vtxy");
73  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxz(m_vtxAlgName+"_vtxz");
74 
75  static const SG::AuxElement::Decorator<std::vector<int> > dec_vtxntrk(m_vtxAlgName+"_vtxntrk");
76  static const SG::AuxElement::Decorator<std::vector<float> > dec_vtxdls(m_vtxAlgName+"_vtxdls");
77 
78 
79  for(auto jet : *jets){
81 
82  if(!bjet){
83  ATH_MSG_WARNING("btagging information not available" );
84  continue;
85  }
86 
87  std::vector< ElementLink< xAOD::VertexContainer > > msvVertices;
88  bjet->variable<std::vector<ElementLink<xAOD::VertexContainer> > >(m_vtxAlgName, "vertices", msvVertices);
89 
90  std::vector<float> vtx_mass;
91  std::vector<float> vtx_pt;
92  std::vector<float> vtx_eta;
93  std::vector<float> vtx_phi;
94  std::vector<float> vtx_efrac;
95  std::vector<float> vtx_x;
96  std::vector<float> vtx_y;
97  std::vector<float> vtx_z;
98  std::vector<int> vtx_ntrk;
99  std::vector<float> vtx_dls;
100 
101 
102  for(auto vtx : msvVertices){//loop in vertices
103 
104  int ntrk = xAOD::SecVtxHelper::VtxNtrk(*vtx);
105  float mass = xAOD::SecVtxHelper::VertexMass(*vtx);
106  float efrc = xAOD::SecVtxHelper::EnergyFraction(*vtx);
107  float pt = xAOD::SecVtxHelper::Vtxpt(*vtx);
108  float eta = xAOD::SecVtxHelper::Vtxeta(*vtx);
109  float phi = xAOD::SecVtxHelper::Vtxphi(*vtx);
110  float dls = xAOD::SecVtxHelper::VtxnormDist(*vtx);
111  float xp = (*vtx)->x();
112  float yp = (*vtx)->y();
113  float zp = (*vtx)->z();
114  // float chi = (*vtx)->chiSquared();
115  // float ndf = (*vtx)->numberDoF();
116 
117  TLorentzVector p;
118  p.SetPtEtaPhiM(pt,eta,phi,mass);
119 
120  vtx_mass.push_back(mass);
121  vtx_pt.push_back(pt);
122  vtx_eta.push_back(eta);
123  vtx_phi.push_back(phi);
124  vtx_efrac.push_back(efrc);
125  vtx_x.push_back(xp);
126  vtx_y.push_back(yp);
127  vtx_z.push_back(zp);
128  vtx_ntrk.push_back(ntrk);
129  vtx_dls.push_back(dls);
130  }
131 
132  dec_vtxmass(*bjet)=vtx_mass;
133  dec_vtxpt(*bjet)=vtx_pt;
134  dec_vtxeta(*bjet)=vtx_eta;
135  dec_vtxphi(*bjet)=vtx_phi;
136  dec_vtxefrac(*bjet)=vtx_efrac;
137  dec_vtxx(*bjet)=vtx_x;
138  dec_vtxy(*bjet)=vtx_y;
139  dec_vtxz(*bjet)=vtx_z;
140  dec_vtxdls(*bjet)=vtx_dls;
141  dec_vtxntrk(*bjet)=vtx_ntrk;
142 
143  }
144 
145  return StatusCode::SUCCESS;
146 
147 }
148 
149 
150 
151 }
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:335
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
BTagging.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAOD::SecVtxHelper::VtxNtrk
int VtxNtrk(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:39
DerivationFramework::JetMSVAugmentation::initialize
StatusCode initialize()
Definition: JetMSVAugmentation.cxx:36
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
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
DerivationFramework::JetMSVAugmentation::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: JetMSVAugmentation.cxx:55
xAOD::SecVtxHelper::VtxnormDist
float VtxnormDist(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:95
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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:58
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:731
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:32
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
AthAlgTool
Definition: AthAlgTool.h:26
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:47
JetMSVAugmentation.h
tool to add some MSV variables to jets