20 m_v0Tools(v0Tools), m_EvtData(nullptr), m_PV_minNTracks(0),
27 m_v0Tools(v0Tools), m_EvtData(eventInfo), m_PV_minNTracks(0),
63 constexpr
float errConst = std::numeric_limits<float>::lowest();
81 const std::vector<const xAOD::Vertex*> &PVlist,
82 const size_t PV_minNTracks)
const {
88 size_t size = PVlist.size();
89 double lowA0zcalc = fabs(m_v0Tools->a0z (Obj.
vtx(), PVlist[0]));
91 if ( PVlist[
i]->nTrackParticles() >= PV_minNTracks ) {
92 double a0z = fabs(m_v0Tools->a0z(Obj.
vtx(), PVlist[
i]));
93 if(a0z < lowA0zcalc) {
104 int DoVertexType,
const bool SetOrignal)
const {
105 const bool doPt = (DoVertexType & 1) != 0;
106 const bool doA0 = (DoVertexType & 2) != 0;
107 const bool doZ0 = (DoVertexType & 4) != 0;
108 const bool doZ0BA = (DoVertexType & 8) != 0;
111 for(; vtxItr!=vtxContainer->
end(); ++vtxItr) {
115 double ptErr = m_v0Tools->pTError( vtx.
vtx() );
143 const bool doPt = (DoVertexType & 1) != 0;
144 const bool doA0 = (DoVertexType & 2) != 0;
145 const bool doZ0 = (DoVertexType & 4) != 0;
146 const bool doZ0BA = (DoVertexType & 8) != 0;
148 for(; vtxItr!=vtxContainer->
end(); ++vtxItr) {
152 double ptErr = m_v0Tools->pTError( vtx.
vtx() );
183 const std::vector<const xAOD::Vertex*> GoodPVs = GetGoodPV(pvContainer);
186 if(GoodPVs.empty() ==
false) {
188 const bool doPt = (DoVertexType & 1) != 0;
189 const bool doA0 = (DoVertexType & 2) != 0;
190 const bool doZ0 = (DoVertexType & 4) != 0;
191 const bool doZ0BA = (DoVertexType & 8) != 0;
194 for(; vtxItr!=vtxContainer->
end(); ++vtxItr) {
198 double ptErr = m_v0Tools->pTError( vtx.
vtx() );
203 size_t highPtindex = FindHighPtIndex(GoodPVs);
210 size_t lowA0 = FindLowA0Index(vtx, GoodPVs, m_PV_minNTracks);
215 size_t lowZ = FindLowZIndex(vtx, GoodPVs, m_PV_minNTracks);
220 size_t lowZBA = FindLowZ0BAIndex(vtx, GoodPVs, m_PV_minNTracks);
221 if ( lowZBA < GoodPVs.size() ) {
233 if(pvContainer->
empty())
return StatusCode::FAILURE;
235 DecorateWithDummyVertex(vtxContainer, pvContainer,
dummy, DoVertexType,
false);
237 return StatusCode::SUCCESS;
251 std::vector<const xAOD::Vertex*> goodPrimaryVertices = GetGoodPV(pvContainer);
259 if(goodPrimaryVertices.empty() ==
false) {
261 size_t pVmax =
std::min(in_PV_max, goodPrimaryVertices.size());
262 std::vector<const xAOD::Vertex*> refPVvertexes;
263 std::vector<xAOD::Vertex*> refPVvertexes_toDelete;
264 std::vector<int> exitCode;
265 refPVvertexes.reserve(pVmax);
266 refPVvertexes_toDelete.reserve(pVmax);
267 exitCode.reserve(pVmax);
269 bool doPt = (DoVertexType & 1) != 0;
270 bool doA0 = (DoVertexType & 2) != 0;
271 bool doZ0 = (DoVertexType & 4) != 0;
272 bool doZ0BA = (DoVertexType & 8) != 0;
275 for(; vtxItr!=vtxContainer->
end(); ++vtxItr) {
279 double ptErr = m_v0Tools->pTError( vtx.
vtx() );
282 for(
size_t i =0;
i < pVmax ;
i++) {
287 exitCode.push_back(
exit);
289 if(refPV ==
nullptr){
290 refPVvertexes.push_back(oldPV);
291 refPVvertexes_toDelete.push_back(
nullptr);
293 refPVvertexes.push_back(refPV);
294 refPVvertexes_toDelete.push_back(refPV);
300 size_t highPtindex = doPt ? FindHighPtIndex(refPVvertexes) : 9999999;
301 size_t lowA0 = doA0 ?
302 FindLowA0Index(vtx, refPVvertexes, m_PV_minNTracks) : 9999998;
304 FindLowZIndex(vtx, refPVvertexes, m_PV_minNTracks) : 9999997;
305 size_t lowZBA = doZ0BA ?
306 FindLowZ0BAIndex(vtx, refPVvertexes, m_PV_minNTracks) : 9999996;
326 (refPVvertexes_toDelete.at(highPtindex)) ? refPvContainer : pvContainer;
327 if(ParentContainer == refPvContainer)
328 refPvContainer->
push_back(refPVvertexes_toDelete.at(highPtindex));
330 FillBPhysHelper(vtx, refPVvertexes[highPtindex],
337 (refPVvertexes_toDelete.at(lowA0)) ? refPvContainer : pvContainer;
338 if(ParentContainer == refPvContainer && highPtindex!=lowA0)
339 refPvContainer->
push_back(refPVvertexes_toDelete.at(lowA0));
341 FillBPhysHelper(vtx, refPVvertexes[lowA0],
351 (refPVvertexes_toDelete.at(lowZ)) ? refPvContainer : pvContainer;
352 if(ParentContainer == refPvContainer && highPtindex!=lowZ && lowZ!=lowA0)
353 refPvContainer->
push_back(refPVvertexes_toDelete.at(lowZ));
355 FillBPhysHelper(vtx, refPVvertexes[lowZ],
362 if ( lowZBA < pVmax ) {
364 (refPVvertexes_toDelete.at(lowZBA)) ?
365 refPvContainer : pvContainer;
366 if (ParentContainer == refPvContainer && highPtindex!=lowZBA
367 && lowZBA!=lowA0 && lowZBA != lowZ) {
369 refPvContainer->
push_back(refPVvertexes_toDelete.at(lowZBA));
371 FillBPhysHelper(vtx, refPVvertexes[lowZBA],
374 vtx.
setOrigPv(goodPrimaryVertices[lowZBA], pvContainer,
389 if(doPt) refPVvertexes_toDelete[highPtindex] =
nullptr;
390 if(doA0) refPVvertexes_toDelete[lowA0] =
nullptr;
391 if(doZ0) refPVvertexes_toDelete[lowZ] =
nullptr;
392 if(doZ0BA && lowZBA < pVmax) refPVvertexes_toDelete[lowZBA] =
nullptr;
398 refPVvertexes.clear();
399 refPVvertexes_toDelete.clear();
405 if(pvContainer->
empty())
return StatusCode::FAILURE;
407 DecorateWithDummyVertex(vtxContainer, pvContainer,
dummy, DoVertexType,
true);
410 return StatusCode::SUCCESS;
415 for(
size_t i =0;
i<PVlist.size();
i++) {
418 ATH_MSG_ERROR(
"High Pt Primary vertex not found - this should not happen");
423 const std::vector<const xAOD::Vertex*> &PVlist,
424 const size_t PV_minNTracks)
const {
430 size_t size = PVlist.size();
431 double lowA0calc = m_v0Tools->a0(Obj.
vtx(), PVlist[0]);
432 for(
size_t i =1;
i<
size;
i++) {
433 if ( PVlist[
i]->nTrackParticles() >= PV_minNTracks ) {
434 double a0 = m_v0Tools->a0(Obj.
vtx(), PVlist[
i]);
448 std::vector<const xAOD::Vertex*> goodPrimaryVertices;
449 goodPrimaryVertices.reserve(pvContainer->
size());
453 if ( thistype == Pileupvtx || thistype == Pvtx ) {
454 goodPrimaryVertices.push_back(*
ptr);
459 return goodPrimaryVertices;
467 m_PV_minNTracks = PV_minNTracks;
474 if(m_EvtData)
return Amg::Vector3D(m_EvtData->beamPosX(), m_EvtData->beamPosY(), m_EvtData->beamPosZ());
476 static const Amg::Vector3D defaultBS(-10000.,-10000.,-10000.);
484 const std::vector<const xAOD::Vertex*> &PVlist,
485 const size_t PV_minNTracks)
const {
489 for (
size_t i = 0;
i<PVlist.size(); ++
i) {
490 if ( PVlist[
i]->nTrackParticles() >= PV_minNTracks ) {
491 double z0BA = m_v0Tools->a0(
obj.vtx(), PVlist[
i]);
492 if (z0BA < lowZ0BAcalc) {
516 TVector3 totP(
obj.totalP());
519 if (
pT.mag2() > 0 ) {
523 xDOCA = xSV - pSV*
pT.dot(xT)/
pT.mag2();
533 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
535 for(
unsigned int i=0;
i< trkprtl.size();
i++)
539 newLinkVector.push_back( mylink );