Skip to content

Commit 908cf8c

Browse files
committed
adding propagated tracks tables
mend fixing commit issue
1 parent 1736757 commit 908cf8c

5 files changed

Lines changed: 343 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", "TRACKPROPAGATED", //! 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", "TRACKPARPROPAGATED", //! 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: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
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{
55+
"registry"};
56+
57+
Produces<aod::tracksPropagated> tracksPropagated;
58+
Produces<aod::tracksParPropagated> tracksParPropagated;
59+
Produces<aod::TracksExtended> tracksExtended;
60+
61+
Service<o2::ccdb::BasicCCDBManager> ccdb;
62+
63+
bool fillTracksPropagated = false;
64+
bool fillTracksParPropagated = false;
65+
bool fillTracksExtended = false;
66+
67+
o2::base::Propagator::MatCorrType matCorr;
68+
69+
const o2::dataformats::MeanVertexObject* mVtx;
70+
71+
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
72+
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
73+
Configurable<std::string> geoPath{"geoPath", "GLO/Config/Geometry", "Path of the geometry file"};
74+
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
75+
Configurable<std::string> mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"};
76+
77+
Configurable<bool> fillQAHists{"fillQAHists", false, "option to fill the QA histograms"};
78+
Configurable<bool> isForceFillTracksPropagated{"isForceFillTracksPropagated", false, "option to fill the tracksPropagated table without workflow requirement"};
79+
Configurable<bool> isForceFillTracksParPropagated{"isForceFillTracksParPropagated", false, "option to fill the tracksParPropagated table without workflow requirement"};
80+
Configurable<bool> isForceFillTracksExtended{"isForceFillTracksExtended", false, "option to fill the tracksExtended tables without workflow requirement"};
81+
82+
void init(o2::framework::InitContext& initContext)
83+
{
84+
85+
// Checking if the tables are requested in the workflow and enabling them
86+
auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
87+
for (DeviceSpec device : workflows.devices) {
88+
for (auto input : device.inputs) {
89+
const std::string tablePropagatedTracks = "PropTracks";
90+
if (input.matcher.binding == tablePropagatedTracks) {
91+
fillTracksPropagated = true;
92+
}
93+
const std::string tablePropagatedExtraTracks = "PropVarTracks";
94+
if (input.matcher.binding == tablePropagatedExtraTracks) {
95+
fillTracksParPropagated = true;
96+
}
97+
const std::string tabledcaTracks = "TracksExtended";
98+
if (input.matcher.binding == tabledcaTracks) {
99+
fillTracksExtended = true;
100+
}
101+
}
102+
}
103+
104+
if (isForceFillTracksPropagated) {
105+
fillTracksPropagated = true
106+
}
107+
if (isForceFillTracksParPropagated) {
108+
fillTracksParPropagated = true
109+
}
110+
if (isForceFillTracksExtended) {
111+
fillTracksExtended = true
112+
}
113+
114+
if (fillQAHists) {
115+
registry.add("hpt", "track #it{p}_{T} (GeV/#it{c});not propagated; propagated to PV", {HistType::kTH2F, {{200, 0., 20.}, {200, 0., 20.}}});
116+
registry.add("hphi", "track #phi; not propagated; propagated to PV", {HistType::kTH2F, {{140, -1., 8.}, {140, -1., 8.}}});
117+
registry.add("heta", "track #eta; not propagated; propagated to PV", {HistType::kTH2F, {{200, -2., 2.}, {200, -2., 2.}}});
118+
}
119+
120+
ccdb->setURL(ccdburl);
121+
ccdb->setCaching(true);
122+
ccdb->setLocalObjectValidityChecking();
123+
124+
auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp<o2::base::MatLayerCylSet>(lutPath, analysis::trackpropagation::run3lut_timestamp));
125+
126+
matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
127+
if (!o2::base::GeometryManager::isGeometryLoaded()) {
128+
129+
auto* gm = ccdb->get<TGeoManager>(geoPath);
130+
o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(grpPath, analysis::trackpropagation::run3grp_timestamp);
131+
132+
o2::base::Propagator::initFieldFromGRP(grpo);
133+
o2::base::Propagator::Instance()->setMatLUT(lut);
134+
}
135+
136+
mVtx = ccdb->get<o2::dataformats::MeanVertexObject>(mVtxPath);
137+
}
138+
139+
void process(aod::Tracks const& tracks, aod::Collisions const&)
140+
{
141+
142+
gpu::gpustd::array<float, 2> dcaInfo;
143+
for (auto& track : tracks) {
144+
145+
auto trackPar = getTrackPar(track);
146+
if (track.has_collision()) {
147+
auto const& collision = track.collision();
148+
149+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, matCorr, &dcaInfo);
150+
if (fillTracksPropagated) {
151+
tracksPropagated(track.collisionId(), track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta());
152+
}
153+
if (fillTracksParPropagated) {
154+
tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt());
155+
}
156+
if (fillTracksExtended) {
157+
tracksExtended(dcaInfo[0], dcaInfo[1]);
158+
}
159+
160+
if (fillQAHists) {
161+
registry.fill(HIST("hpt"), track.pt(), trackPar.getPt());
162+
registry.fill(HIST("hphi"), track.phi(), trackPar.getPhi());
163+
registry.fill(HIST("heta"), track.eta(), trackPar.getEta());
164+
}
165+
166+
} else {
167+
168+
o2::base::Propagator::Instance()->propagateToDCABxByBz({mVtx->getX(), mVtx->getY(), mVtx->getZ()}, trackPar, 2.f, matCorr, &dcaInfo); //put mean collision information here
169+
170+
if (fillTracksPropagated) {
171+
propagatedTracks(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt());
172+
}
173+
if (fillTracksParPropagated) {
174+
propagatedVarTracks(-1, track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta());
175+
}
176+
if (fillTracksExtended) {
177+
tracksExtended(dcaInfo[0], dcaInfo[1]);
178+
}
179+
}
180+
}
181+
}
182+
};
183+
184+
//****************************************************************************************
185+
/**
186+
* Workflow definition.
187+
*/
188+
//****************************************************************************************
189+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
190+
{
191+
WorkflowSpec workflow{adaptAnalysisTask<TrackPropagation>(cfgc)};
192+
return workflow;
193+
}

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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 "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 PropagatedTracks {
35+
36+
HistogramRegistry registry{
37+
"registryTracks",
38+
{{"hcollx", "collision x position (m);entries", {HistType::kTH1F, {{200, -1., 1.}}}},
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+
43+
void process(aod::Collisions const& collision, soa::Join<aod::tracksPropagated, aod::TracksExtra> const& tracks)
44+
{
45+
registry.fill(HIST("hcollx"), collision.posX());
46+
for (auto& track : tracks) {
47+
registry.fill(HIST("hpt"), track.pt());
48+
registry.fill(HIST("hphi"), track.phi());
49+
registry.fill(HIST("heta"), track.eta());
50+
}
51+
}
52+
};
53+
54+
//****************************************************************************************
55+
/**
56+
* Workflow definition.
57+
*/
58+
//****************************************************************************************
59+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
60+
{
61+
WorkflowSpec workflow{adaptAnalysisTask<PropagatedTracks>(cfgc, TaskName{"propagated-tracks"})};
62+
return workflow;
63+
}

0 commit comments

Comments
 (0)