ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::BPhysPVTools Class Reference

#include <BPhysPVTools.h>

Inheritance diagram for DerivationFramework::BPhysPVTools:
Collaboration diagram for DerivationFramework::BPhysPVTools:

Public Member Functions

 BPhysPVTools (const Trk::V0Tools *v0Tools)
 BPhysPVTools (const Trk::V0Tools *v0Tools, const xAOD::EventInfo *)
void SetSave3d (bool v)
StatusCode FillCandExistingVertices (xAOD::VertexContainer *vtxContainer, const xAOD::VertexContainer *pvContainer, int DoVertexType)
void FillBPhysHelperNULL (xAOD::BPhysHelper &vtx, const xAOD::VertexContainer *PvContainer, xAOD::BPhysHelper::pv_type pvtype, bool do3d=false) const
StatusCode FillCandwithRefittedVertices (xAOD::VertexContainer *vtxContainer, const xAOD::VertexContainer *pvContainer, xAOD::VertexContainer *refPvContainer, const Analysis::PrimaryVertexRefitter *, size_t in_PV_max, int DoVertexType)
void DecorateWithNULL (xAOD::VertexContainer *vtxContainer, const xAOD::VertexContainer *pvContainer, int DoVertexType) const
void DecorateWithDummyVertex (xAOD::VertexContainer *vtxContainer, const xAOD::VertexContainer *pvContainer, const xAOD::Vertex *Dummy, int DoVertexType, bool SetOrignal) const
void FillBPhysHelper (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.
size_t FindLowZIndex (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.
size_t FindLowA0Index (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.
size_t FindHighPtIndex (const std::vector< const xAOD::Vertex * > &PVlist) const
void SetMinNTracksInPV (size_t PV_minNTracks)
 Set the minimum number of tracks required for primary vertices to be considered for primary vertex association to a secondary vertex.
Amg::Vector3D GetBeamSpot () const
 Get the current beamspot position either from cache or from BeamCondSvc.
size_t FindLowZ0BAIndex (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.t.
double DistInZtoDOCA (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.
Amg::Vector3D DocaExtrapToBeamSpot (xAOD::BPhysHelper &obj) const
 Point of DOCA w.r.t.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static std::vector< const xAOD::Vertex * > GetGoodPV (const xAOD::VertexContainer *pvContainer)
 Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector containing only PVs of type 1 and 3 - HighPt and Pileup, which have at least PV_minNTracks tracks.
static void PrepareVertexLinks (xAOD::Vertex *theResult, const xAOD::TrackParticleContainer *importedTrackCollection)

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

const Trk::V0Toolsm_v0Tools
const xAOD::EventInfom_EvtData
size_t m_PV_minNTracks
 minimum number of tracks required in PVs considered
bool m_3dCalc
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 25 of file BPhysPVTools.h.

Constructor & Destructor Documentation

◆ BPhysPVTools() [1/2]

DerivationFramework::BPhysPVTools::BPhysPVTools ( const Trk::V0Tools * v0Tools)

Definition at line 18 of file BPhysPVTools.cxx.

18 :
19 AthMessaging("BPhysPVTools"),
20 m_v0Tools(v0Tools), m_EvtData(nullptr), m_PV_minNTracks(0),
21 m_3dCalc(false)
22{
23}
AthMessaging()
Default constructor:
const xAOD::EventInfo * m_EvtData
size_t m_PV_minNTracks
minimum number of tracks required in PVs considered
const Trk::V0Tools * m_v0Tools

◆ BPhysPVTools() [2/2]

DerivationFramework::BPhysPVTools::BPhysPVTools ( const Trk::V0Tools * v0Tools,
const xAOD::EventInfo * eventInfo )

Definition at line 25 of file BPhysPVTools.cxx.

25 :
26 AthMessaging("BPhysPVTools"),
27 m_v0Tools(v0Tools), m_EvtData(eventInfo), m_PV_minNTracks(0),
28 m_3dCalc(false)
29{
30}

Member Function Documentation

◆ DecorateWithDummyVertex()

void DerivationFramework::BPhysPVTools::DecorateWithDummyVertex ( xAOD::VertexContainer * vtxContainer,
const xAOD::VertexContainer * pvContainer,
const xAOD::Vertex * Dummy,
int DoVertexType,
bool SetOrignal ) const

Definition at line 102 of file BPhysPVTools.cxx.

104 {
105 const bool doPt = (DoVertexType & 1) != 0;
106 const bool doA0 = (DoVertexType & 2) != 0;
107 const bool doZ0 = (DoVertexType & 4) != 0;
108 const bool doZ0BA = (DoVertexType & 8) != 0;
109
110 xAOD::VertexContainer::iterator vtxItr = vtxContainer->begin();
111 for(; vtxItr!=vtxContainer->end(); ++vtxItr) {
112 xAOD::BPhysHelper vtx(*vtxItr);
113
114 // 1) pT error
115 double ptErr = m_v0Tools->pTError( vtx.vtx() );
116 BPHYS_CHECK( vtx.setPtErr(ptErr) );
117 if(doPt) {
118 // 2.a) the first PV with the largest sum pT.
119 FillBPhysHelper(vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2, 0);
120 if(SetOrignal) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2);
121 }
122
123 if(doA0) {
124 // 2.b) the closest in 3D:
125 FillBPhysHelper(vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_A0, 0);
126 if(SetOrignal) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_A0);
127 }
128
129 if(doZ0) {
130 FillBPhysHelper(vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0, 0);
131 if(SetOrignal) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0);
132 }
133
134 if(doZ0BA) {
135 FillBPhysHelper(vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA, 0);
136 if(SetOrignal) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA);
137 }
138 }
139}
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void FillBPhysHelper(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.

◆ DecorateWithNULL()

void DerivationFramework::BPhysPVTools::DecorateWithNULL ( xAOD::VertexContainer * vtxContainer,
const xAOD::VertexContainer * pvContainer,
int DoVertexType ) const

Definition at line 141 of file BPhysPVTools.cxx.

142 {
143 const bool doPt = (DoVertexType & 1) != 0;
144 const bool doA0 = (DoVertexType & 2) != 0;
145 const bool doZ0 = (DoVertexType & 4) != 0;
146 const bool doZ0BA = (DoVertexType & 8) != 0;
147 xAOD::VertexContainer::iterator vtxItr = vtxContainer->begin();
148 for(; vtxItr!=vtxContainer->end(); ++vtxItr) {
149 xAOD::BPhysHelper vtx(*vtxItr);
150
151 // 1) pT error
152 double ptErr = m_v0Tools->pTError( vtx.vtx() );
153 BPHYS_CHECK( vtx.setPtErr(ptErr) );
154 if(doPt) {
155 // 2.a) the first PV with the largest sum pT.
157 }
158
159 if(doA0) {
160 // 2.b) the closest in 3D:
162 }
163
164 if(doZ0) {
166 }
167 if(doZ0BA) {
169 }
170 }
171}
void FillBPhysHelperNULL(xAOD::BPhysHelper &vtx, const xAOD::VertexContainer *PvContainer, xAOD::BPhysHelper::pv_type pvtype, bool do3d=false) const

◆ DistInZtoDOCA()

double DerivationFramework::BPhysPVTools::DistInZtoDOCA ( 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.

the beamline.

Definition at line 503 of file BPhysPVTools.cxx.

503 {
504
505 Amg::Vector3D pv = vertex->position();
507 Amg::Vector3D vec = pv - xDOCA;
508 return vec.z();
509}
std::vector< size_t > vec
Amg::Vector3D DocaExtrapToBeamSpot(xAOD::BPhysHelper &obj) const
Point of DOCA w.r.t.
Eigen::Matrix< double, 3, 1 > Vector3D

◆ DocaExtrapToBeamSpot()

Amg::Vector3D DerivationFramework::BPhysPVTools::DocaExtrapToBeamSpot ( xAOD::BPhysHelper & obj) const

Point of DOCA w.r.t.

the beamline backward extrapolated along the B candidate's momentum direction.

Definition at line 513 of file BPhysPVTools.cxx.

513 {
514
515 Amg::Vector3D xDOCA(-99999., -99999., -99999.);
516 TVector3 totP(obj.totalP());
517 Amg::Vector3D pSV(totP.X(), totP.Y(), totP.Z());
518 Amg::Vector3D pT(pSV.x(), pSV.y(), 0.);
519 if ( pT.mag2() > 0 ) {
521 Amg::Vector3D xSV = m_v0Tools->vtx(obj.vtx());
522 Amg::Vector3D xT(xSV.x()-xBS.x(), xSV.y()-xBS.y(), 0.);
523 xDOCA = xSV - pSV*pT.dot(xT)/pT.mag2();
524 } else {
525 ATH_MSG_WARNING("DocaExtrapToBeamSpot: pT == 0.");
526 }
527 return xDOCA;
528}
#define ATH_MSG_WARNING(x)
Amg::Vector3D GetBeamSpot() const
Get the current beamspot position either from cache or from BeamCondSvc.

◆ FillBPhysHelper()

void DerivationFramework::BPhysPVTools::FillBPhysHelper ( xAOD::BPhysHelper & vtx,
const xAOD::Vertex * refPV,
const xAOD::VertexContainer * refPvContainer,
xAOD::BPhysHelper::pv_type pvtype,
int refitCode ) const

Fills the BPhysHelper object with the standard parameters.

Definition at line 32 of file BPhysPVTools.cxx.

34 {
35
36 BPHYS_CHECK( vtx.setPv ( PV, PvContainer, pvtype ) );
37
38 // cout << "BPhysPVTools::FillBPhysHelper for pvtype = " << pvtype << endl;
39
40 // set variables calculated from PV
41 if(m_3dCalc){
42 BPHYS_CHECK( vtx.setLxyz ( m_v0Tools->lxyz (vtx.vtx(), PV), pvtype ) );
43 BPHYS_CHECK( vtx.setLxyzErr ( m_v0Tools->lxyzError (vtx.vtx(), PV), pvtype ) );
44 }
45 BPHYS_CHECK( vtx.setLxy ( m_v0Tools->lxy (vtx.vtx(), PV), pvtype ) );
46 BPHYS_CHECK( vtx.setLxyErr ( m_v0Tools->lxyError (vtx.vtx(), PV), pvtype ) );
47 BPHYS_CHECK( vtx.setA0 ( m_v0Tools->a0 (vtx.vtx(), PV), pvtype ) );
48 BPHYS_CHECK( vtx.setA0Err ( m_v0Tools->a0Error (vtx.vtx(), PV), pvtype ) );
49 BPHYS_CHECK( vtx.setA0xy ( m_v0Tools->a0xy (vtx.vtx(), PV), pvtype ) );
50 BPHYS_CHECK( vtx.setA0xyErr( m_v0Tools->a0xyError (vtx.vtx(), PV), pvtype ) );
51 BPHYS_CHECK( vtx.setZ0 ( m_v0Tools->a0z (vtx.vtx(), PV), pvtype ) );
52 BPHYS_CHECK( vtx.setZ0Err ( m_v0Tools->a0zError (vtx.vtx(), PV), pvtype ) );
53 BPHYS_CHECK( vtx.setRefitPVStatus ( refitCode, pvtype ) );
54
55}
float setZ0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter
bool setLxyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
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 ...
float setZ0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter error
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
float setA0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the 3D and transverse impact parameters and their error.
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.
float setA0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
3D impact parameter error
bool setRefitPVStatus(int code, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the exitCode of the refitter for vertex of type pv_type.
float setA0xyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter error
float setA0xy(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter
bool setLxyz(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
decay distance
bool setLxyzErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error

◆ FillBPhysHelperNULL()

void DerivationFramework::BPhysPVTools::FillBPhysHelperNULL ( xAOD::BPhysHelper & vtx,
const xAOD::VertexContainer * PvContainer,
xAOD::BPhysHelper::pv_type pvtype,
bool do3d = false ) const

Definition at line 57 of file BPhysPVTools.cxx.

59 {
60
61 const xAOD::Vertex* PV = nullptr;
62 BPHYS_CHECK( vtx.setPv ( PV, PvContainer, pvtype ) );
63 constexpr float errConst = std::numeric_limits<float>::lowest();
64 // set variables claculated from PV
65 if(do3d){
66 BPHYS_CHECK( vtx.setLxyz ( errConst, pvtype ) );
67 BPHYS_CHECK( vtx.setLxyzErr ( errConst, pvtype ) );
68 }
69 BPHYS_CHECK( vtx.setLxy ( errConst, pvtype ) );
70 BPHYS_CHECK( vtx.setLxyErr ( errConst, pvtype ) );
71 BPHYS_CHECK( vtx.setA0 ( errConst, pvtype ) );
72 BPHYS_CHECK( vtx.setA0Err ( errConst, pvtype ) );
73 BPHYS_CHECK( vtx.setA0xy ( errConst, pvtype ) );
74 BPHYS_CHECK( vtx.setA0xyErr( errConst, pvtype ) );
75 BPHYS_CHECK( vtx.setZ0 ( errConst, pvtype ) );
76 BPHYS_CHECK( vtx.setZ0Err ( errConst, pvtype ) );
77 BPHYS_CHECK( vtx.setRefitPVStatus ( 0, pvtype ) );
78}
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ FillCandExistingVertices()

StatusCode DerivationFramework::BPhysPVTools::FillCandExistingVertices ( xAOD::VertexContainer * vtxContainer,
const xAOD::VertexContainer * pvContainer,
int DoVertexType )

Definition at line 173 of file BPhysPVTools.cxx.

174 {
175
176
177
178 //----------------------------------------------------
179 // decorate the vertex
180 //----------------------------------------------------
181 // loop over candidates -- Don't apply PV_minNTracks requirement here
182 // because it may result in exclusion of the high-pt PV.
183 const std::vector<const xAOD::Vertex*> GoodPVs = GetGoodPV(pvContainer);
184
185
186 if(GoodPVs.empty() == false) {
187
188 const bool doPt = (DoVertexType & 1) != 0;
189 const bool doA0 = (DoVertexType & 2) != 0;
190 const bool doZ0 = (DoVertexType & 4) != 0;
191 const bool doZ0BA = (DoVertexType & 8) != 0;
192
193 xAOD::VertexContainer::iterator vtxItr = vtxContainer->begin();
194 for(; vtxItr!=vtxContainer->end(); ++vtxItr) {
195 xAOD::BPhysHelper vtx(*vtxItr);
196
197 // 1) pT error
198 double ptErr = m_v0Tools->pTError( vtx.vtx() );
199 BPHYS_CHECK( vtx.setPtErr(ptErr) );
200
201 // 2) refit the primary vertex and set the related decorations.
202 if(doPt) {
203 size_t highPtindex = FindHighPtIndex(GoodPVs); //Should be 0 in PV ordering
204 // 2.a) the first PV with the largest sum pT.
205 FillBPhysHelper(vtx, GoodPVs[highPtindex], pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2, 0);
206 }
207
208 if(doA0) {
209 // 2.b) the closest in 3D:
210 size_t lowA0 = FindLowA0Index(vtx, GoodPVs, m_PV_minNTracks);
211 FillBPhysHelper(vtx, GoodPVs[lowA0], pvContainer, xAOD::BPhysHelper::PV_MIN_A0, 0);
212 }
213
214 if(doZ0) {
215 size_t lowZ = FindLowZIndex(vtx, GoodPVs, m_PV_minNTracks);
216 FillBPhysHelper(vtx, GoodPVs[lowZ], pvContainer, xAOD::BPhysHelper::PV_MIN_Z0, 0);
217 }
218
219 if(doZ0BA) {
220 size_t lowZBA = FindLowZ0BAIndex(vtx, GoodPVs, m_PV_minNTracks);
221 if ( lowZBA < GoodPVs.size() ) { // safety against vector index out-of-bounds
222 FillBPhysHelper(vtx, GoodPVs[lowZBA], pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA, 0);
223 } else {
224 // nothing found -- fill nullptr
226 }
227 }
228
229 }// end of loop over vertices
230 } //end of check for vertices
231 else {
232 // cout << "Warning: DerivationFramework::BPhysPVTools::FillCandExistingVertices No Primary Vertices Found trying to decorate wilth dummy \n";
233 if(pvContainer->empty()) return StatusCode::FAILURE;
234 const xAOD::Vertex* dummy = pvContainer->at(0); //No good vertices so last vertex must be dummy
235 DecorateWithDummyVertex(vtxContainer, pvContainer, dummy, DoVertexType, false);
236 }
237 return StatusCode::SUCCESS;
238}
const T * at(size_type n) const
Access an element, as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
size_t FindLowZ0BAIndex(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....
size_t FindLowZIndex(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.
size_t FindLowA0Index(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.
size_t FindHighPtIndex(const std::vector< const xAOD::Vertex * > &PVlist) const
void DecorateWithDummyVertex(xAOD::VertexContainer *vtxContainer, const xAOD::VertexContainer *pvContainer, const xAOD::Vertex *Dummy, int DoVertexType, bool SetOrignal) const
static std::vector< const xAOD::Vertex * > GetGoodPV(const xAOD::VertexContainer *pvContainer)
Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector contain...

◆ FillCandwithRefittedVertices()

StatusCode DerivationFramework::BPhysPVTools::FillCandwithRefittedVertices ( xAOD::VertexContainer * vtxContainer,
const xAOD::VertexContainer * pvContainer,
xAOD::VertexContainer * refPvContainer,
const Analysis::PrimaryVertexRefitter * pvRefitter,
size_t in_PV_max,
int DoVertexType )

Definition at line 241 of file BPhysPVTools.cxx.

243 {
244
245
246 //----------------------------------------------------
247 // decorate the vertex
248 //----------------------------------------------------
249 // loop over candidates -- Don't apply PV_minNTracks requirement here
250 // because it may result in exclusion of the high-pt PV.
251 std::vector<const xAOD::Vertex*> goodPrimaryVertices = GetGoodPV(pvContainer);
252
253 /*
254 cout << "BPhysPVTools::FillCandwithRefittedVertices: #PVs: all: "
255 << pvContainer->size() << " ref: " << refPvContainer->size()
256 << " good: " << goodPrimaryVertices.size()
257 << " PV_minNTracks: " << m_PV_minNTracks << endl;
258 */
259 if(goodPrimaryVertices.empty() == false) {
260
261 size_t pVmax =std::min(in_PV_max, goodPrimaryVertices.size());
262 std::vector<const xAOD::Vertex*> refPVvertexes;
263 std::vector<xAOD::Vertex*> refPVvertexes_toDelete;
264 std::vector<int> exitCode;
265 refPVvertexes.reserve(pVmax);
266 refPVvertexes_toDelete.reserve(pVmax);
267 exitCode.reserve(pVmax);
268
269 bool doPt = (DoVertexType & 1) != 0;
270 bool doA0 = (DoVertexType & 2) != 0;
271 bool doZ0 = (DoVertexType & 4) != 0;
272 bool doZ0BA = (DoVertexType & 8) != 0;
273
274 xAOD::VertexContainer::iterator vtxItr = vtxContainer->begin();
275 for(; vtxItr!=vtxContainer->end(); ++vtxItr) {
276 xAOD::BPhysHelper vtx(*vtxItr);
277
278 // 1) pT error
279 double ptErr = m_v0Tools->pTError( vtx.vtx() );
280 BPHYS_CHECK( vtx.setPtErr(ptErr) );
281
282 for(size_t i =0; i < pVmax ; i++) {
283 const xAOD::Vertex* oldPV = goodPrimaryVertices.at(i);
284 //when set to false this will return nullptr when a new vertex is not required
285 int exit =0;
286 xAOD::Vertex* refPV = pvRefitter->refitVertex(oldPV, vtx.vtx(), false, &exit);
287 exitCode.push_back(exit);
288 //I want positioning to match the goodPrimaryVertices
289 if(refPV == nullptr){
290 refPVvertexes.push_back(oldPV);
291 refPVvertexes_toDelete.push_back(nullptr);
292 }else{
293 refPVvertexes.push_back(refPV);
294 refPVvertexes_toDelete.push_back(refPV);
295 }
296 }
297
298 // 2) refit the primary vertex and set the related decorations.
299
300 size_t highPtindex = doPt ? FindHighPtIndex(refPVvertexes) : 9999999; //Should be 0 in PV ordering
301 size_t lowA0 = doA0 ?
302 FindLowA0Index(vtx, refPVvertexes, m_PV_minNTracks) : 9999998;
303 size_t lowZ = doZ0 ?
304 FindLowZIndex(vtx, refPVvertexes, m_PV_minNTracks) : 9999997;
305 size_t lowZBA = doZ0BA ?
306 FindLowZ0BAIndex(vtx, refPVvertexes, m_PV_minNTracks) : 9999996;
307 /*
308 cout << "BPhysPVTools::FillCandwithRefittedVertices: in_PV_max/pVMax = "
309 << in_PV_max << ", " << pVmax << endl;
310 cout << "BPhysPVTools::FillCandwithRefittedVertices: m_PV_minNTracks = "
311 << m_PV_minNTracks << endl;
312 cout << "BPhysPVTools::FillCandwithRefittedVertices: hPt,lowA0/Z/ZBA = "
313 << highPtindex << ", "
314 << lowA0 << ", " << lowZ << ", " << lowZBA << " "
315 << (lowA0 != lowZ ? "1!" : " ")
316 << (lowA0 != lowZBA ? "2!" : " ")
317 << (lowZ != lowZBA ? "3!" : " ")
318 << (highPtindex != lowA0 ? "4!" : " ")
319 << (highPtindex != lowZ ? "5!" : " ")
320 << (highPtindex != lowZBA ? "6!" : " ")
321 << endl;
322 */
323 if(doPt) {
324 //Choose old PV container if not refitted
325 const xAOD::VertexContainer* ParentContainer =
326 (refPVvertexes_toDelete.at(highPtindex)) ? refPvContainer : pvContainer;
327 if(ParentContainer == refPvContainer) //if refitted add to refitted container
328 refPvContainer->push_back(refPVvertexes_toDelete.at(highPtindex)); // store the new vertex
329
330 FillBPhysHelper(vtx, refPVvertexes[highPtindex],
331 ParentContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2, exitCode[highPtindex]);
332 vtx.setOrigPv(goodPrimaryVertices[highPtindex], pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2);
333 }
334
335 if(doA0) {
336 const xAOD::VertexContainer* ParentContainer =
337 (refPVvertexes_toDelete.at(lowA0)) ? refPvContainer : pvContainer;
338 if(ParentContainer == refPvContainer && highPtindex!=lowA0)
339 refPvContainer->push_back(refPVvertexes_toDelete.at(lowA0)); // store the new vertex
340
341 FillBPhysHelper(vtx, refPVvertexes[lowA0],
342 ParentContainer, xAOD::BPhysHelper::PV_MIN_A0, exitCode[lowA0]);
343 vtx.setOrigPv(goodPrimaryVertices[lowA0], pvContainer, xAOD::BPhysHelper::PV_MIN_A0);
344 }
345
346
347 // 2.c) the closest in Z:
348 if(doZ0) {
349
350 const xAOD::VertexContainer* ParentContainer =
351 (refPVvertexes_toDelete.at(lowZ)) ? refPvContainer : pvContainer;
352 if(ParentContainer == refPvContainer && highPtindex!=lowZ && lowZ!=lowA0)
353 refPvContainer->push_back(refPVvertexes_toDelete.at(lowZ)); // store the new vertex
354
355 FillBPhysHelper(vtx, refPVvertexes[lowZ],
356 ParentContainer, xAOD::BPhysHelper::PV_MIN_Z0, exitCode[lowZ]);
357 vtx.setOrigPv(goodPrimaryVertices[lowZ], pvContainer, xAOD::BPhysHelper::PV_MIN_Z0);
358 }
359
360 // 2.d) the closest in Z (DOCA w.r.t. beam axis):
361 if (doZ0BA) {
362 if ( lowZBA < pVmax ) { // safety for vector indices
363 const xAOD::VertexContainer* ParentContainer =
364 (refPVvertexes_toDelete.at(lowZBA)) ?
365 refPvContainer : pvContainer;
366 if (ParentContainer == refPvContainer && highPtindex!=lowZBA
367 && lowZBA!=lowA0 && lowZBA != lowZ) {
368 // store the new vertex
369 refPvContainer->push_back(refPVvertexes_toDelete.at(lowZBA));
370 }
371 FillBPhysHelper(vtx, refPVvertexes[lowZBA],
372 ParentContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA,
373 exitCode[lowZBA]);
374 vtx.setOrigPv(goodPrimaryVertices[lowZBA], pvContainer,
376 } else {
377 // nothing found -- fill nullptr
379 // nothing found -- fill dummy vertex (type-0 vertex)
380 // if(pvContainer->empty()) return StatusCode::FAILURE;
381 // const xAOD::Vertex* dummy = pvContainer->at(pvContainer->size()-1); //No good vertices so last vertex must be dummy
382 // FillBPhysHelper(vtx, dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA, 0);
383 // vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA);
384 }
385 }
386
387 //nullptrify ptrs we want to keep so these won't get deleted
388 //"delete nullptr" is valid in C++ and does nothing so this is quicker than a lot of if statements
389 if(doPt) refPVvertexes_toDelete[highPtindex] = nullptr;
390 if(doA0) refPVvertexes_toDelete[lowA0] = nullptr;
391 if(doZ0) refPVvertexes_toDelete[lowZ] = nullptr;
392 if(doZ0BA && lowZBA < pVmax) refPVvertexes_toDelete[lowZBA] = nullptr;
393 //Loop over toDELETE container, anything that is used or was not refitted is nullptr
394 //This cleans up all extra vertices that were created and not used
395 for(const xAOD::Vertex* ptr : refPVvertexes_toDelete) {
396 delete ptr;
397 }
398 refPVvertexes.clear();// Clear lists of now dangling ptrs
399 refPVvertexes_toDelete.clear();
400 exitCode.clear();
401 } // end of loop over vertices
402
403 } else {
404// cout << "Warning: DerivationFramework::BPhysPVTools::FillCandwithRefittedVertices No Primary Vertices Found trying to decorate wilth dummy \n";
405 if(pvContainer->empty()) return StatusCode::FAILURE;
406 const xAOD::Vertex* dummy = pvContainer->at(0); //No good vertices so last vertex must be dummy
407 DecorateWithDummyVertex(vtxContainer, pvContainer, dummy, DoVertexType, true);
408 }
409
410 return StatusCode::SUCCESS;
411}
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void * ptr(T *p)
Definition SGImplSvc.cxx:74
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".

◆ FindHighPtIndex()

size_t DerivationFramework::BPhysPVTools::FindHighPtIndex ( const std::vector< const xAOD::Vertex * > & PVlist) const

Definition at line 413 of file BPhysPVTools.cxx.

413 {
414 // it SHOULD be the first one in the collection but it shouldn't take long to do a quick check
415 for(size_t i =0; i<PVlist.size(); i++) {
416 if(PVlist[i]->vertexType() == xAOD::VxType::PriVtx) return i;
417 }
418 ATH_MSG_ERROR("High Pt Primary vertex not found - this should not happen");
419 return std::numeric_limits<std::size_t>::max(); //This should not happen
420}
#define ATH_MSG_ERROR(x)
@ PriVtx
Primary vertex.

◆ FindLowA0Index()

size_t DerivationFramework::BPhysPVTools::FindLowA0Index ( 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 at line 422 of file BPhysPVTools.cxx.

424 {
425 size_t lowA0 = 0;
426 if(PVlist.empty()) {
427 lowA0=std::numeric_limits<std::size_t>::max();
428 return lowA0;
429 }
430 size_t size = PVlist.size();
431 double lowA0calc = m_v0Tools->a0(Obj.vtx(), PVlist[0]);
432 for(size_t i =1; i<size; i++) {
433 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
434 double a0 = m_v0Tools->a0(Obj.vtx(), PVlist[i]);
435 if(a0 < lowA0calc) {
436 lowA0calc = a0;
437 lowA0 =i;
438 }
439 }
440 }
441 return lowA0;
442}
double a0
Definition globals.cxx:27

◆ FindLowZ0BAIndex()

size_t DerivationFramework::BPhysPVTools::FindLowZ0BAIndex ( 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.t.

the beamline and the PV.

Definition at line 483 of file BPhysPVTools.cxx.

485 {
486
487 size_t ilowZ0BA = std::numeric_limits<std::size_t>::max();
488 double lowZ0BAcalc = std::numeric_limits<double>::max();
489 for (size_t i = 0; i<PVlist.size(); ++i) {
490 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
491 double z0BA = m_v0Tools->a0(obj.vtx(), PVlist[i]);
492 if (z0BA < lowZ0BAcalc) {
493 lowZ0BAcalc = z0BA;
494 ilowZ0BA = i;
495 }
496 }
497 }
498 return ilowZ0BA;
499}

◆ FindLowZIndex()

size_t DerivationFramework::BPhysPVTools::FindLowZIndex ( 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 at line 80 of file BPhysPVTools.cxx.

82 {
83 size_t lowZ = 0;
84 if(PVlist.empty()) {
85 lowZ=std::numeric_limits<std::size_t>::max();
86 return lowZ;
87 }
88 size_t size = PVlist.size();
89 double lowA0zcalc = fabs(m_v0Tools->a0z (Obj.vtx(), PVlist[0]));
90 for(size_t i =1; i<size; i++) {
91 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
92 double a0z = fabs(m_v0Tools->a0z(Obj.vtx(), PVlist[i]));
93 if(a0z < lowA0zcalc) {
94 lowA0zcalc = a0z;
95 lowZ =i;
96 }
97 }
98 }
99 return lowZ;
100}

◆ GetBeamSpot()

Amg::Vector3D DerivationFramework::BPhysPVTools::GetBeamSpot ( ) const
nodiscard

Get the current beamspot position either from cache or from BeamCondSvc.

Before processing a new event, make sure to call GetBeamSpot();

Definition at line 472 of file BPhysPVTools.cxx.

472 {
473
474 if(m_EvtData) return Amg::Vector3D(m_EvtData->beamPosX(), m_EvtData->beamPosY(), m_EvtData->beamPosZ());
475 else {
476 static const Amg::Vector3D defaultBS(-10000.,-10000.,-10000.);
477 return defaultBS;
478 }
479}

◆ GetGoodPV()

vector< const xAOD::Vertex * > DerivationFramework::BPhysPVTools::GetGoodPV ( const xAOD::VertexContainer * pvContainer)
static

Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector containing only PVs of type 1 and 3 - HighPt and Pileup, which have at least PV_minNTracks tracks.

Definition at line 444 of file BPhysPVTools.cxx.

444 {
448 std::vector<const xAOD::Vertex*> goodPrimaryVertices;
449 goodPrimaryVertices.reserve(pvContainer->size());
450
451 for (auto ptr = pvContainer->begin(); ptr!= pvContainer->end(); ++ptr) {
452 VertexType thistype = (*ptr)->vertexType();
453 if ( thistype == Pileupvtx || thistype == Pvtx ) {
454 goodPrimaryVertices.push_back(*ptr);
455 } else {
456// cout << "vertex type " << thistype << endl;
457 }
458 }
459 return goodPrimaryVertices;
460}
size_type size() const noexcept
Returns the number of elements in the collection.
VertexType
Vertex types.
@ PileUp
Pile-up vertex.

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ PrepareVertexLinks()

void DerivationFramework::BPhysPVTools::PrepareVertexLinks ( xAOD::Vertex * theResult,
const xAOD::TrackParticleContainer * importedTrackCollection )
static

Definition at line 530 of file BPhysPVTools.cxx.

532{
533 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
534 const auto &trkprtl = theResult->trackParticleLinks();
535 for(unsigned int i=0; i< trkprtl.size(); i++)
536 {
537 ElementLink<DataVector<xAOD::TrackParticle> > mylink=trkprtl[i]; //makes a copy (non-const)
538 mylink.setStorableObject(*importedTrackCollection, true);
539 newLinkVector.push_back( mylink );
540 }
541 theResult->clearTracks();
542 theResult->setTrackParticleLinks( newLinkVector );
543}
void setTrackParticleLinks(const TrackParticleLinks_t &trackParticles)
Set all track particle links at once.
void clearTracks()
Remove all tracks from the vertex.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ SetMinNTracksInPV()

void DerivationFramework::BPhysPVTools::SetMinNTracksInPV ( size_t PV_minNTracks)

Set the minimum number of tracks required for primary vertices to be considered for primary vertex association to a secondary vertex.

Note that this requirement will not be applied for finding the vertex with the highest pT sum (FindHighPtIndex()) since it would possibly exclude this vertex which has been marked earlier in the tool chain.

Definition at line 464 of file BPhysPVTools.cxx.

465{
466
467 m_PV_minNTracks = PV_minNTracks;
468}

◆ SetSave3d()

void DerivationFramework::BPhysPVTools::SetSave3d ( bool v)
inline

Definition at line 40 of file BPhysPVTools.h.

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_3dCalc

bool DerivationFramework::BPhysPVTools::m_3dCalc
private

Definition at line 34 of file BPhysPVTools.h.

◆ m_EvtData

const xAOD::EventInfo* DerivationFramework::BPhysPVTools::m_EvtData
private

Definition at line 29 of file BPhysPVTools.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_PV_minNTracks

size_t DerivationFramework::BPhysPVTools::m_PV_minNTracks
private

minimum number of tracks required in PVs considered

Definition at line 32 of file BPhysPVTools.h.

◆ m_v0Tools

const Trk::V0Tools* DerivationFramework::BPhysPVTools::m_v0Tools
private

Definition at line 28 of file BPhysPVTools.h.


The documentation for this class was generated from the following files: