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

#include <BPhysPVCascadeTools.h>

Inheritance diagram for DerivationFramework::BPhysPVCascadeTools:
Collaboration diagram for DerivationFramework::BPhysPVCascadeTools:

Public Member Functions

 BPhysPVCascadeTools (const CascadeTools *cascadeTools)
 BPhysPVCascadeTools (const CascadeTools *cascadeTools, const xAOD::EventInfo *)
void ProcessVertex (const std::vector< TLorentzVector > &mom, Amg::MatrixX cov, xAOD::BPhysHypoHelper &vtx, xAOD::BPhysHelper::pv_type pvtype, double mass) const
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.
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.
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.
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 (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.t.
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.
Amg::Vector3D DocaExtrapToBeamSpot (const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj) const
 Point of DOCA w.r.t.
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)
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

template<size_t NTracks>
static bool VerticesMatchTracks (const xAOD::Vertex *v1, const xAOD::Vertex *v2)
template<size_t NTracks>
static const xAOD::VertexFindVertex (const xAOD::VertexContainer *c, const xAOD::Vertex *v)
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 (Trk::VxCascadeInfo *result, const xAOD::TrackParticleContainer *importedTrackCollection)
static void PrepareVertexLinks (Trk::VxCascadeInfo *result, const std::vector< const xAOD::TrackParticleContainer * > &)
static std::vector< const xAOD::TrackParticle * > CollectAllChargedTracks (const std::vector< xAOD::Vertex * > &cascadeVertices)
static void SetVectorInfo (xAOD::BPhysHelper &, const Trk::VxCascadeInfo *)
static bool uniqueCollection (const std::vector< const xAOD::TrackParticle * > &)
static bool uniqueCollection (const std::vector< const xAOD::TrackParticle * > &, const std::vector< const xAOD::TrackParticle * > &)
static bool LinkVertices (SG::AuxElement::Decorator< VertexLinkVector > &decor, const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer, const xAOD::Vertex *vert)

Public Attributes

bool m_copyAllVertices

Private Types

typedef ElementLink< xAOD::VertexContainerVertexLink
typedef std::vector< VertexLinkVertexLinkVector

Private Member Functions

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

Private Attributes

const CascadeToolsm_cascadeTools
const xAOD::EventInfom_eventInfo
size_t m_PV_minNTracks
 minimum number of tracks required in PVs considered
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 30 of file BPhysPVCascadeTools.h.

Member Typedef Documentation

◆ VertexLink

◆ VertexLinkVector

Definition at line 32 of file BPhysPVCascadeTools.h.

Constructor & Destructor Documentation

◆ BPhysPVCascadeTools() [1/2]

DerivationFramework::BPhysPVCascadeTools::BPhysPVCascadeTools ( const CascadeTools * cascadeTools)

Definition at line 16 of file BPhysPVCascadeTools.cxx.

16 :
17 AthMessaging("BPhysPVCascadeTools"),
18 m_cascadeTools(cascadeTools), m_eventInfo(nullptr), m_PV_minNTracks(0),
20{
21}
AthMessaging()
Default constructor:
size_t m_PV_minNTracks
minimum number of tracks required in PVs considered

◆ BPhysPVCascadeTools() [2/2]

DerivationFramework::BPhysPVCascadeTools::BPhysPVCascadeTools ( const CascadeTools * cascadeTools,
const xAOD::EventInfo * eventinfo )

Definition at line 23 of file BPhysPVCascadeTools.cxx.

24 :
25 AthMessaging("BPhysPVCascadeTools"),
26 m_cascadeTools(cascadeTools), m_eventInfo(eventinfo), m_PV_minNTracks(0),
28{
29}

Member Function Documentation

◆ CollectAllChargedTracks()

std::vector< const xAOD::TrackParticle * > DerivationFramework::BPhysPVCascadeTools::CollectAllChargedTracks ( const std::vector< xAOD::Vertex * > & cascadeVertices)
static

Definition at line 245 of file BPhysPVCascadeTools.cxx.

