52 throw std::invalid_argument(
"Missing particles input collection");
55 throw std::invalid_argument(
"Missing hit-particles map input collection");
58 throw std::invalid_argument(
"Missing output filename");
61 throw std::invalid_argument(
"Missing tree name");
71 throw std::ios_base::failure(
"Could not open '" +
path);
76 throw std::bad_alloc();
189 m_outputFile->Close();
195 m_outputTree->Write();
196 m_outputFile->Close();
198 if (
m_cfg.writeCovMat) {
199 ACTS_INFO(
"Wrote full covariance matrix to tree");
201 ACTS_INFO(
"Wrote parameters of trajectories to tree '"
202 <<
m_cfg.treeName <<
"' in '" <<
m_cfg.filePath <<
"'");
210 const auto&
particles = m_inputParticles(ctx);
211 const auto& hitParticlesMap = m_inputMeasurementParticlesMap(ctx);
214 std::vector<ParticleHitCount> particleHitCounts;
217 std::lock_guard<std::mutex> lock(m_writeMutex);
223 for (
size_t itraj = 0; itraj < trajectories.size(); ++itraj) {
224 const auto& traj = trajectories[itraj];
227 const auto& trackTips = traj.tips();
230 if (trackTips.empty()) {
235 const auto& mj = traj.multiTrajectory();
238 m_multiTrajNr.push_back(itraj);
241 for (
unsigned int isubtraj = 0; isubtraj < trackTips.size(); ++isubtraj) {
243 m_subTrajNr.push_back(isubtraj);
245 const auto& trackTip = trackTips[isubtraj];
250 m_nStates.push_back(trajState.nStates);
253 m_nHoles.push_back(trajState.nHoles);
254 m_nSharedHits.push_back(trajState.nSharedHits);
255 m_chi2Sum.push_back(trajState.chi2Sum);
256 m_NDF.push_back(trajState.NDF);
257 m_measurementChi2.push_back(trajState.measurementChi2);
258 m_outlierChi2.push_back(trajState.outlierChi2);
261 m_measurementVolume.emplace_back(trajState.measurementVolume.begin(),
262 trajState.measurementVolume.end());
263 m_measurementLayer.emplace_back(trajState.measurementLayer.begin(),
264 trajState.measurementLayer.end());
265 m_outlierVolume.emplace_back(trajState.outlierVolume.begin(),
266 trajState.outlierVolume.end());
267 m_outlierLayer.emplace_back(trajState.outlierLayer.begin(),
268 trajState.outlierLayer.end());
272 std::numeric_limits<size_t>::max());
273 unsigned int nMajorityHits = std::numeric_limits<unsigned int>::max();
274 int t_charge = std::numeric_limits<int>::max();
293 if (traj.hasTrackParameters(trackTip)) {
294 const auto& boundParam = traj.trackParameters(trackTip);
295 pSurface =
const_cast<Acts::Surface*
>(&boundParam.referenceSurface());
301 bool foundMajorityParticle =
false;
303 if (not particleHitCounts.empty()) {
305 majorityParticleId = particleHitCounts.front().particleId;
306 nMajorityHits = particleHitCounts.front().hitCount;
309 auto ip =
particles.find(majorityParticleId);
311 foundMajorityParticle =
true;
315 << majorityParticleId <<
"="
316 << majorityParticleId.
value());
319 t_charge =
static_cast<int>(
particle.charge());
324 t_px = t_p *
particle.direction().x();
325 t_py = t_p *
particle.direction().y();
326 t_pz = t_p *
particle.direction().z();
333 if (pSurface !=
nullptr) {
339 auto position = intersection.position();
348 ACTS_ERROR(
"Global to local transformation did not succeed.");
353 << majorityParticleId <<
"=" << majorityParticleId.
value()
354 <<
" not found in the input collection!");
357 if (not foundMajorityParticle) {
358 ACTS_DEBUG(
"Truth particle for mj " << itraj <<
" subtraj " << isubtraj
364 m_majorityParticleId.push_back(majorityParticleId.
value());
365 m_nMajorityHits.push_back(nMajorityHits);
366 m_t_charge.push_back(t_charge);
367 m_t_time.push_back(t_time);
368 m_t_vx.push_back(t_vx);
369 m_t_vy.push_back(t_vy);
370 m_t_vz.push_back(t_vz);
371 m_t_px.push_back(t_px);
372 m_t_py.push_back(t_py);
373 m_t_pz.push_back(t_pz);
374 m_t_theta.push_back(t_theta);
375 m_t_phi.push_back(t_phi);
376 m_t_eta.push_back(t_eta);
377 m_t_p.push_back(t_p);
378 m_t_pT.push_back(t_pT);
379 m_t_d0.push_back(t_d0);
380 m_t_z0.push_back(t_z0);
383 std::array<float, Acts::eBoundSize> param = {
385 std::array<float, Acts::eBoundSize>
error = {
389 auto getCov = [&](
auto i,
auto j) {
390 return traj.trackParameters(trackTip).covariance().has_value()
391 ? traj.trackParameters(trackTip).covariance().value()(
i,
j)
395 bool hasFittedParams =
false;
396 bool hasFittedCov =
false;
397 if (traj.hasTrackParameters(trackTip)) {
398 hasFittedParams =
true;
399 const auto& boundParam = traj.trackParameters(trackTip);
400 const auto& parameter = boundParam.parameters();
402 param[
i] = parameter[
i];
405 if (boundParam.covariance().has_value()) {
407 const auto&
covariance = *boundParam.covariance();
418 if (foundMajorityParticle && hasFittedParams) {
422 static_cast<float>(2 * M_PI)),
429 pull[
i] = res[
i] / error[
i];
443 m_res_eLOC0_fit.push_back(res[Acts::eBoundLoc0]);
444 m_res_eLOC1_fit.push_back(res[Acts::eBoundLoc1]);
445 m_res_ePHI_fit.push_back(res[Acts::eBoundPhi]);
446 m_res_eTHETA_fit.push_back(res[Acts::eBoundTheta]);
447 m_res_eQOP_fit.push_back(res[Acts::eBoundQOverP]);
448 m_res_eT_fit.push_back(res[Acts::eBoundTime]);
450 m_err_eLOC0_fit.push_back(error[Acts::eBoundLoc0]);
451 m_err_eLOC1_fit.push_back(error[Acts::eBoundLoc1]);
452 m_err_ePHI_fit.push_back(error[Acts::eBoundPhi]);
453 m_err_eTHETA_fit.push_back(error[Acts::eBoundTheta]);
454 m_err_eQOP_fit.push_back(error[Acts::eBoundQOverP]);
455 m_err_eT_fit.push_back(error[Acts::eBoundTime]);
457 m_pull_eLOC0_fit.push_back(pull[Acts::eBoundLoc0]);
458 m_pull_eLOC1_fit.push_back(pull[Acts::eBoundLoc1]);
459 m_pull_ePHI_fit.push_back(pull[Acts::eBoundPhi]);
460 m_pull_eTHETA_fit.push_back(pull[Acts::eBoundTheta]);
461 m_pull_eQOP_fit.push_back(pull[Acts::eBoundQOverP]);
462 m_pull_eT_fit.push_back(pull[Acts::eBoundTime]);
464 m_hasFittedParams.push_back(hasFittedParams);
465 if (
m_cfg.writeCovMat) {
468 m_cov_eLOC0_eLOC0.push_back(getCov(0, 0));
469 m_cov_eLOC0_eLOC1.push_back(getCov(0, 1));
470 m_cov_eLOC0_ePHI.push_back(getCov(0, 2));
471 m_cov_eLOC0_eTHETA.push_back(getCov(0, 3));
472 m_cov_eLOC0_eQOP.push_back(getCov(0, 4));
473 m_cov_eLOC0_eT.push_back(getCov(0, 5));
475 m_cov_eLOC1_eLOC0.push_back(getCov(1, 0));
476 m_cov_eLOC1_eLOC1.push_back(getCov(1, 1));
477 m_cov_eLOC1_ePHI.push_back(getCov(1, 2));
478 m_cov_eLOC1_eTHETA.push_back(getCov(1, 3));
479 m_cov_eLOC1_eQOP.push_back(getCov(1, 4));
480 m_cov_eLOC1_eT.push_back(getCov(1, 5));
482 m_cov_ePHI_eLOC0.push_back(getCov(2, 0));
483 m_cov_ePHI_eLOC1.push_back(getCov(2, 1));
484 m_cov_ePHI_ePHI.push_back(getCov(2, 2));
485 m_cov_ePHI_eTHETA.push_back(getCov(2, 3));
486 m_cov_ePHI_eQOP.push_back(getCov(2, 4));
487 m_cov_ePHI_eT.push_back(getCov(2, 5));
489 m_cov_eTHETA_eLOC0.push_back(getCov(3, 0));
490 m_cov_eTHETA_eLOC1.push_back(getCov(3, 1));
491 m_cov_eTHETA_ePHI.push_back(getCov(3, 2));
492 m_cov_eTHETA_eTHETA.push_back(getCov(3, 3));
493 m_cov_eTHETA_eQOP.push_back(getCov(3, 4));
494 m_cov_eTHETA_eT.push_back(getCov(3, 5));
496 m_cov_eQOP_eLOC0.push_back(getCov(4, 0));
497 m_cov_eQOP_eLOC1.push_back(getCov(4, 1));
498 m_cov_eQOP_ePHI.push_back(getCov(4, 2));
499 m_cov_eQOP_eTHETA.push_back(getCov(4, 3));
500 m_cov_eQOP_eQOP.push_back(getCov(4, 4));
501 m_cov_eQOP_eT.push_back(getCov(4, 5));
503 m_cov_eT_eLOC0.push_back(getCov(5, 0));
504 m_cov_eT_eLOC1.push_back(getCov(5, 1));
505 m_cov_eT_ePHI.push_back(getCov(5, 2));
506 m_cov_eT_eTHETA.push_back(getCov(5, 3));
507 m_cov_eT_eQOP.push_back(getCov(5, 4));
508 m_cov_eT_eT.push_back(getCov(5, 5));
515 m_outputTree->Fill();
517 m_multiTrajNr.clear();
523 m_nSharedHits.clear();
526 m_measurementChi2.clear();
527 m_outlierChi2.clear();
528 m_measurementVolume.clear();
529 m_measurementLayer.clear();
530 m_outlierVolume.clear();
531 m_outlierLayer.clear();
533 m_nMajorityHits.clear();
534 m_majorityParticleId.clear();
551 m_hasFittedParams.clear();
555 m_eTHETA_fit.clear();
558 m_err_eLOC0_fit.clear();
559 m_err_eLOC1_fit.clear();
560 m_err_ePHI_fit.clear();
561 m_err_eTHETA_fit.clear();
562 m_err_eQOP_fit.clear();
563 m_err_eT_fit.clear();
564 m_res_eLOC0_fit.clear();
565 m_res_eLOC1_fit.clear();
566 m_res_ePHI_fit.clear();
567 m_res_eTHETA_fit.clear();
568 m_res_eQOP_fit.clear();
569 m_res_eT_fit.clear();
570 m_pull_eLOC0_fit.clear();
571 m_pull_eLOC1_fit.clear();
572 m_pull_ePHI_fit.clear();
573 m_pull_eTHETA_fit.clear();
574 m_pull_eQOP_fit.clear();
575 m_pull_eT_fit.clear();
577 if (
m_cfg.writeCovMat) {
578 m_cov_eLOC0_eLOC0.clear();
579 m_cov_eLOC0_eLOC1.clear();
580 m_cov_eLOC0_ePHI.clear();
581 m_cov_eLOC0_eTHETA.clear();
582 m_cov_eLOC0_eQOP.clear();
583 m_cov_eLOC0_eT.clear();
585 m_cov_eLOC1_eLOC0.clear();
586 m_cov_eLOC1_eLOC1.clear();
587 m_cov_eLOC1_ePHI.clear();
588 m_cov_eLOC1_eTHETA.clear();
589 m_cov_eLOC1_eQOP.clear();
590 m_cov_eLOC1_eT.clear();
592 m_cov_ePHI_eLOC0.clear();
593 m_cov_ePHI_eLOC1.clear();
594 m_cov_ePHI_ePHI.clear();
595 m_cov_ePHI_eTHETA.clear();
596 m_cov_ePHI_eQOP.clear();
597 m_cov_ePHI_eT.clear();
599 m_cov_eTHETA_eLOC0.clear();
600 m_cov_eTHETA_eLOC1.clear();
601 m_cov_eTHETA_ePHI.clear();
602 m_cov_eTHETA_eTHETA.clear();
603 m_cov_eTHETA_eQOP.clear();
604 m_cov_eTHETA_eT.clear();
606 m_cov_eQOP_eLOC0.clear();
607 m_cov_eQOP_eLOC1.clear();
608 m_cov_eQOP_ePHI.clear();
609 m_cov_eQOP_eTHETA.clear();
610 m_cov_eQOP_eQOP.clear();
611 m_cov_eQOP_eT.clear();
613 m_cov_eT_eLOC0.clear();
614 m_cov_eT_eLOC1.clear();
615 m_cov_eT_ePHI.clear();
616 m_cov_eT_eTHETA.clear();
617 m_cov_eT_eQOP.clear();