Skip to content

Commit cc18d2d

Browse files
authored
adding propagated tracks tables (#334)
1 parent 40eb41b commit cc18d2d

5 files changed

Lines changed: 379 additions & 2 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#ifndef O2_ANALYSIS_TRACKPROPAGATION_H_
13+
#define O2_ANALYSIS_TRACKPROPAGATION_H_
14+
15+
#include "Framework/AnalysisDataModel.h"
16+
#include "Framework/ASoA.h"
17+
#include "MathUtils/Utils.h"
18+
#include <cmath>
19+
#include "Framework/DataTypes.h"
20+
21+
namespace o2::aod
22+
{
23+
namespace trackpropagated //
24+
{
25+
26+
// Columns to store user needed track params
27+
DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! sign of the track's charge
28+
DECLARE_SOA_COLUMN(Pt, pt, float); //! track transverse momentum GeV/c
29+
DECLARE_SOA_COLUMN(Phi, phi, float); //! track phi
30+
DECLARE_SOA_COLUMN(Eta, eta, float); //! track eta
31+
32+
DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! x-component of the track momentum GeV/c
33+
[](float pt, float phi) -> float {
34+
return pt * std::cos(phi);
35+
});
36+
DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! y-component of the track momentum GeV/c
37+
[](float pt, float phi) -> float {
38+
return pt * std::sin(phi);
39+
});
40+
DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! z-component of the track momentum GeV/c
41+
[](float pt, float eta) -> float {
42+
return pt * std::sinh(eta);
43+
});
44+
45+
} // namespace trackpropagated
46+
47+
DECLARE_SOA_TABLE(tracksPropagated, "AOD", "TRACKPROPAG", //! commonly used track parameters, propagated to the primary vertex
48+
o2::soa::Index<>,
49+
track::CollisionId,
50+
track::TrackType,
51+
trackpropagated::Sign,
52+
trackpropagated::Pt,
53+
trackpropagated::Phi,
54+
trackpropagated::Eta,
55+
trackpropagated::Px<trackpropagated::Pt, trackpropagated::Phi>,
56+
trackpropagated::Py<trackpropagated::Pt, trackpropagated::Phi>,
57+
trackpropagated::Pz<trackpropagated::Pt, trackpropagated::Eta>);
58+
59+
using trackPropagated = tracksPropagated::iterator;
60+
61+
DECLARE_SOA_TABLE(tracksParPropagated, "AOD", "TRACKPARPROPAG", //! additional track parameters, propagated to the primary vertex
62+
track::X, track::Alpha,
63+
track::Y, track::Z, track::Snp, track::Tgl,
64+
track::Signed1Pt,
65+
track::Px<track::Signed1Pt, track::Snp, track::Alpha>,
66+
track::Py<track::Signed1Pt, track::Snp, track::Alpha>,
67+
track::Pz<track::Signed1Pt, track::Tgl>,
68+
track::Sign<track::Signed1Pt>);
69+
70+
using trackParPropagated = tracksParPropagated::iterator;
71+
// TODO: replace this table with dynamical columns in the tracksPropagated table
72+
73+
} // namespace o2::aod
74+
75+
#endif // O2_ANALYSIS_TRACKPROPAGATION_H_