246{
247 std::vector<const xAOD::TrackParticle*> exclTrk;
248 for( size_t jt=0; jt<cascadeVertices.size(); jt++) {
249 for( size_t it=0; it<cascadeVertices[jt]->vxTrackAtVertex().size(); it++) {
250 if(cascadeVertices[jt]->trackParticle(it)->charge() != 0) exclTrk.push_back(cascadeVertices[jt]->trackParticle(it));
251 }
252 }
253 return exclTrk;
254}
double charge(const T &p)
Definition AtlasPID.h:997
size_t size() const
Number of registered mappings.

◆ DistInZtoDOCA()

double DerivationFramework::BPhysPVCascadeTools::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.

the beamline.

Definition at line 173 of file BPhysPVCascadeTools.cxx.

173 {
174
175 Amg::Vector3D pv = vertex->position();
176 Amg::Vector3D xDOCA = DocaExtrapToBeamSpot(mom, obj);
177 Amg::Vector3D vec = pv - xDOCA;
178 return vec.z();
179}
std::vector< size_t > vec
Amg::Vector3D DocaExtrapToBeamSpot(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj) const
Point of DOCA w.r.t.
Eigen::Matrix< double, 3, 1 > Vector3D

◆ DocaExtrapToBeamSpot()

Amg::Vector3D DerivationFramework::BPhysPVCascadeTools::DocaExtrapToBeamSpot ( const std::vector< TLorentzVector > & mom,
const xAOD::BPhysHelper & obj ) const

Point of DOCA w.r.t.

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

Definition at line 182 of file BPhysPVCascadeTools.cxx.

182 {
183
184 Amg::Vector3D xDOCA(-99999., -99999., -99999.);
185 TLorentzVector totalMom;
186 unsigned int NTrk = mom.size();
187 for( unsigned int it=0; it<NTrk; it++) totalMom += mom[it];
188 TVector3 totP = totalMom.Vect();
189 Amg::Vector3D pSV(totP.X(), totP.Y(), totP.Z());
190 Amg::Vector3D pT(pSV.x(), pSV.y(), 0.);
191 if ( pT.mag2() > 0 ) {
193 Amg::Vector3D xSV = obj.vtx()->position();
194 Amg::Vector3D xT(xSV.x()-xBS.x(), xSV.y()-xBS.y(), 0.);
195 xDOCA = xSV - pSV*pT.dot(xT)/pT.mag2();
196 } else {
197 std::cout << "BPhysPVCascadeTools::DocaExtrapToBeamSpot: WARNING pT == 0."
198 << std::endl;
199 }
200 return xDOCA;
201}
Amg::Vector3D GetBeamSpot() const
Get the current beamspot position either from cache or from BeamCondSvc.

◆ FillBPhysHelper()

void DerivationFramework::BPhysPVCascadeTools::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 refitCode ) const

Fills the BPhysHelper object with the standard parameters.

Definition at line 31 of file BPhysPVCascadeTools.cxx.

33 {
34
35 BPHYS_CHECK( vtx.setPv ( PV, PvContainer, pvtype ) );
36
37 // cout << "BPhysPVCascadeTools::FillBPhysHelper for pvtype = " << pvtype << endl;
38 // cout << "lxy " << m_cascadeTools->lxy(mom, vtx.vtx(), PV) << " error " << m_cascadeTools->lxyError(mom, cov, vtx.vtx(), PV) << endl;
39
40 // set variables calculated from PV
41 BPHYS_CHECK( vtx.setLxy ( m_cascadeTools->lxy (mom, vtx.vtx(), PV), pvtype ) );
42 BPHYS_CHECK( vtx.setLxyErr ( m_cascadeTools->lxyError (mom, cov, vtx.vtx(), PV), pvtype ) );
43 BPHYS_CHECK( vtx.setA0 ( m_cascadeTools->a0 (mom, vtx.vtx(), PV), pvtype ) );
44 BPHYS_CHECK( vtx.setA0Err ( m_cascadeTools->a0Error (mom, cov, vtx.vtx(), PV), pvtype ) );
45 BPHYS_CHECK( vtx.setA0xy ( m_cascadeTools->a0xy (mom, vtx.vtx(), PV), pvtype ) );
46 BPHYS_CHECK( vtx.setA0xyErr( m_cascadeTools->a0xyError (mom, cov, vtx.vtx(), PV), pvtype ) );
47 BPHYS_CHECK( vtx.setZ0 ( m_cascadeTools->a0z (mom, vtx.vtx(), PV), pvtype ) );
48 BPHYS_CHECK( vtx.setZ0Err ( m_cascadeTools->a0zError (mom, cov, vtx.vtx(), PV), pvtype ) );
49 BPHYS_CHECK( vtx.setRefitPVStatus ( refitCode, pvtype ) );
50
51}
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
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

