ATLAS Offline Software
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"
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),
20  m_copyAllVertices(true)
21 {
22 }
23 
25  const xAOD::EventInfo* eventinfo) :
26  AthMessaging("BPhysPVCascadeTools"),
27  m_cascadeTools(cascadeTools), m_eventInfo(eventinfo), m_PV_minNTracks(0),
28  m_copyAllVertices(true)
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.;
68  BPHYS_CHECK( vtx.setTau( errConst, pvtype, xAOD::BPhysHypoHelper::TAU_INV_MASS) );
72  }
73 
74 }
75 
76 size_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()) {
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 
98 size_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()) {
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 
120 std::vector<const xAOD::Vertex*> DerivationFramework::BPhysPVCascadeTools::GetGoodPV(const xAOD::VertexContainer* pvContainer) {
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 //
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 //
174 double 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 ) {
193  Amg::Vector3D xBS = GetBeamSpot();
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 
221 void 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 
246 std::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
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 }
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 
443 bool 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 
450 bool 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 
491 double DerivationFramework::BPhysPVCascadeTools::getParticleMass(const HepPDT::ParticleDataTable* pdt, int pdgcode){
492  auto ptr = pdt->particle( pdgcode );
493  return ptr ? ptr->mass() : 0.;
494 }
495 
BPhysPVTools.h
DerivationFramework::BPhysPVCascadeTools::ProcessVertex
void ProcessVertex(const std::vector< TLorentzVector > &mom, Amg::MatrixX cov, xAOD::BPhysHypoHelper &vtx, xAOD::BPhysHelper::pv_type pvtype, double mass) const
Definition: BPhysPVCascadeTools.cxx:54
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
xAOD::BPhysHelper::setA0xyErr
float setA0xyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter error
Definition: BPhysHelper.cxx:1056
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
test_pyathena.px
px
Definition: test_pyathena.py:18
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Trk::VxCascadeInfo
Definition: VxCascadeInfo.h:75
max
#define max(a, b)
Definition: cfImp.cxx:41
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
DerivationFramework::BPhysPVCascadeTools::LinkVertices
static bool LinkVertices(SG::AuxElement::Decorator< VertexLinkVector > &decor, const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer, const xAOD::Vertex *vert)
Definition: BPhysPVCascadeTools.cxx:460
DerivationFramework::BPhysPVCascadeTools::FillCandwithRefittedVertices
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)
Definition: BPhysPVCascadeTools.cxx:257
xAOD::BPhysHypoHelper::setTauErr
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
Definition: BPhysHypoHelper.cxx:176
xAOD::BPhysHelper::setRefitPVStatus
bool setRefitPVStatus(int code, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the exitCode of the refitter for vertex of type pv_type.
Definition: BPhysHelper.cxx:844
index
Definition: index.py:1
DerivationFramework::BPhysPVCascadeTools::getParticleMass
static double getParticleMass(const HepPDT::ParticleDataTable *pdt, int pdg)
Definition: BPhysPVCascadeTools.cxx:491
Trk::VxSecVertexInfo::vertices
const std::vector< xAOD::Vertex * > & vertices() const
Definition: VxSecVertexInfo.cxx:100
skel.it
it
Definition: skel.GENtoEVGEN.py:423
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
DerivationFramework::BPhysPVCascadeTools::FillBPhysHelper
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.
Definition: BPhysPVCascadeTools.cxx:32
DerivationFramework::BPhysPVTools
Definition: BPhysPVTools.h:25
xAOD::BPhysHelper::PV_MIN_Z0
@ PV_MIN_Z0
Definition: BPhysHelper.h:475
athena.exitcode
int exitcode
Definition: athena.py:159
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
PrimaryVertexRefitter.h
DerivationFramework::BPhysPVTools::FillBPhysHelperNULL
void FillBPhysHelperNULL(xAOD::BPhysHelper &vtx, const xAOD::VertexContainer *PvContainer, xAOD::BPhysHelper::pv_type pvtype, bool do3d=false) const
Definition: BPhysPVTools.cxx:57
Trk::VxCascadeInfo::getCovariance
const std::vector< Amg::MatrixX > & getCovariance() const
Definition: VxCascadeInfo.h:132
DerivationFramework::BPhysPVCascadeTools::GetBeamSpot
Amg::Vector3D GetBeamSpot() const
Get the current beamspot position either from cache or from BeamCondSvc.
Definition: BPhysPVCascadeTools.cxx:146
x
#define x
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
xAOD::BPhysHypoHelper::TAU_INV_MASS
@ TAU_INV_MASS
Definition: BPhysHypoHelper.h:137
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
Analysis::PrimaryVertexRefitter::refitVertex
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
Definition: PrimaryVertexRefitter.cxx:40
xAOD::VxType::VertexType
VertexType
Vertex types.
Definition: TrackingPrimitives.h:569
DerivationFramework::BPhysPVCascadeTools::CollectAllChargedTracks
static std::vector< const xAOD::TrackParticle * > CollectAllChargedTracks(const std::vector< xAOD::Vertex * > &cascadeVertices)
Definition: BPhysPVCascadeTools.cxx:246
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DerivationFramework::BPhysPVCascadeTools::GetGoodPV
static std::vector< const xAOD::Vertex * > GetGoodPV(const xAOD::VertexContainer *pvContainer)
Static method call with DerivationFramework::BPhysDerHelpers::GetGoodPV Returns a std::vector contain...
Definition: BPhysPVCascadeTools.cxx:120
xAOD::BPhysHypoHelper
Definition: BPhysHypoHelper.h:73
DerivationFramework::BPhysPVCascadeTools::SetVectorInfo
static void SetVectorInfo(xAOD::BPhysHelper &, const Trk::VxCascadeInfo *)
Definition: BPhysPVCascadeTools.cxx:424
BPHYS_CHECK
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
Definition: BPhysHelper.h:738
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
xAOD::BPhysHelper::pv_type
pv_type
: Enum type of the PV
Definition: BPhysHelper.h:475
Analysis::PrimaryVertexRefitter
Definition: PrimaryVertexRefitter.h:26
xAOD::BPhysHelper::setA0xy
float setA0xy(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter
Definition: BPhysHelper.cxx:1045
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::BPhysPVCascadeTools::FindLowZIndex
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.
Definition: BPhysPVCascadeTools.cxx:76
xAOD::BPhysHelper::setZ0Err
float setZ0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter error
Definition: BPhysHelper.cxx:1078
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
DerivationFramework::BPhysPVCascadeTools::PrepareVertexLinks
static void PrepareVertexLinks(Trk::VxCascadeInfo *result, const xAOD::TrackParticleContainer *importedTrackCollection)
Definition: BPhysPVCascadeTools.cxx:204
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
xAOD::BPhysHelper::PV_MIN_A0
@ PV_MIN_A0
Definition: BPhysHelper.h:475
python.xAODType.dummy
dummy
Definition: xAODType.py:4
DerivationFramework::BPhysPVCascadeTools::FindLowZ0BAIndex
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....
Definition: BPhysPVCascadeTools.cxx:155
DerivationFramework::BPhysPVCascadeTools::uniqueCollection
static bool uniqueCollection(const std::vector< const xAOD::TrackParticle * > &)
Definition: BPhysPVCascadeTools.cxx:443
xAOD::BPhysHelper::setA0Err
float setA0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
3D impact parameter error
Definition: BPhysHelper.cxx:1034
xAOD::BPhysHypoHelper::TAU_CONST_MASS
@ TAU_CONST_MASS
Definition: BPhysHypoHelper.h:137
a0
double a0
Definition: globals.cxx:27
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
BPhysPVCascadeTools.h
xAOD::BPhysHelper::setLxy
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 ...
Definition: BPhysHelper.cxx:888
min
#define min(a, b)
Definition: cfImp.cxx:40
DerivationFramework::BPhysPVCascadeTools::DistInZtoDOCA
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.
Definition: BPhysPVCascadeTools.cxx:174
xAOD::BPhysHelper::setPv
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.
Definition: BPhysHelper.cxx:831
xAOD::VxType::PileUp
@ PileUp
Pile-up vertex.
Definition: TrackingPrimitives.h:573
Amg::py
@ py
Definition: GeoPrimitives.h:39
Py
Definition: PyDataStore.h:24
DerivationFramework::BPhysPVCascadeTools::BPhysPVCascadeTools
BPhysPVCascadeTools(const CascadeTools *cascadeTools)
Definition: BPhysPVCascadeTools.cxx:17
xAOD::BPhysHelper::vtx
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
Definition: BPhysHelper.h:108
charge
double charge(const T &p)
Definition: AtlasPID.h:494
xAOD::BPhysHelper::PV_MAX_SUM_PT2
@ PV_MAX_SUM_PT2
Definition: BPhysHelper.h:475
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::VxCascadeInfo::getParticleMoms
const std::vector< std::vector< TLorentzVector > > & getParticleMoms() const
Definition: VxCascadeInfo.h:131
DerivationFramework::CascadeTools
Definition: CascadeTools.h:21
query_example.col
col
Definition: query_example.py:7
xAOD::BPhysHelper::setLxyErr
bool setLxyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
Definition: BPhysHelper.cxx:899
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
VxCascadeInfo.h
BPhysHelper.h
: B-physics xAOD helpers.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
python.PyAthena.v
v
Definition: PyAthena.py:157
xAOD::BPhysHelper::setOrigPv
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.
Definition: BPhysHelper.cxx:818
xAOD::BPhysHelper::setRefTrks
bool setRefTrks(std::vector< float > px, std::vector< float > py, std::vector< float > pz)
Sets refitted track momenta.
Definition: BPhysHelper.cxx:286
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
DeMoScan.index
string index
Definition: DeMoScan.py:362
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
Trk::V0Tools
Definition: V0Tools.h:36
DerivationFramework::BPhysPVCascadeTools::FindLowA0Index
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.
Definition: BPhysPVCascadeTools.cxx:98
python.changerun.pv
pv
Definition: changerun.py:81
xAOD::BPhysHelper::pv
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
Definition: BPhysHelper.cxx:796
xAOD::BPhysHelper::setA0
float setA0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the 3D and transverse impact parameters and their error.
Definition: BPhysHelper.cxx:1023
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
xAOD::BPhysHelper::setZ0
float setZ0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter
Definition: BPhysHelper.cxx:1067
DerivationFramework::BPhysPVCascadeTools::SetMinNTracksInPV
void SetMinNTracksInPV(size_t PV_minNTracks)
Set the minimum number of tracks required for primary vertices to be considered for primary vertex as...
Definition: BPhysPVCascadeTools.cxx:139
DerivationFramework::BPhysPVCascadeTools::VertexLinkVector
std::vector< VertexLink > VertexLinkVector
Definition: BPhysPVCascadeTools.h:36
python.PyAthena.obj
obj
Definition: PyAthena.py:135
xAOD::BPhysHypoHelper::setTau
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.
Definition: BPhysHypoHelper.cxx:140
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DerivationFramework::BPhysPVTools::FindHighPtIndex
size_t FindHighPtIndex(const std::vector< const xAOD::Vertex * > &PVlist) const
Definition: BPhysPVTools.cxx:413
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
DerivationFramework::BPhysPVCascadeTools::DocaExtrapToBeamSpot
Amg::Vector3D DocaExtrapToBeamSpot(const std::vector< TLorentzVector > &mom, const xAOD::BPhysHelper &obj) const
Point of DOCA w.r.t.
Definition: BPhysPVCascadeTools.cxx:183
xAOD::BPhysHelper::PV_MIN_Z0_BA
@ PV_MIN_Z0_BA
Definition: BPhysHelper.h:475
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.