ATLAS Offline Software
BPhysPVCascadeTools.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef DERIVATIONFRAMEWORK_PVCASCADETOOLS_H
6 #define DERIVATIONFRAMEWORK_PVCASCADETOOLS_H
7 
8 #include "GaudiKernel/ToolHandle.h"
13 #include <vector>
14 // Authors: Adam Barton <abarton@SPAMMENOTTtttcern.ch>
15 // Eva Bouhova <bouhova@SPAMMENOTTtttcern.ch>
16 
17 
18 //class CascadeTools;
19 namespace Trk {
20  class V0Tools;
21  class VxCascadeInfo;
22 }
23 
24 namespace Analysis{
25  class PrimaryVertexRefitter;
26 }
27 
28 namespace HepPDT{
29  class ParticleDataTable;
30 }
31 
32 namespace DerivationFramework {
33 
36  typedef std::vector<VertexLink> VertexLinkVector;
37  private:
40 
43 
44  public:
46  BPhysPVCascadeTools(const CascadeTools *cascadeTools);
47  BPhysPVCascadeTools(const CascadeTools *cascadeTools,
48  const xAOD::EventInfo*);
49 
50 
51  void ProcessVertex(const std::vector<TLorentzVector> &mom, Amg::MatrixX cov, xAOD::BPhysHypoHelper &vtx, xAOD::BPhysHelper::pv_type pvtype, double mass) const;
52 
54  void FillBPhysHelper(const std::vector<TLorentzVector> &mom, Amg::MatrixX cov, xAOD::BPhysHelper &vtx, const xAOD::Vertex* refPV,const xAOD::VertexContainer* refPvContainer,
55  xAOD::BPhysHelper::pv_type pvtype, int) const;
56 
58  size_t FindLowZIndex(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &Obj,
59  const std::vector<const xAOD::Vertex*> &PVlist,
60  const size_t PV_minNTracks=0) const;
62  size_t FindLowA0Index(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &Obj,
63  const std::vector<const xAOD::Vertex*> &PVlist,
64  const size_t PV_minNTracks=0) const;
65 
66  template< size_t NTracks> //NTracks = number of tracks in this type of vertex, if this is not known do not use this method
67  static bool VerticesMatchTracks(const xAOD::Vertex* v1, const xAOD::Vertex* v2);
68 
69  template< size_t NTracks>
70  static const xAOD::Vertex* FindVertex(const xAOD::VertexContainer* c, const xAOD::Vertex* v);
71 
76  static std::vector<const xAOD::Vertex*> GetGoodPV(const xAOD::VertexContainer* pvContainer);
77 
84  void SetMinNTracksInPV(size_t PV_minNTracks);
85 
90  [[nodiscard]] Amg::Vector3D GetBeamSpot() const;
91 
94  size_t FindLowZ0BAIndex(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &obj,
95  const std::vector<const xAOD::Vertex*> &PVlist,
96  const size_t PV_minNTracks=0) const;
99  double DistInZtoDOCA(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &obj,
100  const xAOD::Vertex* vertex) const;
103  Amg::Vector3D DocaExtrapToBeamSpot(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &obj) const;
104 
105  static void PrepareVertexLinks(Trk::VxCascadeInfo *result, const xAOD::TrackParticleContainer* importedTrackCollection);
106  static void PrepareVertexLinks(Trk::VxCascadeInfo *result, const std::vector<const xAOD::TrackParticleContainer*>& );
107 
109  const xAOD::VertexContainer* pvContainer, xAOD::VertexContainer* refPvContainer,
110  const Analysis::PrimaryVertexRefitter *pvRefitter, size_t in_PV_max, int DoVertexType,
111  Trk::VxCascadeInfo* casc, int index,
112  double mass, xAOD::BPhysHypoHelper &vtx);
113 
114  static std::vector<const xAOD::TrackParticle*> CollectAllChargedTracks(const std::vector<xAOD::Vertex*> &cascadeVertices);
115 
116  static void SetVectorInfo(xAOD::BPhysHelper &, const Trk::VxCascadeInfo*);
117  static bool uniqueCollection(const std::vector<const xAOD::TrackParticle*>&);
118  static bool uniqueCollection(const std::vector<const xAOD::TrackParticle*>&, const std::vector<const xAOD::TrackParticle*>&);
119  static bool LinkVertices(SG::AuxElement::Decorator<VertexLinkVector> &decor, const std::vector<const xAOD::Vertex*>& vertices,
120  const xAOD::VertexContainer* vertexContainer, const xAOD::Vertex* vert);
121  static double getParticleMass(const HepPDT::ParticleDataTable* pdt, int pdg);
122  }; // class BPhysPVCascadeTools
123 
124 } // namespace DerivationFramework
125 
126 
127 //added by ab
128 template< size_t NTracks>
130 {
131  if(v1->nTrackParticles() != v2->nTrackParticles()) return false;
132  assert(v1->nTrackParticles() == NTracks);
133  std::array<const xAOD::TrackParticle*, NTracks> a1;
134  std::array<const xAOD::TrackParticle*, NTracks> a2;
135  for(size_t i=0;i<NTracks;i++){
136  a1[i] = v1->trackParticle(i);
137  a2[i] = v2->trackParticle(i);
138  }
139  std::sort(a1.begin(), a1.end());
140  std::sort(a2.begin(), a2.end());
141  return a1 == a2;
142 }
143 
144 template< size_t NTracks>
146  for (const xAOD::Vertex* a : *c){
147  if(VerticesMatchTracks<NTracks>(a,v)) return a;
148  }
149  return nullptr;
150 }
151 #endif // DERIVATIONFRAMEWORK_PVCASCADETOOLS_H
DerivationFramework::BPhysPVCascadeTools::ProcessVertex
void ProcessVertex(const std::vector< TLorentzVector > &mom, Amg::MatrixX cov, xAOD::BPhysHypoHelper &vtx, xAOD::BPhysHelper::pv_type pvtype, double mass) const
Definition: BPhysPVCascadeTools.cxx:54
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
Trk::VxCascadeInfo
Definition: VxCascadeInfo.h:75
DerivationFramework::BPhysPVCascadeTools::LinkVertices
static bool LinkVertices(SG::AuxElement::Decorator< VertexLinkVector > &decor, const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer, const xAOD::Vertex *vert)
Definition: BPhysPVCascadeTools.cxx:460
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
DerivationFramework::BPhysPVCascadeTools::FillCandwithRefittedVertices
StatusCode FillCandwithRefittedVertices(bool refitPV, const xAOD::VertexContainer *pvContainer, xAOD::VertexContainer *refPvContainer, const Analysis::PrimaryVertexRefitter *pvRefitter, size_t in_PV_max, int DoVertexType, Trk::VxCascadeInfo *casc, int index, double mass, xAOD::BPhysHypoHelper &vtx)
Definition: BPhysPVCascadeTools.cxx:257
index
Definition: index.py:1
DerivationFramework::BPhysPVCascadeTools::getParticleMass
static double getParticleMass(const HepPDT::ParticleDataTable *pdt, int pdg)
Definition: BPhysPVCascadeTools.cxx:491
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
DerivationFramework::BPhysPVCascadeTools::FillBPhysHelper
void FillBPhysHelper(const std::vector< TLorentzVector > &mom, Amg::MatrixX cov, xAOD::BPhysHelper &vtx, const xAOD::Vertex *refPV, const xAOD::VertexContainer *refPvContainer, xAOD::BPhysHelper::pv_type pvtype, int) const
Fills the BPhysHelper object with the standard parameters.
Definition: BPhysPVCascadeTools.cxx:32
DerivationFramework::BPhysPVCascadeTools::m_eventInfo
const xAOD::EventInfo * m_eventInfo
Definition: BPhysPVCascadeTools.h:39
DerivationFramework::BPhysPVCascadeTools::GetBeamSpot
Amg::Vector3D GetBeamSpot() const
Get the current beamspot position either from cache or from BeamCondSvc.
Definition: BPhysPVCascadeTools.cxx:146
DerivationFramework::BPhysPVCascadeTools::m_cascadeTools
const CascadeTools * m_cascadeTools
Definition: BPhysPVCascadeTools.h:38
DerivationFramework::BPhysPVCascadeTools::FindVertex
static const xAOD::Vertex * FindVertex(const xAOD::VertexContainer *c, const xAOD::Vertex *v)
Definition: BPhysPVCascadeTools.h:145
DerivationFramework::BPhysPVCascadeTools::CollectAllChargedTracks
static std::vector< const xAOD::TrackParticle * > CollectAllChargedTracks(const std::vector< xAOD::Vertex * > &cascadeVertices)
Definition: BPhysPVCascadeTools.cxx:246
DerivationFramework::BPhysPVCascadeTools::GetGoodPV
static std::vector< const xAOD::Vertex * > GetGoodPV(const xAOD::VertexContainer *pvContainer)
Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector contain...
Definition: BPhysPVCascadeTools.cxx:120
xAOD::BPhysHypoHelper
Definition: BPhysHypoHelper.h:73
DerivationFramework::BPhysPVCascadeTools::SetVectorInfo
static void SetVectorInfo(xAOD::BPhysHelper &, const Trk::VxCascadeInfo *)
Definition: BPhysPVCascadeTools.cxx:424
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
xAOD::BPhysHelper::pv_type
pv_type
: Enum type of the PV
Definition: BPhysHelper.h:475
Analysis::PrimaryVertexRefitter
Definition: PrimaryVertexRefitter.h:26
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
DerivationFramework::BPhysPVCascadeTools::VertexLink
ElementLink< xAOD::VertexContainer > VertexLink
Definition: BPhysPVCascadeTools.h:35
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BPhysHypoHelper.h
: B-physcis xAOD helpers.
DerivationFramework::BPhysPVCascadeTools::FindLowZIndex
size_t FindLowZIndex(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &Obj, const std::vector< const xAOD::Vertex * > &PVlist, const size_t PV_minNTracks=0) const
Returns the index integer of the vertex with the lowest Z in relation to the given vertex.
Definition: BPhysPVCascadeTools.cxx:76
DerivationFramework::BPhysPVCascadeTools::PrepareVertexLinks
static void PrepareVertexLinks(Trk::VxCascadeInfo *result, const xAOD::TrackParticleContainer *importedTrackCollection)
Definition: BPhysPVCascadeTools.cxx:204
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
DerivationFramework::BPhysPVCascadeTools::FindLowZ0BAIndex
size_t FindLowZ0BAIndex(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj, const std::vector< const xAOD::Vertex * > &PVlist, const size_t PV_minNTracks=0) const
Find the index for the PV with the lowest distance in z of the SV's DOCA point w.r....
Definition: BPhysPVCascadeTools.cxx:155
DerivationFramework::BPhysPVCascadeTools::uniqueCollection
static bool uniqueCollection(const std::vector< const xAOD::TrackParticle * > &)
Definition: BPhysPVCascadeTools.cxx:443
xAOD::Vertex_v1::trackParticle
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Definition: Vertex_v1.cxx:249
HepPDT
Definition: BeamHaloGenerator.h:13
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DerivationFramework::BPhysPVCascadeTools::m_copyAllVertices
bool m_copyAllVertices
Definition: BPhysPVCascadeTools.h:45
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
DerivationFramework::BPhysPVCascadeTools::DistInZtoDOCA
double DistInZtoDOCA(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj, const xAOD::Vertex *vertex) const
Calculate the distance along z axis between the PV and SV's DOCA point w.r.t.
Definition: BPhysPVCascadeTools.cxx:174
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
DerivationFramework::BPhysPVCascadeTools::BPhysPVCascadeTools
BPhysPVCascadeTools(const CascadeTools *cascadeTools)
Definition: BPhysPVCascadeTools.cxx:17
DerivationFramework::BPhysPVCascadeTools
Definition: BPhysPVCascadeTools.h:34
CascadeTools.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DerivationFramework::CascadeTools
Definition: CascadeTools.h:21
V0Tools
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:154
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
DerivationFramework::BPhysPVCascadeTools::m_PV_minNTracks
size_t m_PV_minNTracks
minimum number of tracks required in PVs considered
Definition: BPhysPVCascadeTools.h:42
DerivationFramework::BPhysPVCascadeTools::FindLowA0Index
size_t FindLowA0Index(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &Obj, const std::vector< const xAOD::Vertex * > &PVlist, const size_t PV_minNTracks=0) const
Returns the index integer of the vertex with the lowest A0 in relation to the given vertex.
Definition: BPhysPVCascadeTools.cxx:98
AthMessaging.h
DerivationFramework::BPhysPVCascadeTools::SetMinNTracksInPV
void SetMinNTracksInPV(size_t PV_minNTracks)
Set the minimum number of tracks required for primary vertices to be considered for primary vertex as...
Definition: BPhysPVCascadeTools.cxx:139
DerivationFramework::BPhysPVCascadeTools::VertexLinkVector
std::vector< VertexLink > VertexLinkVector
Definition: BPhysPVCascadeTools.h:36
DerivationFramework::BPhysPVCascadeTools::VerticesMatchTracks
static bool VerticesMatchTracks(const xAOD::Vertex *v1, const xAOD::Vertex *v2)
Definition: BPhysPVCascadeTools.h:129
python.PyAthena.obj
obj
Definition: PyAthena.py:132
python.compressB64.c
def c
Definition: compressB64.py:93
DerivationFramework::BPhysPVCascadeTools::DocaExtrapToBeamSpot
Amg::Vector3D DocaExtrapToBeamSpot(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj) const
Point of DOCA w.r.t.
Definition: BPhysPVCascadeTools.cxx:183