ATLAS Offline Software
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  : AthAlgTool(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  declareInterface<DerivationFramework::IAugmentationTool>(this);
378 
379  // Declare branch prefix
380  declareProperty("BranchPrefixes", m_branchPrefixes);
381  declareProperty("BranchBaseName", m_branchBaseName = "iso");
382  declareProperty("BranchSuffix" , m_branchSuffix = "" );
383 
384  // Necessary containers
385  declareProperty("VertexContainerNames" , m_vertexContainerNames);
386  declareProperty("TrackParticleContainerName",
388  declareProperty("TrackToVertexTool" , m_trackToVertexTool);
389  declareProperty("TrackSelectionTools" , m_trackSelectionTools);
390  declareProperty("TVATool" , m_tvaTool);
391  declareProperty("PVContainerName", m_pvContainerName = "PrimaryVertices");
392  declareProperty("RefPVContainerNames" , m_refPVContainerNames);
393  declareProperty("DoVertexType" , m_doVertexType = 8);
394  declareProperty("UseTrackTypes" , m_useTrackTypes = {7});
395  declareProperty("IncPrecVerticesInDecay", m_incPrecVerticesInDecay = true);
396  declareProperty("MinNTracksInPV" , m_minNTracksInPV = 0);
397  declareProperty("PVTypesToConsider" , m_pvTypesToConsider = {1,3});
398  declareProperty("DebugTrackTypes" , m_debugTrackTypes=0);
399  declareProperty("DebugTracksInEvents" , m_debugTracksInEvents = {});
400  }
401  //--------------------------------------------------------------------------
403 
404  ATH_MSG_DEBUG("BPhysVertexTrackBase::initialize() -- begin");
405 
406  if ( m_vertexContainerNames.size() == 0 ) {
407  ATH_MSG_ERROR("No vertex container names provided!");
408  }
409  if ( m_refPVContainerNames.size() == 0 ) {
410  ATH_MSG_ERROR("No refitted PV container names provided!");
411  }
412  if ( m_trackParticleContainerName == "" ) {
413  ATH_MSG_ERROR("No track particle container name provided!");
414  }
415  if ( m_pvContainerName == "" ) {
416  ATH_MSG_ERROR("No PV container name provided!");
417  }
418  if ( m_vertexContainerNames.size() != m_refPVContainerNames.size() ) {
419  ATH_MSG_ERROR("Size mismatch of VertexContainerNames ("
420  << m_vertexContainerNames.size()
421  << ") and RefPVContainerNames ("
422  << m_refPVContainerNames.size() << ") lists!");
423  }
424 
425  if ( m_vertexContainerNames.size() != m_branchPrefixes.size() ) {
426  ATH_MSG_ERROR("Size mismatch of VertexContainerNames ("
427  << m_vertexContainerNames.size()
428  << ") and BranchPrefixes ("
429  << m_branchPrefixes.size() << ") lists!");
430  }
431 
432  // TrackToVertexTool
433  ATH_CHECK(m_trackToVertexTool.retrieve());
434 
435  // TrackSelectionTools
436  for (auto selTool : m_trackSelectionTools ) {
437  ATH_CHECK(selTool.retrieve());
438  }
439 
440  // TrackVertexAssociationTool
441  ATH_CHECK(m_tvaTool.retrieve());
442  // take note of working point
443  // const std::string tvaWp("Loose");
444  const std::string tvaWp =
445  dynamic_cast<CP::TrackVertexAssociationTool*>(m_tvaTool.get())->getProperty("WorkingPoint").toString();
446  m_tvaToolHasWpLoose = (tvaWp == "Loose");
447 
448  // initialize PV-to-SV association type vector
450 
451  // initialize track type request pattern
453 
454  // initialize track type counters
455  if ( m_debugTrackTypes > 0 ) {
456  m_mttc = std::make_unique<TrackTypeCounter>(*this, name());
457  }
458 
459  ATH_MSG_DEBUG("BPhysVertexTrackBase::initialize() -- end");
460 
461  return initializeHook();
462  }
463  //--------------------------------------------------------------------------
465 
466  ATH_MSG_DEBUG("BPhysVertexTrackBase::finalize()");
467 
468  // dump track type counters to log
469  if ( m_debugTrackTypes > 0 ) {
470  ATH_MSG_INFO("Track type counters:\n" << m_mttc->countsToString());
471  }
472 
473  // everything all right
474  return finalizeHook();
475  }
476  //--------------------------------------------------------------------------
478 
479  ATH_MSG_DEBUG("BPhysVertexTrackBase::addBranches() -- begin");
480 
481  // counter
482  m_nEvtsSeen++;
483 
484  // run and event numbers
488 
489  // debug tracks in current event?
491  m_debugTracksInEvents.end(),
492  m_evtNumber)
493  != m_debugTracksInEvents.end());
494 
495  // retrieve primary vertices container
496  m_pvtxContainer = NULL;
498  ATH_MSG_DEBUG("Found PV collection with key " << m_pvContainerName);
499 
500 
501  // retrieve ID track container
502  m_tracks = NULL;
503  m_tracksAux = NULL;
505  if (evtStore()->contains<xAOD::
509  } else {
510  ATH_MSG_DEBUG("No aux track collection with key "
511  << m_trackParticleContainerName+"Aux.");
512  }
513  ATH_MSG_DEBUG("Found track collection with key "
515 
516  // Loop over all vertex containers
517  for (size_t i=0; i<m_vertexContainerNames.size(); ++i) {
518  // vertex container and its auxilliary store
519  const xAOD::VertexContainer* svtxContainer = NULL;
520  const xAOD::VertexAuxContainer* svtxAuxContainer = NULL;
521  // refitted primary vertex container and its auxilliary store
522  const xAOD::VertexContainer* refPVContainer = NULL;
523  const xAOD::VertexAuxContainer* refPVAuxContainer = NULL;
524 
525  // retrieve from StoreGate
526  CHECK(evtStore()->retrieve(svtxContainer, m_vertexContainerNames[i]));
527  CHECK(evtStore()->retrieve(svtxAuxContainer,
528  m_vertexContainerNames[i]+"Aux."));
529  ATH_MSG_DEBUG("Found SV collection with key "
531  CHECK(evtStore()->retrieve(refPVContainer ,
533  CHECK(evtStore()->retrieve(refPVAuxContainer,
534  m_refPVContainerNames[i]+"Aux."));
535  ATH_MSG_DEBUG("Found refitted PV collection with key "
537 
538  // vertex container depending setup in derived class
540 
541  // loop over secondary vertices
543  svtxContainer->begin(); vtxItr!=svtxContainer->end();
544  ++vtxItr) {
545 
546  CHECK(addBranchesSVLoopHook(*vtxItr));
547 
548  } // end of loop over vertices
549  } // end of loop over vertex container names
550 
551  ATH_MSG_DEBUG("BPhysVertexTrackBase::addBranches() -- end");
552 
553  // nothing to do here
554  return addBranchesHook();
555  }
556 
557  //--------------------------------------------------------------------------
558  // Hook method for initialize() -- to be overwritten by derived class
559  //--------------------------------------------------------------------------
561 
562  return StatusCode::SUCCESS;
563  }
564  //--------------------------------------------------------------------------
565  // Hook method for finalize() -- to be overwritten by derived class
566  //--------------------------------------------------------------------------
568 
569  return StatusCode::SUCCESS;
570  }
571  //--------------------------------------------------------------------------
572  // Hook method for addBranches() -- to be overwritten by derived class
573  //--------------------------------------------------------------------------
575 
576  return StatusCode::SUCCESS;
577  }
578  //--------------------------------------------------------------------------
579  // Hook method for addBranches() VC setup
580  // -- to be overwritten by derived class
581  //--------------------------------------------------------------------------
583 
584  // just to avoid a compiler warning
585  ATH_MSG_DEBUG("addBranchesVCSetupHook: Vertex container index " << ivc
586  << " for collection " << m_vertexContainerNames[ivc]
587  << " with prefix " << m_branchPrefixes[ivc]);
588 
589  return StatusCode::SUCCESS;
590  }
591  //--------------------------------------------------------------------------
592  // Hook method for addBranches() SV loop -- to be overwritten by derived class
593  //--------------------------------------------------------------------------
594  StatusCode
596 
597  // just to avoid a compiler warning
598  ATH_MSG_DEBUG("addBranchesSVLoopHook: Vertex " << vtx);
599 
600  return StatusCode::SUCCESS;
601  }
602  //--------------------------------------------------------------------------
603  // Calculate values -- used by calculateValues()
604  // -- to be overwritten by derived class
605  //--------------------------------------------------------------------------
606  StatusCode
608  const unsigned int ipv,
609  const unsigned int its,
610  const unsigned int itt) const {
611 
612  // just to avoid a compiler warning
613  ATH_MSG_DEBUG("calcIsolationOpti: vtx: " << vtx << ", ipv: " << ipv
614  << ", its: " << its << ", itt: " << itt);
615 
616  return StatusCode::SUCCESS;
617  }
618  //--------------------------------------------------------------------------
619  // Fill values from cache if found -- used by calculateValues()
620  // -- to be overwritten by derived class
621  //--------------------------------------------------------------------------
623  const int ipv) const {
624 
625  // just to avoid a compiler warning
626  ATH_MSG_DEBUG("fastIsoFill: vtx: " << vtx << ", ipv: " << ipv);
627 
628  return false;
629  }
630  //--------------------------------------------------------------------------
631  // Calculation loops -- needs to be called from inside the implementation
632  // of addBranchesSVLoopHook() in the derived class.
633  // Derived class also needs to provide override methods for
634  // - fastFillHook -- needs to return true if cached value is used
635  // - calcValuesHook -- actually calculating value(s)
636  //--------------------------------------------------------------------------
637  StatusCode
639 
640  ATH_MSG_DEBUG("BPhysVertexTrackBase::calculateValues -- begin");
641 
642  unsigned int nPvAssocs = m_pvAssocTypes.size();
643  unsigned int nTrackSels = m_trackSelectionTools.size();
644  unsigned int nTrackTypes = m_useTrackTypes.size();
645 
646  m_pvAssocResMap.clear();
647 
648  const xAOD::BPhysHelper cand(vtx);
649  for (unsigned int ipv = 0; ipv < nPvAssocs; ++ipv) {
650  if ( ipv == 0 || ! fastFillHook(vtx, ipv) ) {
651  for (unsigned int its = 0; its < nTrackSels; ++its) {
652  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
653  ATH_MSG_DEBUG("Calling calcValuesHook with ipv: " << ipv
654  << ", its: " << its << ", itt: " << itt);
655  CHECK(calcValuesHook(vtx, ipv, its, itt));
656  } // for itt
657  } // for its
658  // cache result index -- only needed once per ipv value
659  m_pvAssocResMap[buildPvAssocCacheName(vtx, ipv)] = ipv;
660  ATH_MSG_DEBUG("calculateValues: cache index: "
661  << buildPvAssocCacheName(vtx, ipv)
662  << " -- cached ipv: " << ipv);
663  } // if !fastFillHook()
664  } // for ipv
665 
666  return StatusCode::SUCCESS;
667  }
668  //-------------------------------------------------------------------------
669  // Build SV-to-PV association cache index string
670  //-------------------------------------------------------------------------
671  std::string
673  const int ipv) const {
674  xAOD::BPhysHelper cand(vtx);
675  std::string f = std::format("SV_{:p}_RPV_{:p}", static_cast<const void*>(cand.vtx()), static_cast<const void*>(cand.pv(m_pvAssocTypes[ipv])));
676 
677  return f;
678  }
679  //--------------------------------------------------------------------------
680  // getTrackCandPVLogChi2()
681  // Calculate the logChi2 (= log((d0/d0e)^2+(z0/z0e)^2) contribution of a
682  // track at the position closest to the PV associated with the SV.
683  //--------------------------------------------------------------------------
685  track,
686  const xAOD::Vertex* vtx,
687  bool doDCAin3D,
688  int chi2DefToUse
689  ) const {
690 
691  return getTrackLogChi2DCA(track, vtx, doDCAin3D, chi2DefToUse)[4];
692  }
693  //--------------------------------------------------------------------------
694  // getTrackLogChi2DCA()
695  // Calculate logChi2 (= log((d0/d0e)^2+(z0/z0e)^2) contribution of a
696  // track at the position closest to a position and
697  // the distance of closest approach of a track w.r.t.
698  // a position. Either only in the transverse plane or in 3 dimensions.
699  // Option chi2DefToUse:
700  // 0 : from track perigee with uncertainties from track only
701  // 1 : from track perigee with uncertainties from track and vertex
702  // 2 : simple extrapolation from track parameters
703  // with uncertainties from track and vertex
704  // 3 : CalcLogChi2toPV method from NtupleMaker using xAOD::TrackingHelpers.
705  // (only track uncertainties)
706  // 4 : CalcLogChi2toPV method from NtupleMaker using xAOD::TrackingHelpers.
707  // (track and vertex uncertainties)
708  // 5 : use TrackVertexAssociationTool
709  // 6 : full 3D chi2 from track perigee with uncertainties
710  // from track and vertex (sum of 3x3 covariance matrices)
711  // 7 : full 3D chi2 from track perigee with uncertainties
712  // from track and vertex (sum of 2x2 covariance matrices)
713  // 8 : simple extrapolation from track parameters with uncertainties
714  // from track and vertex (sum of 3x3 covariance matrices)
715  // 9 simple extrapolation from track parameters with uncertainties
716  // from track and vertex (sum of 2x2 covariance matrices)
717  // Returned vector components:
718  // 0: d0, 1: d0Err, 2: z0, 3: z0Err, 4: logChi2, 5: dca, 6: okFlag
719  // 7: vtxErrPart2, 8: trkErrPart2, 9: phi0Used
720  //--------------------------------------------------------------------------
721  std::vector<double>
723  const xAOD::Vertex* vtx,
724  bool doDCAin3D,
725  int chi2DefToUse) const {
726  // presets
727  std::vector<double> res = {-999., -99., -999., -99., -100., -100., -1.,
728  -99., -99., -999.};
729 
730  const Amg::Vector3D pos = vtx->position();
731  const AmgSymMatrix(3) poscov = vtx->covariancePosition();
732  auto ctx = Gaudi::Hive::currentContext();
733  if ( track != NULL ) {
734  if ( chi2DefToUse < 2 || (chi2DefToUse > 5 && chi2DefToUse < 8) ) {
735  // use track perigee method
736  std::unique_ptr<const Trk::Perigee>
737  trkPerigee(m_trackToVertexTool->perigeeAtVertex(ctx, *track, pos));
738  if ( trkPerigee != NULL ) {
739  res[0] = trkPerigee->parameters()[Trk::d0];
740  res[2] = trkPerigee->parameters()[Trk::z0];
741  const AmgSymMatrix(5)* locError = trkPerigee->covariance();
742  if ( locError != NULL ) {
743  // uncertainties from track
744  res[1] = Amg::error(*locError, Trk::d0);
745  res[3] = Amg::error(*locError, Trk::z0);
746  if ( chi2DefToUse == 1 ) {
747  // add uncertainties from vertex
748  Amg::Vector3D perppt(trkPerigee->momentum().y()/trkPerigee->pT(),
749  -trkPerigee->momentum().x()/trkPerigee->pT(),
750  0.);
751  double vtxD0Err2 = perppt.transpose()*poscov*perppt;
752  res[1] = sqrt( pow(res[1], 2.) + vtxD0Err2 );
753  res[3] = sqrt( pow(res[3], 2.) + poscov(2,2) );
754  }
755  if ( chi2DefToUse < 2 ) {
756  if ( fabs(res[1]) > 0. && fabs(res[3]) > 0. ) {
757  res[4] = log( pow(res[0]/res[1], 2.)
758  + pow(res[2]/res[3], 2.) );
759  res[6] = 2.; // ok
760  } else {
761  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
762  << " d0 = " << res[0] << ", d0Err = "
763  << res[1] << ", z0 = " << res[2]
764  << ", z0Err = " << res[3]);
765  }
766  }
767  // chi2DefToUse 6 or 7
768  if ( chi2DefToUse > 5 && chi2DefToUse < 8 ) {
769  double phi0 = trkPerigee->parameters()[Trk::phi0];
770  double doca = sqrt(pow(res[0],2.) + pow(res[2], 2.));
771  res[9] = phi0;
772  if ( doca > 0. ) {
773  if ( chi2DefToUse == 6 ) {
774  AmgMatrix(5,3) dmat = AmgMatrix(5,3)::Zero();
775  dmat(0,0) = -sin(phi0);
776  dmat(0,1) = cos(phi0);
777  dmat(1,2) = 1.;
778  dmat(2,0) = -res[0]*cos(phi0);
779  dmat(2,1) = -res[0]*sin(phi0);
780  AmgSymMatrix(3) mCovTrk3D = dmat.transpose()*(*locError)*dmat;
781  Amg::Vector3D dvec(-res[0]*sin(phi0), res[0]*cos(phi0),
782  res[2]); // (x,y,z)
783  Amg::Vector3D duvec = dvec.unit();
784  // log(chi2) = log( docavec^T * V^-1 * docavec )
785  res[4] = log( dvec.transpose() * (poscov+mCovTrk3D).inverse()
786  * dvec );
787  res[7] = duvec.transpose()*poscov*duvec;
788  res[8] = duvec.transpose()*mCovTrk3D*duvec;
789  res[6] = 3.; // ok
790  }
791  if ( chi2DefToUse == 7 ) {
792  AmgMatrix(3,2) dmat = AmgMatrix(3,2)::Zero();
793  dmat(0,0) = -sin(phi0);
794  dmat(1,0) = cos(phi0);
795  dmat(2,0) = 0.;
796  dmat(0,1) = 0.;
797  dmat(1,1) = 0.;
798  dmat(2,1) = 1.;
799  AmgSymMatrix(2) mCovVtx2D = dmat.transpose()*poscov*dmat;
800  AmgSymMatrix(2) mCovTrk2D = AmgSymMatrix(2)::Zero();
801  mCovTrk2D(0,0) = (*locError)(Trk::d0,Trk::d0);
802  mCovTrk2D(0,1) = (*locError)(Trk::d0,Trk::z0);
803  mCovTrk2D(1,0) = (*locError)(Trk::d0,Trk::z0);
804  mCovTrk2D(1,1) = (*locError)(Trk::z0,Trk::z0);
805  Amg::Vector2D dvec(res[0], res[2]); // (d0, z0)
806  Amg::Vector2D duvec = dvec.unit();
807  // log(chi2) = log( (d0, z0) * V^-1 * (d0, z0)^T )
808  res[4] = log( dvec.transpose()*(mCovVtx2D+mCovTrk2D).inverse()
809  * dvec );
810  res[7] = duvec.transpose()*mCovVtx2D*duvec;
811  res[8] = duvec.transpose()*mCovTrk2D*duvec;
812  res[6] = 4.; // ok
813  }
814  } else {
815  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
816  << " doca == 0 !");
817  }
818  } // if chi2DefToUse > 5 && chi2DefToUse < 8
819  res[5] = doDCAin3D ?
820  sqrt( pow(res[0], 2.) + pow(res[2], 2.) ) : res[0];
821  res[6] += 1.; // ok
822  } else {
823  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
824  " locError pointer is NULL!");
825  }
826  } else {
827  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
828  " trkPerigee pointer is NULL!");
829  } // if trkPerigee
830 
831  } else if ( chi2DefToUse == 2
832  || (chi2DefToUse > 7 && chi2DefToUse < 10 )) {
833  // simple extrapolation method
834  // (directly taken from NtupleMaker for comparisons)
835 
836  // SV position and covariance matrix
837  TVector3 SV_def(vtx->x(), vtx->y(), vtx->z());
838  const AmgSymMatrix(3)& SV_cov = poscov;
839 
840  // chi2 track to SV
841  double px = ( track->p4() ).Px();
842  double py = ( track->p4() ).Py();
843  double pt = ( track->p4() ).Pt();
844  double d0 = track->d0();
845  double d0Err2 = track->definingParametersCovMatrixVec()[0];
846  double z0 = track->z0();
847  double z0Err2 = track->definingParametersCovMatrixVec()[2];
848  double theta = track->theta();
849  double d0z0Cov = track->definingParametersCovMatrixVec()[1];
850  double phi = track->phi();
851 
852  TVector3 trk_origin( track->vx(), track->vy(), track->vz() );
853  TVector3 SV = SV_def - trk_origin;
854 
855  // calc. error in direction perpendicular to pT (still x-y plane)
856  double upx = py/pt;
857  double upy = -px/pt;
858  double d0toSV = d0 + (SV[0]*upx + SV[1]*upy);
859  double d0toSVErr2 = upx*SV_cov(0, 0)*upx + 2*upx*SV_cov(1, 0)*upy
860  + upy*SV_cov(1, 1)*upy + d0Err2;
861 
862  upx = px/pt;
863  upy = py/pt;
864  double cot_theta = cos(theta)/sin(theta);
865  double z0corr = (SV[0]*upx + SV[1]*upy)*cot_theta;
866  double z0toSV = z0 + z0corr - SV[2];
867  double z0toSVErr2 = SV_cov(2, 2) + z0Err2;
868 
869  double docaSV = sqrt( pow(d0toSV, 2) + pow(z0toSV, 2) );
870 
871  double chi2testSV(999.);
872  if ( chi2DefToUse == 2 ) {
873  if (d0toSVErr2 !=0 && z0toSVErr2 != 0)
874  chi2testSV = log(pow( d0toSV, 2)/d0toSVErr2
875  + pow( z0toSV, 2)/z0toSVErr2);
876  // set results
877  res = {d0toSV, sqrt(d0toSVErr2), z0toSV, sqrt(z0toSVErr2),
878  chi2testSV, (doDCAin3D ? docaSV : d0toSV), 4,
879  -99., -99., -999.};
880  }
881  if ( chi2DefToUse > 7 && chi2DefToUse < 10 ) {
882  if ( docaSV > 0. ) {
883  if ( chi2DefToUse == 8 ) {
884  AmgMatrix(5,3) dmat = AmgMatrix(5,3)::Zero();
885  dmat(0,0) = -sin(phi);
886  dmat(0,1) = cos(phi);
887  dmat(1,2) = 1.;
888  dmat(2,0) = -d0toSV*cos(phi);
889  dmat(2,1) = -d0toSV*sin(phi);
890  const AmgSymMatrix(5) mCovTrk5D =
891  track->definingParametersCovMatrix();
892  AmgSymMatrix(3) mCovTrk3D = dmat.transpose()*mCovTrk5D*dmat;
893  Amg::Vector3D dvec(-d0toSV*sin(phi), d0toSV*cos(phi),
894  z0toSV); // (x,y,z)
895  Amg::Vector3D duvec = dvec.unit();
896  // log(chi2) = log( docavec^T * V^-1 * docavec )
897  double chi2testSV = log( dvec.transpose()
898  * (poscov+mCovTrk3D).inverse()
899  * dvec );
900  double vtx3DErr2 = duvec.transpose()*poscov*duvec;
901  double trk3DErr2 = duvec.transpose()*mCovTrk3D*duvec;
902  // set results
903  res = {d0toSV, sqrt(d0Err2), z0toSV, sqrt(z0Err2),
904  chi2testSV, (doDCAin3D ? docaSV : d0toSV), 5,
905  vtx3DErr2, trk3DErr2, phi};
906  }
907  if ( chi2DefToUse == 9 ) {
908  AmgMatrix(3,2) dmat = AmgMatrix(3,2)::Zero();
909  dmat(0,0) = -sin(phi);
910  dmat(1,0) = cos(phi);
911  dmat(2,0) = 0.;
912  dmat(0,1) = 0.;
913  dmat(1,1) = 0.;
914  dmat(2,1) = 1.;
915  AmgSymMatrix(2) mCovVtx2D = dmat.transpose()*SV_cov*dmat;
916  AmgSymMatrix(2) mCovTrk2D = AmgSymMatrix(2)::Zero();
917  mCovTrk2D(0,0) = d0Err2;
918  mCovTrk2D(0,1) = d0z0Cov;
919  mCovTrk2D(1,0) = d0z0Cov;
920  mCovTrk2D(1,1) = z0Err2;
921  Amg::Vector2D dvec(d0toSV, z0toSV);
922  Amg::Vector2D duvec = dvec.unit();
923  // log(chi2) = log( (d0, z0) * V^-1 * (d0, z0)^T )
924  chi2testSV = log( dvec.transpose()*(mCovVtx2D+mCovTrk2D).inverse()
925  * dvec );
926  double vtx2DErr2 = duvec.transpose()*mCovVtx2D*duvec;
927  double trk2DErr2 = duvec.transpose()*mCovTrk2D*duvec;
928 
929  if ( vtx2DErr2 < 0. || trk2DErr2 < 0. ) {
930  ATH_MSG_WARNING("BPhysVertexTrackBase::"
931  "getTrackLogChi2DCA(): "
932  << "vtx2DErr2 = " << vtx2DErr2
933  << " trk2DErr2 = " << trk2DErr2
934  << " chi2testSV = " << chi2testSV);
935  ATH_MSG_WARNING("dvec = " << dvec);
936  ATH_MSG_WARNING("mCovVtx2D = " << mCovVtx2D);
937  ATH_MSG_WARNING("mCovTrk2D = " << mCovTrk2D);
938  ATH_MSG_WARNING("dmat = " << dmat);
939  ATH_MSG_WARNING("SV_cov = " << SV_cov);
940  ATH_MSG_WARNING("det(mCovVtx2D) = " << mCovVtx2D.determinant());
941  ATH_MSG_WARNING("det(mCovTrk2D) = " << mCovTrk2D.determinant());
942  ATH_MSG_WARNING("det(SV_cov) = " << SV_cov.determinant());
943  ATH_MSG_WARNING("d0toSV = " << d0toSV
944  << " z0toSV = " << z0toSV
945  << " phi = " << phi
946  << " docaSV = " << docaSV);
947  }
948 
949  // set results
950  res = {d0toSV, sqrt(d0Err2), z0toSV, sqrt(z0Err2),
951  chi2testSV, (doDCAin3D ? docaSV : d0toSV), 6,
952  vtx2DErr2, trk2DErr2, phi};
953  }
954  } else {
955  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
956  << " docaSV == 0 !");
957  }
958  } // if chi2DefToUse > 7 && chi2DefToUse < 10
959 
960  } else if ( chi2DefToUse > 2 && chi2DefToUse < 5 ) {
961  // CalcLogChi2toPV method using xAOD::TrackingHelpers
962  // (simply taken from NtupleMaker for comparisons)
963  // N.B. z0significance method of the helper doesn't include pv_z0
964  // uncertainty
965  double d0sign(0.);
966  if (chi2DefToUse == 4) {
967  d0sign =
972  );
973  } else {
975  }
976  // trk z0 is expressed relative to the beamspot position along z-axis
977  // (trk->vz())
978  // DCA always in 3D
979  double z0toPV = track->z0() + track->vz() - vtx->z();
980  double z0Err2 = track->definingParametersCovMatrixVec()[2];
981  if (chi2DefToUse == 4) z0Err2+= vtx->covariancePosition()(2,2);
982  double z0sign = z0toPV / sqrt( z0Err2 );
983  double chi2 = log( pow(d0sign, 2.) + pow(z0sign, 2.) );
984  // set results
985  res = {-999., -99., z0toPV, sqrt(z0Err2), chi2, -100., 4, -99., -99.,
986  -999.};
987 
988  } // if chi2DefToUse
989  } else {
990  ATH_MSG_WARNING("BPhysVertexTrackBase::getTrackLogChi2DCA():"
991  " track pointer is NULL!");
992  res[6] = -2.;
993  } // if track != NULL
994  return res;
995  }
996  //--------------------------------------------------------------------------
997  // detTrackTypes(): returns a bit pattern of the applicable
998  // track types from {ASSOCPV, PVTYPE0, PVTYPE1, PVTYPE2, PVTYPE3, NONE,
999  // NULLVP, CAPVXXXXXXX, ...} (or'd).
1000  //--------------------------------------------------------------------------
1002  const xAOD::Vertex* candPV,
1003  const xAOD::Vertex* candRefPV) const {
1004  int bits = 0x0;
1005 
1006  // PVTYPE0 - PVTYPE3, NONE
1007  ATH_MSG_ERROR("BPhysVertexTrackBase::detTrackTypes must be adjusted due to changes in TrackParticle");
1008 
1009  // ASOCPV
1010  if ( candPV != NULL ) {
1011  bool found(false);
1012  for (size_t i=0; i<candPV->nTrackParticles(); ++i) {
1013  if ( track == candPV->trackParticle(i) ) {
1014  found = true;
1015  break;
1016  }
1017  }
1018  if ( found ) bits |= track_type_bit[ASSOCPV];
1019  //
1020  // CLOSEAPV
1021  for (unsigned int i=7; i<n_track_types; ++i) {
1022  if ( (track_type_bit[i] & m_trackTypesUsed) > 0x0 ) {
1023  bool useRefittedPvs = ( i%2 == 1 );
1024  bool doDCAin3D = ( (i-7)%4 > 1 );
1025  int chi2DefToUse = (i-7)/4;
1026  // adjustment above bit 20
1027  if ( i > 20 ) {
1028  doDCAin3D = true;
1029  chi2DefToUse = (i-13)/2;
1030  }
1031  const xAOD::Vertex* minChi2PV(nullptr);
1032  if ( chi2DefToUse == 5 ) {
1033  minChi2PV =
1034  findAssocPV(track, candPV, candRefPV, m_pvTypesToConsider,
1035  m_minNTracksInPV, useRefittedPvs);
1036  } else {
1037  minChi2PV =
1038  findMinChi2PV(track, candPV, candRefPV, m_pvTypesToConsider,
1039  m_minNTracksInPV, useRefittedPvs,
1040  doDCAin3D, chi2DefToUse).first;
1041  } // if chi2DefToUse
1042  if ( candPV == minChi2PV
1043  || (candRefPV != nullptr && candRefPV == minChi2PV) ) {
1044  bits |= track_type_bit[i];
1045  }
1046  } // if m_trackTypesUsed
1047  } // for i
1048 
1049  } // if candPV != NULL
1050 
1051  return bits;
1052  }
1053  //--------------------------------------------------------------------------
1054  // findAllTracksInDecay: returns a vector of xAOD::TrackParticle objects
1055  // found in this vertex and subsequent decay vertices (if chosen).
1056  //--------------------------------------------------------------------------
1058  const {
1059 
1060  TrackBag tracks;
1061  findAllTracksInDecay(vtx, tracks);
1062 
1063  return tracks;
1064  }
1065  //--------------------------------------------------------------------------
1066  // findAllTracksInDecay: fills a vector of xAOD::TrackParticle objects
1067  // found in this vertex and subsequent decay vertices (if chosen).
1068  // Method avoids duplicate entries in vector.
1069  // Recursively calls itself if necessary.
1070  //--------------------------------------------------------------------------
1072  TrackBag& tracks)
1073  const {
1074 
1075  for (unsigned int i=0; i < vtx.vtx()->nTrackParticles(); ++i) {
1076  const xAOD::TrackParticle* track = vtx.vtx()->trackParticle(i);
1077  if ( std::find(tracks.begin(),tracks.end(),track) == tracks.end() ) {
1078  tracks.push_back(track);
1079  } // if
1080  } // for
1081  // loop over preceeding vertices
1082  if ( m_incPrecVerticesInDecay ) {
1083  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
1084  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
1085  findAllTracksInDecay(precVtx, tracks);
1086  } // if
1087  } // for
1088  }
1089  //--------------------------------------------------------------------------
1090  // findAllMuonsInDecay: returns a vector of xAOD::Muon objects
1091  // found in this vertex and subsequent decay vertices (if chosen).
1092  //--------------------------------------------------------------------------
1094  const {
1095 
1096  MuonBag muons;
1097  findAllMuonsInDecay(vtx, muons);
1098 
1099  return muons;
1100  }
1101  //--------------------------------------------------------------------------
1102  // findAllMuonsInDecay: fills vector of xAOD::Muon objects
1103  // found in this vertex and subsequent decay vertices (if chosen).
1104  // Method avoids duplicate entries in vector.
1105  // Recursively calls itself if necessary.
1106  //--------------------------------------------------------------------------
1108  MuonBag& muons)
1109  const {
1110 
1111  for (int i=0; i < vtx.nMuons(); ++i) {
1112  if ( std::find(muons.begin(),muons.end(),vtx.muon(i)) == muons.end() ) {
1113  muons.push_back(vtx.muon(i));
1114  } // if
1115  } // for
1116  // loop over preceeding vertices
1117  if ( m_incPrecVerticesInDecay ) {
1118  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
1119  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
1120  findAllMuonsInDecay(precVtx, muons);
1121  } // for
1122  } // if
1123  }
1124  //--------------------------------------------------------------------------
1125  // findAllMuonsIdTracksInDecay: returns a vector of xAOD::TrackParticle
1126  // objects found in this vertex and subsequent decay vertices.
1127  // Returns the tracks.
1128  // The vector of track pointers reeturned may contain NULL elements.
1129  //--------------------------------------------------------------------------
1130  TrackBag
1132  MuonBag& muons) const {
1133 
1134  TrackBag tracks;
1135  muons = findAllMuonsInDecay(vtx);
1136 
1137  for (MuonBag::const_iterator muItr = muons.begin(); muItr != muons.end();
1138  ++muItr) {
1139  const xAOD::TrackParticle* track =
1140  (*muItr)->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
1141  tracks.push_back(track);
1142  } // for
1143 
1144  return tracks;
1145  }
1146  //--------------------------------------------------------------------------
1147  // findMuonRefTrackMomenta: returns a vector<TVector3> containing the
1148  // three momenta of refitted tracks identified as muons.
1149  // The vector may contain (0,0,0) elements indicating an error.
1150  //--------------------------------------------------------------------------
1151  std::vector<TVector3>
1153  MuonBag& muons) const {
1154 
1155  std::vector<TVector3> refMuTracks;
1156 
1157  // quick solution if nRefTrks == nMuons:
1158  if ( vtx.nRefTrks() == vtx.nMuons() && !m_incPrecVerticesInDecay ) {
1159  muons = vtx.muons();
1160  for ( auto refMuTrack : vtx.refTrks() ) {
1161  refMuTracks.push_back(refMuTrack);
1162  }
1163  } else {
1164  TrackBag muonIdTracks = findAllMuonIdTracksInDecay(vtx, muons);
1165  if ( vtx.nRefTrks() == (int)vtx.vtx()->nTrackParticles() ) {
1166  for (int i=0; i<vtx.nRefTrks(); ++i) {
1167  const xAOD::TrackParticle* otp =
1168  (const xAOD::TrackParticle*)vtx.refTrkOrigin(i);
1169  if ( otp != NULL ) {
1170  if ( std::find(muonIdTracks.begin(), muonIdTracks.end(), otp)
1171  != muonIdTracks.end() ) {
1172  refMuTracks.push_back(vtx.refTrk(i));
1173  }
1174  } else {
1175  ATH_MSG_WARNING("BPhysVertexTrackBase::findMuonRefTrackMomenta():"
1176  " refTrkOrigin == NULL for refTrk # "
1177  << i << " !");
1178  }
1179  } // for
1180  } else {
1181  ATH_MSG_WARNING("BPhysVertexTrackBase::findMuonRefTrackMomenta():"
1182  " size mismatch #refTrks = " << vtx.nRefTrks()
1183  << "#trackParticles = " << vtx.vtx()->nTrackParticles()
1184  << " !");
1185  } // if nRefTracks == nTrackParticles
1186  // loop over preceeding vertices -- only if not all refMuTrks found yet
1187  if ( m_incPrecVerticesInDecay && muons.size() > refMuTracks.size() ) {
1188  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
1189  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
1190  std::vector<TVector3> precRefMuTracks =
1191  findMuonRefTrackMomenta(precVtx, muons);
1192  // append only if not yet contained in
1193  for ( auto precRefMuTrack : precRefMuTracks ) {
1194  if ( std::find(refMuTracks.begin(), refMuTracks.end(),
1195  precRefMuTrack) == refMuTracks.end() ) {
1196  refMuTracks.push_back(precRefMuTrack);
1197  } // if
1198  } // for
1199  } // for ivtx
1200  } // if
1201  } // if (shortcut)
1202 
1203  // debug output
1204  if ( msgLvl( MSG::DEBUG ) ) {
1205  ATH_MSG_DEBUG("BPhysVertexTrackBase::findMuonRefTrackMomenta():"
1206  << " #muons: " << muons.size()
1207  << " #refMuTrks: " << refMuTracks.size());
1208  TString str = Form(">> refMuTracks(%d):\n", (int)refMuTracks.size());
1209  for (unsigned int i=0; i < refMuTracks.size(); ++i) {
1210  str += Form("(%10.4f,%10.4f,%10.4f) ",
1211  refMuTracks[i].x(), refMuTracks[i].y(),
1212  refMuTracks[i].z());
1213  }
1214  ATH_MSG_DEBUG(str.Data());
1215  }
1216 
1217  return refMuTracks;
1218  }
1219 
1220  //--------------------------------------------------------------------------
1221  // selectTracks: returns a vector of xAOD::TrackParticle objects
1222  // seleted from the input track collection according to the selection
1223  // criteria and with respect to the B candidate vertex.
1224  //--------------------------------------------------------------------------
1227  inpTracks,
1228  xAOD::BPhysHelper& cand,
1229  const unsigned int ipv,
1230  const unsigned int its,
1231  const unsigned int itt) const {
1232 
1233  return selectTracks(inpTracks, findAllTracksInDecay(cand), cand,
1234  ipv, its, itt);
1235  }
1236  //--------------------------------------------------------------------------
1237  // selectTracks: returns a vector of xAOD::TrackParticle objects
1238  // seleted from the input track collection according to the selection
1239  // criteria and with respect to the B candidate vertex.
1240  //--------------------------------------------------------------------------
1243  inpTracks,
1244  const TrackBag& exclTracks,
1245  xAOD::BPhysHelper& cand,
1246  const unsigned int ipv,
1247  const unsigned int its,
1248  const unsigned int itt) const {
1249 
1250  const xAOD::Vertex* candRefPV = cand.pv(m_pvAssocTypes[ipv]);
1251  const xAOD::Vertex* candPV = cand.origPv(m_pvAssocTypes[ipv]);
1252 
1253  ATH_MSG_DEBUG("selectTracks: Found " << exclTracks.size()
1254  << " " << exclTracks
1255  << " for decay candidate " << cand.vtx()
1256  << "; candPV: " << candPV << " candRefPV: " << candRefPV);
1257 
1258  std::string bname(buildBranchBaseName(its, ipv, itt));
1259 
1260  // tracks to be considered
1261  TrackBag tracks;
1263  inpTracks->begin(); trkItr != inpTracks->end(); ++trkItr) {
1264  const xAOD::TrackParticle* track = *trkItr;
1265  uint64_t trackTypesForTrack(0x0);
1266  // debug track types (before any cuts)
1267  if ( m_debugTrackTypes > 0 ) {
1268  trackTypesForTrack = detTrackTypes(track, candPV, candRefPV);
1269  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "all");
1270  }
1271  // track selection check
1272  if ( ! m_trackSelectionTools[its]->accept(*track, candRefPV) ) continue;
1273  // debug track types (after track selection cuts)
1274  if ( m_debugTrackTypes > 0 ) {
1275  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "ats");
1276  }
1277 
1278  // calcluation of track type bits not necessary if all bits requested
1279  if ( ! ((unsigned int)m_useTrackTypes[itt] == ttall() ||
1280  (unsigned int)m_useTrackTypes[itt] == ttallMin()) ) {
1281  // track type check -- determination if not in debugging mode
1282  // delayed for execution speed reasons
1283  if ( trackTypesForTrack == 0x0 ) {
1284  trackTypesForTrack = detTrackTypes(track, candPV, candRefPV);
1285  }
1286  if ( (trackTypesForTrack & m_useTrackTypes[itt]) == 0x0 ) {
1287  continue;
1288  }
1289  }
1290  // debug track types (after track type cuts)
1291  if ( m_debugTrackTypes > 0 ) {
1292  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "att");
1293  }
1294  // track not in list of tracks to exclude
1295  if ( std::find(exclTracks.begin(), exclTracks.end(), track)
1296  != exclTracks.end() ) continue;
1297  // debug track types (after all cuts)
1298  if ( m_debugTrackTypes > 0 ) {
1299  m_mttc->addToCounter(trackTypesForTrack, itt, bname, "fin");
1300  }
1301  // tracks that survived so far
1302  tracks.push_back(track);
1303  } // for
1304 
1305  return tracks;
1306  }
1307  //--------------------------------------------------------------------------
1308  // buildBranchBaseName: build branch name from track selection, primary
1309  // vertex association and track type qualifiers.
1310  //--------------------------------------------------------------------------
1311  std::string BPhysVertexTrackBase::buildBranchBaseName(unsigned int its,
1312  unsigned int ipv,
1313  unsigned int itt,
1314  const std::string& preSuffix)
1315  const {
1316 
1317  ATH_MSG_DEBUG("BPhysVertexTrackBase::buildBranchBaseName -- begin");
1318 
1319  std::string tsName = m_trackSelectionTools[its].name();
1320  std::string pvAssoc = xAOD::BPhysHelper::pv_type_str[m_pvAssocTypes[ipv]];
1321 
1322  // need to get part of tsname after last underscore
1323  std::size_t ipos = tsName.find_last_of("_");
1324  if ( ipos != std::string::npos ) tsName = tsName.substr(ipos+1);
1325 
1326  // format it nicely
1327  std::string f = std::format("T{:010d}_{}_{}{}{}",
1328  m_useTrackTypes[itt], tsName, pvAssoc,
1329  (preSuffix.length() > 0 ? "_" + preSuffix : ""),
1330  (m_branchSuffix.length() > 0 ? "_" + m_branchSuffix : ""));
1331 
1332  ATH_MSG_DEBUG("BPhysVertexBaseTrackBase::buildBranchBaseName: " << f);
1333  return f;
1334  }
1335  //--------------------------------------------------------------------------
1336  //
1337  // Initialize PV-to-SV association type vector
1338  //
1339  //--------------------------------------------------------------------------
1341 
1342  m_pvAssocTypes.clear();
1343  for (unsigned int i=0; i<xAOD::BPhysHelper::n_pv_types; ++i) {
1344  if ( (m_doVertexType & (1 << i)) > 0 )
1346  }
1347  }
1348  //--------------------------------------------------------------------------
1349  //
1350  // Find primary vertex to which a track is closest to in terms of minimum
1351  // chi2 to any primary vertex. Replace primary vertex by refitted primary
1352  // vertex (for B candidate associated primary vertices)
1353  // if appropriate (and available).
1354  // Only consider primary vertices of specified primary vertex types and
1355  // with a minimum number of tracks.
1356  //
1357  //--------------------------------------------------------------------------
1358  std::pair<const xAOD::Vertex*, double>
1360  const xAOD::Vertex* candPV,
1361  const xAOD::Vertex* candRefPV,
1362  const std::vector<uint64_t>& pvtypes,
1363  const int minNTracksInPV,
1364  const bool useRefittedPvs,
1365  const bool doDCAin3D,
1366  const int chi2DefToUse) const {
1367 
1368  double minChi2 = std::numeric_limits<double>::max();
1369  const xAOD::Vertex* minChi2PV(nullptr);
1370 
1371  for (auto pvtx: *m_pvtxContainer) {
1372  if ( pvtx != nullptr ) {
1373  if ( std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
1374  != pvtypes.end() ) {
1375  const xAOD::Vertex* cvtx = pvtx;
1376  // replace by refitted PV if associated PV matches orignal PV
1377  if ( useRefittedPvs && pvtx == candPV ) {
1378  if ( candRefPV != nullptr ) {
1379  cvtx = candRefPV;
1380  } else {
1381  ATH_MSG_WARNING(" BPhysVertexTrackBase::findMinChi2PV:"
1382  << " candRefPV == NULL!");
1383  continue;
1384  }
1385  } // if pvtx == candPV
1386  if ( (int)cvtx->nTrackParticles() >= minNTracksInPV ) {
1387  double chi2 = getTrackLogChi2DCA(track, cvtx, doDCAin3D,
1388  chi2DefToUse)[4];
1389  if ( chi2 < minChi2 ) {
1390  minChi2 = chi2;
1391  minChi2PV = cvtx;
1392  } // if chi2 < minChi2
1393  } // if minNTracksInPV
1394  } // if pvTypes in pvtypes vector
1395  } // if pvtx != nullptr
1396  } // for pvtx
1397 
1398  return std::make_pair(minChi2PV, minChi2);
1399  }
1400  //--------------------------------------------------------------------------
1401  //
1402  // Find primary vertex to which a track is closest using the
1403  // TrackVertexAssociationTool. Replace primary vertex by refitted primary
1404  // vertex (for B candidate associated primary vertices)
1405  // if appropriate (and available).
1406  // Only consider primary vertices of specified primary vertex types and
1407  // with a minimum number of tracks.
1408  //
1409  //--------------------------------------------------------------------------
1410  const xAOD::Vertex*
1412  const xAOD::Vertex* candPV,
1413  const xAOD::Vertex* candRefPV,
1414  const std::vector<uint64_t>& pvtypes,
1415  const int minNTracksInPV,
1416  const bool useRefittedPvs) const {
1417 
1418  // select PVs to be considered/replace candPV by candRefPV if requested
1419  std::vector<const xAOD::Vertex*> vpvtx;
1420  for (auto pvtx: *m_pvtxContainer) {
1421  if ( pvtx != nullptr ) {
1422  if ( std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
1423  != pvtypes.end() ) {
1424  const xAOD::Vertex* cvtx = pvtx;
1425  // replace by refitted PV if associated PV matches orignal PV
1426  if ( useRefittedPvs && pvtx == candPV ) {
1427  if ( candRefPV != nullptr ) {
1428  cvtx = candRefPV;
1429  } else {
1430  ATH_MSG_WARNING("BPhysVertexTrackBase::findAssocPV:"
1431  << " candRefPV == NULL!");
1432  continue;
1433  }
1434  } // if pvtx == candPV
1435  if ( (int)cvtx->nTrackParticles() >= minNTracksInPV ) {
1436  vpvtx.push_back(cvtx);
1437  } // if minNTracksInPV
1438  } // if pvTypes in pvtypes vector
1439  } // if pvtx != nullptr
1440  } // for pvtx
1441 
1442  const xAOD::Vertex* assocPV(NULL);
1443  if ( useRefittedPvs && m_tvaToolHasWpLoose ) {
1444  // check whether track is in refitted PV - if so accept
1445  // Need to do this here as the TrackVertexAssociationTool
1446  // with WP 'Loose' only checks the track->vertex() pointer
1447  // which always points to the original PV.
1448  for (const auto &tp : candRefPV->trackParticleLinks()) {
1449  if ( *tp == track ) {
1450  // track is part of refitted PV -- accept it
1451  assocPV = candRefPV;
1452  break;
1453  }
1454  } // for tp
1455  // if not matching use the TrackVertexAssociationTool (other PVs etc)
1456  if ( assocPV == nullptr ) {
1457  assocPV = m_tvaTool->getUniqueMatchVertex(*track, vpvtx);
1458  }
1459  } else {
1460  assocPV = m_tvaTool->getUniqueMatchVertex(*track, vpvtx);
1461  } // if useRefittedPvs && m_tvaToolHasWpLoose
1462  if ( assocPV == nullptr ) {
1463  ATH_MSG_WARNING("BPhysVertexTrackBase::findAssocPV:"
1464  << " assocPV == NULL for track!"
1465  << " len(vpvtx) = " << vpvtx.size()
1466  << " useRefittedPvs = " << useRefittedPvs
1467  << " minNTracksInPV = " << minNTracksInPV);
1468  }
1469 
1470  return assocPV;
1471  }
1472  //--------------------------------------------------------------------------
1473 }
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
checkFileSG.line
line
Definition: checkFileSG.py:75
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:574
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.
DerivationFramework::BPhysVertexTrackBase::initialize
virtual StatusCode initialize() override
Definition: BPhysVertexTrackBase.cxx:402
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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:464
DerivationFramework::BPhysVertexTrackBase::findAllMuonsInDecay
MuonBag findAllMuonsInDecay(xAOD::BPhysHelper &vtx) const
Definition: BPhysVertexTrackBase.cxx:1093
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:396
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:567
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:1001
Trk::z0
@ z0
Definition: ParamDefs.h:64
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
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:1359
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
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:1311
DerivationFramework::BPhysVertexTrackBase::ttall
static uint64_t ttall()
Definition: BPhysVertexTrackBase.cxx:318
DerivationFramework::AmgSymMatrix
AmgSymMatrix(3) BPhysAddMuonBasedInvMass
Definition: BPhysAddMuonBasedInvMass.cxx:601
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:607
DerivationFramework::BPhysVertexTrackBase::BaseItem::buildName
virtual std::string buildName(const std::string &qualifier="", const std::string &suffix="") const
Definition: BPhysVertexTrackBase.cxx:201
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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:36
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:582
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:672
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
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:14
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:638
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
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:1057
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:1152
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:135
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:622
DerivationFramework::BPhysVertexTrackBase::addBranchesSVLoopHook
virtual StatusCode addBranchesSVLoopHook(const xAOD::Vertex *vtx) const
Definition: BPhysVertexTrackBase.cxx:595
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:228
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:722
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
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
Pass the thinning service
Definition: BPhysVertexTrackBase.cxx:477
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:684
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:1225
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:1131
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:1411
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
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
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:1340
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::track
@ track
Definition: TrackingPrimitives.h:512
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
AthAlgTool
Definition: AthAlgTool.h:26
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:560
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