From cb86bbb8c2355b2d0e6c24acf0b6553cf7b120ed Mon Sep 17 00:00:00 2001 From: nzardosh Date: Wed, 20 Oct 2021 00:56:33 +0200 Subject: [PATCH] adding propagated tracks tables mend fixing commit issue --- Common/DataModel/TrackPropagation.h | 75 +++++++++ Common/TableProducer/CMakeLists.txt | 9 +- Common/TableProducer/trackPropagation.cxx | 190 ++++++++++++++++++++++ Tutorials/CMakeLists.txt | 5 + Tutorials/src/propagatedTracks.cxx | 102 ++++++++++++ 5 files changed, 379 insertions(+), 2 deletions(-) create mode 100644 Common/DataModel/TrackPropagation.h create mode 100644 Common/TableProducer/trackPropagation.cxx create mode 100644 Tutorials/src/propagatedTracks.cxx diff --git a/Common/DataModel/TrackPropagation.h b/Common/DataModel/TrackPropagation.h new file mode 100644 index 00000000000..11c7ffcc650 --- /dev/null +++ b/Common/DataModel/TrackPropagation.h @@ -0,0 +1,75 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// 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. + +#ifndef O2_ANALYSIS_TRACKPROPAGATION_H_ +#define O2_ANALYSIS_TRACKPROPAGATION_H_ + +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "MathUtils/Utils.h" +#include +#include "Framework/DataTypes.h" + +namespace o2::aod +{ +namespace trackpropagated // +{ + +// Columns to store user needed track params +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! sign of the track's charge +DECLARE_SOA_COLUMN(Pt, pt, float); //! track transverse momentum GeV/c +DECLARE_SOA_COLUMN(Phi, phi, float); //! track phi +DECLARE_SOA_COLUMN(Eta, eta, float); //! track eta + +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! x-component of the track momentum GeV/c + [](float pt, float phi) -> float { + return pt * std::cos(phi); + }); +DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! y-component of the track momentum GeV/c + [](float pt, float phi) -> float { + return pt * std::sin(phi); + }); +DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! z-component of the track momentum GeV/c + [](float pt, float eta) -> float { + return pt * std::sinh(eta); + }); + +} // namespace trackpropagated + +DECLARE_SOA_TABLE(tracksPropagated, "AOD", "TRACKPROPAG", //! commonly used track parameters, propagated to the primary vertex + o2::soa::Index<>, + track::CollisionId, + track::TrackType, + trackpropagated::Sign, + trackpropagated::Pt, + trackpropagated::Phi, + trackpropagated::Eta, + trackpropagated::Px, + trackpropagated::Py, + trackpropagated::Pz); + +using trackPropagated = tracksPropagated::iterator; + +DECLARE_SOA_TABLE(tracksParPropagated, "AOD", "TRACKPARPROPAG", //! additional track parameters, propagated to the primary vertex + track::X, track::Alpha, + track::Y, track::Z, track::Snp, track::Tgl, + track::Signed1Pt, + track::Px, + track::Py, + track::Pz, + track::Sign); + +using trackParPropagated = tracksParPropagated::iterator; +// TODO: replace this table with dynamical columns in the tracksPropagated table + +} // namespace o2::aod + +#endif // O2_ANALYSIS_TRACKPROPAGATION_H_ diff --git a/Common/TableProducer/CMakeLists.txt b/Common/TableProducer/CMakeLists.txt index ebc5a1b9d45..1f92bb4196b 100644 --- a/Common/TableProducer/CMakeLists.txt +++ b/Common/TableProducer/CMakeLists.txt @@ -49,8 +49,13 @@ o2physics_add_dpl_workflow(weak-decay-indices SOURCES weakDecayIndices.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore COMPONENT_NAME Analysis) - + o2physics_add_dpl_workflow(ft0-corrected-table SOURCES ft0CorrectedTable.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase O2::CCDB O2::CommonConstants - COMPONENT_NAME Analysis) + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(track-propagation + SOURCES trackPropagation.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats + COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx new file mode 100644 index 00000000000..c9997205cdb --- /dev/null +++ b/Common/TableProducer/trackPropagation.cxx @@ -0,0 +1,190 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// 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. + +// +// Task to add a table of track parameters propagated to the primary vertex +// + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/TrackPropagation.h" +#include "Common/Core/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsCommonDataFormats/NameConf.h" +#include "CCDB/CcdbApi.h" +#include "DataFormatsParameters/GRPObject.h" +#include "CCDB/BasicCCDBManager.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "DataFormatsCalibration/MeanVertexObject.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2 +{ +namespace analysis +{ +namespace trackpropagation +{ +constexpr long run3lut_timestamp = (1665695116725 + 1634159124442) / 2; +constexpr long run3grp_timestamp = (1619781650000 + 1619781529000) / 2; + +} // namespace trackpropagation +} // namespace analysis +} // namespace o2 + +struct TrackPropagation { + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + Produces tracksPropagated; + Produces tracksParPropagated; + Produces tracksExtended; + + Service ccdb; + + bool fillTracksPropagated = false; + bool fillTracksParPropagated = false; + bool fillTracksExtended = false; + + o2::base::Propagator::MatCorrType matCorr; + + const o2::dataformats::MeanVertexObject* mVtx; + + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/Geometry", "Path of the geometry file"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + + Configurable fillQAHists{"fillQAHists", false, "option to fill the QA histograms"}; + Configurable isForceFillTracksPropagated{"isForceFillTracksPropagated", false, "option to fill the tracksPropagated table without workflow requirement"}; + Configurable isForceFillTracksParPropagated{"isForceFillTracksParPropagated", false, "option to fill the tracksParPropagated table without workflow requirement"}; + Configurable isForceFillTracksExtended{"isForceFillTracksExtended", false, "option to fill the tracksExtended tables without workflow requirement"}; + + void init(o2::framework::InitContext& initContext) + { + + // Checking if the tables are requested in the workflow and enabling them + auto& workflows = initContext.services().get(); + for (DeviceSpec device : workflows.devices) { + for (auto input : device.inputs) { + const std::string tableTracksPropagated = "tracksPropagated"; + if (input.matcher.binding == tableTracksPropagated) { + fillTracksPropagated = true; + } + const std::string tableTracksParPropagated = "tracksParPropagated"; + if (input.matcher.binding == tableTracksParPropagated) { + fillTracksParPropagated = true; + } + const std::string tableTracksExtended = "TracksExtended"; + if (input.matcher.binding == tableTracksExtended) { + fillTracksExtended = true; + } + } + } + + if (isForceFillTracksPropagated) { + fillTracksPropagated = true; + } + if (isForceFillTracksParPropagated) { + fillTracksParPropagated = true; + } + if (isForceFillTracksExtended) { + fillTracksExtended = true; + } + + if (fillQAHists) { + registry.add("hpt", "track #it{p}_{T} (GeV/#it{c});not propagated; propagated to PV", {HistType::kTH2F, {{200, 0., 20.}, {200, 0., 20.}}}); + registry.add("hphi", "track #phi; not propagated; propagated to PV", {HistType::kTH2F, {{140, -1., 8.}, {140, -1., 8.}}}); + registry.add("heta", "track #eta; not propagated; propagated to PV", {HistType::kTH2F, {{200, -2., 2.}, {200, -2., 2.}}}); + } + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + //auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, analysis::trackpropagation::run3lut_timestamp)); + auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); + + matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + if (!o2::base::GeometryManager::isGeometryLoaded()) { + ccdb->get(geoPath); + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, analysis::trackpropagation::run3grp_timestamp); + o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + } + + mVtx = ccdb->get(mVtxPath); + } + + void process(aod::Tracks const& tracks, aod::Collisions const&) + { + + gpu::gpustd::array dcaInfo; + for (auto& track : tracks) { + + auto trackPar = getTrackPar(track); + if (track.has_collision()) { + auto const& collision = track.collision(); + + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, matCorr, &dcaInfo); + if (fillTracksPropagated) { + tracksPropagated(track.collisionId(), track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta()); + } + if (fillTracksParPropagated) { + tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt()); + } + if (fillTracksExtended) { + tracksExtended(dcaInfo[0], dcaInfo[1]); + } + + if (fillQAHists) { + registry.fill(HIST("hpt"), track.pt(), trackPar.getPt()); + registry.fill(HIST("hphi"), track.phi(), trackPar.getPhi()); + registry.fill(HIST("heta"), track.eta(), trackPar.getEta()); + } + } else { + + o2::base::Propagator::Instance()->propagateToDCABxByBz({mVtx->getX(), mVtx->getY(), mVtx->getZ()}, trackPar, 2.f, matCorr, &dcaInfo); //put mean collision information here + + if (fillTracksPropagated) { + tracksPropagated(-1, track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta()); + } + if (fillTracksParPropagated) { + tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt()); + } + if (fillTracksExtended) { + tracksExtended(dcaInfo[0], dcaInfo[1]); + } + } + } + } +}; + +//**************************************************************************************** +/** + * Workflow definition. + */ +//**************************************************************************************** +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/Tutorials/CMakeLists.txt b/Tutorials/CMakeLists.txt index a5112980d4e..c036ef102c8 100644 --- a/Tutorials/CMakeLists.txt +++ b/Tutorials/CMakeLists.txt @@ -180,3 +180,8 @@ o2physics_add_dpl_workflow(using-pdg SOURCES src/usingPDGService.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(propagated-tracks + SOURCES src/propagatedTracks.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) diff --git a/Tutorials/src/propagatedTracks.cxx b/Tutorials/src/propagatedTracks.cxx new file mode 100644 index 00000000000..b5afafa32d4 --- /dev/null +++ b/Tutorials/src/propagatedTracks.cxx @@ -0,0 +1,102 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// 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. + +// +// Task to use tables of track parameters propagated to the primary vertex +// + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/TrackPropagation.h" +#include "Common/Core/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsCommonDataFormats/NameConf.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct PropagatedTracksExtended { + + HistogramRegistry registry{ + "registryTracks", + {{"hcollx", "collision x position (m);entries", {HistType::kTH1F, {{200, -0.5, 0.5}}}}, + {"hpt", "track #it{p}_{T} propagated (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 20.}}}}, + {"hphi", "track #phi propagated;entries", {HistType::kTH1F, {{140, -1., 8.}}}}, + {"heta", "track #eta propagated;entries", {HistType::kTH1F, {{200, -2., 2.}}}}, + {"hdcaXY", "propagated track dcaXY;entries", {HistType::kTH1F, {{160, -2., 2.}}}}}}; + + void process(aod::Collision const& collision, soa::Join const& tracks) + { + registry.fill(HIST("hcollx"), collision.posX()); + for (auto& track : tracks) { + registry.fill(HIST("hpt"), track.pt()); + registry.fill(HIST("hphi"), track.phi()); + registry.fill(HIST("heta"), track.eta()); + registry.fill(HIST("hdcaXY"), track.dcaXY()); + } + } +}; + +struct PropagatedTracksExtra { + + HistogramRegistry registry{ + "registryTracks", + {{"hpt", "track #it{p}_{T} propagated (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 20.}}}}, + {"hphi", "track #phi propagated;entries", {HistType::kTH1F, {{140, -1., 8.}}}}, + {"heta", "track #eta propagated;entries", {HistType::kTH1F, {{200, -2., 2.}}}}}}; + + void process(aod::Collision const& collision, soa::Join const& tracks) + { + for (auto& track : tracks) { + registry.fill(HIST("hpt"), track.pt()); + registry.fill(HIST("hphi"), track.phi()); + registry.fill(HIST("heta"), track.eta()); + } + } +}; + +struct PropagatedTracksPar { + + HistogramRegistry registry{ + "registryTracks", + {{"hX", "propagated track X position;entries", {HistType::kTH1F, {{240, -12., 12.}}}}, + {"hY", "propagated track Y position", {HistType::kTH1F, {{240, -12., 12.}}}}, + {"hZ", "propagated track Z position", {HistType::kTH1F, {{240, -12., 12.}}}}}}; + + void process(aod::trackParPropagated const& track) + { + registry.fill(HIST("hX"), track.x()); + registry.fill(HIST("hY"), track.y()); + registry.fill(HIST("hZ"), track.z()); + } +}; + +//**************************************************************************************** +/** + * Workflow definition. + */ +//**************************************************************************************** +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + }; +} \ No newline at end of file