From c7268d8fb05c2cd631cec8efd9976160ac4c64c5 Mon Sep 17 00:00:00 2001 From: Lucia Anna Tarasovicova Date: Fri, 7 Aug 2026 08:41:04 +0200 Subject: [PATCH] update of the translator to be consistent with the new ACTS output structure --- ALICE3/DataModel/OTFStrangeness.h | 4 +- .../alice3TrackingTranslator.cxx | 703 ++++++++++++------ .../TableProducer/alice3strangenessFinder.cxx | 26 + ALICE3/Tasks/alice3Strangeness.cxx | 43 +- 4 files changed, 528 insertions(+), 248 deletions(-) diff --git a/ALICE3/DataModel/OTFStrangeness.h b/ALICE3/DataModel/OTFStrangeness.h index af8d5f0c14f..2124b258724 100644 --- a/ALICE3/DataModel/OTFStrangeness.h +++ b/ALICE3/DataModel/OTFStrangeness.h @@ -314,7 +314,7 @@ DECLARE_SOA_COLUMN(DcaV0Daughters, dcaV0Daughters, float); DECLARE_SOA_COLUMN(V0Radius, v0Radius, float); DECLARE_SOA_COLUMN(MLambda, mLambda, float); DECLARE_SOA_COLUMN(MAntiLambda, mAntiLambda, float); -DECLARE_SOA_COLUMN(MK0, mK0, float); +DECLARE_SOA_COLUMN(MK0Short, mK0Short, float); // kinematics DECLARE_SOA_COLUMN(Pt, pt, float); @@ -330,7 +330,7 @@ DECLARE_SOA_TABLE(UpgradeV0s, "AOD", "UPGRADEV0S", otfv0::V0Radius, otfv0::MLambda, otfv0::MAntiLambda, - otfv0::MK0, + otfv0::MK0Short, otfv0::Pt); using UpgradeV0 = UpgradeV0s::iterator; diff --git a/ALICE3/TableProducer/alice3TrackingTranslator.cxx b/ALICE3/TableProducer/alice3TrackingTranslator.cxx index d9b2d3874f6..1f465ce02dd 100644 --- a/ALICE3/TableProducer/alice3TrackingTranslator.cxx +++ b/ALICE3/TableProducer/alice3TrackingTranslator.cxx @@ -27,12 +27,15 @@ #include #include #include +#include #include +#include #include #include #include #include +#include #include #include #include @@ -40,6 +43,7 @@ #include #include +#include #include #include @@ -47,12 +51,24 @@ #include #include #include +#include #include #include #include TString inputPath; +using namespace o2::framework; + +namespace +{ +using Key = std::array; // barcode (vp, vs, particle, gen, sub) +Key keyOf(std::uint32_t vp, std::uint32_t vs, std::uint32_t pa, + std::uint32_t ge, std::uint32_t sp) { return Key{vp, vs, pa, ge, sp}; } +// struct ParticleTruthInfo { int pdg; float px, py, pz, m; }; +// struct Seg { double px, py, pz, p; }; +} // namespace + struct Alice3TrackingTranslator { o2::framework::Produces tableCollisions; o2::framework::Produces tableMcCollisionLabels; @@ -77,12 +93,18 @@ struct Alice3TrackingTranslator { o2::framework::Produces tableOTFLUTConfigId; o2::framework::Configurable maxCollisions{"maxCollisions", -1000, "Maximum number of collisions translated"}; - o2::framework::Configurable addDaughterInfo{"addDaughterInfo", false, "Add daughter particle information to the MC truth output tables"}; + o2::framework::Configurable useTrueInfoForRecoTracks{"useTrueInfoForRecoTracks", false, "Use true information for reconstructed tracks"}; + // o2::framework::Configurable addDaughterInfo{"addDaughterInfo", false, "Add daughter particle information to the MC truth output tables"}; + o2::framework::HistogramRegistry histos{"histos", {}, o2::framework::OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) { // Initialization if needed LOG(info) << "Alice3TrackingTranslator init called"; + + histos.add("hPx", "Px distribution;Px [GeV/c];Entries", kTH1F, {{100, -5.0, 5.0}}); + histos.add("hPy", "Py distribution;Py [GeV/c];Entries", kTH1F, {{100, -5.0, 5.0}}); + histos.add("hPz", "Pz distribution;Pz [GeV/c];Entries", kTH1F, {{100, -5.0, 5.0}}); } #define SETADDRESS(branchname, branchvar) \ @@ -130,10 +152,11 @@ struct Alice3TrackingTranslator { SETADDRESS("p", m_p); SETADDRESS("q", m_q); SETADDRESS("number_of_hits", m_number_of_hits); - SETADDRESS("particle_id", m_particleId); - if (mTree->GetBranchStatus("mother_particle_id")) { - SETADDRESS("mother_particle_id", m_motherId); - } + SETADDRESS("vertex_primary", m_vertex_primary); + SETADDRESS("vertex_secondary", m_vertex_secondary); + SETADDRESS("generation", m_generation); + SETADDRESS("sub_particle", m_sub_particle); + SETADDRESS("particle", m_particle); } std::vector* m_particle_type = nullptr; std::vector* m_vx = nullptr; @@ -148,7 +171,46 @@ struct Alice3TrackingTranslator { std::vector* m_number_of_hits = nullptr; std::vector* m_particleId = nullptr; std::vector* m_q = nullptr; - std::vector* m_motherId = nullptr; + std::vector* m_vertex_primary = nullptr; + std::vector* m_vertex_secondary = nullptr; + std::vector* m_generation = nullptr; + std::vector* m_sub_particle = nullptr; + std::vector* m_particle = nullptr; + // std::vector* m_motherId = nullptr; + }; + + struct VertexStruct : public FileStruct { + VertexStruct(std::string filename, std::string treename) : FileStruct(filename, treename) + { + SETADDRESS("vx", m_x); + SETADDRESS("vy", m_y); + SETADDRESS("vz", m_z); + SETADDRESS("vt", m_t); + SETADDRESS("incoming_particles_vertex_primary", m_incoming_particles_vertex_primary); + SETADDRESS("incoming_particles_vertex_secondary", m_incoming_particles_vertex_secondary); + SETADDRESS("incoming_particles_generation", m_incoming_particles_generation); + SETADDRESS("incoming_particles_sub_particle", m_incoming_particles_sub_particle); + SETADDRESS("incoming_particles_particle", m_incoming_particles_particle); + SETADDRESS("outgoing_particles_vertex_primary", m_outgoing_particles_vertex_primary); + SETADDRESS("outgoing_particles_vertex_secondary", m_outgoing_particles_vertex_secondary); + SETADDRESS("outgoing_particles_generation", m_outgoing_particles_generation); + SETADDRESS("outgoing_particles_sub_particle", m_outgoing_particles_sub_particle); + SETADDRESS("outgoing_particles_particle", m_outgoing_particles_particle); + } + std::vector* m_x = nullptr; + std::vector* m_y = nullptr; + std::vector* m_z = nullptr; + std::vector* m_t = nullptr; + std::vector>* m_incoming_particles_vertex_primary = nullptr; + std::vector>* m_incoming_particles_vertex_secondary = nullptr; + std::vector>* m_incoming_particles_generation = nullptr; + std::vector>* m_incoming_particles_sub_particle = nullptr; + std::vector>* m_incoming_particles_particle = nullptr; + std::vector>* m_outgoing_particles_vertex_primary = nullptr; + std::vector>* m_outgoing_particles_vertex_secondary = nullptr; + std::vector>* m_outgoing_particles_generation = nullptr; + std::vector>* m_outgoing_particles_sub_particle = nullptr; + std::vector>* m_outgoing_particles_particle = nullptr; }; struct TrackStruct : public FileStruct { @@ -170,8 +232,6 @@ struct Alice3TrackingTranslator { SETADDRESS("eQOP_fit", m_eQOP_fit); SETADDRESS("eT_fit", m_eT_fit); SETADDRESS("nMajorityHits", m_nMajorityHits); - SETADDRESS("majorityParticleId", m_majorityParticleId); - // mTree->SetBranchAddress("majorityParticleId", &m_majorityParticleId); SETADDRESS("t_charge", m_t_charge); SETADDRESS("t_vx", m_t_vx); SETADDRESS("t_vy", m_t_vy); @@ -184,7 +244,11 @@ struct Alice3TrackingTranslator { SETADDRESS("t_phi", m_t_phi); SETADDRESS("t_pT", m_t_pT); SETADDRESS("t_eta", m_t_eta); - SETADDRESS("majorityParticlePDG", m_majorityParticlePDG); + SETADDRESS("majorityParticleId_vertex_primary", m_majorityParticleId_vertex_primary); + SETADDRESS("majorityParticleId_vertex_secondary", m_majorityParticleId_vertex_secondary); + SETADDRESS("majorityParticleId_generation", m_majorityParticleId_generation); + SETADDRESS("majorityParticleId_sub_particle", m_majorityParticleId_sub_particle); + SETADDRESS("majorityParticleId_particle", m_majorityParticleId_particle); } // Define track-related members here UInt_t* m_event_nr = nullptr; @@ -202,22 +266,25 @@ struct Alice3TrackingTranslator { std::vector* m_eT_fit = nullptr; // time // The majority truth particle info - std::vector* m_nMajorityHits = nullptr; /// The number of hits from majority particle - std::vector* m_majorityParticleId = nullptr; /// The particle Id of the majority particle - std::vector* m_t_charge = nullptr; /// Charge of majority particle - std::vector* m_t_time = nullptr; /// Time of majority particle - std::vector* m_t_vx = nullptr; /// Vertex x positions of majority particle - std::vector* m_t_vy = nullptr; /// Vertex y positions of majority particle - std::vector* m_t_vz = nullptr; /// Vertex z positions of majority particle - std::vector* m_t_px = nullptr; /// Initial momenta m_px of majority particle - std::vector* m_t_py = nullptr; /// Initial momenta m_py of majority particle - std::vector* m_t_pz = nullptr; /// Initial momenta m_pz of majority particle - std::vector* m_t_theta = nullptr; /// Initial momenta theta of majority particle - std::vector* m_t_phi = nullptr; /// Initial momenta phi of majority particle - std::vector* m_t_pT = nullptr; /// Initial momenta pT of majority particle - std::vector* m_t_eta = nullptr; /// Initial momenta eta of majority particle - - std::vector* m_majorityParticlePDG = nullptr; // IA + std::vector* m_nMajorityHits = nullptr; /// The number of hits from majority particle + std::vector* m_t_charge = nullptr; /// Charge of majority particle + std::vector* m_t_time = nullptr; /// Time of majority particle + std::vector* m_t_vx = nullptr; /// Vertex x positions of majority particle + std::vector* m_t_vy = nullptr; /// Vertex y positions of majority particle + std::vector* m_t_vz = nullptr; /// Vertex z positions of majority particle + std::vector* m_t_px = nullptr; /// Initial momenta m_px of majority particle + std::vector* m_t_py = nullptr; /// Initial momenta m_py of majority particle + std::vector* m_t_pz = nullptr; /// Initial momenta m_pz of majority particle + std::vector* m_t_theta = nullptr; /// Initial momenta theta of majority particle + std::vector* m_t_phi = nullptr; /// Initial momenta phi of majority particle + std::vector* m_t_pT = nullptr; /// Initial momenta pT of majority particle + std::vector* m_t_eta = nullptr; /// Initial momenta eta of majority particle + + std::vector* m_majorityParticleId_vertex_primary = nullptr; + std::vector* m_majorityParticleId_vertex_secondary = nullptr; + std::vector* m_majorityParticleId_generation = nullptr; + std::vector* m_majorityParticleId_sub_particle = nullptr; + std::vector* m_majorityParticleId_particle = nullptr; }; struct HitsStruct : public FileStruct { @@ -228,10 +295,10 @@ struct Alice3TrackingTranslator { } std::vector* barcode = nullptr; }; - void addMCParticle(int collIndex, ParticleStruct& fileParticles, int iParticle, uint8_t flags, int firstMother, int firstDaughter, int numberOfHits) + void addMCParticle(int collIndex, ParticleStruct& fileParticles, int iParticle, uint8_t flags, int firstMother, int firstDaughter, int secondDaughter, int numberOfHits) { int mothers[2] = {firstMother, -1}; - int daughters[2] = {firstDaughter, -1}; + int daughters[2] = {firstDaughter, secondDaughter}; tableStoredMcParticles(collIndex, // mcCollisionId fileParticles.m_particle_type->at(iParticle), // pdgCode 0, // statusCode @@ -287,31 +354,32 @@ struct Alice3TrackingTranslator { } LOG(info) << "All files loaded successfully"; // Now open the files to translate and read the trees - ParticleStruct fileParticles(files["particles.root"], "particles"); - LOG(info) << "Particles loaded successfully"; + // ParticleStruct fileParticles(files["particles.root"], "particles"); + // LOG(info) << "Particles loaded successfully"; ParticleStruct fileParticlesSim(files["particles_simulation.root"], "particles"); LOG(info) << "Particles Sim loaded successfully"; - std::string daughterFileName = addDaughterInfo ? "particles_decay.root" : "particles_simulation.root"; - ParticleStruct fileDaughterParticles(files[daughterFileName], "particles"); - LOG(info) << "Daughter particles loaded successfully from file " << daughterFileName; + // std::string daughterFileName = addDaughterInfo ? "particles_decay.root" : "particles_simulation.root"; + // ParticleStruct fileDaughterParticles(files[daughterFileName], "particles"); + // LOG(info) << "Daughter particles loaded successfully from file " << daughterFileName; // FileStruct fileVertices(files["performance_vertexing.root"], "vertexing"); - TrackStruct fileTracksummary(files["tracksummary_ambi.root"], "tracksummary"); + TrackStruct fileTracksummary(files["tracksummary_ambi-tracks-merged.root"], "tracksummary"); // HitsStruct fileHits(files["hits.root"], "hits"); + VertexStruct fileVertices(files["vertices_gen_and_geant.root"], "vertices"); LOG(info) << "Tracks loaded successfully"; - const Long64_t kEvents = fileParticles.getEntries(); - int indexOfLastParticleAfterEvent = -1; + const Long64_t kEvents = fileParticlesSim.getEntries(); + // int indexOfLastParticleAfterEvent = -1; for (Long64_t iEvent = 0; iEvent < kEvents; ++iEvent) { if (iEvent > 0 && maxCollisions.value > 0 && (iEvent % maxCollisions) == 0) { LOG(info) << "Stopping at event " << iEvent << "/" << kEvents; break; } - fileParticles.setEventEntry(iEvent); - // fileVertices.setEventEntry(iEvent); + // fileParticles.setEventEntry(iEvent); + fileVertices.setEventEntry(iEvent); fileTracksummary.setEventEntry(iEvent); // fileHits.setEventEntry(iEvent); - if (addDaughterInfo) - fileDaughterParticles.setEventEntry(iEvent); + // if (addDaughterInfo) + // fileDaughterParticles.setEventEntry(iEvent); fileParticlesSim.setEventEntry(iEvent); LOG(info) << "Processing event " << iEvent << "/" << kEvents; @@ -329,6 +397,122 @@ struct Alice3TrackingTranslator { // If it has entries, lastIndex() returns the index of the last element, so we use lastIndex() + 1. int collisionId = tableCollisions.lastIndex() + 1; + // Convert tracks from ACTS to ALICE format + // const size_t nParticlesGen = fileParticles.m_vx->size(); + const size_t nParticlesSim = fileParticlesSim.m_vx->size(); + // const size_t nDaughterParticles = fileDaughterParticles.m_vx->size(); + const size_t nTracks = fileTracksummary.m_eLOC0_fit->size(); + std::vector idMCparticles; + + // local index k within this event -> global AO2D index + int firstIdxThisEvent = tableStoredMcParticles.lastIndex() + 1; + + // barcode -> global AO2D index (used later for track labels) + std::map barcodeToGlobalIdx; + std::map> barcodeToVertexPosition; + std::map GlobalIdxToMotherIdx; + std::map GlobalIdxToPDGCode; + std::map GlobalToLocalIdx; + std::map> GlobalIdxToDaughterIdxs; + for (size_t iPart = 0; iPart < nParticlesSim; ++iPart) { + Key key = keyOf( + fileParticlesSim.m_vertex_primary->at(iPart), + fileParticlesSim.m_vertex_secondary->at(iPart), + fileParticlesSim.m_particle->at(iPart), + fileParticlesSim.m_generation->at(iPart), + fileParticlesSim.m_sub_particle->at(iPart)); + barcodeToGlobalIdx[key] = firstIdxThisEvent + (int)iPart; + + if (iPart == 0) { + tableMcCollisions(0, // mccollision::BCId, + 0, // mccollision::GeneratorsID, + fileParticlesSim.m_vx->at(iPart), // mccollision::PosX, + fileParticlesSim.m_vy->at(iPart), // mccollision::PosY, + fileParticlesSim.m_vz->at(iPart), // mccollision::PosZ + fileParticlesSim.m_vt->at(iPart), // mccollision::T + 1.0f, // mccollision::Weight + 0.0f, // mccollision::ImpactParameter, + 0.f); // mccollision::EventPlaneAngle, + } + } + + for (size_t j = 0; j < fileVertices.m_incoming_particles_vertex_secondary->size(); ++j) { + for (size_t d = 0; d < (*fileVertices.m_incoming_particles_vertex_secondary)[j].size(); ++d) { + Key kd = keyOf( + (*fileVertices.m_incoming_particles_vertex_primary)[j][d], + (*fileVertices.m_incoming_particles_vertex_secondary)[j][d], + (*fileVertices.m_incoming_particles_particle)[j][d], + (*fileVertices.m_incoming_particles_generation)[j][d], + (*fileVertices.m_incoming_particles_sub_particle)[j][d]); + + auto iteratorMother = barcodeToGlobalIdx.find(kd); + if (iteratorMother != barcodeToGlobalIdx.end()) { + int motherIdx = iteratorMother->second; + for (size_t d2 = 0; d2 < (*fileVertices.m_outgoing_particles_vertex_secondary)[j].size(); ++d2) { + Key kd2 = keyOf( + (*fileVertices.m_outgoing_particles_vertex_primary)[j][d2], + (*fileVertices.m_outgoing_particles_vertex_secondary)[j][d2], + (*fileVertices.m_outgoing_particles_particle)[j][d2], + (*fileVertices.m_outgoing_particles_generation)[j][d2], + (*fileVertices.m_outgoing_particles_sub_particle)[j][d2]); + barcodeToVertexPosition[kd2].push_back(fileVertices.m_x->at(j)); + barcodeToVertexPosition[kd2].push_back(fileVertices.m_y->at(j)); + barcodeToVertexPosition[kd2].push_back(fileVertices.m_z->at(j)); + auto iteratorDaughter = barcodeToGlobalIdx.find(kd2); + if (iteratorDaughter != barcodeToGlobalIdx.end()) { + int daughterIdx = iteratorDaughter->second; + GlobalIdxToMotherIdx[daughterIdx] = motherIdx; + GlobalIdxToDaughterIdxs[motherIdx].push_back(daughterIdx); + } + } + } + } + } + // int idPrimary = -1; + for (size_t iPart = 0; iPart < nParticlesSim; ++iPart) { + int globalIdx = firstIdxThisEvent + (int)iPart; + int motherIdx = -1; + if (GlobalIdxToMotherIdx.find(globalIdx) != GlobalIdxToMotherIdx.end()) { + motherIdx = GlobalIdxToMotherIdx[globalIdx]; + } + int firstDaughter = -1; + int secondDaughter = -1; + if (GlobalIdxToDaughterIdxs.find(globalIdx) != GlobalIdxToDaughterIdxs.end()) { + const auto& daughters = GlobalIdxToDaughterIdxs[globalIdx]; + if (daughters.size() > 0) { + firstDaughter = daughters[0]; + } + if (daughters.size() > 1) { + secondDaughter = daughters[1]; + } + } + // Determine flags for the MC particle + // TODO: For now primary are only those without mother, but all based on PhysicalPrimary definition should be considered. + uint8_t flags = 0; + if (motherIdx == -1) { + collisionX = fileVertices.m_x->at(iPart); + collisionY = fileVertices.m_y->at(iPart); + collisionZ = fileVertices.m_z->at(iPart); + flags |= o2::aod::mcparticle::enums::PhysicalPrimary; + // idPrimary += 1; + } + // if(motherIdx==-1 && std::abs(fileParticlesSim.m_particle_type->at(iPart)) == 211) { + std::cout << "Adding MC particle " << iPart << ", with globalIdx " << globalIdx << ", with motherIdx " << motherIdx << ", firstDaughter " << firstDaughter << ", secondDaughter " << secondDaughter << ", pdg " << fileParticlesSim.m_particle_type->at(iPart) << std::endl; + // std::cout << "PV: " << fileVertices.m_x->at(iPart) << ", " << fileVertices.m_y->at(iPart) << ", " << fileVertices.m_z->at(iPart) << std::endl; + // std::cout << "Daughter info: "; + // if(firstDaughter != -1){ + // std::cout << "firstDaughter pdg " << fileParticlesSim.m_particle_type->at(firstDaughter) << " "; + // } + // if(secondDaughter != -1){ + // std::cout << "secondDaughter pdg " << fileParticlesSim.m_particle_type->at(secondDaughter) << " "; + // } + // std::cout << std::endl; + // } + GlobalIdxToPDGCode[globalIdx] = fileParticlesSim.m_particle_type->at(iPart); + GlobalToLocalIdx[globalIdx] = iPart; + addMCParticle(tableMcCollisions.lastIndex(), fileParticlesSim, iPart, flags, motherIdx, firstDaughter, secondDaughter, fileParticlesSim.m_number_of_hits->at(iPart)); + } + tableCollisions(0, // bcId collisionX, // posX collisionY, // posY @@ -350,126 +534,82 @@ struct Alice3TrackingTranslator { tableCollisionsAlice3(0.f); // multDensity - struct addedParticle { - float px; - float py; - float pz; - float vx; - float vy; - float vz; - }; - // Convert tracks from ACTS to ALICE format - const size_t nParticlesGen = fileParticles.m_vx->size(); - const size_t nParticlesSim = fileParticlesSim.m_vx->size(); - const size_t nDaughterParticles = fileDaughterParticles.m_vx->size(); - const size_t nTracks = fileTracksummary.m_eLOC0_fit->size(); - std::vector idMCparticles; - + // Reconstructed information for (size_t iTrack = 0; iTrack < nTracks; ++iTrack) { - LOG(info) << "Processing track " << iTrack << "/" << nTracks << " (nParticlesSim=" << nParticlesSim << ") nParticlesGen=" << nParticlesGen; - const size_t iParticle = iTrack; - - if (iParticle == 0) { - tableMcCollisions(0, // mccollision::BCId, - 0, // mccollision::GeneratorsID, - fileParticles.m_vx->at(iParticle), // mccollision::PosX, - fileParticles.m_vy->at(iParticle), // mccollision::PosY, - fileParticles.m_vz->at(iParticle), // mccollision::PosZ - fileParticles.m_vt->at(iParticle), // mccollision::T - 1.0f, // mccollision::Weight - 0.0f, // mccollision::ImpactParameter, - 0.f); // mccollision::EventPlaneAngle, + std::cout << "Processing track " << iTrack << "/" << nTracks << std::endl; + + Key key = keyOf( + fileTracksummary.m_majorityParticleId_vertex_primary->at(iTrack), + fileTracksummary.m_majorityParticleId_vertex_secondary->at(iTrack), + fileTracksummary.m_majorityParticleId_particle->at(iTrack), + fileTracksummary.m_majorityParticleId_generation->at(iTrack), + fileTracksummary.m_majorityParticleId_sub_particle->at(iTrack)); + int mcParticleIdx = -1; + auto iterator = barcodeToGlobalIdx.find(key); + if (iterator != barcodeToGlobalIdx.end()) { + mcParticleIdx = iterator->second; } - uint8_t flags = 0; - - ULong64_t idMCTrueParticle = fileTracksummary.m_majorityParticleId->at(iParticle); - int32_t mcParticleId = -1; - int pdgCode = -1; - - for (size_t iMC = 0; iMC < nParticlesGen; ++iMC) { - if (fileParticles.m_particleId->at(iMC) == idMCTrueParticle) { - if (count(idMCparticles.begin(), idMCparticles.end(), fileParticles.m_particleId->at(iMC)) > 0) { - continue; - } - idMCparticles.push_back(fileParticles.m_particleId->at(iMC)); - flags |= o2::aod::mcparticle::enums::PhysicalPrimary; - int nHits = 0; - for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { - if (fileParticlesSim.m_particleId->at(iPartSim) == fileParticles.m_particleId->at(iMC)) { - nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); - break; - } - } - addMCParticle(tableMcCollisions.lastIndex(), fileParticles, iMC, flags, -1, -1, nHits); - mcParticleId = tableStoredMcParticles.lastIndex(); - pdgCode = fileParticles.m_particle_type->at(iMC); - break; - } - } - if (addDaughterInfo) { - for (size_t iMC = 0; iMC < nDaughterParticles; ++iMC) { - if (fileDaughterParticles.m_particleId->at(iMC) == idMCTrueParticle) { - if (count(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_particleId->at(iMC)) > 0) { - break; - } + std::cout << "Track " << iTrack << " is associated with MC particle index " << mcParticleIdx << std::endl; + // Extract ACTS track parameters + float phi = fileTracksummary.m_ePHI_fit->at(iTrack); + float theta = fileTracksummary.m_eTHETA_fit->at(iTrack); + float qOverP = fileTracksummary.m_eQOP_fit->at(iTrack); + float loc0 = fileTracksummary.m_eLOC0_fit->at(iTrack); + float loc1 = fileTracksummary.m_eLOC1_fit->at(iTrack); + float vx = loc0; + float vy = loc1; + float vz = 0.0f; + // auto iteratorVz = barcodeToVertexPosition.find(key); + // if (iteratorVz != barcodeToVertexPosition.end()){ + // vx = iteratorVz->second[0]; + // vy = iteratorVz->second[1]; + // vz = iteratorVz->second[2]; + // } - int nHits = 0; - for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { - if (fileParticlesSim.m_particleId->at(iPartSim) == fileDaughterParticles.m_particleId->at(iMC)) { - nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); - break; - } - } - for (size_t iMother = 0; iMother < nParticlesGen; ++iMother) { - if (fileDaughterParticles.m_motherId->at(iMC) == fileParticles.m_particleId->at(iMother)) { - if (count(idMCparticles.begin(), idMCparticles.end(), fileParticles.m_particleId->at(iMother)) > 0) { - break; - } - idMCparticles.push_back(fileParticles.m_particleId->at(iMother)); - uint8_t flagsMother = o2::aod::mcparticle::enums::PhysicalPrimary; - addMCParticle(tableMcCollisions.lastIndex(), fileParticles, iMother, flagsMother, -1, tableStoredMcParticles.lastIndex() + 2, 0); - break; - } - } - int motherId = -1; - if (count(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iMC)) > 0) { - auto it = find(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iMC)); - motherId = it - idMCparticles.begin() + indexOfLastParticleAfterEvent + 1; - } - idMCparticles.push_back(fileDaughterParticles.m_particleId->at(iMC)); - addMCParticle(tableMcCollisions.lastIndex(), fileDaughterParticles, iMC, flags, motherId, -1, nHits); - mcParticleId = tableStoredMcParticles.lastIndex(); - pdgCode = fileDaughterParticles.m_particle_type->at(iMC); - break; - } + if (useTrueInfoForRecoTracks) { + if (mcParticleIdx != -1) { + int localIdx = GlobalToLocalIdx[mcParticleIdx]; + float p = fileParticlesSim.m_p->at(localIdx); + float m = fileParticlesSim.m_m->at(localIdx); + float pt = std::hypot(fileParticlesSim.m_px->at(localIdx), fileParticlesSim.m_py->at(localIdx)); + phi = std::acos(fileParticlesSim.m_px->at(localIdx) / pt); + theta = std::acos(fileParticlesSim.m_pz->at(localIdx) / p); + qOverP = (fileParticlesSim.m_q->at(localIdx) != 0) ? (fileParticlesSim.m_q->at(localIdx) / p) : 0.0f; + loc0 = fileParticlesSim.m_vx->at(localIdx); + loc1 = fileParticlesSim.m_vy->at(localIdx); } } - // Extract ACTS track parameters - const float phi = fileTracksummary.m_ePHI_fit->at(iTrack); - const float theta = fileTracksummary.m_eTHETA_fit->at(iTrack); - const float qOverP = fileTracksummary.m_eQOP_fit->at(iTrack); - const float loc0 = fileTracksummary.m_eLOC0_fit->at(iTrack); - const float loc1 = fileTracksummary.m_eLOC1_fit->at(iTrack); + std::cout << "Track parameters: phi=" << phi << ", theta=" << theta << ", qOverP=" << qOverP << ", loc0=" << loc0 << ", loc1=" << loc1 << std::endl; + std::cout << "vx= " << vx << ", vy= " << vy << ", vz= " << vz << std::endl; // Convert to ALICE track parameters // ALICE uses: alpha, x, y, z, snp, tgl, signed1Pt - float alpha = phi; // Track angle in global frame - float x = loc0; // Local x position - float y = loc1; // Local y position - float z = 0.0f; // Will be set from DCA or collision vertex + float alpha = phi - M_PI / 2; // Track angle in global frame + float x = vx; // Local x position + float y = vy; // Local y position + float z = vz; // Will be set from DCA or collision vertex // Calculate snp (sin of track momentum azimuthal angle) - float snp = std::sin(phi); + float snp = o2::constants::math::Almost1; // std::sin(phi);// // Calculate tgl (tangent of track momentum dip angle) float tgl = 1.0f / std::tan(theta); // Calculate signed1Pt (charge/pt) const float m_p = (qOverP != 0) ? std::abs(1.0f / qOverP) : 0.0f; + const float px = m_p * std::cos(phi) * std::sin(theta); + const float py = m_p * std::sin(phi) * std::sin(theta); + const float pz = m_p * std::cos(theta); const float pt = m_p * std::sin(theta); int8_t charge = (qOverP > 0) ? 1 : -1; const float signed1Pt = (pt != 0) ? charge / pt : 0.0f; + if (charge > 0) { + histos.fill(HIST("hPx"), px); + histos.fill(HIST("hPy"), py); + histos.fill(HIST("hPz"), pz); + } + // Track quality float m_chi2Sum = fileTracksummary.m_chi2Sum->at(iTrack); uint32_t m_nMeasurements = fileTracksummary.m_nMeasurements->at(iTrack); @@ -498,7 +638,7 @@ struct Alice3TrackingTranslator { cTglY, cTglZ, cTglSnp, cTglTgl, c1PtY, c1PtZ, c1PtSnp, c1PtTgl, c1Pt21Pt2}; o2::track::TrackParCov trackParCov(x, alpha, trackParams, trackCov, charge); - + std::cout << "TrackParCov created with parameters:" << std::endl; // Fill StoredTracks table (basic track parameters) tableStoredTracks(collisionId, // collisionId o2::aod::track::TrackTypeEnum::Track, // trackType @@ -509,13 +649,13 @@ struct Alice3TrackingTranslator { trackParCov.getSnp(), // snp trackParCov.getTgl(), // tgl trackParCov.getQ2Pt()); // signed1Pt - + std::cout << "Filling StoredTracks table" << std::endl; // Fill TracksExtension table tableTracksExtension(trackParCov.getPt(), trackParCov.getP(), trackParCov.getEta(), trackParCov.getPhi()); - + std::cout << "Filling TracksExtension table" << std::endl; tableStoredTracksCov(std::sqrt(trackParCov.getSigmaY2()), // SigmaY std::sqrt(trackParCov.getSigmaZ2()), // SigmaZ std::sqrt(trackParCov.getSigmaSnp2()), // SigmaSnp @@ -531,7 +671,7 @@ struct Alice3TrackingTranslator { 0, // Rho1PtZ 0, // Rho1PtSnp 0); // Rho1PtTgl - + std::cout << "Filling StoredTracksCov table" << std::endl; // covariance matrix at collision vertex tableTracksCovExtension(trackParCov.getSigmaY2(), // sigmaY2 trackParCov.getSigmaZY(), // sigmaZY @@ -547,44 +687,31 @@ struct Alice3TrackingTranslator { trackParCov.getSigma1PtZ(), // sigma1PtZ trackParCov.getSigma1PtSnp(), // sigma1PtSnp trackParCov.getSigma1PtTgl(), // sigma1PtTgl - trackParCov.getSigma1Pt2()); // sigma1Pt2 - - // Fill MC track labels - // Get particle linkage from hits using the majority hit index - // if (fileTracksummary.nMajorityHits && iTrack < fileTracksummary.nMajorityHits->size()) { - // unsigned int hitIndex = fileTracksummary.nMajorityHits->at(iTrack); - // if (fileHits.barcode && hitIndex < fileHits.barcode->size()) { - // mcParticleId = static_cast(fileHits.barcode->at(hitIndex)); - // LOG(debug) << "Track " << iTrack << " linked to MC particle " << mcParticleId - // << " via hit index " << hitIndex; - // } else { - // LOG(warning) << "Hit index " << hitIndex << " out of range for track " << iTrack - // << " (barcode vector size: " << (fileHits.barcode ? fileHits.barcode->size() : 0) << ")"; - // } - // } else { - // LOG(warning) << "No majority hit information available for track " << iTrack; - // } - // for ( const auto &vv : fileTracksummary.majorityParticleId->at(iTrack) ){ - // LOG(info) << vv; - // } - tableMcTrackLabels(mcParticleId, // McParticleId - 0); // mcMask - + trackParCov.getSigma1Pt2()); // sigma1Pt + std::cout << "Filling TracksCovExtension table" << std::endl; + // Fill MC label + tableMcTrackLabels(mcParticleIdx, // McParticleId + 0); // mcMask + std::cout << "Filling McTrackLabels table" << std::endl; // Fill DCA info (simplified - should be calculated properly) tableTracksDCA(0.0f, // dcaXY 0.0f); // dcaZ - + std::cout << "Filling TracksDCA table" << std::endl; tableTracksDCACov(0.0f, // sigmaDcaXY2 0.0f); // sigmaDcaZ2 - + std::cout << "Filling TracksDCACov table" << std::endl; // Fill ALICE3 specific tables - tableTracksAlice3(true); // isReconstructed - tableTracksAlice3Pdg(pdgCode); // PdgCode to the linked MC truth particle - + tableTracksAlice3(true); // isReconstructed + std::cout << GlobalIdxToPDGCode[mcParticleIdx] << std::endl; + if (mcParticleIdx > 0) + tableTracksAlice3Pdg(GlobalIdxToPDGCode[mcParticleIdx]); // PdgCode to the linked MC truth particle + else + tableTracksAlice3Pdg(0); // No linked MC truth particle + std::cout << "Filling TracksAlice3 and TracksAlice3Pdg tables" << std::endl; tableTracksExtraA3(m_nMeasurements, // nSiliconHits (using m_nMeasurements as proxy) 0, // nTPCHits 0); // trackType - + std::cout << "Filling TracksExtraA3 table" << std::endl; // Fill extra track info tableStoredTracksExtra(0.f, // TPCInnerParam static_cast(0), // Flags @@ -607,7 +734,7 @@ struct Alice3TrackingTranslator { 0.f, // TrackPhiEMCAL 0.f, // TrackTime 0.f); // TrackTimeRes - + std::cout << "Filling StoredTracksExtra table" << std::endl; // Fill track selection tableTrackSelection(false, // IsGlobalTrackSDD, false, // TrackCutFlag, @@ -616,7 +743,7 @@ struct Alice3TrackingTranslator { false, // TrackCutFlagFb3, false, // TrackCutFlagFb4, false); // TrackCutFlagFb5, - + std::cout << "Filling TrackSelection table" << std::endl; tableTrackSelectionExtension(false, // PassedTrackType, false, // PassedPtRange, false, // PassedEtaRange, @@ -634,67 +761,177 @@ struct Alice3TrackingTranslator { false, // PassedDCAz, false, // PassedITSHitsFB1, false); // PassedITSHitsFB2 + std::cout << "Filling TrackSelectionExtension table" << std::endl; } - for (size_t iParticle = 0; iParticle < nParticlesGen; ++iParticle) { - if (iParticle == 0 && nTracks == 0) { - tableMcCollisions(0, // mccollision::BCId, - 0, // mccollision::GeneratorsID, - fileParticles.m_vx->at(iParticle), // mccollision::PosX, - fileParticles.m_vy->at(iParticle), // mccollision::PosY, - fileParticles.m_vz->at(iParticle), // mccollision::PosZ - fileParticles.m_vt->at(iParticle), // mccollision::T - 1.0f, // mccollision::Weight - 0.0f, // mccollision::ImpactParameter, - 0.f); // mccollision::EventPlaneAngle, - } - if (idMCparticles.end() != std::find(idMCparticles.begin(), idMCparticles.end(), fileParticles.m_particleId->at(iParticle))) { - // Already added via track - continue; - } - uint8_t flags = 0; - flags |= o2::aod::mcparticle::enums::PhysicalPrimary; - - int nHits = 0; - for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { - if (fileParticlesSim.m_particleId->at(iPartSim) == fileParticles.m_particleId->at(iParticle)) { - nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); - break; - } - } - addMCParticle(tableMcCollisions.lastIndex(), fileParticles, iParticle, flags, -1, -1, nHits); - idMCparticles.push_back(fileParticles.m_particleId->at(iParticle)); - } - if (addDaughterInfo) { - for (size_t iParticle = 0; iParticle < nDaughterParticles; ++iParticle) { - if (idMCparticles.end() != std::find(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_particleId->at(iParticle))) { - // Already added via track - continue; - } - uint8_t flags = 0; - int nHits = 0; - for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { - if (fileParticlesSim.m_particleId->at(iPartSim) == fileDaughterParticles.m_particleId->at(iParticle)) { - nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); - break; - } - } - int motherId = -1; - for (size_t iMother = 0; iMother < nParticlesGen; ++iMother) { - if (fileDaughterParticles.m_motherId->at(iParticle) == fileParticles.m_particleId->at(iMother)) { - if (count(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iParticle)) > 0) { - auto it = find(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iParticle)); - motherId = it - idMCparticles.begin() + indexOfLastParticleAfterEvent + 1; - } - } - } - addMCParticle(tableMcCollisions.lastIndex(), fileDaughterParticles, iParticle, flags, motherId, -1, nHits); - } - } - - LOG(info) << "Event " << iEvent << ": has " << nTracks << " tracks, " << nParticlesGen << " particles " << nDaughterParticles << " daughter particles, " << nParticlesSim << " propagated particles."; - LOG(info) << "Total numbers of stored MC particles: " << tableStoredMcParticles.lastIndex() + 1; - indexOfLastParticleAfterEvent = tableStoredMcParticles.lastIndex(); + // for (size_t iTrack = 0; iTrack < nTracks; ++iTrack) { + // LOG(info) << "Processing track " << iTrack << "/" << nTracks << " (nParticlesSim=" << nParticlesSim << ") nParticlesGen=" << nParticlesGen; + // const size_t iParticle = iTrack; + + // if (iParticle == 0) { + // tableMcCollisions(0, // mccollision::BCId, + // 0, // mccollision::GeneratorsID, + // fileParticles.m_vx->at(iParticle), // mccollision::PosX, + // fileParticles.m_vy->at(iParticle), // mccollision::PosY, + // fileParticles.m_vz->at(iParticle), // mccollision::PosZ + // fileParticles.m_vt->at(iParticle), // mccollision::T + // 1.0f, // mccollision::Weight + // 0.0f, // mccollision::ImpactParameter, + // 0.f); // mccollision::EventPlaneAngle, + // } + // uint8_t flags = 0; + + // Key majorityVertexInfo = keyOf(fileTracksummary.m_majorityParticleId_vertex_primary->at(iTrack), fileTracksummary.m_majorityParticleId_vertex_secondary->at(iTrack), (*ouPa)[j][d], + // (*ouGe)[j][d], (*ouSp)[j][d]); + + // // ULong64_t idMCTrueParticle = fileTracksummary.m_majorityParticleId->at(iParticle); + // // int32_t mcParticleId = -1; + // // int pdgCode = -1; + + // // for (size_t iMC = 0; iMC < nParticlesGen; ++iMC) { + // // if (fileParticles.m_particleId->at(iMC) == idMCTrueParticle) { + // // if (count(idMCparticles.begin(), idMCparticles.end(), fileParticles.m_particleId->at(iMC)) > 0) { + // // continue; + // // } + // // idMCparticles.push_back(fileParticles.m_particleId->at(iMC)); + // // flags |= o2::aod::mcparticle::enums::PhysicalPrimary; + // // int nHits = 0; + // // for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { + // // if (fileParticlesSim.m_particleId->at(iPartSim) == fileParticles.m_particleId->at(iMC)) { + // // nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); + // // break; + // // } + // // } + // // addMCParticle(tableMcCollisions.lastIndex(), fileParticles, iMC, flags, -1, -1, nHits); + // // mcParticleId = tableStoredMcParticles.lastIndex(); + // // pdgCode = fileParticles.m_particle_type->at(iMC); + // // break; + // // } + // // } + // // if (addDaughterInfo) { + // // for (size_t iMC = 0; iMC < nParticlesSim; ++iMC) { + // // if (fileDaughterParticles.m_particleId->at(iMC) == idMCTrueParticle) { + // // if (count(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_particleId->at(iMC)) > 0) { + // // break; + // // } + + // // int nHits = 0; + // // for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { + // // if (fileParticlesSim.m_particleId->at(iPartSim) == fileDaughterParticles.m_particleId->at(iMC)) { + // // nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); + // // break; + // // } + // // } + // // for (size_t iMother = 0; iMother < nParticlesGen; ++iMother) { + // // if (fileDaughterParticles.m_motherId->at(iMC) == fileParticles.m_particleId->at(iMother)) { + // // if (count(idMCparticles.begin(), idMCparticles.end(), fileParticles.m_particleId->at(iMother)) > 0) { + // // break; + // // } + // // idMCparticles.push_back(fileParticles.m_particleId->at(iMother)); + // // uint8_t flagsMother = o2::aod::mcparticle::enums::PhysicalPrimary; + // // addMCParticle(tableMcCollisions.lastIndex(), fileParticles, iMother, flagsMother, -1, tableStoredMcParticles.lastIndex() + 2, 0); + // // break; + // // } + // // } + // // int motherId = -1; + // // if (count(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iMC)) > 0) { + // // auto it = find(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iMC)); + // // motherId = it - idMCparticles.begin() + indexOfLastParticleAfterEvent + 1; + // // } + // // idMCparticles.push_back(fileDaughterParticles.m_particleId->at(iMC)); + // // addMCParticle(tableMcCollisions.lastIndex(), fileDaughterParticles, iMC, flags, motherId, -1, nHits); + // // mcParticleId = tableStoredMcParticles.lastIndex(); + // // pdgCode = fileDaughterParticles.m_particle_type->at(iMC); + // // break; + // // } + // // } + // // } + // + + // + + // + + // // Fill MC track labels + // // Get particle linkage from hits using the majority hit index + // // if (fileTracksummary.nMajorityHits && iTrack < fileTracksummary.nMajorityHits->size()) { + // // unsigned int hitIndex = fileTracksummary.nMajorityHits->at(iTrack); + // // if (fileHits.barcode && hitIndex < fileHits.barcode->size()) { + // // mcParticleId = static_cast(fileHits.barcode->at(hitIndex)); + // // LOG(debug) << "Track " << iTrack << " linked to MC particle " << mcParticleId + // // << " via hit index " << hitIndex; + // // } else { + // // LOG(warning) << "Hit index " << hitIndex << " out of range for track " << iTrack + // // << " (barcode vector size: " << (fileHits.barcode ? fileHits.barcode->size() : 0) << ")"; + // // } + // // } else { + // // LOG(warning) << "No majority hit information available for track " << iTrack; + // // } + // // for ( const auto &vv : fileTracksummary.majorityParticleId->at(iTrack) ){ + // // LOG(info) << vv; + // // } + // + // } + + // for (size_t iParticle = 0; iParticle < nParticlesGen; ++iParticle) { + // if (iParticle == 0 && nTracks == 0) { + // tableMcCollisions(0, // mccollision::BCId, + // 0, // mccollision::GeneratorsID, + // fileParticles.m_vx->at(iParticle), // mccollision::PosX, + // fileParticles.m_vy->at(iParticle), // mccollision::PosY, + // fileParticles.m_vz->at(iParticle), // mccollision::PosZ + // fileParticles.m_vt->at(iParticle), // mccollision::T + // 1.0f, // mccollision::Weight + // 0.0f, // mccollision::ImpactParameter, + // 0.f); // mccollision::EventPlaneAngle, + // } + // if (idMCparticles.end() != std::find(idMCparticles.begin(), idMCparticles.end(), fileParticles.m_particleId->at(iParticle))) { + // // Already added via track + // continue; + // } + // uint8_t flags = 0; + // flags |= o2::aod::mcparticle::enums::PhysicalPrimary; + + // int nHits = 0; + // for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { + // if (fileParticlesSim.m_particleId->at(iPartSim) == fileParticles.m_particleId->at(iParticle)) { + // nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); + // break; + // } + // } + // addMCParticle(tableMcCollisions.lastIndex(), fileParticles, iParticle, flags, -1, -1, nHits); + // idMCparticles.push_back(fileParticles.m_particleId->at(iParticle)); + // } + // // if (addDaughterInfo) { + // // for (size_t iParticle = 0; iParticle < nDaughterParticles; ++iParticle) { + // // if (idMCparticles.end() != std::find(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_particleId->at(iParticle))) { + // // // Already added via track + // // continue; + // // } + // // uint8_t flags = 0; + // // int nHits = 0; + // // for (size_t iPartSim = 0; iPartSim < nParticlesSim; ++iPartSim) { + // // if (fileParticlesSim.m_particleId->at(iPartSim) == fileDaughterParticles.m_particleId->at(iParticle)) { + // // nHits = fileParticlesSim.m_number_of_hits->at(iPartSim); + // // break; + // // } + // // } + // // int motherId = -1; + // // for (size_t iMother = 0; iMother < nParticlesGen; ++iMother) { + // // if (fileDaughterParticles.m_motherId->at(iParticle) == fileParticles.m_particleId->at(iMother)) { + // // if (count(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iParticle)) > 0) { + // // auto it = find(idMCparticles.begin(), idMCparticles.end(), fileDaughterParticles.m_motherId->at(iParticle)); + // // motherId = it - idMCparticles.begin() + indexOfLastParticleAfterEvent + 1; + // // } + // // } + // // } + // // addMCParticle(tableMcCollisions.lastIndex(), fileDaughterParticles, iParticle, flags, motherId, -1, nHits); + // // } + // // } + + // LOG(info) << "Event " << iEvent << ": has " << nTracks << " tracks, " << nParticlesGen << " particles " << nDaughterParticles << " daughter particles, " << nParticlesSim << " propagated particles."; + // LOG(info) << "Total numbers of stored MC particles: " << tableStoredMcParticles.lastIndex() + 1; + // indexOfLastParticleAfterEvent = tableStoredMcParticles.lastIndex(); } } }; diff --git a/ALICE3/TableProducer/alice3strangenessFinder.cxx b/ALICE3/TableProducer/alice3strangenessFinder.cxx index 50683b8ccec..9725d9506cf 100644 --- a/ALICE3/TableProducer/alice3strangenessFinder.cxx +++ b/ALICE3/TableProducer/alice3strangenessFinder.cxx @@ -309,6 +309,17 @@ struct Alice3strangenessFinder { histos.add("CascadeBuilding/hXiMass", "", kTH1D, {axisXiMass}); histos.add("CascadeBuilding/hOmegaMass", "", kTH1D, {axisOmegaMass}); } + histos.add("hPx", "", kTH1D, {{200, -10.f, 10.f}}); + histos.add("hPy", "", kTH1D, {{200, -10.f, 10.f}}); + histos.add("hPz", "", kTH1D, {{200, -10.f, 10.f}}); + + histos.add("hPxPairs", "", kTH1D, {{200, -10.f, 10.f}}); + histos.add("hPyPairs", "", kTH1D, {{200, -10.f, 10.f}}); + histos.add("hPzPairs", "", kTH1D, {{200, -10.f, 10.f}}); + + histos.add("hPxV0CandDaughter", "", kTH1D, {{200, -10.f, 10.f}}); + histos.add("hPyV0CandDaughter", "", kTH1D, {{200, -10.f, 10.f}}); + histos.add("hPzV0CandDaughter", "", kTH1D, {{200, -10.f, 10.f}}); histos.print(); } @@ -516,6 +527,14 @@ struct Alice3strangenessFinder { } o2::track::TrackParCov pos = getTrackParCov(posTrack); + // if constexpr (requires { posTrack.pdgCode(); }) { + // if (posTrack.pdgCode() == kPiPlus) { + histos.fill(HIST("hPx"), posTrack.px()); + histos.fill(HIST("hPy"), posTrack.py()); + histos.fill(HIST("hPz"), posTrack.pz()); + // } + // } + for (auto const& negTrack : negTracksGrouped) { if (!negTrack.isReconstructed()) { continue; // no ghost tracks @@ -571,6 +590,13 @@ struct Alice3strangenessFinder { // } else { // histos.fill(HIST("hV0Counter"), 3.5); // } + histos.fill(HIST("hPxPairs"), posTrack.px()); + histos.fill(HIST("hPyPairs"), posTrack.py()); + histos.fill(HIST("hPzPairs"), posTrack.pz()); + + histos.fill(HIST("hPxV0CandDaughter"), v0Cand.pDau0[0]); + histos.fill(HIST("hPyV0CandDaughter"), v0Cand.pDau0[1]); + histos.fill(HIST("hPzV0CandDaughter"), v0Cand.pDau0[2]); v0CandidateIndices(collision.globalIndex(), posTrack.globalIndex(), diff --git a/ALICE3/Tasks/alice3Strangeness.cxx b/ALICE3/Tasks/alice3Strangeness.cxx index 0a70dd2c410..8c1f3210667 100644 --- a/ALICE3/Tasks/alice3Strangeness.cxx +++ b/ALICE3/Tasks/alice3Strangeness.cxx @@ -90,7 +90,7 @@ struct Alice3Strangeness { Configurable applyLifetimeSelection{"applyLifetimeSelection", true, "apply lifetime selection"}; Configurable applyEtaDaughterSelection{"applyEtaDaughterSelection", true, "apply eta daughter selection"}; Configurable doQAforSelectionVariables{"doQAforSelectionVariables", false, "enable QA plots"}; - Configurable analyseOnlyTrueV0s{"analyseOnlyTrueV0s", false, "analyse only true V0s from MC"}; + Configurable analyseRecoV0Candidates{"analyseRecoV0Candidates", false, "analyse reconstructed V0 candidates"}; } v0SelectionFlags; struct : ConfigurableGroup { @@ -298,6 +298,8 @@ struct Alice3Strangeness { histos.add("reconstructedCandidates/Lambda/hMass1D", "hMass1D", kTH1D, {histAxes.axisLambdaMass}); histos.add("reconstructedCandidates/hArmeterosBeforeAllSelections", "hArmeterosBeforeAllSelections", kTH2D, {{100, -1.0f, 1.0f}, {200, 0.0f, 0.5f}}); histos.add("reconstructedCandidates/hArmeterosAfterAllSelections", "hArmeterosAfterAllSelections", kTH2D, {{100, -1.0f, 1.0f}, {200, 0.0f, 0.5f}}); + histos.add("reconstructedCandidates/hPtEtaPosDaughter", "hPtEtaPosDaughter", kTH2D, {histAxes.axisPt, histAxes.axisEta}); + histos.add("reconstructedCandidates/hPtEtaNegDaughter", "hPtEtaNegDaughter", kTH2D, {histAxes.axisPt, histAxes.axisEta}); if (doprocessFoundCascadeCandidates) { analysedCascade.setCascadeType(static_cast(cascadeFlags.analyseCascade.value)); @@ -415,9 +417,9 @@ struct Alice3Strangeness { auto negV0Daughter = v0Cand.negTrack_as(); // de-reference negative track auto posV0Daughter = v0Cand.posTrack_as(); // de-reference positive track - bool isK0 = v0Cand.mK0() > 0; + bool isK0 = v0Cand.mK0Short() > 0; if (isK0) { - histos.fill(HIST("K0/hMassAllCandidates"), v0Cand.mK0(), v0Cand.pt()); + histos.fill(HIST("K0/hMassAllCandidates"), v0Cand.mK0Short(), v0Cand.pt()); histos.fill(HIST("K0/hSelections"), 0); // all candidates histos.fill(HIST("K0/hDCANegDaughter"), negV0Daughter.dcaXY()); histos.fill(HIST("K0/hDCAPosDaughter"), posV0Daughter.dcaXY()); @@ -436,7 +438,7 @@ struct Alice3Strangeness { if (std::abs(negV0Daughter.eta()) > v0SelectionValues.etaDaughterSelection || std::abs(posV0Daughter.eta()) > v0SelectionValues.etaDaughterSelection) continue; histos.fill(HIST("K0/hSelections"), 5); // eta cut - histos.fill(HIST("K0/hMassSelected"), v0Cand.mK0(), v0Cand.pt()); + histos.fill(HIST("K0/hMassSelected"), v0Cand.mK0Short(), v0Cand.pt()); } } @@ -453,7 +455,7 @@ struct Alice3Strangeness { } } - void processFoundV0Candidates(aod::Collision const& collision, FullV0Candidates const& v0Candidates, Alice3Tracks const&, aod::McParticles const&) + void processFoundV0Candidates(aod::Collision const& collision, FullV0Candidates const& v0Candidates, Alice3Tracks const&, aod::McParticles const& mcParticles) { // if(collision.lutConfigId()!=idGeometry) // return; @@ -533,15 +535,29 @@ struct Alice3Strangeness { selectionCheck = v0.distOverTotMom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; } histos.fill(HIST("hV0CandidateCounter"), 8.5); - auto posTrack = v0.template posTrack_as(); - auto negTrack = v0.template negTrack_as(); - if (v0SelectionFlags.applyEtaDaughterSelection) { - if (std::abs(posTrack.eta()) > v0SelectionValues.etaDaughterSelection || std::abs(negTrack.eta()) > v0SelectionValues.etaDaughterSelection) - continue; + if (v0SelectionFlags.analyseRecoV0Candidates) { + auto posTrack = v0.template posTrack_as(); + auto negTrack = v0.template negTrack_as(); + if (v0SelectionFlags.applyEtaDaughterSelection) { + if (std::abs(posTrack.eta()) > v0SelectionValues.etaDaughterSelection || std::abs(negTrack.eta()) > v0SelectionValues.etaDaughterSelection) + continue; + } + histos.fill(HIST("reconstructedCandidates/hEtaDaughters"), posTrack.eta()); + histos.fill(HIST("reconstructedCandidates/hEtaDaughters"), negTrack.eta()); + histos.fill(HIST("hV0CandidateCounter"), 9.5); + histos.fill(HIST("reconstructedCandidates/hPtEtaPosDaughter"), posTrack.pt(), posTrack.eta()); + histos.fill(HIST("reconstructedCandidates/hPtEtaNegDaughter"), negTrack.pt(), negTrack.eta()); + } else { + int posDaugID = v0.posTrackId(); + int negDaugID = v0.negTrackId(); + auto posMcParticle = mcParticles.rawIteratorAt(posDaugID); + auto negMcParticle = mcParticles.rawIteratorAt(negDaugID); + // auto posTrack = v0.posTrack_as(); + // auto negTrack = v0.negTrack_as(); + + histos.fill(HIST("reconstructedCandidates/hPtEtaPosDaughter"), posMcParticle.pt(), posMcParticle.eta()); + histos.fill(HIST("reconstructedCandidates/hPtEtaNegDaughter"), negMcParticle.pt(), negMcParticle.eta()); } - histos.fill(HIST("reconstructedCandidates/hEtaDaughters"), posTrack.eta()); - histos.fill(HIST("reconstructedCandidates/hEtaDaughters"), negTrack.eta()); - histos.fill(HIST("hV0CandidateCounter"), 9.5); histos.fill(HIST("reconstructedCandidates/hArmeterosAfterAllSelections"), v0.alpha(), v0.qtArm()); if (v0SelectionFlags.doQAforSelectionVariables) { @@ -559,6 +575,7 @@ struct Alice3Strangeness { } }); } + if (isK0) { histos.fill(HIST("reconstructedCandidates/K0/hMass"), v0.mK0Short(), v0.pt(), v0.eta()); histos.fill(HIST("reconstructedCandidates/K0/hMass1D"), v0.mK0Short());