◆ FillCandwithRefittedVertices()

StatusCode DerivationFramework::BPhysPVCascadeTools::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 at line 256 of file BPhysPVCascadeTools.cxx.

261{
262 static const Trk::V0Tools* const dummy = nullptr;
263 static const DerivationFramework::BPhysPVTools pvtool(dummy);
264
265 const std::vector<TLorentzVector> &mom = casc->getParticleMoms()[index];
266 const Amg::MatrixX &cov = casc->getCovariance()[index];
267 const std::vector<xAOD::Vertex*> &cascadeVertices = casc->vertices();
268 const bool doPt = (DoVertexType & 1) != 0;
269 const bool doA0 = (DoVertexType & 2) != 0;
270 const bool doZ0 = (DoVertexType & 4) != 0;
271 const bool doZ0BA = (DoVertexType & 8) != 0;
272
273 // Collect the tracks that should be excluded from the PV
274 std::vector<const xAOD::TrackParticle*> exclTrk = CollectAllChargedTracks(cascadeVertices);
275
276
277 const std::vector<const xAOD::Vertex*> GoodPVs = GetGoodPV(pvContainer);
278 // 2) PV dependent variables
279 if (GoodPVs.empty() == false) {
280 if (refitPV) {
281 size_t pVmax =std::min((size_t)in_PV_max, GoodPVs.size());
282 std::vector<const xAOD::Vertex*> refPVvertexes;
283 std::vector<xAOD::Vertex*> refPVvertexes_toDelete;
284 std::vector<int> exitCode;
285 refPVvertexes.reserve(pVmax);
286 refPVvertexes_toDelete.reserve(pVmax);
287 exitCode.reserve(pVmax);
288
289 // Refit the primary vertex and set the related decorations.
290
291 for (size_t i =0; i < pVmax ; i++) {
292 const xAOD::Vertex* oldPV = GoodPVs.at(i);
293 // when set to false this will return null when a new vertex is not required
294// ATH_MSG_DEBUG("old PV x " << oldPV->x() << " y " << oldPV->y() << " z " << oldPV->z());
295 int exitcode = 0;
296 xAOD::Vertex* refPV = pvRefitter->refitVertex(oldPV, exclTrk, m_copyAllVertices, &exitcode);
297// if (refPV) ATH_MSG_DEBUG("ref PV x " << refPV->x() << " y " << refPV->y() << " z " << refPV->z());
298 exitCode.push_back(exitcode);
299 // we want positioning to match the goodPrimaryVertices
300 if (refPV == nullptr) {
301 refPVvertexes.push_back(oldPV);
302 refPVvertexes_toDelete.push_back(nullptr);
303 } else {
304 refPVvertexes.push_back(refPV);
305 refPVvertexes_toDelete.push_back(refPV);
306 }
307 }
308 boost::container::static_vector<size_t, 4> indexesUsed;
309 boost::container::static_vector<std::pair<size_t, xAOD::BPhysHelper::pv_type>, 4> indexestoProcess;
310
311 if(doPt){
312 indexestoProcess.push_back(std::make_pair
313 (pvtool.FindHighPtIndex(refPVvertexes), xAOD::BPhysHelper::PV_MAX_SUM_PT2));
314 }
315 if(doA0) {
316 indexestoProcess.push_back(std::make_pair( FindLowA0Index(mom, vtx, refPVvertexes, m_PV_minNTracks),
318 }
319 if(doZ0) {
320 indexestoProcess.push_back(std::make_pair(FindLowZIndex(mom, vtx, refPVvertexes, m_PV_minNTracks),
322 }
323 if(doZ0BA) {
324 size_t lowZBA = FindLowZ0BAIndex(mom, vtx, refPVvertexes, m_PV_minNTracks);
325 if( lowZBA < pVmax ) {
326 indexestoProcess.push_back(std::make_pair(lowZBA, xAOD::BPhysHelper::PV_MIN_Z0_BA));
327 }
328 else pvtool.FillBPhysHelperNULL(vtx, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA);
329 }
330
331 for(size_t i =0 ; i<indexestoProcess.size(); i++){
332 //if refitted add to refitted container
333 auto index = indexestoProcess[i].first;
334 auto pvtype = indexestoProcess[i].second;
335 const xAOD::VertexContainer* ParentContainer =
336 (refPVvertexes_toDelete.at(index)) ? refPvContainer : pvContainer;
337 if(ParentContainer == refPvContainer && std::find(indexesUsed.begin(),
338 indexesUsed.end(), index) == indexesUsed.end()) {
339 // store the new vertex
340 refPvContainer->push_back(refPVvertexes_toDelete.at(index));
341 indexesUsed.push_back(index);
342 }
343 FillBPhysHelper(mom, cov, vtx, refPVvertexes[index],
344 ParentContainer, pvtype, exitCode[index]);
345 vtx.setOrigPv(GoodPVs[index], pvContainer, pvtype);
346 }
347 //nullify ptrs we want to keep so these won't get deleted
348 //"delete null" is valid in C++ and does nothing so this is quicker than a lot of if statements
349 for(size_t x : indexesUsed) refPVvertexes_toDelete[x] = nullptr;
350 //Loop over toDELETE container, anything that is used or was not refitted is null
351 //This cleans up all extra vertices that were created and not used
352 for(const xAOD::Vertex* ptr : refPVvertexes_toDelete) delete ptr;
353 refPVvertexes.clear(); // Clear lists of now dangling ptrs
354 refPVvertexes_toDelete.clear();
355 exitCode.clear();
356
357 } else {
358 // 2.a) the first PV with the largest sum pT.
359 if(doPt) {
360 size_t highPtindex = pvtool.FindHighPtIndex(GoodPVs); // Should be 0 in PV ordering
361 FillBPhysHelper(mom, cov, vtx, GoodPVs[highPtindex], pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2, 0);
362 }
363 // 2.b) the closest in 3D:
364 if(doA0) {
365 size_t lowA0 = FindLowA0Index(mom, vtx, GoodPVs, m_PV_minNTracks);
366 FillBPhysHelper(mom, cov, vtx, GoodPVs[lowA0], pvContainer, xAOD::BPhysHelper::PV_MIN_A0, 0);
367 }
368 // 2.c) the closest in Z:
369 if(doZ0) {
370 size_t lowZ = FindLowZIndex(mom, vtx, GoodPVs, m_PV_minNTracks);
371 FillBPhysHelper(mom, cov, vtx, GoodPVs[lowZ], pvContainer, xAOD::BPhysHelper::PV_MIN_Z0, 0);
372 }
373 // 2.d) the closest in Z (DOCA w.r.t. beam axis):
374 if(doZ0BA) {
375 size_t lowZBA = FindLowZ0BAIndex(mom, vtx, GoodPVs, m_PV_minNTracks);
376 if ( lowZBA < GoodPVs.size() ) { // safety against vector index out-of-bounds
377 FillBPhysHelper(mom, cov, vtx, GoodPVs[lowZBA], pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA, 0);
378 } else {
379 // nothing found -- fill NULL
380 pvtool.FillBPhysHelperNULL(vtx, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA);
381 }
382 }
383 } // refitPV
384 } else {
385
386 if(pvContainer->empty()) return StatusCode::FAILURE;
387 const xAOD::Vertex* Dummy = pvContainer->at(0);
388
389 // 2.a) the first PV with the largest sum pT.
390 if(doPt) {
391 FillBPhysHelper(mom, cov, vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2, 0);
392 if(refitPV) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MAX_SUM_PT2);
393 }
394 // 2.b) the closest in 3D:
395 if(doA0) {
396 FillBPhysHelper(mom, cov, vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_A0, 0);
397 if(refitPV) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_A0);
398 }
399 // 2.c) the closest in Z:
400 if(doZ0) {
401 FillBPhysHelper(mom, cov, vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0, 0);
402 if(refitPV) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0);
403 }
404 // 2.d) the closest in Z (DOCA w.r.t. beam axis):
405 if(doZ0BA) {
406 FillBPhysHelper(mom, cov, vtx, Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA, 0);
407 if(refitPV) vtx.setOrigPv(Dummy, pvContainer, xAOD::BPhysHelper::PV_MIN_Z0_BA);
408 }
409 } // GoodPVs.empty()
410
411 // 3) proper decay time and error:
412 // retrieve the refitted PV (or the original one, if the PV refitting was turned off)
413 if(doPt) ProcessVertex(mom, cov, vtx, xAOD::BPhysHelper::PV_MAX_SUM_PT2, mass);
414 if(doA0) ProcessVertex(mom, cov, vtx, xAOD::BPhysHelper::PV_MIN_A0, mass);
415 if(doZ0) ProcessVertex(mom, cov, vtx, xAOD::BPhysHelper::PV_MIN_Z0, mass);
416 if(doZ0BA) ProcessVertex(mom, cov, vtx, xAOD::BPhysHelper::PV_MIN_Z0_BA, mass);
417
418 return StatusCode::SUCCESS;
419}
#define x
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
bool empty() const noexcept
Returns true if the collection is empty.
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.
static std::vector< const xAOD::TrackParticle * > CollectAllChargedTracks(const std::vector< xAOD::Vertex * > &cascadeVertices)
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.
static std::vector< const xAOD::Vertex * > GetGoodPV(const xAOD::VertexContainer *pvContainer)
Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector contain...
void ProcessVertex(const std::vector< TLorentzVector > &mom, Amg::MatrixX cov, xAOD::BPhysHypoHelper &vtx, xAOD::BPhysHelper::pv_type pvtype, double mass) const
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.
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....
const std::vector< Amg::MatrixX > & getCovariance() const
const std::vector< std::vector< TLorentzVector > > & getParticleMoms() const
const std::vector< xAOD::Vertex * > & vertices() const
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.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
str index
Definition DeMoScan.py:362
int exitcode
Definition athena.py:163
void * ptr(T *p)
Definition SGImplSvc.cxx:74
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ FindLowA0Index()

size_t DerivationFramework::BPhysPVCascadeTools::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 at line 97 of file BPhysPVCascadeTools.cxx.

99 {
100 size_t lowA0 = 0;
101 if(PVlist.empty()) {
102 lowA0=std::numeric_limits<std::size_t>::max();
103 return lowA0;
104 }
105 size_t size = PVlist.size();
106 double lowA0calc = m_cascadeTools->a0(mom, Obj.vtx(), PVlist[0]);
107 for(size_t i =1; i<size; i++) {
108 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
109 double a0 = m_cascadeTools->a0(mom, Obj.vtx(), PVlist[i]);
110 if(a0 < lowA0calc) {
111 lowA0calc = a0;
112 lowA0 =i;
113 }
114 }
115 }
116 return lowA0;
117}
double a0
Definition globals.cxx:27

