ATLAS Offline Software
Loading...
Searching...
No Matches
BPhysPVCascadeTools.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "TVector3.h"
9#include "BPhysPVTools.h"
11#include <boost/container/static_vector.hpp>
13#include "HepPDT/ParticleDataTable.hh"
14#include <limits>
15#include <iostream>
16
18 AthMessaging("BPhysPVCascadeTools"),
19 m_cascadeTools(cascadeTools), m_eventInfo(nullptr), m_PV_minNTracks(0),
21{
22}
23
25 const xAOD::EventInfo* eventinfo) :
26 AthMessaging("BPhysPVCascadeTools"),
27 m_cascadeTools(cascadeTools), m_eventInfo(eventinfo), m_PV_minNTracks(0),
29{
30}
31
33 const xAOD::Vertex* PV, const xAOD::VertexContainer* PvContainer,
34 xAOD::BPhysHelper::pv_type pvtype, int refitCode) const {
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}
53
55 xAOD::BPhysHelper::pv_type pvtype, double mass) const {
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}
75
76size_t DerivationFramework::BPhysPVCascadeTools::FindLowZIndex(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &Obj,
77 const std::vector<const xAOD::Vertex*> &PVlist,
78 const size_t PV_minNTracks) const {
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}
97
98size_t DerivationFramework::BPhysPVCascadeTools::FindLowA0Index(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &Obj,
99 const std::vector<const xAOD::Vertex*> &PVlist,
100 const size_t PV_minNTracks) const {
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}
119
120std::vector<const xAOD::Vertex*> DerivationFramework::BPhysPVCascadeTools::GetGoodPV(const xAOD::VertexContainer* pvContainer) {
121 typedef xAOD::VxType::VertexType VertexType;
122 VertexType Pvtx = xAOD::VxType::PriVtx;
123 VertexType Pileupvtx = xAOD::VxType::PileUp;
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}
137//-----------------------------------------------------------------------------
138//
140{
141
142 m_PV_minNTracks = PV_minNTracks;
143}
144//-----------------------------------------------------------------------------
145//
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}
153//-----------------------------------------------------------------------------
154//
155size_t DerivationFramework::BPhysPVCascadeTools::FindLowZ0BAIndex(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &obj,
156 const std::vector<const xAOD::Vertex*> &PVlist,
157 const size_t PV_minNTracks) const {
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}
172//-----------------------------------------------------------------------------
173//
174double DerivationFramework::BPhysPVCascadeTools::DistInZtoDOCA(const std::vector<TLorentzVector> &mom, const xAOD::BPhysHelper &obj, const xAOD::Vertex* vertex) const {
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}
181//-----------------------------------------------------------------------------
182//
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}
203
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}
220
221void DerivationFramework::BPhysPVCascadeTools::PrepareVertexLinks(Trk::VxCascadeInfo *result, const std::vector<const xAOD::TrackParticleContainer*>& trackCols )
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}
245
246std::vector<const xAOD::TrackParticle*> DerivationFramework::BPhysPVCascadeTools::CollectAllChargedTracks(const std::vector<xAOD::Vertex*> &cascadeVertices)
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}
256
258 const xAOD::VertexContainer* pvContainer, xAOD::VertexContainer* refPvContainer,
259 const Analysis::PrimaryVertexRefitter *pvRefitter, size_t in_PV_max, int DoVertexType,
260 Trk::VxCascadeInfo* casc, int index,
261 double mass, xAOD::BPhysHypoHelper &vtx)
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
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}
421
422//-----------------------------------------------------------------------------
423
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}
442
443bool DerivationFramework::BPhysPVCascadeTools::uniqueCollection(const std::vector<const xAOD::TrackParticle*>&col){
444 for(auto p : col){
445 if(std::count(col.begin(), col.end(), p) > 1) return false;
446 }
447 return true;
448}
449
450bool DerivationFramework::BPhysPVCascadeTools::uniqueCollection(const std::vector<const xAOD::TrackParticle*>&col1, const std::vector<const xAOD::TrackParticle*>&col2){
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}
459
461 const xAOD::VertexContainer* vertexContainer, const xAOD::Vertex* vert){
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}
490
491double DerivationFramework::BPhysPVCascadeTools::getParticleMass(const HepPDT::ParticleDataTable* pdt, int pdgcode){
492 auto ptr = pdt->particle( pdgcode );
493 return ptr ? ptr->mass() : 0.;
494}
495
double charge(const T &p)
Definition AtlasPID.h:997
: B-physics xAOD helpers.
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
std::vector< size_t > vec
#define x
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
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.
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.
bool empty() const noexcept
Returns true if the collection is empty.
static bool uniqueCollection(const std::vector< const xAOD::TrackParticle * > &)
size_t m_PV_minNTracks
minimum number of tracks required in PVs considered
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.
static bool LinkVertices(SG::AuxElement::Decorator< VertexLinkVector > &decor, const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer, const xAOD::Vertex *vert)
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.
Amg::Vector3D GetBeamSpot() const
Get the current beamspot position either from cache or from BeamCondSvc.
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 void PrepareVertexLinks(Trk::VxCascadeInfo *result, const xAOD::TrackParticleContainer *importedTrackCollection)
static double getParticleMass(const HepPDT::ParticleDataTable *pdt, int pdg)
void SetMinNTracksInPV(size_t PV_minNTracks)
Set the minimum number of tracks required for primary vertices to be considered for primary vertex as...
ElementLink< xAOD::VertexContainer > VertexLink
Amg::Vector3D DocaExtrapToBeamSpot(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj) const
Point of DOCA w.r.t.
static std::vector< const xAOD::Vertex * > GetGoodPV(const xAOD::VertexContainer *pvContainer)
Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector contain...
static void SetVectorInfo(xAOD::BPhysHelper &, const Trk::VxCascadeInfo *)
void ProcessVertex(const std::vector< TLorentzVector > &mom, Amg::MatrixX cov, xAOD::BPhysHypoHelper &vtx, xAOD::BPhysHelper::pv_type pvtype, double mass) const
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)
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....
BPhysPVCascadeTools(const CascadeTools *cascadeTools)
void FillBPhysHelperNULL(xAOD::BPhysHelper &vtx, const xAOD::VertexContainer *PvContainer, xAOD::BPhysHelper::pv_type pvtype, bool do3d=false) const
size_t FindHighPtIndex(const std::vector< const xAOD::Vertex * > &PVlist) const
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
const std::vector< Amg::MatrixX > & getCovariance() const
const std::vector< std::vector< TLorentzVector > > & getParticleMoms() const
const std::vector< xAOD::Vertex * > & vertices() const
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.
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
pv_type
: Enum type of the PV
bool setRefTrks(std::vector< float > px, std::vector< float > py, std::vector< float > pz)
Sets refitted track momenta.
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 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.
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
double a0
Definition globals.cxx:27
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Definition index.py:1
VertexType
Vertex types.
@ PileUp
Pile-up vertex.
@ PriVtx
Primary vertex.
EventInfo_v1 EventInfo
Definition of the latest event info version.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".