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"
36
37using namespace o2::framework;
38using namespace o2::globaltracking;
41
42namespace o2
43{
44namespace tpc
45{
46
48{
49 //-------- init geometry and field --------//
50 mTimer.Stop();
51 mTimer.Reset();
53 mSlotLength = ic.options().get<uint32_t>("sec-per-slot");
54 mProcessSeeds = ic.options().get<bool>("process-seeds");
55 mMatCorr = ic.options().get<int>("matCorrType");
56 if (mProcessSeeds && mSources != mSourcesMap) {
57 LOG(fatal) << "process-seeds option is not compatible with using different track sources for vDrift and map extraction";
58 }
59 int lane = ic.services().get<const o2::framework::DeviceSpec>().inputTimesliceId;
60 int maxLanes = ic.services().get<const o2::framework::DeviceSpec>().maxInputTimeslices;
61 mInterpolation.setLane(lane, maxLanes);
62}
63
64void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
65{
67 mTPCVDriftHelper.extractCCDBInputs(pc);
68 static bool initOnceDone = false;
69 if (!initOnceDone) { // this params need to be queried only once
70 initOnceDone = true;
71 // other init-once stuff
73 mInterpolation.setSqrtS(o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getSqrtS());
75 mInterpolation.init(mSources, mSourcesMap);
76 if (mProcessITSTPConly) {
77 mInterpolation.setProcessITSTPConly();
78 }
80 bool limitTracks = (param.maxTracksPerCalibSlot < 0) ? false : true;
81 int nTracksPerTfMax = (nTfs > 0 && limitTracks) ? param.maxTracksPerCalibSlot / nTfs : -1;
82 if (nTracksPerTfMax > 0) {
83 LOGP(info, "We will stop processing tracks after validating {} tracks per TF, since we want to accumulate {} tracks for a slot with {} TFs",
84 nTracksPerTfMax, param.maxTracksPerCalibSlot, nTfs);
85 if (param.additionalTracksMap > 0) {
86 int nTracksAdditional = param.additionalTracksMap / nTfs;
87 LOGP(info, "In addition up to {} additional tracks are processed per TF", nTracksAdditional);
88 mInterpolation.setAddTracksForMapPerTF(nTracksAdditional);
89 }
90 } else if (nTracksPerTfMax < 0) {
91 LOG(info) << "The number of processed tracks per TF is not limited";
92 } else {
93 LOG(error) << "No tracks will be processed. maxTracksPerCalibSlot must be greater than slot length in TFs";
94 }
95 mInterpolation.setMaxTracksPerTF(nTracksPerTfMax);
96 mInterpolation.setMatCorr(static_cast<o2::base::Propagator::MatCorrType>(mMatCorr));
97 if (mProcessSeeds) {
98 mInterpolation.setProcessSeeds();
99 }
101 mInterpolation.setExtDetResid(mExtDetResid);
102 mInterpolation.setITSClusterDictionary(mITSDict);
103 if (mDebugOutput) {
104 mInterpolation.setDumpTrackPoints();
105 }
106 }
107 // we may have other params which need to be queried regularly
108 if (mTPCVDriftHelper.isUpdated()) {
109 LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
110 mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
111 mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
112 mTPCVDriftHelper.getSourceName());
113 mInterpolation.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
114 mTPCVDriftHelper.acknowledgeUpdate();
115 }
116}
117
119{
121 return;
122 }
123 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
124 return;
125 }
126 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
127 LOG(info) << "cluster dictionary updated";
128 mITSDict = (const o2::itsmft::TopologyDictionary*)obj;
129 return;
130 }
131}
132
134{
135 mTimer.Start(false);
136 RecoContainer recoData;
137 recoData.collectData(pc, *mDataRequest.get());
138 updateTimeDependentParams(pc);
139 mInterpolation.prepareInputTrackSample(recoData);
140 mInterpolation.process();
141 mTimer.Stop();
142 LOGF(info, "TPC interpolation timing: Cpu: %.3e Real: %.3e s", mTimer.CpuTime(), mTimer.RealTime());
143 pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mInterpolation.getClusterResiduals());
144 pc.outputs().snapshot(Output{"GLO", "DETINFORES", 0}, mInterpolation.getClusterResidualsDetInfo());
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 mInterpolation.finalize();
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 outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
185 outputs.emplace_back("GLO", "DETINFORES", 0, Lifetime::Timeframe);
186 outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
187 if (sendTrackData) {
188 outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);
189 }
190 if (debugOutput) {
191 outputs.emplace_back("GLO", "TRKDATAEXT", 0, Lifetime::Timeframe);
192 }
193
194 return DataProcessorSpec{
195 "tpc-track-interpolation",
196 dataRequest->inputs,
197 outputs,
198 AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid)},
199 Options{
200 {"matCorrType", VariantType::Int, 2, {"material correction type (definition in Propagator.h)"}},
201 {"sec-per-slot", VariantType::UInt32, 300u, {"number of seconds per calibration time slot (put 0 for infinite slot length)"}},
202 {"process-seeds", VariantType::Bool, false, {"do not remove duplicates, e.g. for ITS-TPC-TRD track also process its seeding ITS-TPC part"}}}};
203}
204
205} // namespace tpc
206} // 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)
ServiceRegistryRef services()
Definition InitContext.h:34
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< 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.
void setLane(int lID, int nL)
std::vector< DetInfoResid > & getClusterResidualsDetInfo()
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 ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
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"