diff --git a/Analysis/Tasks/CMakeLists.txt b/Analysis/Tasks/CMakeLists.txt index 429455fae020a..0e5e41ac21bed 100644 --- a/Analysis/Tasks/CMakeLists.txt +++ b/Analysis/Tasks/CMakeLists.txt @@ -18,3 +18,7 @@ o2_add_executable(correlations-collection PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisCore COMPONENT_NAME Analysis) +o2_add_executable(vertexing-hf + SOURCES vertexerhf.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase + COMPONENT_NAME Analysis) diff --git a/Analysis/Tasks/vertexerhf.cxx b/Analysis/Tasks/vertexerhf.cxx new file mode 100644 index 0000000000000..942a815c0c319 --- /dev/null +++ b/Analysis/Tasks/vertexerhf.cxx @@ -0,0 +1,134 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "DetectorsBase/DCAFitter.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +namespace o2::aod +{ +namespace etaphi +{ +DECLARE_SOA_COLUMN(Eta, etas, float, "fEta"); +DECLARE_SOA_COLUMN(Phi, phis, float, "fPhi"); +} // namespace etaphi +namespace secvtx +{ +DECLARE_SOA_COLUMN(Posx, posx, float, "fPosx"); +DECLARE_SOA_COLUMN(Posy, posy, float, "fPosy"); +DECLARE_SOA_COLUMN(Index0, index0, int, "fIndex0"); +DECLARE_SOA_COLUMN(Index1, index1, int, "fIndex1"); +DECLARE_SOA_COLUMN(Index2, index2, int, "fIndex2"); +DECLARE_SOA_COLUMN(Tracky0, tracky0, float, "fTracky0"); +DECLARE_SOA_COLUMN(Tracky1, tracky1, float, "fTracky1"); +DECLARE_SOA_COLUMN(Tracky2, tracky2, float, "fTracky2"); + +} // namespace secvtx +namespace cand2prong +{ +DECLARE_SOA_COLUMN(Mass, mass, float, "fMass"); +} // namespace cand2prong + +DECLARE_SOA_TABLE(EtaPhi, "RN2", "ETAPHI", + etaphi::Eta, etaphi::Phi); +DECLARE_SOA_TABLE(SecVtx, "AOD", "SECVTX", + secvtx::Posx, secvtx::Posy, secvtx::Index0, secvtx::Index1, secvtx::Index2, secvtx::Tracky0, secvtx::Tracky1, secvtx::Tracky2); +DECLARE_SOA_TABLE(Cand2Prong, "AOD", "CAND2PRONG", + cand2prong::Mass); +} // namespace o2::aod + +using namespace o2; +using namespace o2::framework; + +struct TrackQA { + OutputObj hpt_nocuts{TH1F("hpt_nocuts", "pt tracks (#GeV)", 100, 0., 10.)}; + OutputObj htgl_nocuts{TH1F("htgl_nocuts", "tgl tracks (#GeV)", 100, 0., 10.)}; + + void process(aod::Collision const& collision, soa::Join const& tracks) + { + LOGF(info, "Tracks for collision: %d", tracks.size()); + for (auto& track : tracks) { + hpt_nocuts->Fill(track.pt()); + htgl_nocuts->Fill(track.tgl()); + LOGF(info, "track tgl %f", track.tgl()); + } + } +}; +struct VertexerHFTask { + OutputObj hvtx_x_out{TH1F("hvtx_x", "2-track vtx", 100, -0.1, 0.1)}; + OutputObj hvtx_y_out{TH1F("hvtx_y", "2-track vtx", 100, -0.1, 0.1)}; + OutputObj hvtx_z_out{TH1F("hvtx_z", "2-track vtx", 100, -0.1, 0.1)}; + OutputObj hindex_0_coll{TH1F("hindex_0_coll", "track 0 index coll", 1000000, -0.5, 999999.5)}; + Produces secvtx; + + void process(aod::Collision const& collision, soa::Join const& tracks) + { + LOGF(info, "Tracks for collision: %d", tracks.size()); + o2::base::DCAFitter df(5.0, 10.); + + for (auto it_0 = tracks.begin(); it_0 != tracks.end(); ++it_0) { + auto& track_0 = *it_0; + hindex_0_coll->Fill(track_0.index()); + float x0_ = track_0.x(); + float alpha0_ = track_0.alpha(); + std::array arraypar0 = {track_0.y(), track_0.z(), track_0.snp(), track_0.tgl(), track_0.signed1Pt()}; + std::array covpar0 = {track_0.cYY(), track_0.cZY(), track_0.cZZ(), track_0.cSnpY(), track_0.cSnpZ(), + track_0.cSnpSnp(), track_0.cTglY(), track_0.cTglZ(), track_0.cTglSnp(), track_0.cTglTgl(), + track_0.c1PtY(), track_0.c1PtZ(), track_0.c1PtSnp(), track_0.c1PtTgl(), track_0.c1Pt21Pt2()}; + o2::track::TrackParCov trackparvar0(x0_, alpha0_, arraypar0, covpar0); + + for (auto it_1 = it_0 + 1; it_1 != tracks.end(); ++it_1) { + auto& track_1 = *it_1; + float x1_ = track_1.x(); + float alpha1_ = track_1.alpha(); + std::array arraypar1 = {track_1.y(), track_1.z(), track_1.snp(), track_1.tgl(), track_1.signed1Pt()}; + std::array covpar1 = {track_1.cYY(), track_1.cZY(), track_1.cZZ(), track_1.cSnpY(), track_1.cSnpZ(), + track_1.cSnpSnp(), track_1.cTglY(), track_1.cTglZ(), track_1.cTglSnp(), track_1.cTglTgl(), + track_1.c1PtY(), track_1.c1PtZ(), track_1.c1PtSnp(), track_1.c1PtTgl(), track_1.c1Pt21Pt2()}; + o2::track::TrackParCov trackparvar1(x1_, alpha1_, arraypar1, covpar1); + + df.setUseAbsDCA(true); + int nCand = df.process(trackparvar0, trackparvar1); + for (int ic = 0; ic < nCand; ic++) { + const o2::base::DCAFitter::Triplet& vtx = df.getPCACandidate(ic); + LOGF(info, "vertex x %f", vtx.x); + hvtx_x_out->Fill(vtx.x); + hvtx_y_out->Fill(vtx.y); + hvtx_z_out->Fill(vtx.z); + secvtx(vtx.x, vtx.y, track_0.index(), track_1.index(), -1., track_0.y(), track_1.y(), -1.); + } + } + } + } +}; + +struct CandidateBuilder2Prong { + Produces cand2prong; + void process(aod::SecVtx const& secVtxs, aod::Tracks const& tracks) + { + LOGF(info, "NEW EVENT"); + for (auto& secVtx : secVtxs) { + LOGF(INFO, "Consume the table (%f, %f, %f, %f)", secVtx.posx(), secVtx.posy(), secVtx.tracky0(), (tracks.begin() + secVtx.index0()).y()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const&) +{ + return WorkflowSpec{ + adaptAnalysisTask("track-qa"), + adaptAnalysisTask("vertexerhf-task"), + adaptAnalysisTask("skimvtxtable-task")}; +} diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index e607214271ba1..c7c5eb11c94b4 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -69,7 +69,7 @@ DECLARE_SOA_COLUMN(Length, length, float, "fLength"); } // namespace track DECLARE_SOA_TABLE(Tracks, "AOD", "TRACKPAR", - track::CollisionId, track::X, track::Alpha, + o2::soa::Index<>, track::CollisionId, track::X, track::Alpha, track::Y, track::Z, track::Snp, track::Tgl, track::Signed1Pt, track::Phi, diff --git a/Framework/Foundation/include/Framework/StructToTuple.h b/Framework/Foundation/include/Framework/StructToTuple.h index a507953d5bdd2..0dd4bf5e1a4fe 100644 --- a/Framework/Foundation/include/Framework/StructToTuple.h +++ b/Framework/Foundation/include/Framework/StructToTuple.h @@ -60,7 +60,22 @@ template auto constexpr to_tuple_refs(T&& object) noexcept { using type = std::decay_t; - if constexpr (is_braces_constructible{}) { + if constexpr (is_braces_constructible{}) { + auto&& [p0, p1, p2, p3, p4, p5, p6, p7, p8] = object; + return std::tie(p0, p1, p2, p3, p4, p5, p6, p7, p8); + } else if constexpr (is_braces_constructible{}) { + auto&& [p0, p1, p2, p3, p4, p5, p6, p7] = object; + return std::tie(p0, p1, p2, p3, p4, p5, p6, p7); + } else if constexpr (is_braces_constructible{}) { + auto&& [p0, p1, p2, p3, p4, p5, p6] = object; + return std::tie(p0, p1, p2, p3, p4, p5, p6); + } else if constexpr (is_braces_constructible{}) { + auto&& [p0, p1, p2, p3, p4, p5] = object; + return std::tie(p0, p1, p2, p3, p4, p5); + } else if constexpr (is_braces_constructible{}) { + auto&& [p0, p1, p2, p3, p4] = object; + return std::tie(p0, p1, p2, p3, p4); + } else if constexpr (is_braces_constructible{}) { auto&& [p0, p1, p2, p3] = object; return std::tie(p0, p1, p2, p3); } else if constexpr (is_braces_constructible{}) {