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