◆ FindLowZ0BAIndex()

size_t DerivationFramework::BPhysPVCascadeTools::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.t.

the beamline and the PV.

Definition at line 154 of file BPhysPVCascadeTools.cxx.

156 {
157
158 size_t ilowZ0BA = std::numeric_limits<std::size_t>::max();
159 double lowZ0BAcalc = std::numeric_limits<double>::max();
160 for (size_t i = 0; i<PVlist.size(); ++i) {
161 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
162 double z0BA = m_cascadeTools->a0(mom, obj.vtx(), PVlist[i]);
163 if (z0BA < lowZ0BAcalc) {
164 lowZ0BAcalc = z0BA;
165 ilowZ0BA = i;
166 }
167 }
168 }
169 return ilowZ0BA;
170}

◆ FindLowZIndex()

size_t DerivationFramework::BPhysPVCascadeTools::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 at line 75 of file BPhysPVCascadeTools.cxx.

77 {
78 size_t lowZ = 0;
79 if(PVlist.empty()) {
80 lowZ=std::numeric_limits<std::size_t>::max();
81 return lowZ;
82 }
83 size_t size = PVlist.size();
84 double lowA0zcalc = fabs(m_cascadeTools->a0z (mom, Obj.vtx(), PVlist[0]));
85 for(size_t i =1; i<size; i++) {
86 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
87 double a0z = fabs(m_cascadeTools->a0z(mom, Obj.vtx(), PVlist[i]));
88 if(a0z < lowA0zcalc) {
89 lowA0zcalc = a0z;
90 lowZ =i;
91 }
92 }
93 }
94 return lowZ;
95}

