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 }
109 mInterpolation.setExtDetResid(mExtDetResid);
110 mInterpolation.setITSClusterDictionary(mITSDict);
111}
112
114{
116 return;
117 }
118 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
119 return;
120 }
121 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
122 LOG(info) << "cluster dictionary updated";
123 mITSDict = (const o2::itsmft::TopologyDictionary*)obj;
124 return;
125 }
126}
127
129{
130 mTimer.Start(false);
131 RecoContainer recoData;
132 recoData.collectData(pc, *mDataRequest.get());
133 updateTimeDependentParams(pc);
134 mInterpolation.prepareInputTrackSample(recoData);
135 mInterpolation.process();
136 mTimer.Stop();
137 LOGF(info, "TPC interpolation timing: Cpu: %.3e Real: %.3e s", mTimer.CpuTime(), mTimer.RealTime());
138 if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
139 // these are the residuals and tracks before outlier rejection; they are not used in production
140 pc.outputs().snapshot(Output{"GLO", "TPCINT_RES", 0}, mInterpolation.getClusterResidualsUnfiltered());
141 if (mSendTrackData) {
142 pc.outputs().snapshot(Output{"GLO", "TPCINT_TRK", 0}, mInterpolation.getReferenceTracksUnfiltered());
143 }
144 }
145 pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mInterpolation.getClusterResiduals());
146 pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mInterpolation.getTrackDataCompact());
147 if (mSendTrackData) {
148 pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mInterpolation.getReferenceTracks());
149 }
150 if (mDebugOutput) {
151 pc.outputs().snapshot(Output{"GLO", "TRKDATAEXT", 0}, mInterpolation.getTrackDataExtended());
152 }
153 mInterpolation.reset();
154}
155
157{
158 LOGF(info, "TPC residuals extraction total timing: Cpu: %.3e Real: %.3e s in %d slots",
159 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
160}
161
162DataProcessorSpec 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)
163{
164 auto dataRequest = std::make_shared<DataRequest>();
165 std::vector<OutputSpec> outputs;
166
167 if (useMC) {
168 LOG(fatal) << "MC usage must be disabled for this workflow, since it is not yet implemented";
169 }
170
171 dataRequest->requestTracks(srcVtx, useMC);
172 dataRequest->requestClusters(srcCls, useMC);
173 dataRequest->requestPrimaryVertices(useMC);
174
175 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
176 true, // GRPECS=true
177 true, // GRPLHCIF
178 true, // GRPMagField
179 true, // askMatLUT
181 dataRequest->inputs,
182 true);
183 o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
184 if (SpacePointsCalibConfParam::Instance().writeUnfiltered) {
185 outputs.emplace_back("GLO", "TPCINT_TRK", 0, Lifetime::Timeframe);
186 if (sendTrackData) {
187 outputs.emplace_back("GLO", "TPCINT_RES", 0, Lifetime::Timeframe);
188 }
189 }
190 outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
191 outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
192 if (sendTrackData) {
193 outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);
194 }
195 if (debugOutput) {
196 outputs.emplace_back("GLO", "TRKDATAEXT", 0, Lifetime::Timeframe);
197 }
198
199 return DataProcessorSpec{
200 "tpc-track-interpolation",
201 dataRequest->inputs,
202 outputs,
203 AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid)},
204 Options{
205 {"matCorrType", VariantType::Int, 2, {"material correction type (definition in Propagator.h)"}},
206 {"sec-per-slot", VariantType::UInt32, 600u, {"number of seconds per calibration time slot (put 0 for infinite slot length)"}},
207 {"process-seeds", VariantType::Bool, false, {"do not remove duplicates, e.g. for ITS-TPC-TRD track also process its seeding ITS-TPC part"}}}};
208}
209
210} // namespace tpc
211} // 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, 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"