ATLAS Offline Software
BVertexClosestTrackTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //============================================================================
6 // BVertexClosestTrackTool.cxx
7 //============================================================================
8 //
9 // Author : Wolfgang Walkowiak <Wolfgang.Walkowiak@cern.ch.>
10 // Changes:
11 //
12 // Add B vertex closest track information for different configurations,
13 // different track selections and different PV-to-SV association methods.
14 //
15 // For an usage example see BPHY8.py .
16 //
17 // Job options provided by this class:
18 // - CloseTrackChi2SetName -- list with labels for the following
19 // four settings (all five lists must
20 // be of exactly same length)
21 // - CloseTrackCorrChi2 -- list with options for using the
22 // SV uncertainties in the chi2 calculation
23 // in addition to track uncertainties
24 // 0 : use old method
25 // (only track uncertainties)
26 // 1 : from track perigee with
27 // uncertainties from track and vertex
28 // 2 : simple extrapolation from track
29 // parameters with uncertainties from
30 // track and vertex (extrapolation
31 // used for track swimming)
32 // - CloseTrackMinDCAin3D -- use 3-dimensional information in
33 // minimization (list)
34 // - CloseTrackMaxLogChi2 -- maximum chi2 distance of closest track
35 // to B vertex (list)
36 // - NCloseTrackMaxLogChi2 -- maximum chi2 distance of track
37 // to B vertex for track counting (list)
38 //
39 //============================================================================
40 //
42 #include "xAODMuon/MuonContainer.h"
44 #include "xAODBPhys/BPhysHelper.h"
47 #include "AthLinks/ElementLink.h"
48 
49 #include <format>
50 #include "TVector3.h"
51 #include <algorithm>
52 #include <sstream>
53 
54 namespace DerivationFramework {
55 
56  //-------------------------------------------------------------------------
57  //
58  // helper class
60  const std::string& Bname,
61  const std::string& Prefix,
62  double Dca, double DcaErr,
63  double Zca, double ZcaErr,
64  double VtxNDErr2, double TrkNDErr2, double Phi0Used,
65  int NTrksChi2,
66  xAOD::TrackParticle* CloseTrack,
67  const TrackBag& Tracks,
68  const std::vector<std::vector<double> >& Vtap,
69  const std::vector<unsigned short>& Selpat)
70  : BaseItem(Name, Bname, Prefix), dca(Dca), dcaErr(DcaErr),
71  zca(Zca), zcaErr(ZcaErr), vtxNDErr2(VtxNDErr2), trkNDErr2(TrkNDErr2),
72  phi0Used(Phi0Used),
73  nTrksChi2(NTrksChi2), closeTrack(CloseTrack),
74  tracks(Tracks), vtap(Vtap), selpat(Selpat) {
75  }
76 
78  }
79 
81  const std::string& Bname,
82  const std::string& Prefix) {
83  BaseItem::setup(Name, Bname, Prefix);
84  dca = -999.;
85  dcaErr = -99.;
86  zca = -999.;
87  zcaErr = -99.;
88  vtxNDErr2 = -99.;
89  trkNDErr2 = -99.;
90  phi0Used = -999.;
91  nTrksChi2 = 0;
92  closeTrack = NULL;
93  tracks.clear();
94  vtap.clear();
95  selpat.clear();
96  }
97 
99  const std::string& Bname,
100  const std::string& Prefix,
101  double Dca, double DcaErr,
102  double Zca, double ZcaErr,
103  double VtxNDErr2, double TrkNDErr2, double Phi0Used,
104  int NTrksChi2,
106  CloseTrack,
108  std::vector<std::vector<double> > Vtap,
109  std::vector<unsigned short> Selpat) {
110  BaseItem::setup(Name, Bname, Prefix);
111  dca = Dca;
112  dcaErr = DcaErr;
113  zca = Zca;
114  zcaErr = ZcaErr;
115  vtxNDErr2 = VtxNDErr2;
116  trkNDErr2 = TrkNDErr2;
117  phi0Used = Phi0Used;
118  nTrksChi2 = NTrksChi2;
119  closeTrack = CloseTrack;
120  tracks = Tracks;
121  vtap = Vtap;
122  selpat = Selpat;
123  }
124 
126  dca = -999.;
127  dcaErr = -99.;
128  zca = -999.;
129  zcaErr = -99.;
130  vtxNDErr2 = -99.;
131  trkNDErr2 = -99.;
132  phi0Used = -999.;
133  nTrksChi2 = 0;
134  closeTrack = NULL;
135  tracks.clear();
136  vtap.clear();
137  selpat.clear();
138  }
139 
141  copyVals((const CtItem&)item);
142  }
143 
145  dca = item.dca;
146  dcaErr = item.dcaErr;
147  zca = item.zca;
148  zcaErr = item.zcaErr;
149  vtxNDErr2 = item.vtxNDErr2;
150  trkNDErr2 = item.trkNDErr2;
151  phi0Used = item.phi0Used;
152  nTrksChi2 = item.nTrksChi2;
153  closeTrack = item.closeTrack;
154  tracks = item.tracks;
155  vtap = item.vtap;
156  selpat = item.selpat;
157  }
158 
160  return buildName("DCA");
161  }
162 
164  return buildName("DCAError");
165  }
166 
168  return buildName("ZCA");
169  }
170 
172  return buildName("ZCAError");
173  }
174 
176  return buildName("VtxNDError2");
177  }
178 
180  return buildName("TrkNDError2");
181  }
182 
184  return buildName("Phi0Used");
185  }
186 
188  return buildName("NTracksChi2");
189  }
190 
192  return buildName("CloseTrack", "_Link");
193  }
194 
196  std::string f1 = std::format("dca: {:10.6f} {:10.6f} zca: {:10.6f} {:10.6f} nt: {:10d}",
197  dca, dcaErr, zca, zcaErr, nTrksChi2);
198  std::string f2 = std::format("{}\n {}\n",
200  f1);
201  std::string rstr = f2;
202  rstr += "per track: p(px, py, pz)\n";
203  rstr += " d(d0, z0, phi, theta, qoverp)\n";
204  rstr += " d0, d0Err, z0, z0Err, logChi2, dca, okFlag\n";
205  rstr += " vtxNDErr2, trkNDErr2, phi0Used\n";
206  rstr += " vtxNDErr, trkNDErr, log(chi2Err2Sum)\n";
207  // loop over tracks
208  if (tracks.size() == vtap.size() && vtap.size() == selpat.size()) {
209  for (unsigned int i=0; i<tracks.size(); ++i) {
210  std::string f3str = std::format(" {:3d} {:2d} ", i, selpat[i]);
211  // 0: d0, 1: d0Err, 2: z0, 3: z0Err, 4: logChi2, 5: dca, 6: okFlag
212  // 7: vtxNDErr2, 8: trkNDErr2, 9: phi0Used
213  std::string f4 = std::format("%s\nd0: %10.4f %10.4f z0: %10.4f %10.4f "
214  "lc2: %10.4f dca: %10.4f ok: %3f\n"
215  "vtxNDErr2: %10.4f trkNDErr2: %10.4f "
216  "phi0Used: %10.4f\n"
217  "vtxNDErr: %10.4f trkNDErr2 %10.4f "
218  "logChi2Err2Sum: %10.4f"
219  , trackToString(tracks[i])
220  , vtap[i][0] , vtap[i][1] , vtap[i][2] , vtap[i][3]
221  , vtap[i][4] , vtap[i][5] , vtap[i][6]
222  , vtap[i][7] , vtap[i][8] , vtap[i][9]
223  , (vtap[i][7] < 0. ? -99. : sqrt(vtap[i][7]))
224  , (vtap[i][8] < 0. ? -99. : sqrt(vtap[i][8]))
225  , ((vtap[i][7]+vtap[i][8] > 0.) ?
226  log(vtap[i][5]*vtap[i][5]/(vtap[i][7]+vtap[i][8])) : -999.));
227  std::string tstr = wrapLines(f4,
228  std::string(f3str.length(), ' '));
229  tstr.replace(0,f3str.length(),f3str);
230  rstr.append(tstr+"\n");
231  } // for i
232  } else {
233  std::string f5 = std::format("Mismatch: nTracks: {} nVtap: {} nSelpat: {}\n",tracks.size(), vtap.size(), selpat.size());
234  rstr.append(f5);
235  } // if sizes
236 
237  rstr.erase(rstr.length()-1);
238  return rstr;
239  }
240 
241  //--------------------------------------------------------------------------
243  const std::string& n,
244  const IInterface* p)
246  m_svIdx(0) {
247 
248  declareInterface<DerivationFramework::IAugmentationTool>(this);
249 
250  declareProperty("CloseTrackChi2SetName", m_closeTrackChi2SetName = {"def"});
251  declareProperty("CloseTrackCorrChi2" , m_closeTrackCorrChi2 = {0});
252  declareProperty("CloseTrackMinDCAin3D" , m_minDCAin3D = {true});
253  declareProperty("CloseTrackMaxLogChi2" , m_closeTrackMaxLogChi2 = {-1.});
254  declareProperty("NCloseTrackMaxLogChi2", m_nCloseTrackMaxLogChi2 = {-1.});
255  }
256  //--------------------------------------------------------------------------
258 
259  ATH_MSG_DEBUG("BVertexClosestTrackTool::initializeHook() -- begin");
260 
261  // check job options
262  if ( m_closeTrackChi2SetName.size() == 0 ) {
263  ATH_MSG_ERROR("No chi2 set names provided!");
264  }
265  if ( m_closeTrackCorrChi2.size() == 0 ) {
266  ATH_MSG_ERROR("No use of corrected chi2 settings provided!");
267  }
268  if ( m_minDCAin3D.size() == 0 ) {
269  ATH_MSG_ERROR("No use of min DCA in 3D settings provided!");
270  }
271  if ( m_closeTrackMaxLogChi2.size() == 0 ) {
272  ATH_MSG_ERROR("No cuts on max log chi2 for DOCA calculation provided!");
273  }
274  if ( m_nCloseTrackMaxLogChi2.size() == 0 ) {
275  ATH_MSG_ERROR("No cuts on max log chi2 for nClosetTracks calculation "
276  "provided!");
277  }
278  if ( m_closeTrackCorrChi2.size() != m_closeTrackChi2SetName.size() ||
279  m_minDCAin3D.size() != m_closeTrackChi2SetName.size() ||
282  ATH_MSG_ERROR("Size mismatch of CloseTrackChi2SetName ("
283  << m_closeTrackChi2SetName.size() << "), "
284  << "CloseTrackCorrChi2 ("
285  << m_closeTrackCorrChi2 << "), "
286  << "CloseTrackMinDCAin3D ("
287  << m_minDCAin3D.size() << "), "
288  << "CloseTrackMaxLogChi2 ("
289  << m_closeTrackMaxLogChi2.size() << ") and/or "
290  << "NCloseTrackMaxLogChi2 ("
291  << m_nCloseTrackMaxLogChi2.size() << ")");
292  }
293 
294  // initialize results array
295  initResults();
296 
297  ATH_MSG_DEBUG("BVertexClosestTrackTool::initializeHook() -- end");
298 
299  return StatusCode::SUCCESS;
300  }
301  //--------------------------------------------------------------------------
303 
304  ATH_MSG_DEBUG("BVertexClosestTrackTool::finalizeHook()");
305 
306  // everything all right
307  return StatusCode::SUCCESS;
308  }
309  //--------------------------------------------------------------------------
310  StatusCode
312 
313  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesVCLoopHook() -- begin");
314 
315  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesVCSetupHook: "
316  << "Vertex container index " << ivc
317  << " for collection " << m_vertexContainerNames[ivc]
318  << " with prefix " << m_branchPrefixes[ivc]);
319 
321 
322  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesVCSetupHook() -- end");
323 
324  // nothing to do here
325  return StatusCode::SUCCESS;
326  }
327 
328  //--------------------------------------------------------------------------
329  StatusCode
331 
332  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesSVLoopHook() -- begin");
333 
334  // calculate closest track values
335  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesSVLoopHook(): "
336  "calculate closest track ...");
337  CHECK(calculateValues(vtx));
338 
339  // save the closest track values
340  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesSVLoopHook(): "
341  "save closest track ...");
342  CHECK(saveClosestTrack(vtx));
343 
344  // dump close track item debugging information
347  }
348 
349  ATH_MSG_DEBUG("BVertexClosestTrackTool::addBranchesSVLoopHook() -- end");
350 
351  // nothing to do here
352  return StatusCode::SUCCESS;
353  }
354  //--------------------------------------------------------------------------
355  // Calculate closest track variables -- method called from caching loop
356  //--------------------------------------------------------------------------
357  StatusCode
359  const unsigned int ipv,
360  const unsigned int its,
361  const unsigned int itt) const {
362 
363  ATH_MSG_DEBUG("calcValuesHook: ipv: " << ipv
364  << ", its: " << its << ", itt: " << itt);
365 
366  // candidate tracks and momentum
367  xAOD::BPhysHelper cand(vtx);
368 
369  // tracks to be considered
370  TrackBag tracks = selectTracks(m_tracks, cand, ipv, its, itt);
371 
372  // loop over chi2 setting sets
373  unsigned int nChi2Sets = m_closeTrackChi2SetName.size();
374  for (unsigned int ics = 0; ics < nChi2Sets; ++ics) {
375 
376  CtItem& cti = m_results[its][ipv][itt][ics];
377 
378  // presets
379  cti.resetVals();
380 
381  double closestTrkDCA = 9999.;
382  int closestTrkIdx(-1);
383  unsigned int trkIdx(0);
384  for (TrackBag::const_iterator trkItr = tracks.begin();
385  trkItr != tracks.end(); ++trkItr, ++trkIdx) {
386 
387  //
388  // track selection bit pattern:
389  // bit 0 : included in number of close tracks
390  // bit 1 : chosen as closest track
391  //
392  unsigned short selpat(0);
393 
394  // Returned vector components:
395  // 0: d0, 1: d0Err, 2: z0, 3: z0Err, 4: logChi2, 5: dca, 6: okFlag
396  // 7: vtxErrPart2, 8: trkErrPart2, 9: phi0Used
397  std::vector<double> vtap =
398  getTrackLogChi2DCA(*trkItr, cand.vtx(),
400  ATH_MSG_DEBUG("calcValuesHook: track: " << *trkItr
401  << ", logChi2: " << vtap[4] << ", dca: " << vtap[5]);
402 
403  // track values at perigee found?
404  if ( vtap[6] >= 0. ) {
405  ATH_MSG_DEBUG("calcValuesHook: checking track count for "
406  "m_nCloseTrackMaxLogChi2[ics] = "
407  << m_nCloseTrackMaxLogChi2[ics]);
408  // count tracks
409  if ( vtap[4] < m_nCloseTrackMaxLogChi2[ics] ) {
410  cti.nTrksChi2++;
411  selpat |= 1;
412  ATH_MSG_DEBUG("calcValuesHook: nTrksChi2++ for track " << *trkItr);
413  }
414  // find closest track
415  ATH_MSG_DEBUG("calcValuesHook: log(chi2) check: "
416  "m_closeTrackMaxLogChi2[ics]: "
417  << m_closeTrackMaxLogChi2[ics]
418  << ", logChi2: " << vtap[4]
419  << ", closestTrkDCA: " << closestTrkDCA
420  << ", dca: " << fabs(vtap[5]));
421  if ( fabs(vtap[5]) < closestTrkDCA &&
422  vtap[4] < m_closeTrackMaxLogChi2[ics] ) {
423  closestTrkDCA = fabs(vtap[5]);
424  cti.dca = vtap[0];
425  cti.dcaErr = vtap[1];
426  cti.zca = vtap[2];
427  cti.zcaErr = vtap[3];
428  cti.vtxNDErr2 = vtap[7];
429  cti.trkNDErr2 = vtap[8];
430  cti.phi0Used = vtap[9];
431  cti.closeTrack = *trkItr;
432  closestTrkIdx = trkIdx;
433  ATH_MSG_DEBUG("calcValuesHook: closestTrkDCA now: "
434  << closestTrkDCA
435  << " for track " << *trkItr);
436  }
437  } // if ok
438  cti.tracks.push_back(*trkItr);
439  cti.vtap.push_back(vtap);
440  cti.selpat.push_back(selpat);
441  } // for tracks
442  // mark closest track
443  if (closestTrkIdx > -1 && closestTrkIdx < (int)cti.selpat.size()) {
444  cti.selpat[closestTrkIdx] |= 2;
445  }
446  } // for ics
447 
448  return StatusCode::SUCCESS;
449  }
450  //--------------------------------------------------------------------------
451  // Fill closest track values from cache if found
452  //--------------------------------------------------------------------------
454  const int ipv) const {
455 
456  ATH_MSG_DEBUG("fastFillHook: ipv: " << ipv);
457 
458  bool found(false);
459 
461  m_pvAssocResMap.find(buildPvAssocCacheName(vtx, ipv));
462  if ( itpv != m_pvAssocResMap.end() ) {
463  found = true;
464  unsigned int nTrackSels = m_trackSelectionTools.size();
465  unsigned int nTrackTypes = m_useTrackTypes.size();
466  unsigned int nChi2Sets = m_closeTrackChi2SetName.size();
467  for (unsigned int its = 0; its < nTrackSels; ++its) {
468  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
469  for (unsigned int ics = 0; ics < nChi2Sets; ++ics) {
470  m_results[its][ipv][itt][ics]
471  .copyVals(m_results[its][itpv->second][itt][ics]);
472  } // for ics
473  } // for its
474  } // for itt
475  } // if found
476 
477  ATH_MSG_DEBUG("fastFillHook: cache index: "
478  << buildPvAssocCacheName(vtx, ipv)
479  << ", found ? " << found
480  << ", ipv_ref: "
481  << (found ? itpv->second : -1));
482 
483  return found;
484  }
485  //--------------------------------------------------------------------------
486  StatusCode
488 
490 
491  unsigned int nTrackSels = m_trackSelectionTools.size();
492  unsigned int nPvAssocs = m_pvAssocTypes.size();
493  unsigned int nTrackTypes = m_useTrackTypes.size();
494  unsigned int nChi2Sets = m_closeTrackChi2SetName.size();
495 
496  for (unsigned int its = 0; its < nTrackSels; ++its) {
497  for (unsigned int ipv = 0; ipv < nPvAssocs; ++ipv) {
498  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
499  for (unsigned int ics = 0; ics < nChi2Sets; ++ics) {
500  CtItem result = m_results[its][ipv][itt][ics];
502  d_dca_value(result.dcaName());
504  d_dcaErr_value(result.dcaErrName());
506  d_zca_value(result.zcaName());
508  d_zcaErr_value(result.zcaErrName());
510  d_nTrksChi2_value(result.nTrksChi2Name());
511  d_dca_value(*vtx) = result.dca;
512  d_dcaErr_value(*vtx) = result.dcaErr;
513  d_zca_value(*vtx) = result.zca;
514  d_zcaErr_value(*vtx) = result.zcaErr;
515  d_nTrksChi2_value(*vtx) = result.nTrksChi2;
516  ATH_MSG_DEBUG("BVertexClosestTrackTool::saveClosestTrack() "
517  << "-- dca: " << result.dcaName()
518  << ", dcaErr: " << result.dcaErrName()
519  << ", zca: " << result.zcaName()
520  << ", zcaErr: " << result.zcaErrName()
521  << ", nTrksChi2: " << result.nTrksChi2Name());
522  ATH_MSG_DEBUG("BVertexClosestTrackTool::saveClosestTrack() "
523  << "-- vertex: ("
524  << vtx->x() << ", "
525  << vtx->y() << ", "
526  << vtx->z() << ")"
527  << ", dca: " << result.dca
528  << ", dcaErr: " << result.dcaErr
529  << ", zca: " << result.zca
530  << ", zcaErr: " << result.zcaErr
531  << ", nTrksChi2: " << result.nTrksChi2);
532  // add ElementLink to closest track
533  std::string linkName = result.closeTrackName();
535  tpLinkDecor(linkName);
536  TrackParticleLink_t tpLink;
537  if ( result.closeTrack != NULL ) {
538  tpLink.toContainedElement( *m_tracks, result.closeTrack );
539  }
540  ATH_MSG_DEBUG("saveClosestTrack: Decorate vtx "
541  << vtx << " with " << linkName
542  << ", closeTrkPtr: " << result.closeTrack);
543  tpLinkDecor(*vtx) = tpLink;
544  if ( tpLink.isValid() ) {
545  ATH_MSG_DEBUG("saveClosestTrack: Decorated vtx "
546  << vtx << " with " << linkName
547  << ", closeTrkPtr: " << result.closeTrack);
548  } else {
549  ATH_MSG_VERBOSE("saveClosestTrack: Failed to decorate vtx "
550  << vtx << " with " << linkName
551  << ", closeTrkPtr: "
552  << result.closeTrack << " !");
553  }
554  // if valid
555  } // for ics
556  } // for itt
557  } // for ipv
558  } // for its
559 
560  return StatusCode::SUCCESS;
561  }
562  //--------------------------------------------------------------------------
564 
565  ATH_MSG_DEBUG("BVertexClosestTrackTool::setResultsPrefix -- begin");
566 
567  unsigned int nTrackSels = m_trackSelectionTools.size();
568  unsigned int nPvAssocs = m_pvAssocTypes.size();
569  unsigned int nTrackTypes = m_useTrackTypes.size();
570  unsigned int nChi2Sets = m_closeTrackChi2SetName.size();
571 
572  for (unsigned int its = 0; its < nTrackSels; ++its) {
573  for (unsigned int ipv = 0; ipv < nPvAssocs; ++ipv) {
574  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
575  for (unsigned int ics = 0; ics < nChi2Sets; ++ics) {
576  m_results[its][ipv][itt][ics].setPrefix(prefix);
577  } // for ics
578  } // for itt
579  } // for ipv
580  } // for its
581 
582  ATH_MSG_DEBUG("BVertexClosestTrackTool::setResultsPrefix -- end");
583  }
584  //--------------------------------------------------------------------------
586 
587  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults -- begin");
588 
589  unsigned int nTrackSels = m_trackSelectionTools.size();
590  unsigned int nPvAssocs = m_pvAssocTypes.size();
591  unsigned int nTrackTypes = m_useTrackTypes.size();
592  unsigned int nChi2Sets = m_closeTrackChi2SetName.size();
593 
594  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults : nTrackSels = "
595  << nTrackSels);
596  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults : nPvAssocs = "
597  << nPvAssocs);
598  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults : nTrackTypes = "
599  << nTrackTypes);
600  m_results.resize(boost::extents[nTrackSels][nPvAssocs][nTrackTypes][nChi2Sets]);
601  for (unsigned int its = 0; its < nTrackSels; ++its) {
602  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults -- its = " << its);
603  for (unsigned int ipv = 0; ipv < nPvAssocs; ++ipv) {
604  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults -- ipv = " << ipv);
605  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
606  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults -- itt = "
607  << itt);
608  for (unsigned int ics = 0; ics < nChi2Sets; ++ics) {
609  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults -- ics = "
610  << ics);
611  std::string csname = m_closeTrackChi2SetName[ics];
612  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults : "
613  << m_branchBaseName << ", "
614  << buildBranchBaseName(its, ipv, itt, csname));
615  m_results[its][ipv][itt][ics].setup(buildBranchBaseName(its, ipv,
616  itt,
617  csname),
619  } // for ics
620  } // for itt
621  } // for ipv
622  } // for its
623 
624  ATH_MSG_DEBUG("BVertexClosestTrackTool::initResults -- end");
625  }
626  //--------------------------------------------------------------------------
627  // Dump CloseTracks debug information to log file
628  //--------------------------------------------------------------------------
630 
631  // Count candidates
635  m_svIdx = 0;
636  } else {
637  m_svIdx++;
638  }
639 
640  std::string str(">>>>> logCloseTracksDebugInfo:\n");
641  str.append(std::format("Run {} Event {} SV {}\n", m_runNumber, m_evtNumber, m_svIdx));
642 
643  unsigned int nTrackSels = m_trackSelectionTools.size();
644  unsigned int nPvAssocs = m_pvAssocTypes.size();
645  unsigned int nTrackTypes = m_useTrackTypes.size();
646  unsigned int nChi2Sets = m_closeTrackChi2SetName.size();
647 
648  for (unsigned int its = 0; its < nTrackSels; ++its) {
649  for (unsigned int ipv = 0; ipv < nPvAssocs; ++ipv) {
650  for (unsigned int itt = 0; itt < nTrackTypes; ++itt) {
651  for (unsigned int ics = 0; ics < nChi2Sets; ++ics) {
652  std::string f1 =std::format("its: %d ipv: %d itt: %d ics: %d\n"
653  , its , ipv , itt , its);
654  str.append(f1);
655  CtItem result = m_results[its][ipv][itt][ics];
656  str.append(result.toString()+"\n");
657  } // for ics
658  } // for itt
659  } // for ipv
660  } // for its
661 
662  str.append("<<<<< logCloseTracksDebugInfo");
663  ATH_MSG_INFO(str);
664 
665  return StatusCode::SUCCESS;
666  }
667  //--------------------------------------------------------------------------
668 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DerivationFramework::BVertexClosestTrackTool::addBranchesVCSetupHook
virtual StatusCode addBranchesVCSetupHook(size_t ivc) const
Definition: BVertexClosestTrackTool.cxx:311
DerivationFramework::BVertexClosestTrackTool::CtItem::vtxNDErr2
double vtxNDErr2
Definition: BVertexClosestTrackTool.h:91
DerivationFramework::BVertexClosestTrackTool::CtItem::copyVals
virtual void copyVals(const BaseItem &item)
Definition: BVertexClosestTrackTool.cxx:140
DerivationFramework::BPhysVertexTrackBase::BaseItem::toString
virtual std::string toString() const
Definition: BPhysVertexTrackBase.cxx:212
xAOD::Vertex_v1::x
float x() const
Returns the x position.
InDetGNNHardScatterSelection::getter_utils::Tracks
std::vector< const xAOD::TrackParticle * > Tracks
Definition: InnerDetector/InDetRecTools/InDetGNNHardScatterSelection/InDetGNNHardScatterSelection/CustomGetterUtils.h:49
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
DerivationFramework::BPhysVertexTrackBase::m_pvAssocTypes
std::vector< xAOD::BPhysHelper::pv_type > m_pvAssocTypes
Definition: BPhysVertexTrackBase.h:280
DerivationFramework::BVertexClosestTrackTool::saveClosestTrack
virtual StatusCode saveClosestTrack(const xAOD::Vertex *vtx) const
Definition: BVertexClosestTrackTool.cxx:487
DerivationFramework::BVertexClosestTrackTool::logCloseTracksDebugInfo
virtual StatusCode logCloseTracksDebugInfo() const
Definition: BVertexClosestTrackTool.cxx:629
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::BVertexClosestTrackTool::CtItem::dcaName
virtual std::string dcaName() const
Definition: BVertexClosestTrackTool.cxx:159
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DerivationFramework::BVertexClosestTrackTool::CtItem::tracks
TrackBag tracks
Definition: BVertexClosestTrackTool.h:96
EventPrimitivesHelpers.h
DerivationFramework::BPhysVertexTrackBase::m_pvAssocResMap
StringIntMap_t m_pvAssocResMap
Definition: BPhysVertexTrackBase.h:289
DerivationFramework::BVertexClosestTrackTool::CtItem::dcaErrName
virtual std::string dcaErrName() const
Definition: BVertexClosestTrackTool.cxx:163
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::m_runNumber
unsigned int m_runNumber
Definition: BPhysVertexTrackBase.h:298
DerivationFramework::BPhysVertexTrackBase::m_evtNumber
uint64_t m_evtNumber
Definition: BPhysVertexTrackBase.h:299
DerivationFramework::BPhysVertexTrackBase::m_useTrackTypes
std::vector< uint64_t > m_useTrackTypes
Definition: BPhysVertexTrackBase.h:260
DerivationFramework::BVertexClosestTrackTool::m_lastEvtNumber
uint64_t m_lastEvtNumber
Definition: BVertexClosestTrackTool.h:142
DerivationFramework::BVertexClosestTrackTool::CtItem::trkNDErr2Name
virtual std::string trkNDErr2Name() const
Definition: BVertexClosestTrackTool.cxx:179
DerivationFramework::BVertexClosestTrackTool::CtItem::vtxNDErr2Name
virtual std::string vtxNDErr2Name() const
Definition: BVertexClosestTrackTool.cxx:175
DerivationFramework::BVertexClosestTrackTool::CtItem::dcaErr
double dcaErr
Definition: BVertexClosestTrackTool.h:88
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::BVertexClosestTrackTool::CtItem::CtItem
CtItem(const std::string &Name="_none_", const std::string &Bname="ctrk", const std::string &Prefix="", double Dca=-999., double DcaErr=-99., double Zca=-999., double ZcaErr=-99., double VtxNDErr2=-99., double TrkNDErr2=-99., double Phi0Used=-999., int NTrksChi2=0, xAOD::TrackParticle *CloseTrack=NULL, const TrackBag &Tracks={}, const std::vector< std::vector< double > > &Vtap={}, const std::vector< unsigned short > &Selpat={})
Definition: BVertexClosestTrackTool.cxx:59
DerivationFramework::BVertexClosestTrackTool::calcValuesHook
virtual StatusCode calcValuesHook(const xAOD::Vertex *vtx, const unsigned int ipv, const unsigned int its, const unsigned int itt) const
Definition: BVertexClosestTrackTool.cxx:358
DerivationFramework::BVertexClosestTrackTool::CtItem::phi0Used
double phi0Used
Definition: BVertexClosestTrackTool.h:93
DerivationFramework::BVertexClosestTrackTool::m_nCloseTrackMaxLogChi2
std::vector< double > m_nCloseTrackMaxLogChi2
Definition: BVertexClosestTrackTool.h:134
DerivationFramework::BVertexClosestTrackTool::initializeHook
virtual StatusCode initializeHook()
Definition: BVertexClosestTrackTool.cxx:257
DerivationFramework::BVertexClosestTrackTool::CtItem::nTrksChi2
int nTrksChi2
Definition: BVertexClosestTrackTool.h:94
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::BVertexClosestTrackTool::m_minDCAin3D
std::vector< bool > m_minDCAin3D
Definition: BVertexClosestTrackTool.h:132
read_hist_ntuple.f2
f2
Definition: read_hist_ntuple.py:20
DerivationFramework::BPhysVertexTrackBase::m_branchPrefixes
std::vector< std::string > m_branchPrefixes
Definition: BPhysVertexTrackBase.h:245
DerivationFramework::BVertexClosestTrackTool::CtItem::zcaErrName
virtual std::string zcaErrName() const
Definition: BVertexClosestTrackTool.cxx:171
DerivationFramework::BVertexClosestTrackTool::m_closeTrackMaxLogChi2
std::vector< double > m_closeTrackMaxLogChi2
Definition: BVertexClosestTrackTool.h:133
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::BVertexClosestTrackTool::CtItem::setup
virtual void setup(const std::string &Name="_none_", const std::string &Bname="ctrk", const std::string &Prefix="")
Definition: BVertexClosestTrackTool.cxx:80
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
DerivationFramework::BVertexClosestTrackTool::CtItem::~CtItem
virtual ~CtItem()
Definition: BVertexClosestTrackTool.cxx:77
DerivationFramework::BPhysVertexTrackBase::m_tracks
const xAOD::TrackParticleContainer * m_tracks
Definition: BPhysVertexTrackBase.h:271
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DerivationFramework::BVertexClosestTrackTool::CtItem::zca
double zca
Definition: BVertexClosestTrackTool.h:89
DerivationFramework::BVertexClosestTrackTool::CtItem::zcaErr
double zcaErr
Definition: BVertexClosestTrackTool.h:90
DerivationFramework::BPhysVertexTrackBase::m_branchBaseName
std::string m_branchBaseName
Definition: BPhysVertexTrackBase.h:246
DerivationFramework::BVertexClosestTrackTool::CtItem::zcaName
virtual std::string zcaName() const
Definition: BVertexClosestTrackTool.cxx:167
DerivationFramework::BPhysVertexTrackBase::calculateValues
StatusCode calculateValues(const xAOD::Vertex *vtx) const
Definition: BPhysVertexTrackBase.cxx:638
DerivationFramework::BVertexClosestTrackTool::fastFillHook
virtual bool fastFillHook(const xAOD::Vertex *vtx, const int ipv) const
Definition: BVertexClosestTrackTool.cxx:453
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
DerivationFramework::BPhysVertexTrackBase::trackToString
static std::string trackToString(const xAOD::TrackParticle *track)
Definition: BPhysVertexTrackBase.cxx:338
IInDetTrackSelectionTool.h
DerivationFramework::BVertexClosestTrackTool::CtItem::phi0UsedName
virtual std::string phi0UsedName() const
Definition: BVertexClosestTrackTool.cxx:183
DerivationFramework::BVertexClosestTrackTool::BVertexClosestTrackTool
BVertexClosestTrackTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: BVertexClosestTrackTool.cxx:242
DerivationFramework::BVertexClosestTrackTool::CtItem::resetVals
virtual void resetVals()
Definition: BVertexClosestTrackTool.cxx:125
DerivationFramework::BVertexClosestTrackTool::CtItem::dca
double dca
Definition: BVertexClosestTrackTool.h:87
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::BVertexClosestTrackTool::m_closeTrackChi2SetName
std::vector< std::string > m_closeTrackChi2SetName
Definition: BVertexClosestTrackTool.h:130
item
Definition: ItemListSvc.h:43
DerivationFramework::BPhysVertexTrackBase::wrapLines
static std::string wrapLines(const std::string &lines, const std::string &prefix)
Definition: BPhysVertexTrackBase.cxx:353
DerivationFramework::BPhysVertexTrackBase::m_trackSelectionTools
ToolHandleArray< TrkSelTool > m_trackSelectionTools
Definition: BPhysVertexTrackBase.h:250
EventInfo.h
MuonContainer.h
DerivationFramework::BVertexClosestTrackTool::CtItem::vtap
std::vector< std::vector< double > > vtap
Definition: BVertexClosestTrackTool.h:97
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.
DerivationFramework::BVertexClosestTrackTool::CtItem
Definition: BVertexClosestTrackTool.h:40
DerivationFramework::BVertexClosestTrackTool::initResults
virtual void initResults()
Definition: BVertexClosestTrackTool.cxx:585
Name
JetDumper::Name Name
Definition: JetDumper.cxx:19
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
DerivationFramework::BVertexClosestTrackTool::m_closeTrackCorrChi2
std::vector< int > m_closeTrackCorrChi2
Definition: BVertexClosestTrackTool.h:131
BVertexClosestTrackTool.h
DerivationFramework::BVertexClosestTrackTool::setResultsPrefix
virtual void setResultsPrefix(std::string prefix) const
Definition: BVertexClosestTrackTool.cxx:563
DerivationFramework::BPhysVertexTrackBase::m_vertexContainerNames
std::vector< std::string > m_vertexContainerNames
Definition: BPhysVertexTrackBase.h:248
DerivationFramework::BVertexClosestTrackTool::CtItem::nTrksChi2Name
virtual std::string nTrksChi2Name() const
Definition: BVertexClosestTrackTool.cxx:187
xAOD::Vertex_v1::y
float y() const
Returns the y position.
TrackParticleLink_t
INav4MomToTrackParticleAssocs::asso_link TrackParticleLink_t
Definition: INav4MomToTrackParticleAssocsCnv_p1.cxx:27
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
DerivationFramework::BPhysVertexTrackBase::BaseItem
Definition: BPhysVertexTrackBase.h:60
DerivationFramework::BPhysVertexTrackBase::m_debugTracksInThisEvent
bool m_debugTracksInThisEvent
Definition: BPhysVertexTrackBase.h:302
DerivationFramework::BVertexClosestTrackTool::m_lastRunNumber
unsigned int m_lastRunNumber
Definition: BVertexClosestTrackTool.h:141
DerivationFramework::BVertexClosestTrackTool::CtItem::trkNDErr2
double trkNDErr2
Definition: BVertexClosestTrackTool.h:92
DerivationFramework::BVertexClosestTrackTool::m_svIdx
unsigned int m_svIdx
Definition: BVertexClosestTrackTool.h:145
str
Definition: BTagTrackIpAccessor.cxx:11
DerivationFramework::BVertexClosestTrackTool::m_results
CtItem4_t m_results
Definition: BVertexClosestTrackTool.h:138
DerivationFramework::BVertexClosestTrackTool::CtItem::closeTrack
const xAOD::TrackParticle * closeTrack
Definition: BVertexClosestTrackTool.h:95
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DerivationFramework::BPhysVertexTrackBase
Definition: BPhysVertexTrackBase.h:57
DerivationFramework::BVertexClosestTrackTool::CtItem::closeTrackName
virtual std::string closeTrackName() const
Definition: BVertexClosestTrackTool.cxx:191
DerivationFramework::BVertexClosestTrackTool::CtItem::selpat
std::vector< unsigned short > selpat
Definition: BVertexClosestTrackTool.h:98
DerivationFramework::BVertexClosestTrackTool::CtItem::toString
virtual std::string toString() const
Definition: BVertexClosestTrackTool.cxx:195
read_hist_ntuple.f1
f1
Definition: read_hist_ntuple.py:4
DerivationFramework::BVertexClosestTrackTool::finalizeHook
virtual StatusCode finalizeHook()
Definition: BVertexClosestTrackTool.cxx:302
DerivationFramework::BVertexClosestTrackTool::addBranchesSVLoopHook
virtual StatusCode addBranchesSVLoopHook(const xAOD::Vertex *vtx) const
Definition: BVertexClosestTrackTool.cxx:330