◆ FindVertex()

template<size_t NTracks>
const xAOD::Vertex * DerivationFramework::BPhysPVCascadeTools::FindVertex ( const xAOD::VertexContainer * c,
const xAOD::Vertex * v )
static

Definition at line 140 of file BPhysPVCascadeTools.h.

140 {
141 for (const xAOD::Vertex* a : *c){
142 if(VerticesMatchTracks<NTracks>(a,v)) return a;
143 }
144 return nullptr;
145}
static Double_t a
static bool VerticesMatchTracks(const xAOD::Vertex *v1, const xAOD::Vertex *v2)

◆ GetBeamSpot()

Amg::Vector3D DerivationFramework::BPhysPVCascadeTools::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 145 of file BPhysPVCascadeTools.cxx.

145 {
146 if(m_eventInfo) return Amg::Vector3D(m_eventInfo->beamPosX(), m_eventInfo->beamPosY(), m_eventInfo->beamPosZ());
147 else {
148 static const Amg::Vector3D defaultBS(-10000.,-10000.,-10000.);
149 return defaultBS;
150 }
151}

◆ GetGoodPV()

std::vector< const xAOD::Vertex * > DerivationFramework::BPhysPVCascadeTools::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 119 of file BPhysPVCascadeTools.cxx.

119 {
123 std::vector<const xAOD::Vertex*> goodPrimaryVertices;
124 goodPrimaryVertices.reserve(pvContainer->size());
125
126 for (auto ptr = pvContainer->begin(); ptr!= pvContainer->end(); ++ptr) {
127 VertexType thistype = (*ptr)->vertexType();
128 if ( thistype == Pileupvtx || thistype == Pvtx ) {
129 goodPrimaryVertices.push_back(*ptr);
130 } else {
131// cout << "vertex type " << thistype << endl;
132 }
133 }
134 return goodPrimaryVertices;
135}
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.
size_type size() const noexcept
Returns the number of elements in the collection.
VertexType
Vertex types.
@ PileUp
Pile-up vertex.
@ PriVtx
Primary 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)

