47 #include "AthLinks/ElementLink.h"
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,
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),
73 nTrksChi2(NTrksChi2), closeTrack(CloseTrack),
74 tracks(
Tracks), vtap(Vtap), selpat(Selpat) {
81 const std::string& Bname,
82 const std::string& Prefix) {
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,
108 std::vector<std::vector<double> > Vtap,
109 std::vector<unsigned short> Selpat) {
115 vtxNDErr2 = VtxNDErr2;
116 trkNDErr2 = TrkNDErr2;
118 nTrksChi2 = NTrksChi2;
119 closeTrack = CloseTrack;
146 dcaErr =
item.dcaErr;
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;
156 selpat =
item.selpat;
160 return buildName(
"DCA");
164 return buildName(
"DCAError");
168 return buildName(
"ZCA");
172 return buildName(
"ZCAError");
176 return buildName(
"VtxNDError2");
180 return buildName(
"TrkNDError2");
184 return buildName(
"Phi0Used");
188 return buildName(
"NTracksChi2");
192 return buildName(
"CloseTrack",
"_Link");
196 std::string
f1 =
std::format(
"dca: {:10.6f} {:10.6f} zca: {:10.6f} {:10.6f} nt: {:10d}",
197 dca, dcaErr, zca, zcaErr, nTrksChi2);
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";
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]);
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 "
217 "vtxNDErr: %10.4f trkNDErr2 %10.4f "
218 "logChi2Err2Sum: %10.4f"
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.));
228 std::string(f3str.length(),
' '));
229 tstr.replace(0,f3str.length(),f3str);
230 rstr.append(tstr+
"\n");
233 std::string f5 =
std::format(
"Mismatch: nTracks: {} nVtap: {} nSelpat: {}\n",tracks.size(), vtap.size(), selpat.size());
237 rstr.erase(rstr.length()-1);
243 const std::string&
n,
248 declareInterface<DerivationFramework::IAugmentationTool>(
this);
259 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initializeHook() -- begin");
266 ATH_MSG_ERROR(
"No use of corrected chi2 settings provided!");
272 ATH_MSG_ERROR(
"No cuts on max log chi2 for DOCA calculation provided!");
275 ATH_MSG_ERROR(
"No cuts on max log chi2 for nClosetTracks calculation "
284 <<
"CloseTrackCorrChi2 ("
286 <<
"CloseTrackMinDCAin3D ("
288 <<
"CloseTrackMaxLogChi2 ("
290 <<
"NCloseTrackMaxLogChi2 ("
297 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initializeHook() -- end");
299 return StatusCode::SUCCESS;
307 return StatusCode::SUCCESS;
313 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesVCLoopHook() -- begin");
315 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesVCSetupHook: "
316 <<
"Vertex container index " << ivc
322 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesVCSetupHook() -- end");
325 return StatusCode::SUCCESS;
332 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesSVLoopHook() -- begin");
335 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesSVLoopHook(): "
336 "calculate closest track ...");
340 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesSVLoopHook(): "
341 "save closest track ...");
349 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::addBranchesSVLoopHook() -- end");
352 return StatusCode::SUCCESS;
359 const unsigned int ipv,
360 const unsigned int its,
361 const unsigned int itt)
const {
364 <<
", its: " << its <<
", itt: " << itt);
374 for (
unsigned int ics = 0; ics < nChi2Sets; ++ics) {
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) {
392 unsigned short selpat(0);
397 std::vector<double> vtap =
401 <<
", logChi2: " << vtap[4] <<
", dca: " << vtap[5]);
404 if ( vtap[6] >= 0. ) {
406 "m_nCloseTrackMaxLogChi2[ics] = "
412 ATH_MSG_DEBUG(
"calcValuesHook: nTrksChi2++ for track " << *trkItr);
416 "m_closeTrackMaxLogChi2[ics]: "
418 <<
", logChi2: " << vtap[4]
419 <<
", closestTrkDCA: " << closestTrkDCA
420 <<
", dca: " << fabs(vtap[5]));
421 if ( fabs(vtap[5]) < closestTrkDCA &&
423 closestTrkDCA = fabs(vtap[5]);
432 closestTrkIdx = trkIdx;
435 <<
" for track " << *trkItr);
438 cti.
tracks.push_back(*trkItr);
439 cti.
vtap.push_back(vtap);
440 cti.
selpat.push_back(selpat);
443 if (closestTrkIdx > -1 && closestTrkIdx < (
int)cti.
selpat.size()) {
444 cti.
selpat[closestTrkIdx] |= 2;
448 return StatusCode::SUCCESS;
454 const int ipv)
const {
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) {
471 .copyVals(
m_results[its][itpv->second][itt][ics]);
479 <<
", found ? " <<
found
481 << (
found ? itpv->second : -1));
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) {
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;
517 <<
"-- dca: " <<
result.dcaName()
518 <<
", dcaErr: " <<
result.dcaErrName()
519 <<
", zca: " <<
result.zcaName()
520 <<
", zcaErr: " <<
result.zcaErrName()
521 <<
", nTrksChi2: " <<
result.nTrksChi2Name());
527 <<
", dca: " <<
result.dca
528 <<
", dcaErr: " <<
result.dcaErr
529 <<
", zca: " <<
result.zca
530 <<
", zcaErr: " <<
result.zcaErr
531 <<
", nTrksChi2: " <<
result.nTrksChi2);
533 std::string linkName =
result.closeTrackName();
535 tpLinkDecor(linkName);
537 if (
result.closeTrack != NULL ) {
541 << vtx <<
" with " << linkName
542 <<
", closeTrkPtr: " <<
result.closeTrack);
543 tpLinkDecor(*vtx) = tpLink;
546 << vtx <<
" with " << linkName
547 <<
", closeTrkPtr: " <<
result.closeTrack);
550 << vtx <<
" with " << linkName
552 <<
result.closeTrack <<
" !");
560 return StatusCode::SUCCESS;
565 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::setResultsPrefix -- begin");
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) {
582 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::setResultsPrefix -- end");
587 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initResults -- begin");
594 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initResults : nTrackSels = "
596 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initResults : nPvAssocs = "
598 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initResults : 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 = "
608 for (
unsigned int ics = 0; ics < nChi2Sets; ++ics) {
609 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initResults -- ics = "
624 ATH_MSG_DEBUG(
"BVertexClosestTrackTool::initResults -- end");
640 std::string
str(
">>>>> logCloseTracksDebugInfo:\n");
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);
662 str.append(
"<<<<< logCloseTracksDebugInfo");
665 return StatusCode::SUCCESS;