Common/TableProducer/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ o2physics_add_dpl_workflow(weak-decay-indices
4949
SOURCES weakDecayIndices.cxx
5050
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore
5151
COMPONENT_NAME Analysis)
52-
52+
5353
o2physics_add_dpl_workflow(ft0-corrected-table
5454
SOURCES ft0CorrectedTable.cxx
5555
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase O2::CCDB O2::CommonConstants
56-
COMPONENT_NAME Analysis)
56+
COMPONENT_NAME Analysis)
57+
58+
o2physics_add_dpl_workflow(track-propagation
59+
SOURCES trackPropagation.cxx
60+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats
61+
COMPONENT_NAME Analysis)
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
//
13+
// Task to add a table of track parameters propagated to the primary vertex
14+
//
15+
16+
#include "Framework/AnalysisDataModel.h"
17+
#include "Framework/AnalysisTask.h"
18+
#include "Framework/runDataProcessing.h"
19+
#include "Framework/RunningWorkflowInfo.h"
20+
#include "Common/Core/TrackSelection.h"
21+
#include "Common/DataModel/TrackSelectionTables.h"
22+
#include "Common/DataModel/TrackPropagation.h"
23+
#include "Common/Core/trackUtilities.h"
24+
#include "ReconstructionDataFormats/DCA.h"
25+
#include "DetectorsBase/Propagator.h"
26+
#include "DetectorsBase/GeometryManager.h"
27+
#include "DetectorsCommonDataFormats/NameConf.h"
28+
#include "CCDB/CcdbApi.h"
29+
#include "DataFormatsParameters/GRPObject.h"
30+
#include "CCDB/BasicCCDBManager.h"
31+
#include "Framework/HistogramRegistry.h"
32+
#include "Framework/runDataProcessing.h"
33+
#include "DataFormatsCalibration/MeanVertexObject.h"
34+
35+
using namespace o2;
36+
using namespace o2::framework;
37+
using namespace o2::framework::expressions;
38+
39+
namespace o2
40+
{
41+
namespace analysis
42+
{
43+
namespace trackpropagation
44+
{
45+
constexpr long run3lut_timestamp = (1665695116725 + 1634159124442) / 2;
46+
constexpr long run3grp_timestamp = (1619781650000 + 1619781529000) / 2;
47+
48+
} // namespace trackpropagation
49+
} // namespace analysis
50+
} // namespace o2
51+
52+
struct TrackPropagation {
53+
54+
HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
55+
56+
Produces<aod::tracksPropagated> tracksPropagated;
57+
Produces<aod::tracksParPropagated> tracksParPropagated;
58+
Produces<aod::TracksExtended> tracksExtended;
59+
60+
Service<o2::ccdb::BasicCCDBManager> ccdb;
61+
62+
bool fillTracksPropagated = false;
63+
bool fillTracksParPropagated = false;
64+
bool fillTracksExtended = false;
65+
66+
o2::base::Propagator::MatCorrType matCorr;
67+
68+
const o2::dataformats::MeanVertexObject* mVtx;
69+
70+
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
71+
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
72+
Configurable<std::string> geoPath{"geoPath", "GLO/Config/Geometry", "Path of the geometry file"};
73+
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
74+
Configurable<std::string> mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"};
75+
76+
Configurable<bool> fillQAHists{"fillQAHists", false, "option to fill the QA histograms"};
77+
Configurable<bool> isForceFillTracksPropagated{"isForceFillTracksPropagated", false, "option to fill the tracksPropagated table without workflow requirement"};
78+
Configurable<bool> isForceFillTracksParPropagated{"isForceFillTracksParPropagated", false, "option to fill the tracksParPropagated table without workflow requirement"};
79+
Configurable<bool> isForceFillTracksExtended{"isForceFillTracksExtended", false, "option to fill the tracksExtended tables without workflow requirement"};
80+
81+
void init(o2::framework::InitContext& initContext)
82+
{
83+
84+
// Checking if the tables are requested in the workflow and enabling them
85+
auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
86+
for (DeviceSpec device : workflows.devices) {
87+
for (auto input : device.inputs) {
88+
const std::string tableTracksPropagated = "tracksPropagated";
89+
if (input.matcher.binding == tableTracksPropagated) {
90+
fillTracksPropagated = true;
91+
}
92+
const std::string tableTracksParPropagated = "tracksParPropagated";
93+
if (input.matcher.binding == tableTracksParPropagated) {
94+
fillTracksParPropagated = true;
95+
}
96+
const std::string tableTracksExtended = "TracksExtended";
97+
if (input.matcher.binding == tableTracksExtended) {
98+
fillTracksExtended = true;
99+
}
100+
}
101+
}
102+
103+
if (isForceFillTracksPropagated) {
104+
fillTracksPropagated = true;
105+
}
106+
if (isForceFillTracksParPropagated) {
107+
fillTracksParPropagated = true;
108+
}
109+
if (isForceFillTracksExtended) {
110+
fillTracksExtended = true;
111+
}
112+
113+
if (fillQAHists) {
114+
registry.add("hpt", "track #it{p}_{T} (GeV/#it{c});not propagated; propagated to PV", {HistType::kTH2F, {{200, 0., 20.}, {200, 0., 20.}}});
115+
registry.add("hphi", "track #phi; not propagated; propagated to PV", {HistType::kTH2F, {{140, -1., 8.}, {140, -1., 8.}}});
116+
registry.add("heta", "track #eta; not propagated; propagated to PV", {HistType::kTH2F, {{200, -2., 2.}, {200, -2., 2.}}});
117+
}
118+
119+
ccdb->setURL(ccdburl);
120+
ccdb->setCaching(true);
121+
ccdb->setLocalObjectValidityChecking();
122+
123+
//auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp<o2::base::MatLayerCylSet>(lutPath, analysis::trackpropagation::run3lut_timestamp));
124+
auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
125+
126+
matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
127+
if (!o2::base::GeometryManager::isGeometryLoaded()) {
128+
ccdb->get<TGeoManager>(geoPath);
129+
o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(grpPath, analysis::trackpropagation::run3grp_timestamp);
130+
o2::base::Propagator::initFieldFromGRP(grpo);
131+
o2::base::Propagator::Instance()->setMatLUT(lut);
132+
}
133+
134+
mVtx = ccdb->get<o2::dataformats::MeanVertexObject>(mVtxPath);
135+
}
136+
137+
void process(aod::Tracks const& tracks, aod::Collisions const&)
138+
{
139+
140+
gpu::gpustd::array<float, 2> dcaInfo;
141+
for (auto& track : tracks) {
142+
143+
auto trackPar = getTrackPar(track);
144+
if (track.has_collision()) {
145+
auto const& collision = track.collision();
146+
147+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, matCorr, &dcaInfo);
148+
if (fillTracksPropagated) {
149+
tracksPropagated(track.collisionId(), track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta());
150+
}
151+
if (fillTracksParPropagated) {
152+
tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt());
153+
}
154+
if (fillTracksExtended) {
155+
tracksExtended(dcaInfo[0], dcaInfo[1]);
156+
}
157+
158+
if (fillQAHists) {
159+
registry.fill(HIST("hpt"), track.pt(), trackPar.getPt());
160+
registry.fill(HIST("hphi"), track.phi(), trackPar.getPhi());
161+
registry.fill(HIST("heta"), track.eta(), trackPar.getEta());
162+
}
163+
} else {
164+
165+
o2::base::Propagator::Instance()->propagateToDCABxByBz({mVtx->getX(), mVtx->getY(), mVtx->getZ()}, trackPar, 2.f, matCorr, &dcaInfo); //put mean collision information here
166+
167+
if (fillTracksPropagated) {
168+
tracksPropagated(-1, track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta());
169+
}
170+
if (fillTracksParPropagated) {
171+
tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt());
172+
}
173+
if (fillTracksExtended) {
174+
tracksExtended(dcaInfo[0], dcaInfo[1]);
175+
}
176+
}
177+
}
178+
}
179+
};
180+
181+
//****************************************************************************************
182+
/**
183+
* Workflow definition.
184+
*/
185+
//****************************************************************************************
186+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
187+
{
188+
WorkflowSpec workflow{adaptAnalysisTask<TrackPropagation>(cfgc)};
189+
return workflow;
190+
}