◆ LinkVertices()

bool DerivationFramework::BPhysPVCascadeTools::LinkVertices ( SG::AuxElement::Decorator< VertexLinkVector > & decor,
const std::vector< const xAOD::Vertex * > & vertices,
const xAOD::VertexContainer * vertexContainer,
const xAOD::Vertex * vert )
static

Definition at line 459 of file BPhysPVCascadeTools.cxx.

460 {
461 // create tmp vector of preceding vertex links
462 VertexLinkVector precedingVertexLinks;
463
464 // loop over input precedingVertices
465 auto precedingVerticesItr = vertices.begin();
466 for(; precedingVerticesItr!=vertices.end(); ++precedingVerticesItr) {
467 // sanity check 1: protect against null pointers
468 if( !(*precedingVerticesItr) )
469 return false;
470
471 // create element link
472 VertexLink vertexLink;
473 vertexLink.setElement(*precedingVerticesItr);
474 vertexLink.setStorableObject(*vertexContainer);
475
476 // sanity check 2: is the link valid?
477 if( !vertexLink.isValid() )
478 return false;
479
480 // link is OK, store it in the tmp vector
481 precedingVertexLinks.push_back( vertexLink );
482
483 } // end of loop over preceding vertices
484
485 // all OK: store preceding vertex links in the aux store
486 decor(*vert) = precedingVertexLinks;
487 return true;
488}
ElementLink< xAOD::VertexContainer > VertexLink

