ATLAS Offline Software
JetParticleOriginVertexAssociation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // author: cpollard@cern.ch
6 
8 #include "AsgMessaging/Check.h"
9 
10 using namespace std;
11 using namespace xAOD;
12 
15 
16  declareProperty("coneSizeFitPar1", m_coneSizeFitPar1=0);
17  declareProperty("coneSizeFitPar2", m_coneSizeFitPar2=0);
18  declareProperty("coneSizeFitPar3", m_coneSizeFitPar3=0);
19  declareProperty("dzCut", m_dzCut=10);
20  declareProperty("useMinZ0Vertex", m_useMinZ0Vertex=false);
21  return;
22  }
23 
24 
25 const std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >*
27 
28  //Get the vertex associated to each track by reading the decoration
29  const SG::AuxElement::ConstAccessor<std::vector<ElementLink<xAOD::VertexContainer>>> trkOrigin("btagIp_ByVertex_TrkOriginVtx");
30  const SG::AuxElement::ConstAccessor<std::vector<float>> z0SinTheta("btagIp_ByVertex_z0SinTheta");
31  //Create the 2d output vector
32  std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >* matchedparts =
33  new vector<std::vector<ElementLink<xAOD::IParticleContainer> > >(jets.size());
34 
35  //loop through the tracks
36  for (const IParticle* part: parts) {
37 
38  // Retrieve the vector of vertex ElementLinks associated with the track and the corresponding z0 vector
39  const std::vector<ElementLink<xAOD::VertexContainer>>& vertexLink_vec = trkOrigin(*part);
40  const std::vector<float>& z0SinTheta_vec = z0SinTheta(*part);
41  // check if the vectors are not empty
42  if(z0SinTheta_vec.empty()) continue;
43  // index of vertex with min(z0)
44  unsigned int selectedVertexIndex = -1;
45  if (m_useMinZ0Vertex) {
46  // Find the vertex with the minimum absolute value of z0SinTheta
47  auto minAbsIt = std::min_element(z0SinTheta_vec.begin(), z0SinTheta_vec.end(),
48  [](float a, float b) {
49  return std::abs(a) < std::abs(b);
50  });
51  // find index of the vertex with mindZ
52  if (minAbsIt != z0SinTheta_vec.end()) {
53  selectedVertexIndex = std::distance(z0SinTheta_vec.begin(), minAbsIt);
54  }
55  }
56  // loop through vertices
57  for (unsigned int iVtx=0; iVtx < z0SinTheta_vec.size(); iVtx++){
58  // if we want to do exclusive, only use the vertex with the min(z0)
59  if (m_useMinZ0Vertex && selectedVertexIndex!=iVtx) continue;
60  // retrieve vertex link
61  const ElementLink<xAOD::VertexContainer>& vertexLink = vertexLink_vec.at(iVtx);
62  // check if link is valid
63  if (!vertexLink.isValid()) {
64  ATH_MSG_WARNING("Track decoration 'btagIp_TrkOriginVertex' is missing for this track");
65  continue;
66  }
67  // if the dz(track, vertex) doesnt pass the cut then continue to next vertex
68  if (z0SinTheta_vec.at(iVtx) > m_dzCut) continue;
69 
70  // Continue processing
71  //Get vertex associated with the track
72  const Vertex* vtx_to_trk = *vertexLink;
73  int matchjetidx = -1;
74  double drmin = -1.0;
75  // Loop through jets
76  for (unsigned int iJet = 0; iJet < jets.size(); iJet++) {
77  //get jet
78  const Jet* jet = jets[iJet];
79  // if origin of jet is not the same as the vertex associated to the track then continue to next jet
80  if (jet->getAssociatedObject<xAOD::Vertex>("OriginVertex") != vtx_to_trk) continue;
81 
82  // do dR matching between jet and track
83  double match_dr = coneSize(jet->pt());
84  double dr = jet->p4().DeltaR(part->p4());
85  if (dr > match_dr) continue;
86  if (drmin < 0 || dr < drmin) {
87  drmin = dr;
88  matchjetidx = iJet;
89  }
90  }
91  if (matchjetidx >= 0) {
93  EL.toContainedElement(parts, part);
94  (*matchedparts)[matchjetidx].push_back(EL);
95  }
96  }
97 
98  }
99 
100  return matchedparts;
101 
102 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
DMTest::EL
ElementLink< CVec > EL
Definition: xAODTestWriteCLinks.cxx:22
Check.h
JetParticleAssociation
Definition: JetParticleAssociation.h:22
JetParticleOriginVertexAssociation::m_coneSizeFitPar3
double m_coneSizeFitPar3
Definition: JetParticleOriginVertexAssociation.h:34
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:111
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
IDTPM::z0SinTheta
float z0SinTheta(const U &p)
Definition: TrackParametersHelper.h:75
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
JetParticleOriginVertexAssociation::JetParticleOriginVertexAssociation
JetParticleOriginVertexAssociation(const std::string &name)
Definition: JetParticleOriginVertexAssociation.cxx:13
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AsgComponentFactories.h:16
JetParticleOriginVertexAssociation::match
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const override
Definition: JetParticleOriginVertexAssociation.cxx:26
JetParticleOriginVertexAssociation::m_useMinZ0Vertex
bool m_useMinZ0Vertex
Definition: JetParticleOriginVertexAssociation.h:36
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
JetParticleOriginVertexAssociation::m_dzCut
float m_dzCut
Definition: JetParticleOriginVertexAssociation.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JetParticleOriginVertexAssociation.h
doL1CaloHVCorrections.parts
parts
Definition: doL1CaloHVCorrections.py:334
JetParticleOriginVertexAssociation::coneSize
double coneSize(double pt) const
Definition: JetParticleOriginVertexAssociation.h:26
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
JetParticleOriginVertexAssociation::m_coneSizeFitPar1
double m_coneSizeFitPar1
Definition: JetParticleOriginVertexAssociation.h:32
JetParticleOriginVertexAssociation::m_coneSizeFitPar2
double m_coneSizeFitPar2
Definition: JetParticleOriginVertexAssociation.h:33