Skip to content

Commit 862bdf2

Browse files
[Common] Common - add trackdcacov table producer for Run2 converted data (AliceO2Group#11434)
1 parent 06e8c9e commit 862bdf2

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed

Common/TableProducer/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ o2physics_add_dpl_workflow(track-propagation
6262
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
6363
COMPONENT_NAME Analysis)
6464

65+
o2physics_add_dpl_workflow(track-dca-cov-filler-run2
66+
SOURCES trackDcaCovFillerRun2.cxx
67+
PUBLIC_LINK_LIBRARIES O2::DetectorsBase O2Physics::AnalysisCore
68+
COMPONENT_NAME Analysis)
69+
6570
o2physics_add_dpl_workflow(track-propagation-tester
6671
SOURCES trackPropagationTester.cxx
6772
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::trackSelectionRequest
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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+
/// \file trackDcaCovFillerRun2.cxx
13+
/// \author Aimeric Landou <[email protected]>, CERN
14+
/// \brief Fills DCA and DCA Cov tables for Run 2 tracks
15+
// Run 2 AO2Ds cannot have their dcacov filled by the current track-propagation workflow as the workflow isn't designed for them, given Run 2 tracks are already propagated to the PV.
16+
// This task fills the DCA Cov (and DCA) tables for Run 2 tracks by "propagating" the tracks (though given they are already at the PV it doesn't actually do the propagation) and retrieving the DCA and DCA cov given by the propagateToDCABxByBz function
17+
18+
#include <string>
19+
20+
#include "TableHelper.h"
21+
#include "Common/Tools/TrackTuner.h"
22+
#include "DataFormatsParameters/GRPObject.h"
23+
24+
using namespace o2;
25+
using namespace o2::framework;
26+
// using namespace o2::framework::expressions;
27+
28+
struct TrackDcaCovFillerRun2 {
29+
Produces<aod::TracksDCA> tracksDCA;
30+
Produces<aod::TracksDCACov> tracksDCACov;
31+
32+
// Produces<aod::TrackTunerTable> tunertable;
33+
34+
Service<o2::ccdb::BasicCCDBManager> ccdb;
35+
36+
bool fillTracksDCA = false;
37+
bool fillTracksDCACov = false;
38+
int runNumber = -1;
39+
40+
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
41+
42+
const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr;
43+
o2::parameters::GRPMagField* grpmag = nullptr;
44+
o2::base::MatLayerCylSet* lut = nullptr;
45+
46+
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
47+
Configurable<std::string> ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "CCDB path of the grp file (run2)"};
48+
Configurable<std::string> mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"};
49+
50+
HistogramRegistry registry{"registry"};
51+
52+
void init(o2::framework::InitContext& initContext)
53+
{
54+
// Checking if the tables are requested in the workflow and enabling them
55+
fillTracksDCA = isTableRequiredInWorkflow(initContext, "TracksDCA");
56+
fillTracksDCACov = isTableRequiredInWorkflow(initContext, "TracksDCACov");
57+
58+
ccdb->setURL(ccdburl);
59+
ccdb->setCaching(true);
60+
ccdb->setLocalObjectValidityChecking();
61+
}
62+
63+
void initCCDB(aod::BCsWithTimestamps::iterator const& bc)
64+
{
65+
if (runNumber == bc.runNumber()) {
66+
return;
67+
}
68+
69+
// Run 2 GRP object
70+
o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(ccdbPathGrp, bc.timestamp());
71+
if (grpo == nullptr) {
72+
LOGF(fatal, "Run 2 GRP object (type o2::parameters::GRPObject) is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp());
73+
}
74+
o2::base::Propagator::initFieldFromGRP(grpo);
75+
LOGF(info, "Setting magnetic field to %d kG for run %d from its GRP CCDB object (type o2::parameters::GRPObject)", grpo->getNominalL3Field(), bc.runNumber());
76+
77+
mMeanVtx = ccdb->getForTimeStamp<o2::dataformats::MeanVertexObject>(mVtxPath, bc.timestamp());
78+
runNumber = bc.runNumber();
79+
}
80+
81+
// Running variables
82+
std::array<float, 2> mDcaInfo;
83+
o2::dataformats::DCA mDcaInfoCov;
84+
o2::dataformats::VertexBase mVtx;
85+
o2::track::TrackParametrization<float> mTrackPar;
86+
o2::track::TrackParametrizationWithError<float> mTrackParCov;
87+
88+
template <typename TTrack, typename TParticle, bool isMc, bool fillCovMat = false>
89+
void fillTrackTables(TTrack const& tracks,
90+
TParticle const&,
91+
aod::Collisions const&,
92+
aod::BCsWithTimestamps const& bcs)
93+
{
94+
if (bcs.size() == 0) {
95+
return;
96+
}
97+
initCCDB(bcs.begin());
98+
99+
if constexpr (fillCovMat) {
100+
if (fillTracksDCACov) {
101+
tracksDCACov.reserve(tracks.size());
102+
}
103+
} else {
104+
if (fillTracksDCA) {
105+
tracksDCA.reserve(tracks.size());
106+
}
107+
}
108+
109+
for (auto const& track : tracks) {
110+
if constexpr (fillCovMat) {
111+
if (fillTracksDCA || fillTracksDCACov) {
112+
mDcaInfoCov.set(999, 999, 999, 999, 999);
113+
}
114+
setTrackParCov(track, mTrackParCov);
115+
} else {
116+
if (fillTracksDCA) {
117+
mDcaInfo[0] = 999;
118+
mDcaInfo[1] = 999;
119+
}
120+
setTrackPar(track, mTrackPar);
121+
}
122+
123+
if (track.has_collision()) {
124+
auto const& collision = track.collision();
125+
if constexpr (fillCovMat) {
126+
mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()});
127+
mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ());
128+
o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, mTrackParCov, 2.f, matCorr, &mDcaInfoCov);
129+
} else {
130+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, mTrackPar, 2.f, matCorr, &mDcaInfo);
131+
}
132+
} else {
133+
if constexpr (fillCovMat) {
134+
mVtx.setPos({mMeanVtx->getX(), mMeanVtx->getY(), mMeanVtx->getZ()});
135+
mVtx.setCov(mMeanVtx->getSigmaX() * mMeanVtx->getSigmaX(), 0.0f, mMeanVtx->getSigmaY() * mMeanVtx->getSigmaY(), 0.0f, 0.0f, mMeanVtx->getSigmaZ() * mMeanVtx->getSigmaZ());
136+
o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, mTrackParCov, 2.f, matCorr, &mDcaInfoCov);
137+
} else {
138+
o2::base::Propagator::Instance()->propagateToDCABxByBz({mMeanVtx->getX(), mMeanVtx->getY(), mMeanVtx->getZ()}, mTrackPar, 2.f, matCorr, &mDcaInfo);
139+
}
140+
}
141+
142+
if constexpr (fillCovMat) {
143+
if (fillTracksDCA) {
144+
tracksDCA(mDcaInfoCov.getY(), mDcaInfoCov.getZ());
145+
}
146+
if (fillTracksDCACov) {
147+
tracksDCACov(mDcaInfoCov.getSigmaY2(), mDcaInfoCov.getSigmaZ2());
148+
}
149+
} else {
150+
if (fillTracksDCA) {
151+
tracksDCA(mDcaInfo[0], mDcaInfo[1]);
152+
}
153+
}
154+
}
155+
}
156+
157+
void processCovariance(soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksCov> const& tracks, aod::Collisions const& collisions, aod::BCsWithTimestamps const& bcs)
158+
{
159+
fillTrackTables</*TTrack*/ soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksCov>, /*Particle*/ soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksCov>, /*isMc = */ false, /*fillCovMat =*/true>(tracks, tracks, collisions, bcs);
160+
}
161+
PROCESS_SWITCH(TrackDcaCovFillerRun2, processCovariance, "Process with covariance", false);
162+
163+
void processStandard(soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksCov> const& tracks, aod::Collisions const& collisions, aod::BCsWithTimestamps const& bcs)
164+
{
165+
fillTrackTables</*TTrack*/ soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksCov>, /*Particle*/ soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksCov>, /*isMc = */ false, /*fillCovMat =*/false>(tracks, tracks, collisions, bcs);
166+
}
167+
PROCESS_SWITCH(TrackDcaCovFillerRun2, processStandard, "Process without covariance", true);
168+
};
169+
170+
//****************************************************************************************
171+
/**
172+
* Workflow definition.
173+
*/
174+
//****************************************************************************************
175+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
176+
{
177+
WorkflowSpec workflow{adaptAnalysisTask<TrackDcaCovFillerRun2>(cfgc)};
178+
return workflow;
179+
}

0 commit comments

Comments
 (0)