◆ 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 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
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 182 of file AthMessaging.h.

183{ 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 user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ PrepareVertexLinks() [1/2]

void DerivationFramework::BPhysPVCascadeTools::PrepareVertexLinks ( Trk::VxCascadeInfo * result,
const std::vector< const xAOD::TrackParticleContainer * > & trackCols )
static

Definition at line 220 of file BPhysPVCascadeTools.cxx.

221{
222 auto &collection = result->vertices();
223 for(auto v : collection) {
224 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
225 for(auto mylink : v->trackParticleLinks()) {
226 const xAOD::TrackParticle* myptr= *mylink;
227 const xAOD::TrackParticleContainer* foundcontainer = nullptr;
228 for(auto col : trackCols){
229 if(std::find(col->begin(), col->end(), myptr) != col->end()){
230 foundcontainer =col;
231 break;
232 }
233 }
234 if(foundcontainer == nullptr){
235 throw std::runtime_error("Could not find track in original containers");
236 }
237 mylink.setStorableObject(*foundcontainer, true);
238 newLinkVector.push_back( mylink );
239 }
240 v->clearTracks();
241 v->setTrackParticleLinks( newLinkVector );
242 }
243}
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".

◆ PrepareVertexLinks() [2/2]

void DerivationFramework::BPhysPVCascadeTools::PrepareVertexLinks ( Trk::VxCascadeInfo * result,
const xAOD::TrackParticleContainer * importedTrackCollection )
static

Definition at line 203 of file BPhysPVCascadeTools.cxx.

204{
205 auto &collection = result->vertices();
206 for(auto v : collection)
207 {
208 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
209 for(unsigned int i=0; i< v->trackParticleLinks().size(); i++)
210 {
211 ElementLink<DataVector<xAOD::TrackParticle> > mylink=v->trackParticleLinks()[i]; // makes a copy (non-const)
212 mylink.setStorableObject(*importedTrackCollection, true);
213 newLinkVector.push_back( mylink );
214 }
215 v->clearTracks();
216 v->setTrackParticleLinks( newLinkVector );
217 }
218}

◆ ProcessVertex()

void DerivationFramework::BPhysPVCascadeTools::ProcessVertex ( const std::vector< TLorentzVector > & mom,
Amg::MatrixX cov,
xAOD::BPhysHypoHelper & vtx,
xAOD::BPhysHelper::pv_type pvtype,
double mass ) const

Definition at line 53 of file BPhysPVCascadeTools.cxx.

54 {
55
56 const xAOD::Vertex* pv = vtx.pv(pvtype);
57 if (pv) {
58 // decorate the vertex.
59 vtx.setTau( m_cascadeTools->tau(mom, vtx.vtx(), pv), pvtype, xAOD::BPhysHypoHelper::TAU_INV_MASS );
60 vtx.setTauErr( m_cascadeTools->tauError(mom, cov, vtx.vtx(), pv), pvtype, xAOD::BPhysHypoHelper::TAU_INV_MASS );
61 // Proper decay time assuming constant mass hypothesis
62 vtx.setTau( m_cascadeTools->tau(mom, vtx.vtx(), pv, mass), pvtype, xAOD::BPhysHypoHelper::TAU_CONST_MASS );
63 vtx.setTauErr( m_cascadeTools->tauError(mom, cov, vtx.vtx(), pv, mass), pvtype, xAOD::BPhysHypoHelper::TAU_CONST_MASS );
64 //enum pv_type {PV_MAX_SUM_PT2, PV_MIN_A0, PV_MIN_Z0, PV_MIN_Z0_BA};
65 } else {
66 const float errConst = -9999999.;
71 }
72
73}
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
bool setTau(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0, const tau_type tauType=BPhysHypoHelper::TAU_CONST_MASS)
: Set the proper decay time and error.
bool setTauErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0, const tau_type tauType=BPhysHypoHelper::TAU_CONST_MASS)
proper decay time error

