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.setSqrtS(o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getSqrtS());
71 mInterpolation.init(mSources, mSourcesMap);
72 if (mProcessITSTPConly) {
73 mInterpolation.setProcessITSTPConly();
74 }
76 bool limitTracks = (param.maxTracksPerCalibSlot < 0) ? false : true;
77 int nTracksPerTfMax = (nTfs > 0 && limitTracks) ? param.maxTracksPerCalibSlot / nTfs : -1;
78 if (nTracksPerTfMax > 0) {
79 LOGP(info, "We will stop processing tracks after validating {} tracks per TF, since we want to accumulate {} tracks for a slot with {} TFs",
80 nTracksPerTfMax, param.maxTracksPerCalibSlot, nTfs);
81 if (param.additionalTracksMap > 0) {
82 int nTracksAdditional = param.additionalTracksMap / nTfs;
83 LOGP(info, "In addition up to {} additional tracks are processed per TF", nTracksAdditional);
84 mInterpolation.setAddTracksForMapPerTF(nTracksAdditional);
85 }
86 } else if (nTracksPerTfMax < 0) {
87 LOG(info) << "The number of processed tracks per TF is not limited";
88 } else {
89 LOG(error) << "No tracks will be processed. maxTracksPerCalibSlot must be greater than slot length in TFs";
90 }
91 mInterpolation.setMaxTracksPerTF(nTracksPerTfMax);
92 mInterpolation.setMatCorr(static_cast<o2::base::Propagator::MatCorrType>(mMatCorr));
93 if (mProcessSeeds) {
94 mInterpolation.setProcessSeeds();
95 }
97 mInterpolation.setExtDetResid(mExtDetResid);
98 mInterpolation.setITSClusterDictionary(mITSDict);
99 if (mDebugOutput) {
100 mInterpolation.setDumpTrackPoints();
101 }
102 }
103 // we may have other params which need to be queried regularly
104 if (mTPCVDriftHelper.isUpdated()) {
105 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
106 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
107 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
108 mTPCVDriftHelper.getSourceName());
109 mInterpolation.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
110 mTPCVDriftHelper.acknowledgeUpdate();
111 }
112}
113
115{
117 return;
118 }
119 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
120 return;
121 }
122 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
123 LOG(info) << "cluster dictionary updated";
124 mITSDict = (const o2::itsmft::TopologyDictionary*)obj;
125 return;
126 }
127}
128
130{
131 mTimer.Start(false);
132 RecoContainer recoData;
133 recoData.collectData(pc, *mDataRequest.get());
134 updateTimeDependentParams(pc);
135 mInterpolation.prepareInputTrackSample(recoData);
136 mInterpolation.process();
137 mTimer.Stop();
138 LOGF(info, "TPC interpolation timing: Cpu: %.3e Real: %.3e s", mTimer.CpuTime(), mTimer.RealTime());
139 if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
140 // these are the residuals and tracks before outlier rejection; they are not used in production
141 pc.outputs().snapshot(Output{"GLO", "TPCINT_RES", 0}, mInterpolation.getClusterResidualsUnfiltered());
142 if (mSendTrackData) {
143 pc.outputs().snapshot(Output{"GLO", "TPCINT_TRK", 0}, mInterpolation.getReferenceTracksUnfiltered());
144 }
145 }
146 pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mInterpolation.getClusterResiduals());
147 pc.outputs().snapshot(Output{"GLO", "DETINFORES", 0}, mInterpolation.getClusterResidualsDetInfo());
148 pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mInterpolation.getTrackDataCompact());
149 if (mSendTrackData) {
150 pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mInterpolation.getReferenceTracks());
151 }
152 if (mDebugOutput) {
153 pc.outputs().snapshot(Output{"GLO", "TRKDATAEXT", 0}, mInterpolation.getTrackDataExtended());
154 }
155 mInterpolation.reset();
156}
157
159{
160 LOGF(info, "TPC residuals extraction total timing: Cpu: %.3e Real: %.3e s in %d slots",
161 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
162}
163
164DataProcessorSpec 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, bool extDetResid)
165{
166 auto dataRequest = std::make_shared<DataRequest>();
167 std::vector<OutputSpec> outputs;
168
169 if (useMC) {
170 LOG(fatal) << "MC usage must be disabled for this workflow, since it is not yet implemented";
171 }
172
173 dataRequest->requestTracks(srcVtx, useMC);
174 dataRequest->requestClusters(srcCls, useMC);
175 dataRequest->requestPrimaryVertices(useMC);
176
177 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
178 true, // GRPECS=true
179 true, // GRPLHCIF
180 true, // GRPMagField
181 true, // askMatLUT
183 dataRequest->inputs,
184 true);
185 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
186 if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
187 outputs.emplace_back("GLO", "TPCINT_TRK", 0, Lifetime::Timeframe);
188 if (sendTrackData) {
189 outputs.emplace_back("GLO", "TPCINT_RES", 0, Lifetime::Timeframe);
190 }
191 }
192 outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
193 outputs.emplace_back("GLO", "DETINFORES", 0, Lifetime::Timeframe);
194 outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
195 if (sendTrackData) {
196 outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);
197 }
198 if (debugOutput) {
199 outputs.emplace_back("GLO", "TRKDATAEXT", 0, Lifetime::Timeframe);
200 }
201
202 return DataProcessorSpec{
203 "tpc-track-interpolation",
204 dataRequest->inputs,
205 outputs,
206 AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid)},
207 Options{
208 {"matCorrType", VariantType::Int, 2, {"material correction type (definition in Propagator.h)"}},
209 {"sec-per-slot", VariantType::UInt32, 600u, {"number of seconds per calibration time slot (put 0 for infinite slot length)"}},
210 {"process-seeds", VariantType::Bool, false, {"do not remove duplicates, e.g. for ITS-TPC-TRD track also process its seeding ITS-TPC part"}}}};
211}
212
213} // namespace tpc
214} // 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< DetInfoResid > & getClusterResidualsDetInfo()
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.
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, bool extDetResid)
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"