Tutorials/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,8 @@ o2physics_add_dpl_workflow(using-pdg
180180
SOURCES src/usingPDGService.cxx
181181
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
182182
COMPONENT_NAME AnalysisTutorial)
183+
184+
o2physics_add_dpl_workflow(propagated-tracks
185+
SOURCES src/propagatedTracks.cxx
186+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
187+
COMPONENT_NAME AnalysisTutorial)

Tutorials/src/propagatedTracks.cxx

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
//
13+
// Task to use tables of track parameters propagated to the primary vertex
14+
//
15+
16+
#include "Framework/AnalysisDataModel.h"
17+
#include "Framework/AnalysisTask.h"
18+
#include "Framework/runDataProcessing.h"
19+
#include "Framework/RunningWorkflowInfo.h"
20+
#include "Common/Core/TrackSelection.h"
21+
#include "Common/DataModel/TrackSelectionTables.h"
22+
#include "Common/DataModel/TrackPropagation.h"
23+
#include "Common/Core/trackUtilities.h"
24+
#include "ReconstructionDataFormats/DCA.h"
25+
#include "DetectorsBase/Propagator.h"
26+
#include "DetectorsCommonDataFormats/NameConf.h"
27+
#include "Framework/HistogramRegistry.h"
28+
#include "Framework/runDataProcessing.h"
29+
30+
using namespace o2;
31+
using namespace o2::framework;
32+
using namespace o2::framework::expressions;
33+
34+
struct PropagatedTracksExtended {
35+
36+
HistogramRegistry registry{
37+
"registryTracks",
38+
{{"hcollx", "collision x position (m);entries", {HistType::kTH1F, {{200, -0.5, 0.5}}}},
39+
{"hpt", "track #it{p}_{T} propagated (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 20.}}}},
40+
{"hphi", "track #phi propagated;entries", {HistType::kTH1F, {{140, -1., 8.}}}},
41+
{"heta", "track #eta propagated;entries", {HistType::kTH1F, {{200, -2., 2.}}}},
42+
{"hdcaXY", "propagated track dcaXY;entries", {HistType::kTH1F, {{160, -2., 2.}}}}}};
43+
44+
void process(aod::Collision const& collision, soa::Join<aod::tracksPropagated, aod::TracksExtended> const& tracks)
45+
{
46+
registry.fill(HIST("hcollx"), collision.posX());
47+
for (auto& track : tracks) {
48+
registry.fill(HIST("hpt"), track.pt());
49+
registry.fill(HIST("hphi"), track.phi());
50+
registry.fill(HIST("heta"), track.eta());
51+
registry.fill(HIST("hdcaXY"), track.dcaXY());
52+
}
53+
}
54+
};
55+
56+
struct PropagatedTracksExtra {
57+
58+
HistogramRegistry registry{
59+
"registryTracks",
60+
{{"hpt", "track #it{p}_{T} propagated (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 20.}}}},
61+
{"hphi", "track #phi propagated;entries", {HistType::kTH1F, {{140, -1., 8.}}}},
62+
{"heta", "track #eta propagated;entries", {HistType::kTH1F, {{200, -2., 2.}}}}}};
63+
64+
void process(aod::Collision const& collision, soa::Join<aod::tracksPropagated, aod::TracksExtra> const& tracks)
65+
{
66+
for (auto& track : tracks) {
67+
registry.fill(HIST("hpt"), track.pt());
68+
registry.fill(HIST("hphi"), track.phi());
69+
registry.fill(HIST("heta"), track.eta());
70+
}
71+
}
72+
};
73+
74+
struct PropagatedTracksPar {
75+
76+
HistogramRegistry registry{
77+
"registryTracks",
78+
{{"hX", "propagated track X position;entries", {HistType::kTH1F, {{240, -12., 12.}}}},
79+
{"hY", "propagated track Y position", {HistType::kTH1F, {{240, -12., 12.}}}},
80+
{"hZ", "propagated track Z position", {HistType::kTH1F, {{240, -12., 12.}}}}}};
81+
82+
void process(aod::trackParPropagated const& track)
83+
{
84+
registry.fill(HIST("hX"), track.x());
85+
registry.fill(HIST("hY"), track.y());
86+
registry.fill(HIST("hZ"), track.z());
87+
}
88+
};
89+
90+
//****************************************************************************************
91+
/**
92+
* Workflow definition.
93+
*/
94+
//****************************************************************************************
95+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
96+
{
97+
return WorkflowSpec{
98+
adaptAnalysisTask<PropagatedTracksExtended>(cfgc),
99+
adaptAnalysisTask<PropagatedTracksExtra>(cfgc),
100+
adaptAnalysisTask<PropagatedTracksPar>(cfgc),
101+
};
102+
}

0 commit comments

Comments
 (0)