◆ 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::BPhysPVCascadeTools::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 138 of file BPhysPVCascadeTools.cxx.

139{
140
141 m_PV_minNTracks = PV_minNTracks;
142}

◆ SetVectorInfo()

void DerivationFramework::BPhysPVCascadeTools::SetVectorInfo ( xAOD::BPhysHelper & vtx,
const Trk::VxCascadeInfo * casc )
static

Definition at line 423 of file BPhysPVCascadeTools.cxx.

423 {
424
425 const std::vector< std::vector<TLorentzVector> > &moms = casc->getParticleMoms();
426 const std::vector<xAOD::Vertex*> &cascadeVertices = casc->vertices();
427 // Get refitted track momenta from all vertices, charged tracks only
428 std::vector<float> px;
429 std::vector<float> py;
430 std::vector<float> pz;
431 for( size_t jt=0; jt<moms.size(); jt++) {
432 for( size_t it=0; it<cascadeVertices[jt]->vxTrackAtVertex().size(); it++) {
433 px.push_back( moms[jt][it].Px() );
434 py.push_back( moms[jt][it].Py() );
435 pz.push_back( moms[jt][it].Pz() );
436 }
437 }
438 vtx.setRefTrks(std::move(px),std::move(py),std::move(pz));
439
440}
bool setRefTrks(std::vector< float > px, std::vector< float > py, std::vector< float > pz)
Sets refitted track momenta.

◆ uniqueCollection() [1/2]

bool DerivationFramework::BPhysPVCascadeTools::uniqueCollection ( const std::vector< const xAOD::TrackParticle * > & col)
static

Definition at line 442 of file BPhysPVCascadeTools.cxx.

442 {
443 for(auto p : col){
444 if(std::count(col.begin(), col.end(), p) > 1) return false;
445 }
446 return true;
447}

◆ uniqueCollection() [2/2]

bool DerivationFramework::BPhysPVCascadeTools::uniqueCollection ( const std::vector< const xAOD::TrackParticle * > & col1,
const std::vector< const xAOD::TrackParticle * > & col2 )
static

Definition at line 449 of file BPhysPVCascadeTools.cxx.

449 {
450 for(auto p : col1){
451 if((std::count(col1.begin(), col1.end(), p) + std::count(col2.begin(), col2.end(), p)) > 1) return false;
452 }
453 for(auto p : col2){
454 if((std::count(col1.begin(), col1.end(), p) + std::count(col2.begin(), col2.end(), p)) > 1) return false;
455 }
456 return true;
457}

◆ VerticesMatchTracks()

template<size_t NTracks>
bool DerivationFramework::BPhysPVCascadeTools::VerticesMatchTracks ( const xAOD::Vertex * v1,
const xAOD::Vertex * v2 )
static

Definition at line 124 of file BPhysPVCascadeTools.h.

125{
126 if(v1->nTrackParticles() != v2->nTrackParticles()) return false;
127 assert(v1->nTrackParticles() == NTracks);
128 std::array<const xAOD::TrackParticle*, NTracks> a1;
129 std::array<const xAOD::TrackParticle*, NTracks> a2;
130 for(size_t i=0;i<NTracks;i++){
131 a1[i] = v1->trackParticle(i);
132 a2[i] = v2->trackParticle(i);
133 }
134 std::sort(a1.begin(), a1.end());
135 std::sort(a2.begin(), a2.end());
136 return a1 == a2;
137}
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

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_cascadeTools

const CascadeTools* DerivationFramework::BPhysPVCascadeTools::m_cascadeTools
private

Definition at line 34 of file BPhysPVCascadeTools.h.

◆ m_copyAllVertices

bool DerivationFramework::BPhysPVCascadeTools::m_copyAllVertices

Definition at line 41 of file BPhysPVCascadeTools.h.

◆ m_eventInfo

const xAOD::EventInfo* DerivationFramework::BPhysPVCascadeTools::m_eventInfo
private

Definition at line 35 of file BPhysPVCascadeTools.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::BPhysPVCascadeTools::m_PV_minNTracks
private

minimum number of tracks required in PVs considered

Definition at line 38 of file BPhysPVCascadeTools.h.


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