ATLAS Offline Software
BPhysHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
52 #ifndef XAOD_BPHYSHELPER_H
53 #define XAOD_BPHYSHELPER_H
54 
56 #include "xAODTracking/VertexFwd.h"
58 #include "xAODMuon/MuonContainer.h"
60 
61 
62 #include "TVector3.h"
63 #include "TLorentzVector.h"
64 #include "TMatrixTSym.h"
65 
66 #include <assert.h>
67 
68 
70 namespace xAOD {
71  class BPhysHelper {
72 
73 
74  public:
75 
76  /************************************************************************/
86  m_b(b),
87  m_covCached(false),
88  m_cachedCov(0),
89  m_refTracksCached(false),
91  m_muonsCached(false),
92  m_electronsCached(false),
93  m_cachedMuons(0),
99  {
100  assert(m_b!=0); // sanity check: m_b must not be null
101  }
102 
103  /************************************************************************/
108  const xAOD::Vertex* vtx() const { return m_b; }
109 
110  /************************************************************************/
123  const TMatrixTSym<double>& covariance();
124 
125  /************************************************************************/
135  int nRefTrks();
136 
142  TVector3 refTrk(const size_t index);
143 
150  const std::vector<TVector3>& refTrks();
151 
158  TLorentzVector refTrk(const size_t index, const float mass);
159 
186  const xAOD::IParticle* refTrkOrigin(const size_t index) const;
187 
198  TVector3 refTrkOriginP(const size_t index) const;
199 
216  TLorentzVector refTrkOriginP(const size_t index, const float mass) const;
217 
228  float refTrkCharge(const size_t index) const;
229 
235  bool setRefTrks(std::vector<float> px,
236  std::vector<float> py,
237  std::vector<float> pz);
238 
244  bool setRefTrks(const std::vector<TVector3>& refTrks);
245 
246 #ifndef XAOD_ANALYSIS
247 
263  bool setRefTrks();
264 
265 
266 #endif // not XAOD_ANALYSIS
267 
270  /************************************************************************/
286  TVector3 totalP();
287 
295  TLorentzVector totalP(std::span<const double> masses);
296 
302  float ptErr();
303 
310  bool setPtErr(const float val);
311 
314  /************************************************************************/
327  int nMuons();
328  int nElectrons();
329 
335  const xAOD::Muon* muon(const size_t index);
336  const xAOD::Electron* electron(const size_t index);
337 
342  const std::vector<const xAOD::Muon*>& muons();
343  const std::vector<const xAOD::Electron*>& electrons();
344 
351  bool setMuons(const std::vector<const xAOD::Muon*>& muons,
353 
354  bool setElectrons(const std::vector<const xAOD::Electron*>& electrons,
358  /************************************************************************/
376  int nPrecedingVertices();
377 
384  const xAOD::Vertex* precedingVertex(const size_t index);
385 
391  const std::vector<const xAOD::Vertex*>& precedingVertices();
392 
399  bool setPrecedingVertices(const std::vector<const xAOD::Vertex*>& vertices,
400  const xAOD::VertexContainer* vertexContainer);
401 
402 
405  /************************************************************************/
420  int nCascadeVertices();
421 
428  const xAOD::Vertex* cascadeVertex(const size_t index);
429 
435  const std::vector<const xAOD::Vertex*>& cascadeVertices();
436 
443  bool setCascadeVertices(const std::vector<const xAOD::Vertex*>& vertices,
444  const xAOD::VertexContainer* vertexContainer);
445 
452  int nRefTrksCascade();
453 
456  /************************************************************************/
476 
477  /************************************************************************/
493 
501  bool setOrigPv(const xAOD::Vertex* pv,
502  const xAOD::VertexContainer* vertexContainer,
504 
513  bool setPv(const xAOD::Vertex* pv,
514  const xAOD::VertexContainer* vertexContainer,
516 
523 
530 
533  /************************************************************************/
545  float lxy (const pv_type vertexType = BPhysHelper::PV_MIN_A0);
547 
556  bool setLxy (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
557  bool setLxyErr(const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
558 
561  bool setLxyz (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
562  bool setLxyzErr(const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
563 
566  /************************************************************************/
577  float a0 (const pv_type vertexType = BPhysHelper::PV_MIN_A0);
581  float z0 (const pv_type vertexType = BPhysHelper::PV_MIN_A0);
583 
591  float setA0 (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
592  float setA0Err (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
593  float setA0xy (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
594  float setA0xyErr(const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
595  float setZ0 (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
596  float setZ0Err (const float val, const pv_type vertexType = BPhysHelper::PV_MIN_A0);
597 
600  /************************************************************************/
605  static const std::string pv_type_str[];
608  /************************************************************************/
613  static const unsigned int n_pv_types;
616  /************************************************************************/
617  /************************************************************************/
618  protected:
619 
628  bool cacheCov();
629 
638  bool cacheRefTracks();
639 
648  bool cacheMuons();
649  bool cacheElectrons();
650 
651 
660  bool cachePrecedingVertices();
661 
670  bool cacheCascadeVertices();
671 
672  /************************************************************************/
675 
676  /************************************************************************/
682  TMatrixTSym<double> m_cachedCov;
683 
686  /************************************************************************/
692  std::vector<TVector3> m_cachedRefTracks;
693 
696  /************************************************************************/
703  std::vector<const xAOD::Muon*> m_cachedMuons;
704  std::vector<const xAOD::Electron*> m_cachedElectrons;
705 
708  /************************************************************************/
714  std::vector<const xAOD::Vertex*> m_cachedPrecedingVertices;
716  std::vector<const xAOD::Vertex*> m_cachedCascadeVertices;
717 
720  /************************************************************************/
725  static const std::vector<TVector3> s_emptyVectorOfTVector3;
726  static const std::vector<const xAOD::Muon*> s_emptyVectorOfMuons;
727  static const std::vector<const xAOD::Electron*> s_emptyVectorOfElectrons;
728  static const TMatrixTSym<double> s_emptyMatrix;
729  static const std::vector<const xAOD::Vertex*> s_emptyVectorOfVertices;
732  }; // BPhysHelper
733 
734 } // namespace xAOD
735 
738 #define BPHYS_CHECK( EXP ) { if( ! EXP ) ATH_MSG_WARNING ( "Call of \"" << #EXP << "\" failed" ); }
739 
740 #endif // XAOD_BPHYSHELPER_H
xAOD::BPhysHelper::electrons
const std::vector< const xAOD::Electron * > & electrons()
Definition: BPhysHelper.cxx:548
muonContainer
xAOD::MuonContainer * muonContainer
Definition: TrigGlobEffCorrValidation.cxx:188
xAOD::BPhysHelper::RefitPVStatus
int RefitPVStatus(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the exitCode of the refitter for vertex of type pv_type.
Definition: BPhysHelper.cxx:855
xAOD::BPhysHelper::refTrkCharge
float refTrkCharge(const size_t index) const
Returns charge of the i-th track.
Definition: BPhysHelper.cxx:255
xAOD::BPhysHelper::totalP
TVector3 totalP()
: Returns total 3-momentum calculated from the refitted tracks
Definition: BPhysHelper.cxx:374
xAOD::BPhysHelper::setA0xyErr
float setA0xyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter error
Definition: BPhysHelper.cxx:1056
electronContainer
xAOD::ElectronContainer * electronContainer
Definition: TrigGlobEffCorrValidation.cxx:187
VertexContainerFwd.h
xAOD::BPhysHelper::nMuons
int nMuons()
: Methods providing access to the linked muons
Definition: BPhysHelper.cxx:441
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
test_pyathena.px
px
Definition: test_pyathena.py:18
xAOD::BPhysHelper::s_emptyVectorOfTVector3
static const std::vector< TVector3 > s_emptyVectorOfTVector3
Definition: BPhysHelper.h:725
xAOD::BPhysHelper::pv_type_str
static const std::string pv_type_str[]
Definition: BPhysHelper.h:605
xAOD::BPhysHelper::nRefTrks
int nRefTrks()
Returns number of stored refitted track momenta.
Definition: BPhysHelper.cxx:115
xAOD::BPhysHelper::nCascadeVertices
int nCascadeVertices()
: Links to cascade vertices
Definition: BPhysHelper.cxx:682
xAOD::BPhysHelper::m_cachedElectrons
std::vector< const xAOD::Electron * > m_cachedElectrons
Definition: BPhysHelper.h:704
xAOD::BPhysHelper::setRefitPVStatus
bool setRefitPVStatus(int code, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the exitCode of the refitter for vertex of type pv_type.
Definition: BPhysHelper.cxx:844
index
Definition: index.py:1
xAOD::BPhysHelper::m_cachedCascadeVertices
std::vector< const xAOD::Vertex * > m_cachedCascadeVertices
Definition: BPhysHelper.h:716
xAOD::BPhysHelper::m_electronsCached
bool m_electronsCached
Definition: BPhysHelper.h:702
xAOD::BPhysHelper::a0xyErr
float a0xyErr(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
rtansverse impact parameter error
Definition: BPhysHelper.cxx:990
xAOD::BPhysHelper::m_cachedRefTracks
std::vector< TVector3 > m_cachedRefTracks
Definition: BPhysHelper.h:692
xAOD::BPhysHelper::muon
const xAOD::Muon * muon(const size_t index)
Returns pointer to the i-th linked muon.
Definition: BPhysHelper.cxx:452
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::BPhysHelper::setCascadeVertices
bool setCascadeVertices(const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer)
Sets links to cascade vertices.
Definition: BPhysHelper.cxx:722
xAOD::BPhysHelper::PV_MIN_Z0
@ PV_MIN_Z0
Definition: BPhysHelper.h:475
xAOD::BPhysHelper::ptErr
float ptErr()
Returns pT error.
Definition: BPhysHelper.cxx:431
xAOD::BPhysHelper::setPrecedingVertices
bool setPrecedingVertices(const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer)
Sets links to preceding vertices.
Definition: BPhysHelper.cxx:641
xAOD::BPhysHelper::z0Err
float z0Err(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter error
Definition: BPhysHelper.cxx:1012
xAOD::BPhysHelper::m_cachedCov
TMatrixTSym< double > m_cachedCov
Definition: BPhysHelper.h:682
xAOD::BPhysHelper::lxyErr
float lxyErr(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
Definition: BPhysHelper.cxx:877
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::py
py
Definition: CompositeParticle_v1.cxx:160
xAOD::BPhysHelper::z0
float z0(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter
Definition: BPhysHelper.cxx:1001
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
xAOD::BPhysHelper::lxyzErr
float lxyzErr(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
Definition: BPhysHelper.cxx:923
xAOD::BPhysHelper::m_cachedMuons
std::vector< const xAOD::Muon * > m_cachedMuons
Definition: BPhysHelper.h:703
xAOD::BPhysHelper::s_emptyVectorOfElectrons
static const std::vector< const xAOD::Electron * > s_emptyVectorOfElectrons
Definition: BPhysHelper.h:727
xAOD::BPhysHelper::nRefTrksCascade
int nRefTrksCascade()
Returns number of stored refitted tracks INCLUDING those from the linked cascade vertices.
Definition: BPhysHelper.cxx:764
xAOD::BPhysHelper::setPtErr
bool setPtErr(const float val)
Set pT error.
Definition: BPhysHelper.cxx:436
xAOD::BPhysHelper::pv_type
pv_type
: Enum type of the PV
Definition: BPhysHelper.h:475
xAOD::BPhysHelper::m_muonsCached
bool m_muonsCached
Definition: BPhysHelper.h:701
xAOD::BPhysHelper::setA0xy
float setA0xy(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter
Definition: BPhysHelper.cxx:1045
ElectronContainer.h
xAOD::BPhysHelper::lxyz
float lxyz(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
decay distance
Definition: BPhysHelper.cxx:912
xAOD::BPhysHelper::m_precedingVerticesCached
bool m_precedingVerticesCached
Definition: BPhysHelper.h:713
xAOD::BPhysHelper::electron
const xAOD::Electron * electron(const size_t index)
Definition: BPhysHelper.cxx:532
xAOD::BPhysHelper::m_b
const xAOD::Vertex * m_b
Cached B decay xAOD vertex.
Definition: BPhysHelper.h:674
xAOD::BPhysHelper::s_emptyVectorOfVertices
static const std::vector< const xAOD::Vertex * > s_emptyVectorOfVertices
Definition: BPhysHelper.h:729
xAOD::BPhysHelper::precedingVertex
const xAOD::Vertex * precedingVertex(const size_t index)
Returns pointer to a preceding vertex.
Definition: BPhysHelper.cxx:613
xAOD::BPhysHelper::BPhysHelper
BPhysHelper(const xAOD::Vertex *b)
: Main constructor
Definition: BPhysHelper.h:85
xAOD::BPhysHelper::m_cachedPrecedingVertices
std::vector< const xAOD::Vertex * > m_cachedPrecedingVertices
Definition: BPhysHelper.h:714
xAOD::BPhysHelper::setZ0Err
float setZ0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter error
Definition: BPhysHelper.cxx:1078
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
xAOD::BPhysHelper::PV_MIN_A0
@ PV_MIN_A0
Definition: BPhysHelper.h:475
xAOD::BPhysHelper::setA0Err
float setA0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
3D impact parameter error
Definition: BPhysHelper.cxx:1034
xAOD::BPhysHelper::origPv
const xAOD::Vertex * origPv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
original PV
Definition: BPhysHelper.cxx:807
xAOD::BPhysHelper::setElectrons
bool setElectrons(const std::vector< const xAOD::Electron * > &electrons, const xAOD::ElectronContainer *electronContainer)
Definition: BPhysHelper.cxx:559
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::BPhysHelper::cacheElectrons
bool cacheElectrons()
Definition: BPhysHelper.cxx:1226
xAOD::BPhysHelper::s_emptyVectorOfMuons
static const std::vector< const xAOD::Muon * > s_emptyVectorOfMuons
Definition: BPhysHelper.h:726
xAOD::BPhysHelper::setRefTrks
bool setRefTrks()
: Sets refitted track momenta
Definition: BPhysHelper.cxx:341
xAOD::BPhysHelper::setLxy
bool setLxy(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the transverse decay distance and its error measured between the refitted primary vertex of type ...
Definition: BPhysHelper.cxx:888
xAOD::BPhysHelper::cachePrecedingVertices
bool cachePrecedingVertices()
: Cache preceding vertices
Definition: BPhysHelper.cxx:1271
xAOD::BPhysHelper::refTrkOrigin
const xAOD::IParticle * refTrkOrigin(const size_t index) const
: Returns the original track (charged or neutral) corresponding to the i-th refitted track
Definition: BPhysHelper.cxx:171
xAOD::BPhysHelper::m_cascadeVerticesCached
bool m_cascadeVerticesCached
Definition: BPhysHelper.h:715
xAOD::BPhysHelper::setMuons
bool setMuons(const std::vector< const xAOD::Muon * > &muons, const xAOD::MuonContainer *muonContainer)
Set links to muons.
Definition: BPhysHelper.cxx:479
xAOD::BPhysHelper::setPv
bool setPv(const xAOD::Vertex *pv, const xAOD::VertexContainer *vertexContainer, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the refitted collision vertex of type pv_type.
Definition: BPhysHelper.cxx:831
xAOD::BPhysHelper::cascadeVertices
const std::vector< const xAOD::Vertex * > & cascadeVertices()
Returns vector of pointers to cascade vertices.
Definition: BPhysHelper.cxx:710
pmontree.code
code
Definition: pmontree.py:443
xAOD::BPhysHelper::vtx
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
Definition: BPhysHelper.h:108
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
xAOD::BPhysHelper::s_emptyMatrix
static const TMatrixTSym< double > s_emptyMatrix
Definition: BPhysHelper.h:728
xAOD::BPhysHelper::PV_MAX_SUM_PT2
@ PV_MAX_SUM_PT2
Definition: BPhysHelper.h:475
xAOD::vertexType
vertexType
Definition: Vertex_v1.cxx:166
xAOD::BPhysHelper::cacheCov
bool cacheCov()
: Cache covariance matrix
Definition: BPhysHelper.cxx:1089
xAOD::Electron_v1
Definition: Electron_v1.h:34
VertexFwd.h
xAOD::BPhysHelper::setLxyErr
bool setLxyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
Definition: BPhysHelper.cxx:899
xAOD::BPhysHelper::cacheRefTracks
bool cacheRefTracks()
: Cache refitted tracks
Definition: BPhysHelper.cxx:1137
xAOD::BPhysHelper::a0Err
float a0Err(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
3D impact parameter error
Definition: BPhysHelper.cxx:968
MuonContainer.h
xAOD::BPhysHelper::cacheMuons
bool cacheMuons()
: Cache linked muons
Definition: BPhysHelper.cxx:1181
xAOD::BPhysHelper::precedingVertices
const std::vector< const xAOD::Vertex * > & precedingVertices()
Returns vector of pointers to preceding vertices.
Definition: BPhysHelper.cxx:629
xAOD::BPhysHelper::setOrigPv
bool setOrigPv(const xAOD::Vertex *pv, const xAOD::VertexContainer *vertexContainer, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the original collision vertex of type pv_type.
Definition: BPhysHelper.cxx:818
xAOD::BPhysHelper::lxy
float lxy(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the transverse decay distance and its error measured between the refitted primary vertex of type ...
Definition: BPhysHelper.cxx:866
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::BPhysHelper::refTrk
TVector3 refTrk(const size_t index)
Returns i-th refitted track 3-momentum.
Definition: BPhysHelper.cxx:126
xAOD::BPhysHelper::a0xy
float a0xy(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter
Definition: BPhysHelper.cxx:979
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TrackParticleFwd.h
xAOD::BPhysHelper::nPrecedingVertices
int nPrecedingVertices()
: Links to preceding vertices
Definition: BPhysHelper.cxx:601
xAOD::BPhysHelper::pv
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
Definition: BPhysHelper.cxx:796
xAOD::BPhysHelper::refTrks
const std::vector< TVector3 > & refTrks()
Returns refitted track momenta.
Definition: BPhysHelper.cxx:142
xAOD::BPhysHelper::setLxyzErr
bool setLxyzErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
Definition: BPhysHelper.cxx:945
xAOD::BPhysHelper::nElectrons
int nElectrons()
Definition: BPhysHelper.cxx:521
xAOD::BPhysHelper::m_covCached
bool m_covCached
Definition: BPhysHelper.h:681
xAOD::BPhysHelper::m_refTracksCached
bool m_refTracksCached
Definition: BPhysHelper.h:691
xAOD::BPhysHelper::setA0
float setA0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the 3D and transverse impact parameters and their error.
Definition: BPhysHelper.cxx:1023
xAOD::BPhysHelper::n_pv_types
static const unsigned int n_pv_types
Definition: BPhysHelper.h:613
xAOD::BPhysHelper::setZ0
float setZ0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter
Definition: BPhysHelper.cxx:1067
xAOD::BPhysHelper::muons
const std::vector< const xAOD::Muon * > & muons()
Returns linked muons.
Definition: BPhysHelper.cxx:468
xAOD::BPhysHelper::a0
float a0(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the 3D, transverse, and longitudinal impact parameters and their error.
Definition: BPhysHelper.cxx:957
xAOD::BPhysHelper::setLxyz
bool setLxyz(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
decay distance
Definition: BPhysHelper.cxx:934
xAOD::BPhysHelper::covariance
const TMatrixTSym< double > & covariance()
: Returns full covariance matrix
Definition: BPhysHelper.cxx:103
xAOD::BPhysHelper::cascadeVertex
const xAOD::Vertex * cascadeVertex(const size_t index)
Returns pointer to a cascade vertex.
Definition: BPhysHelper.cxx:694
xAOD::BPhysHelper::cacheCascadeVertices
bool cacheCascadeVertices()
: Cache cascade vertices
Definition: BPhysHelper.cxx:1316
xAOD::BPhysHelper::PV_MIN_Z0_BA
@ PV_MIN_Z0_BA
Definition: BPhysHelper.h:475
SUSY_SimplifiedModel_PreInclude.masses
dictionary masses
Definition: SUSY_SimplifiedModel_PreInclude.py:7
xAOD::BPhysHelper::refTrkOriginP
TVector3 refTrkOriginP(const size_t index) const
Returns perigee 3-momentum of the original track corresponding i-th refitted track.
Definition: BPhysHelper.cxx:194