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)
static double getParticleMass (const HepPDT::ParticleDataTable *pdt, int pdg)

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 34 of file BPhysPVCascadeTools.h.

Member Typedef Documentation

◆ VertexLink

◆ VertexLinkVector

Definition at line 36 of file BPhysPVCascadeTools.h.

Constructor & Destructor Documentation

◆ BPhysPVCascadeTools() [1/2]

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

Definition at line 17 of file BPhysPVCascadeTools.cxx.

17 :
18 AthMessaging("BPhysPVCascadeTools"),
19 m_cascadeTools(cascadeTools), m_eventInfo(nullptr), m_PV_minNTracks(0),
21{
22}
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 24 of file BPhysPVCascadeTools.cxx.

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

Member Function Documentation

◆ CollectAllChargedTracks()

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

Definition at line 246 of file BPhysPVCascadeTools.cxx.

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

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

174 {
175
176 Amg::Vector3D pv = vertex->position();
177 Amg::Vector3D xDOCA = DocaExtrapToBeamSpot(mom, obj);
178 Amg::Vector3D vec = pv - xDOCA;
179 return vec.z();
180}
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 183 of file BPhysPVCascadeTools.cxx.

183 {
184
185 Amg::Vector3D xDOCA(-99999., -99999., -99999.);
186 TLorentzVector totalMom;
187 unsigned int NTrk = mom.size();
188 for( unsigned int it=0; it<NTrk; it++) totalMom += mom[it];
189 TVector3 totP = totalMom.Vect();
190 Amg::Vector3D pSV(totP.X(), totP.Y(), totP.Z());
191 Amg::Vector3D pT(pSV.x(), pSV.y(), 0.);
192 if ( pT.mag2() > 0 ) {
194 Amg::Vector3D xSV = obj.vtx()->position();
195 Amg::Vector3D xT(xSV.x()-xBS.x(), xSV.y()-xBS.y(), 0.);
196 xDOCA = xSV - pSV*pT.dot(xT)/pT.mag2();
197 } else {
198 std::cout << "BPhysPVCascadeTools::DocaExtrapToBeamSpot: WARNING pT == 0."
199 << std::endl;
200 }
201 return xDOCA;
202}
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 32 of file BPhysPVCascadeTools.cxx.

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

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

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

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

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

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

◆ FindVertex()

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

Definition at line 145 of file BPhysPVCascadeTools.h.

145 {
146 for (const xAOD::Vertex* a : *c){
147 if(VerticesMatchTracks<NTracks>(a,v)) return a;
148 }
149 return nullptr;
150}
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 146 of file BPhysPVCascadeTools.cxx.

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

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

120 {
124 std::vector<const xAOD::Vertex*> goodPrimaryVertices;
125 goodPrimaryVertices.reserve(pvContainer->size());
126
127 for (auto ptr = pvContainer->begin(); ptr!= pvContainer->end(); ++ptr) {
128 VertexType thistype = (*ptr)->vertexType();
129 if ( thistype == Pileupvtx || thistype == Pvtx ) {
130 goodPrimaryVertices.push_back(*ptr);
131 } else {
132// cout << "vertex type " << thistype << endl;
133 }
134 }
135 return goodPrimaryVertices;
136}
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.

◆ getParticleMass()

double DerivationFramework::BPhysPVCascadeTools::getParticleMass ( const HepPDT::ParticleDataTable * pdt,
int pdg )
static

Definition at line 491 of file BPhysPVCascadeTools.cxx.

491 {
492 auto ptr = pdt->particle( pdgcode );
493 return ptr ? ptr->mass() : 0.;
494}

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

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

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

Definition at line 221 of file BPhysPVCascadeTools.cxx.

222{
223 auto &collection = result->vertices();
224 for(auto v : collection) {
225 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
226 for(auto mylink : v->trackParticleLinks()) {
227 const xAOD::TrackParticle* myptr= *mylink;
228 const xAOD::TrackParticleContainer* foundcontainer = nullptr;
229 for(auto col : trackCols){
230 if(std::find(col->begin(), col->end(), myptr) != col->end()){
231 foundcontainer =col;
232 break;
233 }
234 }
235 if(foundcontainer == nullptr){
236 throw std::runtime_error("Could not find track in original containers");
237 }
238 mylink.setStorableObject(*foundcontainer, true);
239 newLinkVector.push_back( mylink );
240 }
241 v->clearTracks();
242 v->setTrackParticleLinks( newLinkVector );
243 }
244}
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 204 of file BPhysPVCascadeTools.cxx.

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

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

55 {
56
57 const xAOD::Vertex* pv = vtx.pv(pvtype);
58 if (pv) {
59 // decorate the vertex.
60 vtx.setTau( m_cascadeTools->tau(mom, vtx.vtx(), pv), pvtype, xAOD::BPhysHypoHelper::TAU_INV_MASS );
61 vtx.setTauErr( m_cascadeTools->tauError(mom, cov, vtx.vtx(), pv), pvtype, xAOD::BPhysHypoHelper::TAU_INV_MASS );
62 // Proper decay time assuming constant mass hypothesis
63 vtx.setTau( m_cascadeTools->tau(mom, vtx.vtx(), pv, mass), pvtype, xAOD::BPhysHypoHelper::TAU_CONST_MASS );
64 vtx.setTauErr( m_cascadeTools->tauError(mom, cov, vtx.vtx(), pv, mass), pvtype, xAOD::BPhysHypoHelper::TAU_CONST_MASS );
65 //enum pv_type {PV_MAX_SUM_PT2, PV_MIN_A0, PV_MIN_Z0, PV_MIN_Z0_BA};
66 } else {
67 const float errConst = -9999999.;
72 }
73
74}
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 139 of file BPhysPVCascadeTools.cxx.

140{
141
142 m_PV_minNTracks = PV_minNTracks;
143}

◆ SetVectorInfo()

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

Definition at line 424 of file BPhysPVCascadeTools.cxx.

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

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

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

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

◆ VerticesMatchTracks()

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

Definition at line 129 of file BPhysPVCascadeTools.h.

130{
131 if(v1->nTrackParticles() != v2->nTrackParticles()) return false;
132 assert(v1->nTrackParticles() == NTracks);
133 std::array<const xAOD::TrackParticle*, NTracks> a1;
134 std::array<const xAOD::TrackParticle*, NTracks> a2;
135 for(size_t i=0;i<NTracks;i++){
136 a1[i] = v1->trackParticle(i);
137 a2[i] = v2->trackParticle(i);
138 }
139 std::sort(a1.begin(), a1.end());
140 std::sort(a2.begin(), a2.end());
141 return a1 == a2;
142}
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 38 of file BPhysPVCascadeTools.h.

◆ m_copyAllVertices

bool DerivationFramework::BPhysPVCascadeTools::m_copyAllVertices

Definition at line 45 of file BPhysPVCascadeTools.h.

◆ m_eventInfo

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

Definition at line 39 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 42 of file BPhysPVCascadeTools.h.


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