Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
BPhysVertexTrackBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //============================================================================
6 // BPhysVertexTrackBase.cxx
7 //============================================================================
8 //
9 // Author : Wolfgang Walkowiak <Wolfgang.Walkowiak@cern.ch.>
10 // Changes:
11 //
12 // Base class for vertex-track related classes in need of
13 // track-to-vertex association handling.
14 //
15 // Derived classes should overwrite the following methods instead
16 // of the orginal initialize() etc methods:
17 // - initializeHook()
18 // - finalizeHook()
19 // - addBranchesHook() -- only called at end of addBranches()
20 // - addBranchesSVLoopHook() -- preferred (inside SV loop)
21 //
22 // From within addBranchesSVLoopHook()
23 // - calculateValues()
24 // should be called and the following hook methods should be overwritten:
25 // - calcValuesHook() -- called for the actual calculation of values
26 // - fastFillHook() -- called to check and apply caching of values
27 //
28 // For an usage example see BVertexTrackIsoTool and BPHY8.py .
29 //
30 // Job options provided by this class:
31 // - BranchPrefixes -- vector of prefixes to assign to
32 // added branches
33 // (Must be of same size as VertexContainerNames
34 // and in the same order.)
35 // - BranchBaseName -- assign the base name of added branches
36 // (default: iso)
37 // - BranchSuffix -- assign the suffix of added branches
38 // (default: empty = none)
39 // - VertexContainerNames -- names of containers for secondary vertices
40 // - TrackParticleContainerName -- name of container for TrackParticles
41 // - TrackToVertexTool -- ToolHandle for track-to-vertex tool
42 // - TrackSelectionTools -- Array of ToolHandles for track
43 // selection tools; each tool should
44 // be named XXXX_YYYY, where the YYYY
45 // suffix string which needs to be unique;
46 // will be used to name the isolation track
47 // category (part of the new attribute names)
48 // - RefPVContainerNames -- List of refitted PV container names.
49 // (Must be of same size as VertexContainerNames
50 // and in the same order.)
51 // - DoVertexType -- PV-to-SV association types to be
52 // considered (bitwise variable, see
53 // xAODBPhys::BPhysHelper)
54 // - UseTrackTypes -- List of or-ed bit-wise selection of
55 // track sets to consider:
56 // bit : meaning
57 // 0 : tracks close to PV associated
58 // with SV
59 // 1 : tracks associated with dummy PV
60 // ("type-0 PV tracks")
61 // 2 : tracks associated with PV of type 1
62 // 3 : tracks associated with PV of type 2
63 // 4 : tracks associated with PV of type 3
64 // 5 : tracks associated with PV with types
65 // other than 0 to 4.
66 // 6 : tracks with missing pointer to
67 // PV (NULL pointer)
68 // 7-22: tracks being closest to assoc. PV
69 // useRefittedPVs doDCAin3D chi2DefToUse
70 // 7 : yes no 0
71 // 8 : no no 0
72 // 9 : yes yes 0
73 // 10 : no yes 0
74 // 11 : yes no 1
75 // 12 : no no 1
76 // 13 : yes yes 1
77 // 14 : no yes 1
78 // 15 : yes no 2
79 // 16 : no no 2
80 // 17 : yes yes 2
81 // 18 : no yes 2
82 // 19 : yes -- 3
83 // 20 : no -- 3
84 // 21 : yes -- 4
85 // 22 : no -- 4
86 // 23 : yes -- 5
87 // 24 : no -- 5
88 // 25 : yes yes 6
89 // 26 : no yes 6
90 // 27 : yes yes 7
91 // 28 : no yes 7
92 // 29 : yes yes 8
93 // 30 : no yes 8
94 // 31 : yes yes 9
95 // 32 : no yes 9
96 // useRefittedPVs:
97 // replace PV associated to decay candidate
98 // by the refitted PV
99 // doDCAin3D:
100 // use d0 and z0 in the determination of
101 // of the point of closest approach of
102 // a track to a vertex
103 // chi2DefToUse:
104 // PV uncertainties in the chi2 calculation
105 // in addition to track uncertainties
106 // 0 : use old method
107 // (only track uncertainties)
108 // 1 : from track perigee with
109 // uncertainties from track and vertex
110 // 2 : simple extrapolation from track
111 // parameters with uncertainties from
112 // track and vertex (extrapolation
113 // used for track swimming)
114 // 3 : CalcLogChi2toPV method from NtupleMaker
115 // using xAOD::TrackingHelpers.
116 // (only track uncertainties)
117 // 4 : CalcLogChi2toPV method from NtupleMaker
118 // using xAOD::TrackingHelpers.
119 // (track and vertex uncertainties)
120 // 5 : use TrackVertexAssociationTool
121 // 6 : full 3D chi2 from track perigee
122 // with uncertainties from track and
123 // vertex (sum of 3x3 covariance matrices)
124 // 7 : full 3D chi2 from track perigee with
125 // uncertainties from track and vertex
126 // (sum of 2x2 covariance matrices)
127 // 8 : simple extrapolation from track
128 // parameters with uncertainties
129 // from track and vertex
130 // (sum of 3x3 covariance matrices)
131 // 9 simple extrapolation from track
132 // parameters with uncertainties
133 // from track and vertex
134 // (sum of 2x2 covariance matrices)
135 // (E.g. 127 means to consider all tracks.)
136 // - IncPrecVerticesInDecay -- Include preceeding vertices in search
137 // for ID tracks and muons from decaying
138 // particle. (May be a bit slower but
139 // more accurate. Double-counting of track
140 // or muon objects is excluded.
141 // Default: True)
142 // - MinNTracksInPV -- Minimum number of tracks in PV for
143 // PV to be considered in calculation
144 // of closest PV to a track
145 // - PVTypesToConsider -- List of primary vertex types to consider
146 // in calculation of closest PV to a track
147 // - DebugTrackTypes -- Count tracks of specific types (bit
148 // patterns w.r.t. vertex association)
149 // and dump statistics to log file
150 // 0 : disabled
151 // 1 : count tracks of certain types
152 // - DebugTracksInEvents -- debug track selections in detail for
153 // a list of event numbers.
154 //
155 //
156 //============================================================================
157 //
160 #include "xAODBPhys/BPhysHelper.h"
164 #include "TVector3.h"
165 #include "TString.h"
166 #include <format>
167 #include <algorithm>
168 #include <sstream>
169 #include <limits>
170 
171 namespace DerivationFramework {
172 
173  //-------------------------------------------------------------------------
174  //
175  // helper class
177  const std::string& Bname,
178  const std::string& Prefix) :
179  name(std::move(Name)), bname(std::move(Bname)), prefix(std::move(Prefix)) {
180  }
181 
183  }
184 
186  const std::string& Bname,
187  const std::string& Prefix) {
188  name = std::move(Name);
189  bname = std::move(Bname);
190  prefix = std::move(Prefix);
191  }
192 
193  void BPhysVertexTrackBase::BaseItem::setPrefix(std::string Prefix) {
194  prefix = std::move(Prefix);
195  }
196 
198  // needs to be implemented by derived class
199  }
200 
201  std::string BPhysVertexTrackBase::BaseItem::buildName(const std::string& qualifier,
202  const std::string& suffix) const {
203  std::string f = std::format("{}{}{}{}{}",
204  (prefix.length() > 0 ? prefix + "_" : ""),
205  (bname.length() > 0 ? bname + "_" : ""),
206  (qualifier.length() > 0 ? qualifier + "_" : ""),
207  name,
208  suffix);
209  return f;
210  }
211 
213  std::string f = std::format("nm: {}\nbn: {}", name, bname);
214  return f;
215  }
216  //-------------------------------------------------------------------------
217  //
218  // helper class (for track types)
219  //
221  TrackTypeCounter(BPhysVertexTrackBase& Parent, std::string Name)
222  : name(std::move(Name)), m_parent(Parent) {
223  }
224 
226 
228  uint64_t rtype,
229  const std::string &prefix,
230  const std::string &suffix,
231  uint64_t counts) {
232  std::string f = std::format("{}T{:010d}_R{:010d}{}",
233  (prefix.length() > 0 ? prefix + "_" : ""),
234  atype,
235  m_parent.m_useTrackTypes[rtype],
236  (suffix.length() > 0 ? "_" + suffix : ""));
237 
238  addToCounter(f, atype, counts);
239  }
240 
242  uint64_t atype,
243  uint64_t counts) {
244 
245  NameCountMap_t::const_iterator it = m_cnts.find(name);
246 
247  if ( it != m_cnts.end() ) {
248  m_cnts[name].first += counts;
249  } else {
250  m_cnts[name] = std::make_pair(counts, atype);
251  }
252  }
253 
255  countsToString(uint indent) const {
256 
257  std::string str = std::format("{}Counters for {}:\n", std::string(indent, ' '), name);
258 
259  int lmax(0);
260  for (NameCountMap_t::const_iterator it = m_cnts.begin();
261  it != m_cnts.end(); ++it) {
262  lmax = std::max(lmax, (int)(it->first).length());
263  }
264 
265  for (NameCountMap_t::const_iterator it = m_cnts.begin();
266  it != m_cnts.end(); ++it) {
267  std::string f = std::format("{:>{}}{:<{}} : {:>10} {:>33}",
268  " ", indent + 4,
269  it->first, lmax,
270  (it->second).first,
271  std::bitset<33>((it->second).second).to_string());
272  str += f + "\n";
273  }
274  // clean up last newline
275  str.erase(str.length()-1);
276 
277  return str;
278  }
279  //--------------------------------------------------------------------------
280  //-------------------------------------------------------------------------
281  // static members
283  const std::string BPhysVertexTrackBase::track_type_str[] =
284  {"ASSOCPV", "PVTYPE0", "PVTYPE1", "PVTYPE2", "PVTYPE3", "NONE", "NULLVP",
285  "CAPVRFN3U0", "CAPVNRN3U0", "CAPVRF3DU0", "CAPVNR3DU0",
286  "CAPVRFN3U1", "CAPVNRN3U1", "CAPVRF3DU1", "CAPVNR3DU1",
287  "CAPVRFN3U2", "CAPVNRN3U2", "CAPVRF3DU2", "CAPVNR3DU2",
288  "CAPVRFNNU3", "CAPVNRNNU3", "CAPVRFNNU4", "CAPVNRNNU4",
289  "CAPVRFNNU5", "CAPVNRNNU5", "CAPVRFNNU6", "CAPVNRNNU6",
290  "CAPVRFNNU7", "CAPVNRNNU7", "CAPVRFNNU8", "CAPVNRNNU8",
291  "CAPVRFNNU9", "CAPVNRNNU9"};
293  {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40,
294  0x80, 0x100, 0x200, 0x400,
295  0x800, 0x1000, 0x2000, 0x4000,
296  0x8000, 0x10000, 0x20000, 0x40000,
297  0x80000, 0x100000, 0x200000, 0x400000,
298  0x800000, 0x1000000, 0x2000000, 0x4000000,
299  0x8000000, 0x10000000, 0x20000000, 0x40000000,
300  0x80000000, 0x100000000};
302 
303  // static methods
304  const std::string
306  return track_type_str[type];
307  }
308 
310  return track_type_bit[type];
311  }
312 
314  // only bits 0 - 6
315  return 127;
316  }
317 
319  if ( s_track_type_all_cached == 0x0 ) {
320  for (unsigned int i=0; i<n_track_types; ++i) {
322  }
323  }
325  }
326 
327  uint64_t BPhysVertexTrackBase::rttor(const std::vector<uint64_t> &vtypes) {
328  // or of requested track types
329  uint64_t ttor(0);
330  for (size_t i=0; i<vtypes.size(); ++i) {
331  ttor |= vtypes[i];
332  }
333  return ttor;
334  }
335 
336  // track to string
337  std::string
339  std::string str;
340  if (track != nullptr) {
341  std::string str = std::format("p({:10.4f},{:10.4f},{:10.4f})\n"
342  "d:({:10.5f},{:10.5f},{:10.5f},{:10.5f},{:10.6f})",
343  (track->p4()).Px(), (track->p4()).Py(), (track->p4()).Pz(),
344  track->d0(), track->z0(), track->phi0(), track->theta(),
345  track->qOverP());
346  } // if track
347  return str;
348  }
349 
350  //--------------------------------------------------------------------------
351  // Static utility method to prefix every line by a certain string
352  //--------------------------------------------------------------------------
353  std::string BPhysVertexTrackBase::wrapLines(const std::string& lines,
354  const std::string& prefix) {
355 
356  std::string ostr;
357  std::istringstream stream(lines);
358  std::string line;
359  while ( std::getline(stream, line) ) {
360  if ( !ostr.empty() ) ostr += "\n";
361  ostr += prefix + line;
362  }
363  return ostr;
364  }
365  //--------------------------------------------------------------------------
366  //--------------------------------------------------------------------------
368  const std::string& n,
369  const IInterface* p)
370  : base_class(t,n,p), m_trackToVertexTool("Reco::TrackToVertex"),
371  m_tvaTool("CP::TrackVertexAssociationTool"),
372  m_tvaToolHasWpLoose(false),
373  m_tracks(NULL), m_tracksAux(NULL), m_nEvtsSeen(0), m_eventInfo(nullptr),
375  m_debugTracksInThisEvent(false) {
376 
377 
378  // Declare branch prefix
379  declareProperty("BranchPrefixes", m_branchPrefixes);
380  declareProperty("BranchBaseName", m_branchBaseName = "iso");
381  declareProperty("BranchSuffix" , m_branchSuffix = "" );
382 
383  // Necessary containers
384  declareProperty("VertexContainerNames" , m_vertexContainerNames);
385  declareProperty("TrackParticleContainerName",
387  declareProperty("TrackToVertexTool" , m_trackToVertexTool);
388  declareProperty("TrackSelectionTools" , m_trackSelectionTools);
389  declareProperty("TVATool" , m_tvaTool);
390  declareProperty("PVContainerName", m_pvContainerName = "PrimaryVertices");
391  declareProperty("RefPVContainerNames" , m_refPVContainerNames);
392  declareProperty("DoVertexType" , m_doVertexType = 8);
393  declareProperty("UseTrackTypes" , m_useTrackTypes = {7});
394  declareProperty("IncPrecVerticesInDecay", m_incPrecVerticesInDecay = true);
395  declareProperty("MinNTracksInPV" , m_minNTracksInPV = 0);
396  declareProperty("PVTypesToConsider" , m_pvTypesToConsider = {1,3});
397  declareProperty("DebugTrackTypes" , m_debugTrackTypes=0);
398  declareProperty("DebugTracksInEvents" , m_debugTracksInEvents = {});
399  }
400  //--------------------------------------------------------------------------
402 
403  ATH_MSG_DEBUG("BPhysVertexTrackBase::initialize() -- begin");
404 
405  if ( m_vertexContainerNames.size() == 0 ) {
406  ATH_MSG_ERROR("No vertex container names provided!");
407  }
408  if ( m_refPVContainerNames.size() == 0 ) {
409  ATH_MSG_ERROR("No refitted PV container names provided!");
410  }
411  if ( m_trackParticleContainerName == "" ) {
412  ATH_MSG_ERROR("No track particle container name provided!");
413  }
414  if ( m_pvContainerName == "" ) {
415  ATH_MSG_ERROR("No PV container name provided!");
416  }
417  if ( m_vertexContainerNames.size() != m_refPVContainerNames.size() ) {
418  ATH_MSG_ERROR("Size mismatch of VertexContainerNames ("
419  << m_vertexContainerNames.size()
420  << ") and RefPVContainerNames ("
421  << m_refPVContainerNames.size() << ") lists!");
422  }
423 
424  if ( m_vertexContainerNames.size() != m_branchPrefixes.size() ) {
425  ATH_MSG_ERROR("Size mismatch of VertexContainerNames ("
426  << m_vertexContainerNames.size()
427  << ") and BranchPrefixes ("
428  << m_branchPrefixes.size() << ") lists!");
429  }
430 
431  // TrackToVertexTool
432  ATH_CHECK(m_trackToVertexTool.retrieve());
433 
434  // TrackSelectionTools
435  for (auto selTool : m_trackSelectionTools ) {
436  ATH_CHECK(selTool.retrieve());
437  }
438 
439  // TrackVertexAssociationTool
440  ATH_CHECK(m_tvaTool.retrieve());
441  // take note of working point
442  // const std::string tvaWp("Loose");
443  const std::string tvaWp =
444  dynamic_cast<CP::TrackVertexAssociationTool*>(m_tvaTool.get())->getProperty("WorkingPoint").toString();
445  m_tvaToolHasWpLoose = (tvaWp == "Loose");
446 
447  // initialize PV-to-SV association type vector
449 
450  // initialize track type request pattern
452 
453  // initialize track type counters
454  if ( m_debugTrackTypes > 0 ) {
455  m_mttc = std::make_unique<TrackTypeCounter>(*this, name());
456  }
457 
458  ATH_MSG_DEBUG("BPhysVertexTrackBase::initialize() -- end");
459 
460  return initializeHook();
461  }
462  //--------------------------------------------------------------------------
464 
465  ATH_MSG_DEBUG("BPhysVertexTrackBase::finalize()");
466 
467  // dump track type counters to log
468  if ( m_debugTrackTypes > 0 ) {
469  ATH_MSG_INFO("Track type counters:\n" << m_mttc->countsToString());
470  }
471 
472  // everything all right
473  return finalizeHook();
474  }
475  //--------------------------------------------------------------------------
477 
478  ATH_MSG_DEBUG("BPhysVertexTrackBase::addBranches() -- begin");
479 
480  // counter
481  m_nEvtsSeen++;
482 
483  // run and event numbers
484  CHECK(evtStore()->retrieve(m_eventInfo));
487 
488  // debug tracks in current event?
490  m_debugTracksInEvents.end(),
491  m_evtNumber)
492  != m_debugTracksInEvents.end());
493 
494  // retrieve primary vertices container
495  m_pvtxContainer = NULL;
497  ATH_MSG_DEBUG("Found PV collection with key " << m_pvContainerName);
498 
499 
500  // retrieve ID track container
501  m_tracks = NULL;
502  m_tracksAux = NULL;
504  if (evtStore()->contains<xAOD::
506  CHECK(evtStore()->retrieve(m_tracksAux,
508  } else {
509  ATH_MSG_DEBUG("No aux track collection with key "
510  << m_trackParticleContainerName+"Aux.");
511  }
512  ATH_MSG_DEBUG("Found track collection with key "
514 
515  // Loop over all vertex containers
516  for (size_t i=0; i<m_vertexContainerNames.size(); ++i) {
517  // vertex container and its auxilliary store
518  const xAOD::VertexContainer* svtxContainer = NULL;
519  const xAOD::VertexAuxContainer* svtxAuxContainer = NULL;
520  // refitted primary vertex container and its auxilliary store
521  const xAOD::VertexContainer* refPVContainer = NULL;
522  const xAOD::VertexAuxContainer* refPVAuxContainer = NULL;
523 
524  // retrieve from StoreGate
525  CHECK(evtStore()->retrieve(svtxContainer, m_vertexContainerNames[i]));
526  CHECK(evtStore()->retrieve(svtxAuxContainer,
527  m_vertexContainerNames[i]+"Aux."));
528  ATH_MSG_DEBUG("Found SV collection with key "
530  CHECK(evtStore()->retrieve(refPVContainer ,
532  CHECK(evtStore()->retrieve(refPVAuxContainer,
533  m_refPVContainerNames[i]+"Aux."));
534  ATH_MSG_DEBUG("Found refitted PV collection with key "
536 
537  // vertex container depending setup in derived class
539 
540  // loop over secondary vertices
542  svtxContainer->begin(); vtxItr!=svtxContainer->end();
543  ++vtxItr) {
544 
545  CHECK(addBranchesSVLoopHook(*vtxItr));
546 
547  } // end of loop over vertices
548  } // end of loop over vertex container names
549 
550  ATH_MSG_DEBUG("BPhysVertexTrackBase::addBranches() -- end");
551 
552  // nothing to do here
553  return addBranchesHook();
554  }
555 
556  //--------------------------------------------------------------------------
557  // Hook method for initialize() -- to be overwritten by derived class
558  //--------------------------------------------------------------------------
560 
561  return StatusCode::SUCCESS;
562  }
563  //--------------------------------------------------------------------------
564  // Hook method for finalize() -- to be overwritten by derived class
565  //--------------------------------------------------------------------------
567 
568  return StatusCode::SUCCESS;
569  }
570  //--------------------------------------------------------------------------
571  // Hook method for addBranches() -- to be overwritten by derived class
572  //--------------------------------------------------------------------------
574 
575  return StatusCode::SUCCESS;
576  }
577  //--------------------------------------------------------------------------
578  // Hook method for addBranches() VC setup
579  // -- to be overwritten by derived class
580  //--------------------------------------------------------------------------
582 
583  // just to avoid a compiler warning
584  ATH_MSG_DEBUG("addBranchesVCSetupHook: Vertex container index " << ivc
585  << " for collection " << m_vertexContainerNames[ivc]
586  << " with prefix " << m_branchPrefixes[ivc]);
587 
588  return StatusCode::SUCCESS;
589  }
590  //--------------------------------------------------------------------------
591  // Hook method for addBranches() SV loop -- to be overwritten by derived class
592  //--------------------------------------------------------------------------
593  StatusCode
595 
596  // just to avoid a compiler warning
597  ATH_MSG_DEBUG("addBranchesSVLoopHook: Vertex " << vtx);
598 
599  return StatusCode::SUCCESS;
600  }
601  //--------------------------------------------------------------------------
602  // Calculate values -- used by calculateValues()
603  // -- to be overwritten by derived class
604  //--------------------------------------------------------------------------
605  StatusCode
607  const unsigned int ipv,
608  const unsigned int its,
609  const unsigned int itt) const {
610 
611  // just to avoid a compiler warning
612  ATH_MSG_DEBUG("calcIsolationOpti: vtx: " << vtx << ", ipv: " << ipv
613  << ", its: " << its << ", itt: " << itt);
614 
615  return StatusCode::SUCCESS;
616  }
617  //--------------------------------------------------------------------------
618  // Fill values from cache if found -- used by calculateValues()
619  // -- to be overwritten by derived class
620  //--------------------------------------------------------------------------
622  const int ipv) const {
623 
624  // just to avoid a compiler warning
625  ATH_MSG_DEBUG("fastIsoFill: vtx: " << vtx << ", ipv: " << ipv);
626 
627  return false;
628  }
629  //--------------------------------------------------------------------------
630  // Calculation loops -- needs to be called from inside the implementation
631  // of addBranchesSVLoopHook() in the derived class.
632  // Derived class also needs to provide override methods for
633  // - fastFillHook -- needs to return true if cached value is used
634  // - calcValuesHook -- actually calculating value(s)
635  //--------------------------------------------------------------------------
636  StatusCode
638 
639  ATH_MSG_DEBUG("BPhysVertexTrackBase::calculateValues -- begin");
640 
641  unsigned int nPvAssocs = m_pvAssocTypes.size();
642  unsigned int nTrackSels = m_trackSelectionTools.size();
643  unsigned int nTrackTypes = m_useTrackTypes.size();
644 
645  m_pvAssocResMap.clear();
646 
647  const xAOD::BPhysHelper cand(vtx);
648  for (unsigned int ipv = 0; ipv < nPvAssocs; ++ipv) {
649  if ( ipv == 0 || ! fastFillHook(vtx, ipv) ) {
650  for (unsigned int its = 0; its < nTrackSels; ++its) {
651  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
652  ATH_MSG_DEBUG("Calling calcValuesHook with ipv: " << ipv
653  << ", its: " << its << ", itt: " << itt);
654  CHECK(calcValuesHook(vtx, ipv, its, itt));
655  } // for itt
656  } // for its
657  // cache result index -- only needed once per ipv value
658  m_pvAssocResMap[buildPvAssocCacheName(vtx, ipv)] = ipv;
659  ATH_MSG_DEBUG("calculateValues: cache index: "
660  << buildPvAssocCacheName(vtx, ipv)
661  << " -- cached ipv: " << ipv);
662  } // if !fastFillHook()
663  } // for ipv
664 
665  return StatusCode::SUCCESS;
666  }
667  //-------------------------------------------------------------------------
668  // Build SV-to-PV association cache index string
669  //-------------------------------------------------------------------------
670  std::string
672  const int ipv) const {
673  xAOD::BPhysHelper cand(vtx);
674  std::string f = std::format("SV_{:p}_RPV_{:p}", static_cast<const void*>(cand.vtx()), static_cast<const void*>(cand.pv(m_pvAssocTypes[ipv])));
675 
676  return f;
677  }
678  //--------------------------------------------------------------------------
679  // getTrackCandPVLogChi2()
680  // Calculate the logChi2 (= log((d0/d0e)^2+(z0/z0e)^2) contribution of a
681  // track at the position closest to the PV associated with the SV.
682  //--------------------------------------------------------------------------
684  track,
685  const xAOD::Vertex* vtx,
686  bool doDCAin3D,
687  int chi2DefToUse
688  ) const {
689 
690  return getTrackLogChi2DCA(track, vtx, doDCAin3D, chi2DefToUse)[4];
691  }
692  //--------------------------------------------------------------------------
693  // getTrackLogChi2DCA()
694  // Calculate logChi2 (= log((d0/d0e)^2+(z0/z0e)^2) contribution of a
695  // track at the position closest to a position and
696  // the distance of closest approach of a track w.r.t.
697  // a position. Either only in the transverse plane or in 3 dimensions.
698  // Option chi2DefToUse:
699  // 0 : from track perigee with uncertainties from track only
700  // 1 : from track perigee with uncertainties from track and vertex
701  // 2 : simple extrapolation from track parameters
702  // with uncertainties from track and vertex
703  // 3 : CalcLogChi2toPV method from NtupleMaker using xAOD::TrackingHelpers.
704  // (only track uncertainties)
705  // 4 : CalcLogChi2toPV method from NtupleMaker using xAOD::TrackingHelpers.
706  // (track and vertex uncertainties)
707  // 5 : use TrackVertexAssociationTool
708  // 6 : full 3D chi2 from track perigee with uncertainties
709  // from track and vertex (sum of 3x3 covariance matrices)
710  // 7 : full 3D chi2 from track perigee with uncertainties
711  // from track and vertex (sum of 2x2 covariance matrices)
712  // 8 : simple extrapolation from track parameters with uncertainties
713  // from track and vertex (sum of 3x3 covariance matrices)
714  // 9 simple extrapolation from track parameters with uncertainties
715  // from track and vertex (sum of 2x2 covariance matrices)
716  // Returned vector components:
717  // 0: d0, 1: d0Err, 2: z0, 3: z0Err, 4: logChi2, 5: dca, 6: okFlag
718  // 7: vtxErrPart2, 8: trkErrPart2, 9: phi0Used
719  //--------------------------------------------------------------------------
720  std::vector<double>
722  const xAOD::Vertex* vtx,
723  bool doDCAin3D,
724  int chi2DefToUse) const {
725  // presets
726  std::vector<double> res = {-999., -99., -999., -99., -100., -100., -1.,
727  -99., -99., -999.};
728 
729  const Amg::Vector3D pos = vtx->position();
730  const AmgSymMatrix(3) poscov = vtx->covariancePosition();
731  auto ctx = Gaudi::Hive::currentContext();
732  if ( track != NULL ) {
733  if ( chi2DefToUse < 2 || (chi2DefToUse > 5 && chi2DefToUse < 8) ) {
734  // use track perigee method
735  std::unique_ptr<const Trk::Perigee>
736  trkPerigee(m_trackToVertexTool->perigeeAtVertex(ctx, *track, pos));
737  if ( trkPerigee != NULL ) {
738  res[0] = trkPerigee->parameters()[Trk::d0];
739  res[2] = trkPerigee->parameters()[Trk::z0];
740  const AmgSymMatrix(5)* locError = trkPerigee->covariance();
741  if ( locError != NULL ) {
742  // uncertainties from track
743  res[1] = Amg::error(*locError, Trk::d0);
744  res[3] = Amg::error(*locError, Trk::z0);
745  if ( chi2DefToUse == 1 ) {
746  // add uncertainties from vertex
747  Amg::Vector3D perppt(trkPerigee->momentum().y()/trkPerigee->pT(),
748  -trkPerigee->momentum().x()/trkPerigee->pT(),
749  0.);
750  double vtxD0Err2 = perppt.transpose()*poscov*perppt;
751  res[1] = sqrt( pow(res[1], 2.) + vtxD0Err2 );
752  res[3] = sqrt( pow(res[3], 2.) + poscov(2,2) );
753  }
754  if ( chi2DefToUse < 2 ) {
755  if ( fabs(res[1]) > 0. && fabs(res[3]) > 0. ) {
756  res[4] = log( pow(res[0]/res[1], 2.)
757  + pow(res[2]/res[3], 2.) );
758  res[6] = 2.; // ok
759  } else {
760  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
761  << " d0 = " << res[0] << ", d0Err = "
762  << res[1] << ", z0 = " << res[2]
763  << ", z0Err = " << res[3]);
764  }
765  }
766  // chi2DefToUse 6 or 7
767  if ( chi2DefToUse > 5 && chi2DefToUse < 8 ) {
768  double phi0 = trkPerigee->parameters()[Trk::phi0];
769  double doca = sqrt(pow(res[0],2.) + pow(res[2], 2.));
770  res[9] = phi0;
771  if ( doca > 0. ) {
772  if ( chi2DefToUse == 6 ) {
773  AmgMatrix(5,3) dmat = AmgMatrix(5,3)::Zero();
774  dmat(0,0) = -sin(phi0);
775  dmat(0,1) = cos(phi0);
776  dmat(1,2) = 1.;
777  dmat(2,0) = -res[0]*cos(phi0);
778  dmat(2,1) = -res[0]*sin(phi0);
779  AmgSymMatrix(3) mCovTrk3D = dmat.transpose()*(*locError)*dmat;
780  Amg::Vector3D dvec(-res[0]*sin(phi0), res[0]*cos(phi0),
781  res[2]); // (x,y,z)
782  Amg::Vector3D duvec = dvec.unit();
783  // log(chi2) = log( docavec^T * V^-1 * docavec )
784  res[4] = log( dvec.transpose() * (poscov+mCovTrk3D).inverse()
785  * dvec );
786  res[7] = duvec.transpose()*poscov*duvec;
787  res[8] = duvec.transpose()*mCovTrk3D*duvec;
788  res[6] = 3.; // ok
789  }
790  if ( chi2DefToUse == 7 ) {
791  AmgMatrix(3,2) dmat = AmgMatrix(3,2)::Zero();
792  dmat(0,0) = -sin(phi0);
793  dmat(1,0) = cos(phi0);
794  dmat(2,0) = 0.;
795  dmat(0,1) = 0.;
796  dmat(1,1) = 0.;
797  dmat(2,1) = 1.;
798  AmgSymMatrix(2) mCovVtx2D = dmat.transpose()*poscov*dmat;
799  AmgSymMatrix(2) mCovTrk2D = AmgSymMatrix(2)::Zero();
800  mCovTrk2D(0,0) = (*locError)(Trk::d0,Trk::d0);
801  mCovTrk2D(0,1) = (*locError)(Trk::d0,Trk::z0);
802  mCovTrk2D(1,0) = (*locError)(Trk::d0,Trk::z0);
803  mCovTrk2D(1,1) = (*locError)(Trk::z0,Trk::z0);
804  Amg::Vector2D dvec(res[0], res[2]); // (d0, z0)
805  Amg::Vector2D duvec = dvec.unit();
806  // log(chi2) = log( (d0, z0) * V^-1 * (d0, z0)^T )
807  res[4] = log( dvec.transpose()*(mCovVtx2D+mCovTrk2D).inverse()
808  * dvec );
809  res[7] = duvec.transpose()*mCovVtx2D*duvec;
810  res[8] = duvec.transpose()*mCovTrk2D*duvec;
811  res[6] = 4.; // ok
812  }
813  } else {
814  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
815  << " doca == 0 !");
816  }
817  } // if chi2DefToUse > 5 && chi2DefToUse < 8
818  res[5] = doDCAin3D ?
819  sqrt( pow(res[0], 2.) + pow(res[2], 2.) ) : res[0];
820  res[6] += 1.; // ok
821  } else {
822  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
823  " locError pointer is NULL!");
824  }
825  } else {
826  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
827  " trkPerigee pointer is NULL!");
828  } // if trkPerigee
829 
830  } else if ( chi2DefToUse == 2
831  || (chi2DefToUse > 7 && chi2DefToUse < 10 )) {
832  // simple extrapolation method
833  // (directly taken from NtupleMaker for comparisons)
834 
835  // SV position and covariance matrix
836  TVector3 SV_def(vtx->x(), vtx->y(), vtx->z());
837  const AmgSymMatrix(3)& SV_cov = poscov;
838 
839  // chi2 track to SV
840  double px = ( track->p4() ).Px();
841  double py = ( track->p4() ).Py();
842  double pt = ( track->p4() ).Pt();
843  double d0 = track->d0();
844  double d0Err2 = track->definingParametersCovMatrixVec()[0];
845  double z0 = track->z0();
846  double z0Err2 = track->definingParametersCovMatrixVec()[2];
847  double theta = track->theta();
848  double d0z0Cov = track->definingParametersCovMatrixVec()[1];
849  double phi = track->phi();
850 
851  TVector3 trk_origin( track->vx(), track->vy(), track->vz() );
852  TVector3 SV = SV_def - trk_origin;
853 
854  // calc. error in direction perpendicular to pT (still x-y plane)
855  double upx = py/pt;
856  double upy = -px/pt;
857  double d0toSV = d0 + (SV[0]*upx + SV[1]*upy);
858  double d0toSVErr2 = upx*SV_cov(0, 0)*upx + 2*upx*SV_cov(1, 0)*upy
859  + upy*SV_cov(1, 1)*upy + d0Err2;
860 
861  upx = px/pt;
862  upy = py/pt;
863  double cot_theta = cos(theta)/sin(theta);
864  double z0corr = (SV[0]*upx + SV[1]*upy)*cot_theta;
865  double z0toSV = z0 + z0corr - SV[2];
866  double z0toSVErr2 = SV_cov(2, 2) + z0Err2;
867 
868  double docaSV = sqrt( pow(d0toSV, 2) + pow(z0toSV, 2) );
869 
870  double chi2testSV(999.);
871  if ( chi2DefToUse == 2 ) {
872  if (d0toSVErr2 !=0 && z0toSVErr2 != 0)
873  chi2testSV = log(pow( d0toSV, 2)/d0toSVErr2
874  + pow( z0toSV, 2)/z0toSVErr2);
875  // set results
876  res = {d0toSV, sqrt(d0toSVErr2), z0toSV, sqrt(z0toSVErr2),
877  chi2testSV, (doDCAin3D ? docaSV : d0toSV), 4,
878  -99., -99., -999.};
879  }
880  if ( chi2DefToUse > 7 && chi2DefToUse < 10 ) {
881  if ( docaSV > 0. ) {
882  if ( chi2DefToUse == 8 ) {
883  AmgMatrix(5,3) dmat = AmgMatrix(5,3)::Zero();
884  dmat(0,0) = -sin(phi);
885  dmat(0,1) = cos(phi);
886  dmat(1,2) = 1.;
887  dmat(2,0) = -d0toSV*cos(phi);
888  dmat(2,1) = -d0toSV*sin(phi);
889  const AmgSymMatrix(5) mCovTrk5D =
890  track->definingParametersCovMatrix();
891  AmgSymMatrix(3) mCovTrk3D = dmat.transpose()*mCovTrk5D*dmat;
892  Amg::Vector3D dvec(-d0toSV*sin(phi), d0toSV*cos(phi),
893  z0toSV); // (x,y,z)
894  Amg::Vector3D duvec = dvec.unit();
895  // log(chi2) = log( docavec^T * V^-1 * docavec )
896  double chi2testSV = log( dvec.transpose()
897  * (poscov+mCovTrk3D).inverse()
898  * dvec );
899  double vtx3DErr2 = duvec.transpose()*poscov*duvec;
900  double trk3DErr2 = duvec.transpose()*mCovTrk3D*duvec;
901  // set results
902  res = {d0toSV, sqrt(d0Err2), z0toSV, sqrt(z0Err2),
903  chi2testSV, (doDCAin3D ? docaSV : d0toSV), 5,
904  vtx3DErr2, trk3DErr2, phi};
905  }
906  if ( chi2DefToUse == 9 ) {
907  AmgMatrix(3,2) dmat = AmgMatrix(3,2)::Zero();
908  dmat(0,0) = -sin(phi);
909  dmat(1,0) = cos(phi);
910  dmat(2,0) = 0.;
911  dmat(0,1) = 0.;
912  dmat(1,1) = 0.;
913  dmat(2,1) = 1.;
914  AmgSymMatrix(2) mCovVtx2D = dmat.transpose()*SV_cov*dmat;
915  AmgSymMatrix(2) mCovTrk2D = AmgSymMatrix(2)::Zero();
916  mCovTrk2D(0,0) = d0Err2;
917  mCovTrk2D(0,1) = d0z0Cov;
918  mCovTrk2D(1,0) = d0z0Cov;
919  mCovTrk2D(1,1) = z0Err2;
920  Amg::Vector2D dvec(d0toSV, z0toSV);
921  Amg::Vector2D duvec = dvec.unit();
922  // log(chi2) = log( (d0, z0) * V^-1 * (d0, z0)^T )
923  chi2testSV = log( dvec.transpose()*(mCovVtx2D+mCovTrk2D).inverse()
924  * dvec );
925  double vtx2DErr2 = duvec.transpose()*mCovVtx2D*duvec;
926  double trk2DErr2 = duvec.transpose()*mCovTrk2D*duvec;
927 
928  if ( vtx2DErr2 < 0. || trk2DErr2 < 0. ) {
929  ATH_MSG_WARNING("BPhysVertexTrackBase::"
930  "getTrackLogChi2DCA(): "
931  << "vtx2DErr2 = " << vtx2DErr2
932  << " trk2DErr2 = " << trk2DErr2
933  << " chi2testSV = " << chi2testSV);
934  ATH_MSG_WARNING("dvec = " << dvec);
935  ATH_MSG_WARNING("mCovVtx2D = " << mCovVtx2D);
936  ATH_MSG_WARNING("mCovTrk2D = " << mCovTrk2D);
937  ATH_MSG_WARNING("dmat = " << dmat);
938  ATH_MSG_WARNING("SV_cov = " << SV_cov);
939  ATH_MSG_WARNING("det(mCovVtx2D) = " << mCovVtx2D.determinant());
940  ATH_MSG_WARNING("det(mCovTrk2D) = " << mCovTrk2D.determinant());
941  ATH_MSG_WARNING("det(SV_cov) = " << SV_cov.determinant());
942  ATH_MSG_WARNING("d0toSV = " << d0toSV
943  << " z0toSV = " << z0toSV
944  << " phi = " << phi
945  << " docaSV = " << docaSV);
946  }
947 
948  // set results
949  res = {d0toSV, sqrt(d0Err2), z0toSV, sqrt(z0Err2),
950  chi2testSV, (doDCAin3D ? docaSV : d0toSV), 6,
951  vtx2DErr2, trk2DErr2, phi};
952  }
953  } else {
954  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
955  << " docaSV == 0 !");
956  }
957  } // if chi2DefToUse > 7 && chi2DefToUse < 10
958 
959  } else if ( chi2DefToUse > 2 && chi2DefToUse < 5 ) {
960  // CalcLogChi2toPV method using xAOD::TrackingHelpers
961  // (simply taken from NtupleMaker for comparisons)
962  // N.B. z0significance method of the helper doesn't include pv_z0
963  // uncertainty
964  double d0sign(0.);
965  if (chi2DefToUse == 4) {
966  d0sign =
971  );
972  } else {
973  d0sign = xAOD::TrackingHelpers::d0significance( track );
974  }
975  // trk z0 is expressed relative to the beamspot position along z-axis
976  // (trk->vz())
977  // DCA always in 3D
978  double z0toPV = track->z0() + track->vz() - vtx->z();
979  double z0Err2 = track->definingParametersCovMatrixVec()[2];
980  if (chi2DefToUse == 4) z0Err2+= vtx->covariancePosition()(2,2);
981  double z0sign = z0toPV / sqrt( z0Err2 );
982  double chi2 = log( pow(d0sign, 2.) + pow(z0sign, 2.) );
983  // set results
984  res = {-999., -99., z0toPV, sqrt(z0Err2), chi2, -100., 4, -99., -99.,
985  -999.};
986 
987  } // if chi2DefToUse
988  } else {
989  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
990  " track pointer is NULL!");
991  res[6] = -2.;
992  } // if track != NULL
993  return res;
994  }
995  //--------------------------------------------------------------------------
996  // detTrackTypes(): returns a bit pattern of the applicable
997  // track types from {ASSOCPV, PVTYPE0, PVTYPE1, PVTYPE2, PVTYPE3, NONE,
998  // NULLVP, CAPVXXXXXXX, ...} (or'd).
999  //--------------------------------------------------------------------------
1001  const xAOD::Vertex* candPV,
1002  const xAOD::Vertex* candRefPV) const {
1003  int bits = 0x0;
1004 
1005  // PVTYPE0 - PVTYPE3, NONE
1006  ATH_MSG_ERROR("BPhysVertexTrackBase::detTrackTypes must be adjusted due to changes in TrackParticle");
1007 
1008  // ASOCPV
1009  if ( candPV != NULL ) {
1010  bool found(false);
1011  for (size_t i=0; i<candPV->nTrackParticles(); ++i) {
1012  if ( track == candPV->trackParticle(i) ) {
1013  found = true;
1014  break;
1015  }
1016  }
1017  if ( found ) bits |= track_type_bit[ASSOCPV];
1018  //
1019  // CLOSEAPV
1020  for (unsigned int i=7; i<n_track_types; ++i) {
1021  if ( (track_type_bit[i] & m_trackTypesUsed) > 0x0 ) {
1022  bool useRefittedPvs = ( i%2 == 1 );
1023  bool doDCAin3D = ( (i-7)%4 > 1 );
1024  int chi2DefToUse = (i-7)/4;
1025  // adjustment above bit 20
1026  if ( i > 20 ) {
1027  doDCAin3D = true;
1028  chi2DefToUse = (i-13)/2;
1029  }
1030  const xAOD::Vertex* minChi2PV(nullptr);
1031  if ( chi2DefToUse == 5 ) {
1032  minChi2PV =
1033  findAssocPV(track, candPV, candRefPV, m_pvTypesToConsider,
1034  m_minNTracksInPV, useRefittedPvs);
1035  } else {
1036  minChi2PV =
1037  findMinChi2PV(track, candPV, candRefPV, m_pvTypesToConsider,
1038  m_minNTracksInPV, useRefittedPvs,
1039  doDCAin3D, chi2DefToUse).first;
1040  } // if chi2DefToUse
1041  if ( candPV == minChi2PV
1042  || (candRefPV != nullptr && candRefPV == minChi2PV) ) {
1043  bits |= track_type_bit[i];
1044  }
1045  } // if m_trackTypesUsed
1046  } // for i
1047 
1048  } // if candPV != NULL
1049 
1050  return bits;
1051  }
1052  //--------------------------------------------------------------------------
1053  // findAllTracksInDecay: returns a vector of xAOD::TrackParticle objects
1054  // found in this vertex and subsequent decay vertices (if chosen).
1055  //--------------------------------------------------------------------------
1057  const {
1058 
1059  TrackBag tracks;
1060  findAllTracksInDecay(vtx, tracks);
1061 
1062  return tracks;
1063  }
1064  //--------------------------------------------------------------------------
1065  // findAllTracksInDecay: fills a vector of xAOD::TrackParticle objects
1066  // found in this vertex and subsequent decay vertices (if chosen).
1067  // Method avoids duplicate entries in vector.
1068  // Recursively calls itself if necessary.
1069  //--------------------------------------------------------------------------
1071  TrackBag& tracks)
1072  const {
1073 
1074  for (unsigned int i=0; i < vtx.vtx()->nTrackParticles(); ++i) {
1075  const xAOD::TrackParticle* track = vtx.vtx()->trackParticle(i);
1076  if ( std::find(tracks.begin(),tracks.end(),track) == tracks.end() ) {
1077  tracks.push_back(track);
1078  } // if
1079  } // for
1080  // loop over preceeding vertices
1081  if ( m_incPrecVerticesInDecay ) {
1082  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
1083  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
1084  findAllTracksInDecay(precVtx, tracks);
1085  } // if
1086  } // for
1087  }
1088  //--------------------------------------------------------------------------
1089  // findAllMuonsInDecay: returns a vector of xAOD::Muon objects
1090  // found in this vertex and subsequent decay vertices (if chosen).
1091  //--------------------------------------------------------------------------
1093  const {
1094 
1095  MuonBag muons;
1096  findAllMuonsInDecay(vtx, muons);
1097 
1098  return muons;
1099  }
1100  //--------------------------------------------------------------------------
1101  // findAllMuonsInDecay: fills vector of xAOD::Muon objects
1102  // found in this vertex and subsequent decay vertices (if chosen).
1103  // Method avoids duplicate entries in vector.
1104  // Recursively calls itself if necessary.
1105  //--------------------------------------------------------------------------
1107  MuonBag& muons)
1108  const {
1109 
1110  for (int i=0; i < vtx.nMuons(); ++i) {
1111  if ( std::find(muons.begin(),muons.end(),vtx.muon(i)) == muons.end() ) {
1112  muons.push_back(vtx.muon(i));
1113  } // if
1114  } // for
1115  // loop over preceeding vertices
1116  if ( m_incPrecVerticesInDecay ) {
1117  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
1118  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
1119  findAllMuonsInDecay(precVtx, muons);
1120  } // for
1121  } // if
1122  }
1123  //--------------------------------------------------------------------------
1124  // findAllMuonsIdTracksInDecay: returns a vector of xAOD::TrackParticle
1125  // objects found in this vertex and subsequent decay vertices.
1126  // Returns the tracks.
1127  // The vector of track pointers reeturned may contain NULL elements.
1128  //--------------------------------------------------------------------------
1129  TrackBag
1131  MuonBag& muons) const {
1132 
1133  TrackBag tracks;
1134  muons = findAllMuonsInDecay(vtx);
1135 
1136  for (MuonBag::const_iterator muItr = muons.begin(); muItr != muons.end();
1137  ++muItr) {
1138  const xAOD::TrackParticle* track =
1139  (*muItr)->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
1140  tracks.push_back(track);
1141  } // for
1142 
1143  return tracks;
1144  }
1145  //--------------------------------------------------------------------------
1146  // findMuonRefTrackMomenta: returns a vector<TVector3> containing the
1147  // three momenta of refitted tracks identified as muons.
1148  // The vector may contain (0,0,0) elements indicating an error.
1149  //--------------------------------------------------------------------------
1150  std::vector<TVector3>
1152  MuonBag& muons) const {
1153 
1154  std::vector<TVector3> refMuTracks;
1155 
1156  // quick solution if nRefTrks == nMuons:
1157  if ( vtx.nRefTrks() == vtx.nMuons() && !m_incPrecVerticesInDecay ) {
1158  muons = vtx.muons();
1159  for ( auto refMuTrack : vtx.refTrks() ) {
1160  refMuTracks.push_back(refMuTrack);
1161  }
1162  } else {
1163  TrackBag muonIdTracks = findAllMuonIdTracksInDecay(vtx, muons);
1164  if ( vtx.nRefTrks() == (int)vtx.vtx()->nTrackParticles() ) {
1165  for (int i=0; i<vtx.nRefTrks(); ++i) {
1166  const xAOD::TrackParticle* otp =
1167  (const xAOD::TrackParticle*)vtx.refTrkOrigin(i);
1168  if ( otp != NULL ) {
1169  if ( std::find(muonIdTracks.begin(), muonIdTracks.end(), otp)
1170  != muonIdTracks.end() ) {
1171  refMuTracks.push_back(vtx.refTrk(i));
1172  }
1173  } else {
1174  ATH_MSG_WARNING("BPhysVertexTrackBase::findMuonRefTrackMomenta():"
1175  " refTrkOrigin == NULL for refTrk # "
1176  << i << " !");
1177  }
1178  } // for
1179  } else {
1180  ATH_MSG_WARNING("BPhysVertexTrackBase::findMuonRefTrackMomenta():"
1181  " size mismatch #refTrks = " << vtx.nRefTrks()
1182  << "#trackParticles = " << vtx.vtx()->nTrackParticles()
1183  << " !");
1184  } // if nRefTracks == nTrackParticles
1185  // loop over preceeding vertices -- only if not all refMuTrks found yet
1186  if ( m_incPrecVerticesInDecay && muons.size() > refMuTracks.size() ) {
1187  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
1188  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
1189  std::vector<TVector3> precRefMuTracks =
1190  findMuonRefTrackMomenta(precVtx, muons);
1191  // append only if not yet contained in
1192  for ( auto precRefMuTrack : precRefMuTracks ) {
1193  if ( std::find(refMuTracks.begin(), refMuTracks.end(),
1194  precRefMuTrack) == refMuTracks.end() ) {
1195  refMuTracks.push_back(precRefMuTrack);
1196  } // if
1197  } // for
1198  } // for ivtx
1199  } // if
1200  } // if (shortcut)
1201 
1202  // debug output
1203  if ( msgLvl( MSG::DEBUG ) ) {
1204  ATH_MSG_DEBUG("BPhysVertexTrackBase::findMuonRefTrackMomenta():"
1205  << " #muons: " << muons.size()
1206  << " #refMuTrks: " << refMuTracks.size());
1207  TString str = Form(">> refMuTracks(%d):\n", (int)refMuTracks.size());
1208  for (unsigned int i=0; i < refMuTracks.size(); ++i) {
1209  str += Form("(%10.4f,%10.4f,%10.4f) ",
1210  refMuTracks[i].x(), refMuTracks[i].y(),
1211  refMuTracks[i].z());
1212  }
1213  ATH_MSG_DEBUG(str.Data());
1214  }
1215 
1216  return refMuTracks;
1217  }
1218 
1219  //--------------------------------------------------------------------------
1220  // selectTracks: returns a vector of xAOD::TrackParticle objects
1221  // seleted from the input track collection according to the selection
1222  // criteria and with respect to the B candidate vertex.
1223  //--------------------------------------------------------------------------
1226  inpTracks,
1227  xAOD::BPhysHelper& cand,
1228  const unsigned int ipv,
1229  const unsigned int its,
1230  const unsigned int itt) const {
1231 
1232  return selectTracks(inpTracks, findAllTracksInDecay(cand), cand,
1233  ipv, its, itt);
1234  }
1235  //--------------------------------------------------------------------------
1236  // selectTracks: returns a vector of xAOD::TrackParticle objects
1237  // seleted from the input track collection according to the selection
1238  // criteria and with respect to the B candidate vertex.
1239  //--------------------------------------------------------------------------
1242  inpTracks,
1243  const TrackBag& exclTracks,
1244  xAOD::BPhysHelper& cand,
1245  const unsigned int ipv,
1246  const unsigned int its,
1247  const unsigned int itt) const {
1248 
1249  const xAOD::Vertex* candRefPV = cand.pv(m_pvAssocTypes[ipv]);
1250  const xAOD::Vertex* candPV = cand.origPv(m_pvAssocTypes[ipv]);
1251 
1252  ATH_MSG_DEBUG("selectTracks: Found " << exclTracks.size()
1253  << " " << exclTracks
1254  << " for decay candidate " << cand.vtx()
1255  << "; candPV: " << candPV << " candRefPV: " << candRefPV);
1256 
1257  std::string bname(buildBranchBaseName(its, ipv, itt));
1258 
1259  // tracks to be considered
1260  TrackBag tracks;
1262  inpTracks->begin(); trkItr != inpTracks->end(); ++trkItr) {
1263  const xAOD::TrackParticle* track = *trkItr;
1264  uint64_t trackTypesForTrack(0x0);
1265  // debug track types (before any cuts)
1266  if ( m_debugTrackTypes > 0 ) {
1267  trackTypesForTrack = detTrackTypes(track, candPV, candRefPV);
1268  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "all");
1269  }
1270  // track selection check
1271  if ( ! m_trackSelectionTools[its]->accept(*track, candRefPV) ) continue;
1272  // debug track types (after track selection cuts)
1273  if ( m_debugTrackTypes > 0 ) {
1274  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "ats");
1275  }
1276 
1277  // calcluation of track type bits not necessary if all bits requested
1278  if ( ! ((unsigned int)m_useTrackTypes[itt] == ttall() ||
1279  (unsigned int)m_useTrackTypes[itt] == ttallMin()) ) {
1280  // track type check -- determination if not in debugging mode
1281  // delayed for execution speed reasons
1282  if ( trackTypesForTrack == 0x0 ) {
1283  trackTypesForTrack = detTrackTypes(track, candPV, candRefPV);
1284  }
1285  if ( (trackTypesForTrack & m_useTrackTypes[itt]) == 0x0 ) {
1286  continue;
1287  }
1288  }
1289  // debug track types (after track type cuts)
1290  if ( m_debugTrackTypes > 0 ) {
1291  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "att");
1292  }
1293  // track not in list of tracks to exclude
1294  if ( std::find(exclTracks.begin(), exclTracks.end(), track)
1295  != exclTracks.end() ) continue;
1296  // debug track types (after all cuts)
1297  if ( m_debugTrackTypes > 0 ) {
1298  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "fin");
1299  }
1300  // tracks that survived so far
1301  tracks.push_back(track);
1302  } // for
1303 
1304  return tracks;
1305  }
1306  //--------------------------------------------------------------------------
1307  // buildBranchBaseName: build branch name from track selection, primary
1308  // vertex association and track type qualifiers.
1309  //--------------------------------------------------------------------------
1310  std::string BPhysVertexTrackBase::buildBranchBaseName(unsigned int its,
1311  unsigned int ipv,
1312  unsigned int itt,
1313  const std::string& preSuffix)
1314  const {
1315 
1316  ATH_MSG_DEBUG("BPhysVertexTrackBase::buildBranchBaseName -- begin");
1317 
1318  std::string tsName = m_trackSelectionTools[its].name();
1319  std::string pvAssoc = xAOD::BPhysHelper::pv_type_str[m_pvAssocTypes[ipv]];
1320 
1321  // need to get part of tsname after last underscore
1322  std::size_t ipos = tsName.find_last_of("_");
1323  if ( ipos != std::string::npos ) tsName = tsName.substr(ipos+1);
1324 
1325  // format it nicely
1326  std::string f = std::format("T{:010d}_{}_{}{}{}",
1327  m_useTrackTypes[itt], tsName, pvAssoc,
1328  (preSuffix.length() > 0 ? "_" + preSuffix : ""),
1329  (m_branchSuffix.length() > 0 ? "_" + m_branchSuffix : ""));
1330 
1331  ATH_MSG_DEBUG("BPhysVertexBaseTrackBase::buildBranchBaseName: " << f);
1332  return f;
1333  }
1334  //--------------------------------------------------------------------------
1335  //
1336  // Initialize PV-to-SV association type vector
1337  //
1338  //--------------------------------------------------------------------------
1340 
1341  m_pvAssocTypes.clear();
1342  for (unsigned int i=0; i<xAOD::BPhysHelper::n_pv_types; ++i) {
1343  if ( (m_doVertexType & (1 << i)) > 0 )
1345  }
1346  }
1347  //--------------------------------------------------------------------------
1348  //
1349  // Find primary vertex to which a track is closest to in terms of minimum
1350  // chi2 to any primary vertex. Replace primary vertex by refitted primary
1351  // vertex (for B candidate associated primary vertices)
1352  // if appropriate (and available).
1353  // Only consider primary vertices of specified primary vertex types and
1354  // with a minimum number of tracks.
1355  //
1356  //--------------------------------------------------------------------------
1357  std::pair<const xAOD::Vertex*, double>
1359  const xAOD::Vertex* candPV,
1360  const xAOD::Vertex* candRefPV,
1361  const std::vector<uint64_t>& pvtypes,
1362  const int minNTracksInPV,
1363  const bool useRefittedPvs,
1364  const bool doDCAin3D,
1365  const int chi2DefToUse) const {
1366 
1367  double minChi2 = std::numeric_limits<double>::max();
1368  const xAOD::Vertex* minChi2PV(nullptr);
1369 
1370  for (auto pvtx: *m_pvtxContainer) {
1371  if ( pvtx != nullptr ) {
1372  if ( std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
1373  != pvtypes.end() ) {
1374  const xAOD::Vertex* cvtx = pvtx;
1375  // replace by refitted PV if associated PV matches orignal PV
1376  if ( useRefittedPvs && pvtx == candPV ) {
1377  if ( candRefPV != nullptr ) {
1378  cvtx = candRefPV;
1379  } else {
1380  ATH_MSG_WARNING(" BPhysVertexTrackBase::findMinChi2PV:"
1381  << " candRefPV == NULL!");
1382  continue;
1383  }
1384  } // if pvtx == candPV
1385  if ( (int)cvtx->nTrackParticles() >= minNTracksInPV ) {
1386  double chi2 = getTrackLogChi2DCA(track, cvtx, doDCAin3D,
1387  chi2DefToUse)[4];
1388  if ( chi2 < minChi2 ) {
1389  minChi2 = chi2;
1390  minChi2PV = cvtx;
1391  } // if chi2 < minChi2
1392  } // if minNTracksInPV
1393  } // if pvTypes in pvtypes vector
1394  } // if pvtx != nullptr
1395  } // for pvtx
1396 
1397  return std::make_pair(minChi2PV, minChi2);
1398  }
1399  //--------------------------------------------------------------------------
1400  //
1401  // Find primary vertex to which a track is closest using the
1402  // TrackVertexAssociationTool. Replace primary vertex by refitted primary
1403  // vertex (for B candidate associated primary vertices)
1404  // if appropriate (and available).
1405  // Only consider primary vertices of specified primary vertex types and
1406  // with a minimum number of tracks.
1407  //
1408  //--------------------------------------------------------------------------
1409  const xAOD::Vertex*
1411  const xAOD::Vertex* candPV,
1412  const xAOD::Vertex* candRefPV,
1413  const std::vector<uint64_t>& pvtypes,
1414  const int minNTracksInPV,
1415  const bool useRefittedPvs) const {
1416 
1417  // select PVs to be considered/replace candPV by candRefPV if requested
1418  std::vector<const xAOD::Vertex*> vpvtx;
1419  for (auto pvtx: *m_pvtxContainer) {
1420  if ( pvtx != nullptr ) {
1421  if ( std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
1422  != pvtypes.end() ) {
1423  const xAOD::Vertex* cvtx = pvtx;
1424  // replace by refitted PV if associated PV matches orignal PV
1425  if ( useRefittedPvs && pvtx == candPV ) {
1426  if ( candRefPV != nullptr ) {
1427  cvtx = candRefPV;
1428  } else {
1429  ATH_MSG_WARNING("BPhysVertexTrackBase::findAssocPV:"
1430  << " candRefPV == NULL!");
1431  continue;
1432  }
1433  } // if pvtx == candPV
1434  if ( (int)cvtx->nTrackParticles() >= minNTracksInPV ) {
1435  vpvtx.push_back(cvtx);
1436  } // if minNTracksInPV
1437  } // if pvTypes in pvtypes vector
1438  } // if pvtx != nullptr
1439  } // for pvtx
1440 
1441  const xAOD::Vertex* assocPV(NULL);
1442  if ( useRefittedPvs && m_tvaToolHasWpLoose ) {
1443  // check whether track is in refitted PV - if so accept
1444  // Need to do this here as the TrackVertexAssociationTool
1445  // with WP 'Loose' only checks the track->vertex() pointer
1446  // which always points to the original PV.
1447  for (const auto &tp : candRefPV->trackParticleLinks()) {
1448  if ( *tp == track ) {
1449  // track is part of refitted PV -- accept it
1450  assocPV = candRefPV;
1451  break;
1452  }
1453  } // for tp
1454  // if not matching use the TrackVertexAssociationTool (other PVs etc)
1455  if ( assocPV == nullptr ) {
1456  assocPV = m_tvaTool->getUniqueMatchVertex(*track, vpvtx);
1457  }
1458  } else {
1459  assocPV = m_tvaTool->getUniqueMatchVertex(*track, vpvtx);
1460  } // if useRefittedPvs && m_tvaToolHasWpLoose
1461  if ( assocPV == nullptr ) {
1462  ATH_MSG_WARNING("BPhysVertexTrackBase::findAssocPV:"
1463  << " assocPV == NULL for track!"
1464  << " len(vpvtx) = " << vpvtx.size()
1465  << " useRefittedPvs = " << useRefittedPvs
1466  << " minNTracksInPV = " << minNTracksInPV);
1467  }
1468 
1469  return assocPV;
1470  }
1471  //--------------------------------------------------------------------------
1472 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::BPhysVertexTrackBase::BaseItem::toString
virtual std::string toString() const
Definition: BPhysVertexTrackBase.cxx:212
xAOD::Vertex_v1::x
float x() const
Returns the x position.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
DerivationFramework::BPhysVertexTrackBase::track_type_str
static const std::string track_type_str[]
Definition: BPhysVertexTrackBase.h:124
xAOD::BPhysHelper::nMuons
int nMuons()
: Methods providing access to the linked muons
Definition: BPhysHelper.cxx:441
DerivationFramework::BPhysVertexTrackBase::addBranchesHook
virtual StatusCode addBranchesHook() const
Definition: BPhysVertexTrackBase.cxx:573
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
test_pyathena.px
px
Definition: test_pyathena.py:18
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
hotSpotInTAG.suffix
string suffix
Definition: hotSpotInTAG.py:186
xAOD::BPhysHelper::pv_type_str
static const std::string pv_type_str[]
Definition: BPhysHelper.h:605
DerivationFramework::BPhysVertexTrackBase::m_pvtxContainer
const xAOD::VertexContainer * m_pvtxContainer
Definition: BPhysVertexTrackBase.h:273
TrackParticlexAODHelpers.h
DerivationFramework::BPhysVertexTrackBase::m_pvAssocTypes
std::vector< xAOD::BPhysHelper::pv_type > m_pvAssocTypes
Definition: BPhysVertexTrackBase.h:280
xAOD::BPhysHelper::nRefTrks
int nRefTrks()
Returns number of stored refitted track momenta.
Definition: BPhysHelper.cxx:115
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::BPhysVertexTrackBase::m_pvContainerName
std::string m_pvContainerName
Definition: BPhysVertexTrackBase.h:256
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
collListGuids.line
string line
Definition: collListGuids.py:77
DerivationFramework::BPhysVertexTrackBase::initialize
virtual StatusCode initialize() override
Definition: BPhysVertexTrackBase.cxx:401
DerivationFramework::BPhysVertexTrackBase::BaseItem::BaseItem
BaseItem(const std::string &Name="_none_", const std::string &Bname="iso", const std::string &Prefix="")
Definition: BPhysVertexTrackBase.cxx:176
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
CP::TrackVertexAssociationTool
General track-vertex association tool.
Definition: InnerDetector/InDetRecTools/TrackVertexAssociationTool/TrackVertexAssociationTool/TrackVertexAssociationTool.h:53
xAOD::Vertex_v1::trackParticleLinks
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
DerivationFramework::BPhysVertexTrackBase::ttb
static uint64_t ttb(track_type type)
Definition: BPhysVertexTrackBase.cxx:309
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
EventPrimitivesHelpers.h
DerivationFramework::BPhysVertexTrackBase::m_pvAssocResMap
StringIntMap_t m_pvAssocResMap
Definition: BPhysVertexTrackBase.h:289
DerivationFramework::BPhysVertexTrackBase::finalize
virtual StatusCode finalize() override
Definition: BPhysVertexTrackBase.cxx:463
DerivationFramework::BPhysVertexTrackBase::findAllMuonsInDecay
MuonBag findAllMuonsInDecay(xAOD::BPhysHelper &vtx) const
Definition: BPhysVertexTrackBase.cxx:1092
xAOD::TrackParticleAuxContainer
TrackParticleAuxContainer_v5 TrackParticleAuxContainer
Definition of the current TrackParticle auxiliary container.
Definition: TrackParticleAuxContainer.h:19
xAOD::TrackingHelpers::d0significance
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Definition: TrackParticlexAODHelpers.cxx:42
TrackVertexAssociationTool.h
skel.it
it
Definition: skel.GENtoEVGEN.py:407
DerivationFramework::BPhysVertexTrackBase::m_nEvtsSeen
unsigned int m_nEvtsSeen
Definition: BPhysVertexTrackBase.h:282
test_pyathena.pt
pt
Definition: test_pyathena.py:11
DerivationFramework::BPhysVertexTrackBase::BaseItem::setup
virtual void setup(const std::string &Name, const std::string &Bname="iso", const std::string &Prefix="")
Definition: BPhysVertexTrackBase.cxx:185
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::countsToString
std::string countsToString(uint indent=0) const
Definition: BPhysVertexTrackBase.cxx:255
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::BPhysHelper::muon
const xAOD::Muon * muon(const size_t index)
Returns pointer to the i-th linked muon.
Definition: BPhysHelper.cxx:452
DerivationFramework::BPhysVertexTrackBase::finalizeHook
virtual StatusCode finalizeHook()
Definition: BPhysVertexTrackBase.cxx:566
DerivationFramework::BPhysVertexTrackBase::m_runNumber
unsigned int m_runNumber
Definition: BPhysVertexTrackBase.h:298
DerivationFramework::BPhysVertexTrackBase::detTrackTypes
uint64_t detTrackTypes(const xAOD::TrackParticle *track, const xAOD::Vertex *candPV, const xAOD::Vertex *candRefPV) const
Definition: BPhysVertexTrackBase.cxx:1000
Trk::z0
@ z0
Definition: ParamDefs.h:64
xAOD::EventInfo_v1::beamPosSigmaX
float beamPosSigmaX() const
The width of the beam spot in the X direction.
DerivationFramework::BPhysVertexTrackBase::m_evtNumber
uint64_t m_evtNumber
Definition: BPhysVertexTrackBase.h:299
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
DerivationFramework::BPhysVertexTrackBase::m_useTrackTypes
std::vector< uint64_t > m_useTrackTypes
Definition: BPhysVertexTrackBase.h:260
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
BPhysVertexTrackBase.h
DerivationFramework::BPhysVertexTrackBase::findMinChi2PV
std::pair< const xAOD::Vertex *, double > findMinChi2PV(const xAOD::TrackParticle *track, const xAOD::Vertex *candPV, const xAOD::Vertex *candRefPV, const std::vector< uint64_t > &pvtypes, const int minNTracksInPV, const bool useRefittedPvs, const bool doDCAin3D, const int chi2DefToUse) const
Definition: BPhysVertexTrackBase.cxx:1358
x
#define x
DerivationFramework::BPhysVertexTrackBase::m_trackTypesUsed
uint64_t m_trackTypesUsed
Definition: BPhysVertexTrackBase.h:292
DerivationFramework::BPhysVertexTrackBase::ASSOCPV
@ ASSOCPV
Definition: BPhysVertexTrackBase.h:114
DerivationFramework::MuonBag
std::vector< const xAOD::Muon * > MuonBag
Definition: BPhysAddMuonBasedInvMass.h:33
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
AmgMatrix
#define AmgMatrix(rows, cols)
Definition: EventPrimitives.h:49
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
DerivationFramework::BPhysVertexTrackBase::buildBranchBaseName
std::string buildBranchBaseName(unsigned int its, unsigned int ipv, unsigned int itt, const std::string &preSuffix="") const
Definition: BPhysVertexTrackBase.cxx:1310
DerivationFramework::BPhysVertexTrackBase::ttall
static uint64_t ttall()
Definition: BPhysVertexTrackBase.cxx:318
DerivationFramework::AmgSymMatrix
AmgSymMatrix(3) BPhysAddMuonBasedInvMass
Definition: BPhysAddMuonBasedInvMass.cxx:600
DerivationFramework::BPhysVertexTrackBase::m_branchPrefixes
std::vector< std::string > m_branchPrefixes
Definition: BPhysVertexTrackBase.h:245
DerivationFramework::BPhysVertexTrackBase::calcValuesHook
virtual StatusCode calcValuesHook(const xAOD::Vertex *vtx, const unsigned int ipv, const unsigned int its, const unsigned int itt) const
Definition: BPhysVertexTrackBase.cxx:606
DerivationFramework::BPhysVertexTrackBase::BaseItem::buildName
virtual std::string buildName(const std::string &qualifier="", const std::string &suffix="") const
Definition: BPhysVertexTrackBase.cxx:201
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::TrackTypeCounter
TrackTypeCounter(BPhysVertexTrackBase &Parent, std::string Name)
Definition: BPhysVertexTrackBase.cxx:221
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
xAOD::BPhysHelper::pv_type
pv_type
: Enum type of the PV
Definition: BPhysHelper.h:475
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCondBlobAlgs_fillNoiseFromASCII.lines
lines
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:104
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:37
DerivationFramework::BPhysVertexTrackBase::m_mttc
std::unique_ptr< TrackTypeCounter > m_mttc
Definition: BPhysVertexTrackBase.h:295
DerivationFramework::BPhysVertexTrackBase::m_pvTypesToConsider
std::vector< uint64_t > m_pvTypesToConsider
Definition: BPhysVertexTrackBase.h:263
DerivationFramework::BPhysVertexTrackBase::addBranchesVCSetupHook
virtual StatusCode addBranchesVCSetupHook(size_t ivc) const
Definition: BPhysVertexTrackBase.cxx:581
DerivationFramework::BPhysVertexTrackBase::m_tracks
const xAOD::TrackParticleContainer * m_tracks
Definition: BPhysVertexTrackBase.h:271
DerivationFramework::BPhysVertexTrackBase::m_branchSuffix
std::string m_branchSuffix
Definition: BPhysVertexTrackBase.h:247
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
DerivationFramework::BPhysVertexTrackBase::tts
static const std::string tts(track_type type)
Definition: BPhysVertexTrackBase.cxx:305
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::BPhysVertexTrackBase::m_tvaTool
ToolHandle< CP::ITrackVertexAssociationTool > m_tvaTool
Definition: BPhysVertexTrackBase.h:254
DerivationFramework::BPhysVertexTrackBase::buildPvAssocCacheName
virtual std::string buildPvAssocCacheName(const xAOD::Vertex *vtx, const int ipv) const
Definition: BPhysVertexTrackBase.cxx:671
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::BPhysHelper::precedingVertex
const xAOD::Vertex * precedingVertex(const size_t index)
Returns pointer to a preceding vertex.
Definition: BPhysHelper.cxx:613
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.CaloAddPedShiftConfig.str
str
Definition: CaloAddPedShiftConfig.py:42
DerivationFramework::BPhysVertexTrackBase::m_branchBaseName
std::string m_branchBaseName
Definition: BPhysVertexTrackBase.h:246
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
TestMuonSF::getProperty
T getProperty(const asg::IAsgTool *interface_tool, const std::string &prop_name)
Definition: MuonSFTestHelper.cxx:17
DerivationFramework::BPhysVertexTrackBase::m_tracksAux
const xAOD::TrackParticleAuxContainer * m_tracksAux
Definition: BPhysVertexTrackBase.h:272
DerivationFramework::BPhysVertexTrackBase::calculateValues
StatusCode calculateValues(const xAOD::Vertex *vtx) const
Definition: BPhysVertexTrackBase.cxx:637
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
DerivationFramework::BPhysVertexTrackBase::findAllTracksInDecay
TrackBag findAllTracksInDecay(xAOD::BPhysHelper &vtx) const
Definition: BPhysVertexTrackBase.cxx:1056
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::BPhysVertexTrackBase::findMuonRefTrackMomenta
std::vector< TVector3 > findMuonRefTrackMomenta(xAOD::BPhysHelper &vtx, MuonBag &muons) const
Definition: BPhysVertexTrackBase.cxx:1151
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework::BPhysVertexTrackBase::track_type
track_type
Definition: BPhysVertexTrackBase.h:114
hist_file_dump.f
f
Definition: hist_file_dump.py:141
xAOD::Vertex_v1::trackParticle
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Definition: Vertex_v1.cxx:249
DerivationFramework::TrackBag
std::vector< const xAOD::TrackParticle * > TrackBag
Definition: BPhysAddMuonBasedInvMass.h:32
xAOD::Vertex_v1::z
float z() const
Returns the z position.
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
xAOD::BPhysHelper::origPv
const xAOD::Vertex * origPv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
original PV
Definition: BPhysHelper.cxx:807
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
DerivationFramework::BPhysVertexTrackBase::trackToString
static std::string trackToString(const xAOD::TrackParticle *track)
Definition: BPhysVertexTrackBase.cxx:338
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
IInDetTrackSelectionTool.h
DerivationFramework::BPhysVertexTrackBase::fastFillHook
virtual bool fastFillHook(const xAOD::Vertex *vtx, const int ipv) const
Definition: BPhysVertexTrackBase.cxx:621
DerivationFramework::BPhysVertexTrackBase::addBranchesSVLoopHook
virtual StatusCode addBranchesSVLoopHook(const xAOD::Vertex *vtx) const
Definition: BPhysVertexTrackBase.cxx:594
xAOD::BPhysHelper::refTrkOrigin
const xAOD::IParticle * refTrkOrigin(const size_t index) const
: Returns the original track (charged or neutral) corresponding to the i-th refitted track
Definition: BPhysHelper.cxx:171
xAOD::EventInfo_v1::beamPosSigmaY
float beamPosSigmaY() const
The width of the beam spot in the Y direction.
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Trk::d0
@ d0
Definition: ParamDefs.h:63
DerivationFramework::BPhysVertexTrackBase::getTrackLogChi2DCA
std::vector< double > getTrackLogChi2DCA(const xAOD::TrackParticle *track, const xAOD::Vertex *vtx, bool doDCAin3D=false, int chi2DefToUse=0) const
Definition: BPhysVertexTrackBase.cxx:721
xAOD::BPhysHelper::vtx
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
Definition: BPhysHelper.h:108
DerivationFramework::BPhysVertexTrackBase::m_debugTracksInEvents
std::vector< uint64_t > m_debugTracksInEvents
Definition: BPhysVertexTrackBase.h:265
Amg::error
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Definition: EventPrimitivesHelpers.h:40
DerivationFramework::BPhysVertexTrackBase::m_trackParticleContainerName
std::string m_trackParticleContainerName
Definition: BPhysVertexTrackBase.h:249
DerivationFramework::BPhysVertexTrackBase::BaseItem::setPrefix
virtual void setPrefix(std::string Prefix)
Definition: BPhysVertexTrackBase.cxx:193
DerivationFramework::BPhysVertexTrackBase::track_type_bit
static const uint64_t track_type_bit[]
Definition: BPhysVertexTrackBase.h:125
DerivationFramework::BPhysVertexTrackBase::m_tvaToolHasWpLoose
bool m_tvaToolHasWpLoose
Definition: BPhysVertexTrackBase.h:268
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
DerivationFramework::BPhysVertexTrackBase::wrapLines
static std::string wrapLines(const std::string &lines, const std::string &prefix)
Definition: BPhysVertexTrackBase.cxx:353
DerivationFramework::BPhysVertexTrackBase::addBranches
virtual StatusCode addBranches() const override
Definition: BPhysVertexTrackBase.cxx:476
DerivationFramework::BPhysVertexTrackBase::m_trackSelectionTools
ToolHandleArray< TrkSelTool > m_trackSelectionTools
Definition: BPhysVertexTrackBase.h:250
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DerivationFramework::BPhysVertexTrackBase::m_refPVContainerNames
std::vector< std::string > m_refPVContainerNames
Definition: BPhysVertexTrackBase.h:257
DerivationFramework::BPhysVertexTrackBase::BaseItem::resetVals
virtual void resetVals()
Definition: BPhysVertexTrackBase.cxx:197
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DerivationFramework::BPhysVertexTrackBase::getTrackCandPVLogChi2
double getTrackCandPVLogChi2(const xAOD::TrackParticle *track, const xAOD::Vertex *vtx, bool doDCAin3D=false, int chi2DefToUse=0) const
Definition: BPhysVertexTrackBase.cxx:683
DerivationFramework::BPhysVertexTrackBase::selectTracks
TrackBag selectTracks(const xAOD::TrackParticleContainer *inpTracks, xAOD::BPhysHelper &cand, const unsigned int ipv, const unsigned int its, const unsigned int itt) const
Definition: BPhysVertexTrackBase.cxx:1224
BPhysHelper.h
: B-physics xAOD helpers.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DerivationFramework::BPhysVertexTrackBase::m_incPrecVerticesInDecay
bool m_incPrecVerticesInDecay
Definition: BPhysVertexTrackBase.h:261
DerivationFramework::BPhysVertexTrackBase::findAllMuonIdTracksInDecay
TrackBag findAllMuonIdTracksInDecay(xAOD::BPhysHelper &vtx, MuonBag &muons) const
Definition: BPhysVertexTrackBase.cxx:1130
DerivationFramework::BPhysVertexTrackBase::findAssocPV
const xAOD::Vertex * findAssocPV(const xAOD::TrackParticle *track, const xAOD::Vertex *candPV, const xAOD::Vertex *candRefPV, const std::vector< uint64_t > &pvtypes, const int minNTracksInPV, const bool useRefittedPvs) const
Definition: BPhysVertexTrackBase.cxx:1410
Name
JetDumper::Name Name
Definition: JetDumper.cxx:19
Prompt::Def::Pt
@ Pt
Definition: VarHolder.h:76
xAOD::EventInfo_v1::beamPosSigmaXY
float beamPosSigmaXY() const
The beam spot shape's X-Y correlation.
DerivationFramework::BPhysVertexTrackBase::ttallMin
static uint64_t ttallMin()
Definition: BPhysVertexTrackBase.cxx:313
y
#define y
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::BPhysHelper::refTrk
TVector3 refTrk(const size_t index)
Returns i-th refitted track 3-momentum.
Definition: BPhysHelper.cxx:126
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::BPhysVertexTrackBase::m_vertexContainerNames
std::vector< std::string > m_vertexContainerNames
Definition: BPhysVertexTrackBase.h:248
DEBUG
#define DEBUG
Definition: page_access.h:11
xAOD::BPhysHelper::nPrecedingVertices
int nPrecedingVertices()
: Links to preceding vertices
Definition: BPhysHelper.cxx:601
DerivationFramework::BPhysVertexTrackBase::m_debugTrackTypes
int m_debugTrackTypes
Definition: BPhysVertexTrackBase.h:264
xAOD::Vertex_v1::y
float y() const
Returns the y position.
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
DerivationFramework::BPhysVertexTrackBase::m_doVertexType
int m_doVertexType
Definition: BPhysVertexTrackBase.h:259
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::refTrks
const std::vector< TVector3 > & refTrks()
Returns refitted track momenta.
Definition: BPhysHelper.cxx:142
DerivationFramework::BPhysVertexTrackBase::m_debugTracksInThisEvent
bool m_debugTracksInThisEvent
Definition: BPhysVertexTrackBase.h:302
DerivationFramework::BPhysVertexTrackBase::initPvAssocTypeVec
virtual void initPvAssocTypeVec()
Definition: BPhysVertexTrackBase.cxx:1339
str
Definition: BTagTrackIpAccessor.cxx:11
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::~TrackTypeCounter
~TrackTypeCounter()
xAOD::BPhysHelper::n_pv_types
static const unsigned int n_pv_types
Definition: BPhysHelper.h:613
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::BPhysHelper::muons
const std::vector< const xAOD::Muon * > & muons()
Returns linked muons.
Definition: BPhysHelper.cxx:468
DerivationFramework::BPhysVertexTrackBase::s_track_type_all_cached
static uint64_t s_track_type_all_cached
Definition: BPhysVertexTrackBase.h:127
DerivationFramework::BPhysVertexTrackBase
Definition: BPhysVertexTrackBase.h:57
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::addToCounter
void addToCounter(uint64_t atype, uint64_t rtype=0, const std::string &prefix="", const std::string &suffix="", uint64_t counts=1)
Definition: BPhysVertexTrackBase.cxx:227
DerivationFramework::BPhysVertexTrackBase::initializeHook
virtual StatusCode initializeHook()
Definition: BPhysVertexTrackBase.cxx:559
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
DerivationFramework::BPhysVertexTrackBase::m_minNTracksInPV
int m_minNTracksInPV
Definition: BPhysVertexTrackBase.h:262
DerivationFramework::BPhysVertexTrackBase::n_track_types
static const int n_track_types
Definition: BPhysVertexTrackBase.h:123
DerivationFramework::BPhysVertexTrackBase::rttor
static uint64_t rttor(const std::vector< uint64_t > &vtypes)
Definition: BPhysVertexTrackBase.cxx:327
DerivationFramework::BPhysVertexTrackBase::m_eventInfo
const xAOD::EventInfo * m_eventInfo
Definition: BPhysVertexTrackBase.h:285
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
DerivationFramework::BPhysVertexTrackBase::BaseItem::~BaseItem
virtual ~BaseItem()
Definition: BPhysVertexTrackBase.cxx:182
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DerivationFramework::BPhysVertexTrackBase::BPhysVertexTrackBase
BPhysVertexTrackBase(const std::string &t, const std::string &n, const IInterface *p)
Definition: BPhysVertexTrackBase.cxx:367
DerivationFramework::BPhysVertexTrackBase::m_trackToVertexTool
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
Definition: BPhysVertexTrackBase.h:252