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