2525#include " SimulationDataFormat/DigitizationContext.h"
2626#include " Steer/MCKinematicsReader.h"
2727#include " ITSMFTBase/DPLAlpideParam.h"
28+ #include " DetectorsRaw/HBFUtils.h"
2829
2930#ifdef VTX_DEBUG
3031#include " TTree.h"
@@ -574,16 +575,25 @@ void VertexerTraits::addTruthSeedingVertices()
574575 int64_t roFrameBiasInBC = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance ().roFrameBiasInBC ;
575576 int64_t roFrameLengthInBC = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance ().roFrameLengthInBC ;
576577 o2::steer::MCKinematicsReader mcReader (dc);
577- std::map<int , bounded_vector<Vertex>> vertices;
578+ struct VertInfo {
579+ bounded_vector<Vertex> vertices;
580+ bounded_vector<int > srcs;
581+ bounded_vector<int > events;
582+ };
583+ std::map<int , VertInfo> vertices;
578584 for (int iSrc{0 }; iSrc < mcReader.getNSources (); ++iSrc) {
579585 auto eveId2colId = dc->getCollisionIndicesForSource (iSrc);
580586 for (int iEve{0 }; iEve < mcReader.getNEvents (iSrc); ++iEve) {
581587 const auto & ir = irs[eveId2colId[iEve]];
582588 if (!ir.isDummy ()) { // do we need this, is this for diffractive events?
583589 const auto & eve = mcReader.getMCEventHeader (iSrc, iEve);
584- int rofId = (ir .toLong () - roFrameBiasInBC) / roFrameLengthInBC;
590+ int rofId = ((ir - raw::HBFUtils::Instance (). getFirstSampledTFIR ()) .toLong () - roFrameBiasInBC) / roFrameLengthInBC;
585591 if (!vertices.contains (rofId)) {
586- vertices[rofId] = bounded_vector<Vertex>(mMemoryPool .get ());
592+ vertices[rofId] = {
593+ .vertices = bounded_vector<Vertex>(mMemoryPool .get ()),
594+ .srcs = bounded_vector<int >(mMemoryPool .get ()),
595+ .events = bounded_vector<int >(mMemoryPool .get ()),
596+ };
587597 }
588598 Vertex vert;
589599 vert.setTimeStamp (rofId);
@@ -594,7 +604,9 @@ void VertexerTraits::addTruthSeedingVertices()
594604 vert.setChi2 (1 );
595605 constexpr float cov = 50e-9 ;
596606 vert.setCov (cov, cov, cov, cov, cov, cov);
597- vertices[rofId].push_back (vert);
607+ vertices[rofId].vertices .push_back (vert);
608+ vertices[rofId].srcs .push_back (iSrc);
609+ vertices[rofId].events .push_back (iEve);
598610 }
599611 }
600612 }
@@ -603,10 +615,11 @@ void VertexerTraits::addTruthSeedingVertices()
603615 bounded_vector<Vertex> verts (mMemoryPool .get ());
604616 bounded_vector<std::pair<o2::MCCompLabel, float >> polls (mMemoryPool .get ());
605617 if (vertices.contains (iROF)) {
606- verts = vertices[iROF];
618+ const auto & vertInfo = vertices[iROF];
619+ verts = vertInfo.vertices ;
607620 nVerts += verts.size ();
608621 for (size_t i{0 }; i < verts.size (); ++i) {
609- o2::MCCompLabel lbl; // unset label for now
622+ o2::MCCompLabel lbl ( o2::MCCompLabel::maxTrackID (), vertInfo. events [i], vertInfo. srcs [i], false );
610623 polls.emplace_back (lbl, 1 .f );
611624 }
612625 } else {
0 commit comments