|
10 | 10 | // or submit itself to any jurisdiction. |
11 | 11 | /// |
12 | 12 |
|
13 | | -#include <iostream> |
14 | 13 | #include <memory> |
15 | | -#include <string> |
16 | | -#include <chrono> |
| 14 | +#include <ranges> |
| 15 | +#include <map> |
| 16 | +#include <algorithm> |
17 | 17 |
|
18 | 18 | #include <oneapi/tbb/blocked_range.h> |
19 | 19 | #include <oneapi/tbb/parallel_for.h> |
|
22 | 22 | #include "ITStracking/BoundedAllocator.h" |
23 | 23 | #include "ITStracking/ClusterLines.h" |
24 | 24 | #include "ITStracking/Tracklet.h" |
| 25 | +#include "SimulationDataFormat/DigitizationContext.h" |
| 26 | +#include "Steer/MCKinematicsReader.h" |
| 27 | +#include "ITSMFTBase/DPLAlpideParam.h" |
25 | 28 |
|
26 | 29 | #ifdef VTX_DEBUG |
27 | 30 | #include "TTree.h" |
@@ -693,6 +696,59 @@ void VertexerTraits::computeVerticesInRof(int rofId, |
693 | 696 | verticesInRof.push_back(foundVertices); |
694 | 697 | } |
695 | 698 |
|
| 699 | +void VertexerTraits::addTruthSeedingVertices() |
| 700 | +{ |
| 701 | + LOGP(info, "Using truth seeds as vertices; will skip computations"); |
| 702 | + mTimeFrame->resetRofPV(); |
| 703 | + const auto dc = o2::steer::DigitizationContext::loadFromFile("collisioncontext.root"); |
| 704 | + const auto irs = dc->getEventRecords(); |
| 705 | + int64_t roFrameBiasInBC = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance().roFrameBiasInBC; |
| 706 | + int64_t roFrameLengthInBC = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance().roFrameLengthInBC; |
| 707 | + o2::steer::MCKinematicsReader mcReader(dc); |
| 708 | + std::map<int, bounded_vector<Vertex>> vertices; |
| 709 | + for (int iSrc{0}; iSrc < mcReader.getNSources(); ++iSrc) { |
| 710 | + auto eveId2colId = dc->getCollisionIndicesForSource(iSrc); |
| 711 | + for (int iEve{0}; iEve < mcReader.getNEvents(iSrc); ++iEve) { |
| 712 | + const auto& ir = irs[eveId2colId[iEve]]; |
| 713 | + if (!ir.isDummy()) { // do we need this, is this for diffractive events? |
| 714 | + const auto& eve = mcReader.getMCEventHeader(iSrc, iEve); |
| 715 | + int rofId = (ir.toLong() - roFrameBiasInBC) / roFrameLengthInBC; |
| 716 | + if (!vertices.contains(rofId)) { |
| 717 | + vertices[rofId] = bounded_vector<Vertex>(mMemoryPool.get()); |
| 718 | + } |
| 719 | + Vertex vert; |
| 720 | + vert.setTimeStamp(rofId); |
| 721 | + vert.setNContributors(std::ranges::count_if(mcReader.getTracks(iSrc, iEve), [](const auto& trk) { |
| 722 | + return trk.isPrimary() && trk.GetPt() > 0.2 && std::abs(trk.GetEta()) < 1.3; |
| 723 | + })); |
| 724 | + vert.setXYZ((float)eve.GetX(), (float)eve.GetY(), (float)eve.GetZ()); |
| 725 | + vert.setChi2(1); |
| 726 | + constexpr float cov = 50e-9; |
| 727 | + vert.setCov(cov, cov, cov, cov, cov, cov); |
| 728 | + vertices[rofId].push_back(vert); |
| 729 | + } |
| 730 | + } |
| 731 | + } |
| 732 | + size_t nVerts{0}; |
| 733 | + for (int iROF{0}; iROF < mTimeFrame->getNrof(); ++iROF) { |
| 734 | + bounded_vector<Vertex> verts(mMemoryPool.get()); |
| 735 | + bounded_vector<std::pair<o2::MCCompLabel, float>> polls(mMemoryPool.get()); |
| 736 | + if (vertices.contains(iROF)) { |
| 737 | + verts = vertices[iROF]; |
| 738 | + nVerts += verts.size(); |
| 739 | + for (size_t i{0}; i < verts.size(); ++i) { |
| 740 | + o2::MCCompLabel lbl; // unset label for now |
| 741 | + polls.emplace_back(lbl, 1.f); |
| 742 | + } |
| 743 | + } else { |
| 744 | + mTimeFrame->getNoVertexROF()++; |
| 745 | + } |
| 746 | + mTimeFrame->addPrimaryVertices(verts, iROF, 0); |
| 747 | + mTimeFrame->addPrimaryVerticesLabels(polls); |
| 748 | + } |
| 749 | + LOGP(info, "Found {}/{} ROFs with {} vertices -> <NV>={:.2f}", vertices.size(), mTimeFrame->getNrof(), nVerts, (float)nVerts / (float)vertices.size()); |
| 750 | +} |
| 751 | + |
696 | 752 | void VertexerTraits::setNThreads(int n, std::shared_ptr<tbb::task_arena>& arena) |
697 | 753 | { |
698 | 754 | #if defined(VTX_DEBUG) |
|
0 commit comments