Project
Loading...
Searching...
No Matches
TPCInterpolationSpec.cxx
Go to the documentation of this file.
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
13
14#include <vector>
15#include <unordered_map>
16
22#include "DataFormatsTPC/Defs.h"
35
36using namespace o2::framework;
37using namespace o2::globaltracking;
40
41namespace o2
42{
43namespace tpc
44{
45
47{
48 //-------- init geometry and field --------//
49 mTimer.Stop();
50 mTimer.Reset();
52 mSlotLength = ic.options().get<uint32_t>("sec-per-slot");
53 mProcessSeeds = ic.options().get<bool>("process-seeds");
54 mMatCorr = ic.options().get<int>("matCorrType");
55 if (mProcessSeeds && mSources != mSourcesMap) {
56 LOG(fatal) << "process-seeds option is not compatible with using different track sources for vDrift and map extraction";
57 }
58}
59
60void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
61{
63 mTPCVDriftHelper.extractCCDBInputs(pc);
64 static bool initOnceDone = false;
65 if (!initOnceDone) { // this params need to be queried only once
66 initOnceDone = true;
67 // other init-once stuff
69 mInterpolation.init(mSources, mSourcesMap);
70 if (mProcessITSTPConly) {
71 mInterpolation.setProcessITSTPConly();
72 }
73 mInterpolation.setSqrtS(o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getSqrtS());
75 bool limitTracks = (param.maxTracksPerCalibSlot < 0) ? false : true;
76 int nTracksPerTfMax = (nTfs > 0 && limitTracks) ? param.maxTracksPerCalibSlot / nTfs : -1;
77 if (nTracksPerTfMax > 0) {
78 LOGP(info, "We will stop processing tracks after validating {} tracks per TF, since we want to accumulate {} tracks for a slot with {} TFs",
79 nTracksPerTfMax, param.maxTracksPerCalibSlot, nTfs);
80 if (param.additionalTracksMap > 0) {
81 int nTracksAdditional = param.additionalTracksMap / nTfs;
82 LOGP(info, "In addition up to {} additional tracks are processed per TF", nTracksAdditional);
83 mInterpolation.setAddTracksForMapPerTF(nTracksAdditional);
84 }
85 } else if (nTracksPerTfMax < 0) {
86 LOG(info) << "The number of processed tracks per TF is not limited";
87 } else {
88 LOG(error) << "No tracks will be processed. maxTracksPerCalibSlot must be greater than slot length in TFs";
89 }
90 mInterpolation.setMaxTracksPerTF(nTracksPerTfMax);
91 mInterpolation.setMatCorr(static_cast<o2::base::Propagator::MatCorrType>(mMatCorr));
92 if (mProcessSeeds) {
93 mInterpolation.setProcessSeeds();
94 }
96 }
97 // we may have other params which need to be queried regularly
98 if (mTPCVDriftHelper.isUpdated()) {
99 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
100 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
101 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
102 mTPCVDriftHelper.getSourceName());
103 mInterpolation.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
104 mTPCVDriftHelper.acknowledgeUpdate();
105 }
106 if (mDebugOutput) {
107 mInterpolation.setDumpTrackPoints();
108 mInterpolation.setITSClusterDictionary(mITSDict);
109 }
110}
111
113{
115 return;
116 }
117 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
118 return;
119 }
120 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
121 LOG(info) << "cluster dictionary updated";
122 mITSDict = (const o2::itsmft::TopologyDictionary*)obj;
123 return;
124 }
125}
126
128{
129 mTimer.Start(false);
130 RecoContainer recoData;
131 recoData.collectData(pc, *mDataRequest.get());
132 updateTimeDependentParams(pc);
133 mInterpolation.prepareInputTrackSample(recoData);
134 mInterpolation.process();
135 mTimer.Stop();
136 LOGF(info, "TPC interpolation timing: Cpu: %.3e Real: %.3e s", mTimer.CpuTime(), mTimer.RealTime());
137 if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
138 // these are the residuals and tracks before outlier rejection; they are not used in production
139 pc.outputs().snapshot(Output{"GLO", "TPCINT_RES", 0}, mInterpolation.getClusterResidualsUnfiltered());
140 if (mSendTrackData) {
141 pc.outputs().snapshot(Output{"GLO", "TPCINT_TRK", 0}, mInterpolation.getReferenceTracksUnfiltered());
142 }
143 }
144 pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mInterpolation.getClusterResiduals());
145 pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mInterpolation.getTrackDataCompact());
146 if (mSendTrackData) {
147 pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mInterpolation.getReferenceTracks());
148 }
149 if (mDebugOutput) {
150 pc.outputs().snapshot(Output{"GLO", "TRKDATAEXT", 0}, mInterpolation.getTrackDataExtended());
151 }
152 mInterpolation.reset();
153}
154
156{
157 LOGF(info, "TPC residuals extraction total timing: Cpu: %.3e Real: %.3e s in %d slots",
158 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
159}
160
161DataProcessorSpec getTPCInterpolationSpec(GTrackID::mask_t srcCls, GTrackID::mask_t srcVtx, GTrackID::mask_t srcTrk, GTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput)
162{
163 auto dataRequest = std::make_shared<DataRequest>();
164 std::vector<OutputSpec> outputs;
165
166 if (useMC) {
167 LOG(fatal) << "MC usage must be disabled for this workflow, since it is not yet implemented";
168 }
169
170 dataRequest->requestTracks(srcVtx, useMC);
171 dataRequest->requestClusters(srcCls, useMC);
172 dataRequest->requestPrimaryVertices(useMC);
173
174 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
175 true, // GRPECS=true
176 true, // GRPLHCIF
177 true, // GRPMagField
178 true, // askMatLUT
180 dataRequest->inputs,
181 true);
182 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
183 if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
184 outputs.emplace_back("GLO", "TPCINT_TRK", 0, Lifetime::Timeframe);
185 if (sendTrackData) {
186 outputs.emplace_back("GLO", "TPCINT_RES", 0, Lifetime::Timeframe);
187 }
188 }
189 outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
190 outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
191 if (sendTrackData) {
192 outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);
193 }
194 if (debugOutput) {
195 outputs.emplace_back("GLO", "TRKDATAEXT", 0, Lifetime::Timeframe);
196 }
197
198 return DataProcessorSpec{
199 "tpc-track-interpolation",
200 dataRequest->inputs,
201 outputs,
202 AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput)},
203 Options{
204 {"matCorrType", VariantType::Int, 2, {"material correction type (definition in Propagator.h)"}},
205 {"sec-per-slot", VariantType::UInt32, 600u, {"number of seconds per calibration time slot (put 0 for infinite slot length)"}},
206 {"process-seeds", VariantType::Bool, false, {"do not remove duplicates, e.g. for ITS-TPC-TRD track also process its seeding ITS-TPC part"}}}};
207}
208
209} // namespace tpc
210} // namespace o2
Class of a TPC cluster in TPC-native coordinates (row, time)
Wrapper container for different reconstructed object types.
Definition of the GeometryManager class.
Definition of the GeometryTGeo class.
Wrapper container for different reconstructed object types.
Parameters used for TPC space point calibration.
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
Helper class to obtain TPC clusters / digits / labels from DPL.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
void endOfStream(EndOfStreamContext &ec) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
void prepareInputTrackSample(const o2::globaltracking::RecoContainer &inp)
Prepare input track sample (not relying on CreateTracksVariadic functionality)
std::vector< TrackData > & getReferenceTracks()
std::vector< TrackData > & getReferenceTracksUnfiltered()
std::vector< TrackDataExtended > & getTrackDataExtended()
void setMatCorr(MatCorrType matCorr)
Sets the flag if material correction should be applied when extrapolating the tracks.
void setProcessSeeds()
Enable processing of seeds.
void setMaxTracksPerTF(int n)
Sets the maximum number of tracks to be processed (successfully) per TF.
std::vector< TrackDataCompact > & getTrackDataCompact()
void setAddTracksForMapPerTF(int n)
In addition to mMaxTracksPerTF up to the set number of additional tracks can be processed.
std::vector< TPCClusterResiduals > & getClusterResidualsUnfiltered()
void process()
Main processing function.
void setITSClusterDictionary(const o2::itsmft::TopologyDictionary *dict)
Allow setting the ITS cluster dictionary from outside.
std::vector< UnbinnedResid > & getClusterResiduals()
void setDumpTrackPoints()
Enable full output.
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void setProcessITSTPConly()
Enable ITS-TPC only processing.
void setSqrtS(float s)
Set the centre of mass energy required for pT downsampling Tsalis function.
void reset()
Reset cache and output vectors.
void init(o2::dataformats::GlobalTrackID::mask_t src, o2::dataformats::GlobalTrackID::mask_t srcMap)
Initialize everything, set the requested track sources.
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, bool laser=true, bool itstpcTgl=true)
void extractCCDBInputs(o2::framework::ProcessingContext &pc, bool laser=true, bool itstpcTgl=true)
const VDriftCorrFact & getVDriftObject() const
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
static std::string_view getSourceName(Source s)
bool isUpdated() const
GLenum GLfloat param
Definition glcorearb.h:271
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getTPCInterpolationSpec(o2::dataformats::GlobalTrackID::mask_t srcCls, o2::dataformats::GlobalTrackID::mask_t srcVtx, o2::dataformats::GlobalTrackID::mask_t srcTrk, o2::dataformats::GlobalTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
static constexpr int T2L
Definition Cartesian.h:55
static constexpr int T2GRot
Definition Cartesian.h:57
float refTimeOffset
additive time offset reference (\mus)
float refVDrift
reference vdrift for which factor was extracted
float timeOffsetCorr
additive time offset correction (\mus)
float corrFact
drift velocity correction factor (multiplicative)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"