Project
Loading...
Searching...
No Matches
TRDGlobalTrackingSpec.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 <TMap.h>
15#include <TObjString.h>
17#include "TRDBase/Geometry.h"
37#include "ITStracking/IOUtils.h"
45
46// GPU header
47#include "GPUReconstruction.h"
48#include "GPUChainTracking.h"
49#include "GPUChainTrackingGetters.inc"
51#include "GPUO2InterfaceUtils.h"
52#include "GPUSettings.h"
54#include "GPUDataTypesIO.h"
55#include "GPUTRDDef.h"
56#include "GPUTRDTrack.h"
57#include "GPUTRDTrackletWord.h"
58#include "GPUTRDInterfaces.h"
59#include "GPUTRDGeometry.h"
60#include "GPUConstantMem.h"
62
63#ifdef ENABLE_UPGRADES
65#endif
66
67#include <regex>
68#include <algorithm>
69#include <numeric>
70
71using namespace o2::framework;
72using namespace o2::gpu;
73using namespace o2::globaltracking;
74using namespace o2::trd::constants;
75
77
78namespace o2
79{
80namespace trd
81{
82
84
86{
88 mTimer.Stop();
89 mTimer.Reset();
90}
91
92void TRDGlobalTracking::updateTimeDependentParams(ProcessingContext& pc)
93{
95 mTPCVDriftHelper.extractCCDBInputs(pc);
96
97 auto const& raw = pc.inputs().get<const char*>("corrMap");
98 mTPCCorrMaps = &o2::gpu::TPCFastTransformPOD::get(raw);
99 float lumiCTP = mRequestCTPLumi ? pc.inputs().get<float>("lumiCTP") : 0;
100
101 // pc.inputs().get<TopologyDictionary*>("cldict"); // called by the RecoContainer to trigger finaliseCCDB
102 static bool initOnceDone = false;
103 if (!initOnceDone) { // this params need to be queried only once
104 initOnceDone = true;
105 // init-once stuff
106
107 auto geo = Geometry::instance();
108 o2::its::GeometryTGeo::Instance()->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2GRot) | o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L));
109 geo->createPadPlaneArray();
110 geo->createClusterMatrixArray();
111 mFlatGeo = std::make_unique<GeometryFlat>(*geo);
112
113 GPURecoStepConfiguration cfgRecoStep;
114 cfgRecoStep.steps = gpudatatypes::RecoStep::NoRecoStep;
115 cfgRecoStep.inputs.clear();
116 cfgRecoStep.outputs.clear();
117 mRec = GPUReconstruction::CreateInstance("CPU", true);
118
120 config.ReadConfigurableParam(config);
122 config.configProcessing.o2PropagatorUseGPUField = false;
123 mRecoParam.init(o2::base::Propagator::Instance()->getNominalBz(), &config.configReconstruction);
124
125 mRec->SetSettings(&config.configGRP, &config.configReconstruction, &config.configProcessing, &cfgRecoStep);
126
127 mChainTracking = mRec->AddChain<GPUChainTracking>();
129
130 mTracker = new GPUTRDTracker();
131 mTracker->SetNCandidates(mRec->GetProcessingSettings().trdNCandidates); // must be set before initialization
132 if (mStrict && mRec->GetProcessingSettings().trdNCandidates == 1) {
133 LOG(error) << "Strict matching mode requested, but tracks with another close hypothesis will not be rejected. Please set trdNCandidates to at least 3.";
134 }
135 mTracker->SetProcessPerTimeFrame(true);
136 mTracker->SetGenerateSpacePoints(false); // set to true to force space point calculation by the TRD tracker itself
137
138 mRec->RegisterGPUProcessor(mTracker, false);
139 mChainTracking->SetTRDGeometry(std::move(mFlatGeo));
140 mChainTracking->SetTRDRecoParam(&mRecoParam);
141 if (mRec->Init()) {
142 LOG(fatal) << "GPUReconstruction could not be initialized";
143 }
144
145 mTracker->PrintSettings();
146 LOG(info) << "Strict matching mode is " << ((mStrict) ? "ON" : "OFF");
147 LOGF(info, "The search road in time for ITS-TPC tracks is set to %.1f sigma and %.2f us are added to it on top",
148 mRec->GetParam().rec.trd.nSigmaTerrITSTPC, mRec->GetParam().rec.trd.addTimeRoadITSTPC);
149
151 if (mWithPID) {
152 mBase = getTRDPIDPolicy(mPolicy);
153 mBase->init(pc);
154 mBase->setLocalGainFactors(pc.inputs().get<o2::trd::LocalGainFactor*>("localgainfactors").get());
155 }
156
157 pc.inputs().get<std::array<int, constants::MAXCHAMBER>*>("chamberstatus"); // called to trigger finaliseCCDB
158 // pc.inputs().get<o2::trd::PadStatus*>("padstatus"); // called to trigger finaliseCCDB
159 }
160
161 const auto& trackTune = TrackTuneParams::Instance();
162 float scale = lumiCTP;
163 if (scale < 0.f) {
164 scale = 0.f;
165 }
166 mCovDiagInner = trackTune.getCovInnerTotal(scale);
167 mCovDiagOuter = trackTune.getCovOuterTotal(scale);
168
169 if (mTPCVDriftHelper.isUpdated()) {
171 mTPCTBinMUS = elParam.ZbinWidth;
172 mTPCTBinMUSInv = 1. / mTPCTBinMUS;
173 auto& vd = mTPCVDriftHelper.getVDriftObject();
174 mTPCVdrift = vd.getVDrift();
175 mTPCTDriftOffset = vd.getTimeOffset();
176 LOGP(info, "Updating TPC VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
177 vd.corrFact, vd.refVDrift, vd.timeOffsetCorr, vd.refTimeOffset, mTPCVDriftHelper.getSourceName());
178 mTracker->SetTPCVdrift(mTPCVdrift);
179 mTracker->SetTPCTDriftOffset(mTPCTDriftOffset);
180 mTPCVDriftHelper.acknowledgeUpdate();
181 }
182}
183
185{
187 return;
188 }
189 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
190 return;
191 }
192 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
193 LOG(info) << "cluster dictionary updated";
194 mITSDict = (const o2::itsmft::TopologyDictionary*)obj;
195 return;
196 }
197#ifdef ENABLE_UPGRADES
198 if (matcher == ConcreteDataMatcher("IT3", "CLUSDICT", 0)) {
199 LOG(info) << "it3 cluster dictionary updated";
200 mIT3Dict = (const o2::its3::TopologyDictionary*)obj;
201 return;
202 }
203#endif
204 if (matcher == ConcreteDataMatcher("TRD", "CHAMBERSTATUS", 0)) {
205 LOG(info) << "chamber status object updated";
206 const std::array<int, constants::MAXCHAMBER>* chamberStatus = (const std::array<int, constants::MAXCHAMBER>*)obj;
207 for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) {
208 if ((*chamberStatus)[iDet] == 3) {
209 mTracker->SetChamberStatus(iDet, false); // chamber is good
210 } else {
211 mTracker->SetChamberStatus(iDet, true); // chamber is bad
212 }
213 }
214 return;
215 }
216 /*if (matcher == ConcreteDataMatcher("TRD", "PADSTATUS", 0)) {
217 LOG(info) << "pad status object updated";
218 const o2::trd::PadStatus* padStatus = (const o2::trd::PadStatus*)obj;
219 for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) {
220 for (int iCol = 0; iCol < constants::NCOLUMN; iCol++) {
221 for (int iRow = 0; iRow < ((iDet % 30) / 6 == 2 ? constants::NROWC0 : constants::NROWC1); iRow++) {
222 if (padStatus->isMasked(iDet, iCol, iRow) || padStatus->isNotConnected(iDet, iCol, iRow)) {
223 mTracker->SetPadStatus(iDet * constants::NCOLUMN * constants::NROWC1 + iCol * constants::NROWC1 + iRow, true); // pad is masked
224 } else {
225 mTracker->SetPadStatus(iDet * constants::NCOLUMN * constants::NROWC1 + iCol * constants::NROWC1 + iRow, false); // pad is not masked
226 }
227 }
228 }
229 }
230 return;
231 }*/
232}
233
234void TRDGlobalTracking::fillMCTruthInfo(const TrackTRD& trk, o2::MCCompLabel lblSeed, std::vector<o2::MCCompLabel>& lblContainerTrd, std::vector<o2::MCCompLabel>& lblContainerMatch, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* trkltLabels) const
235{
236 // Check MC labels of the TRD tracklets attached to the track seed.
237 // Set TRD track label to the most frequent tracklet label.
238 // Fake flag is set if either not all TRD tracklets have most frequent label
239 // or if the seeding label is different from the most frequent TRD label.
240 // In case multiple tracklet labels occur most often we choose the one which matches the label of the seed, or,
241 // if that is not the case one of the most frequent labels is chosen arbitrarily
242 LOG(debug) << "Checking seed with label: " << lblSeed;
243 std::unordered_map<o2::MCCompLabel, unsigned int> labelCounter;
244 int maxOccurences = 0;
245 for (int iLy = 0; iLy < constants::NLAYER; ++iLy) {
246 auto trkltIndex = trk.getTrackletIndex(iLy);
247 if (trkltIndex == -1) {
248 // no tracklet in this layer
249 continue;
250 }
251 const auto& lblsTrklt = trkltLabels->getLabels(trkltIndex);
252 for (const auto lblTrklt : lblsTrklt) {
253 int nOcc = ++labelCounter[lblTrklt];
254 if (nOcc > maxOccurences) {
255 maxOccurences = nOcc;
256 }
257 }
258 }
259 o2::MCCompLabel mostFrequentLabel;
260 for (const auto& [lbl, count] : labelCounter) {
261 LOG(debug) << "Label " << lbl << " occured " << count << " times.";
262 if (count == maxOccurences) {
263 if (lblSeed == lbl) {
264 // most frequent label matches seed label
265 mostFrequentLabel = lbl;
266 mostFrequentLabel.setFakeFlag(maxOccurences != trk.getNtracklets());
267 lblContainerTrd.push_back(mostFrequentLabel);
268 lblContainerMatch.push_back(lblSeed); // is not fake by definition, since the seed label matches the TRD track label
269 return;
270 } else {
271 // maybe multiple labels occur with the same frequency and the next one might match the seed?
272 mostFrequentLabel = lbl;
273 }
274 }
275 }
276 mostFrequentLabel.setFakeFlag(maxOccurences != trk.getNtracklets());
277 lblContainerTrd.push_back(mostFrequentLabel);
278 lblSeed.setFakeFlag(lblSeed != mostFrequentLabel);
279 lblContainerMatch.push_back(lblSeed);
280}
281
282void TRDGlobalTracking::fillTrackTriggerRecord(const std::vector<TrackTRD>& tracks, std::vector<TrackTriggerRecord>& trigRec, const gsl::span<const o2::trd::TriggerRecord>& trackletTrigRec) const
283{
284 // after the tracking is done we assemble here a TrackTriggerRecord similar to the TriggerRecord
285 // which for each TRD trigger stores the index of the first found track and the total number of tracks
286
287 int nTracksCurr = 0;
288 int iTrackFirst = 0;
289 int prevCollisionID = -1;
290
291 for (size_t iTrk = 0; iTrk < tracks.size(); ++iTrk) {
292 const auto& trk = tracks[iTrk];
293 auto collisionID = trk.getCollisionId();
294 if (iTrk == 0) {
295 prevCollisionID = collisionID;
296 }
297 if (collisionID != prevCollisionID) {
298 // we have a track from a new trigger within the same TF
299 trigRec.emplace_back(trackletTrigRec[prevCollisionID].getBCData(), iTrackFirst, nTracksCurr);
300 iTrackFirst += nTracksCurr;
301 prevCollisionID = collisionID;
302 nTracksCurr = 0;
303 }
304 ++nTracksCurr;
305 }
306 if (nTracksCurr > 0) {
307 // this is the last trigger record for this TF, we can take the collision ID from the last track
308 trigRec.emplace_back(trackletTrigRec[tracks.back().getCollisionId()].getBCData(), iTrackFirst, nTracksCurr);
309 }
310}
311
313{
314 mTimer.Start(false);
316 inputTracks.collectData(pc, *mDataRequest);
317 updateTimeDependentParams(pc);
318 storeConfigs(pc);
319 mTriggeredBCFT0.clear();
320 mChainTracking->ClearIOPointers();
321
322 mTPCClusterIdxStruct = &inputTracks.inputsTPCclusters->clusterIndex;
323 mTPCRefitter = std::make_unique<o2::gpu::GPUO2InterfaceRefit>(mTPCClusterIdxStruct, mTPCCorrMaps, o2::base::Propagator::Instance()->getNominalBz(), inputTracks.getTPCTracksClusterRefs().data(), 0, inputTracks.clusterShMapTPC.data(), inputTracks.occupancyMapTPC.data(), inputTracks.occupancyMapTPC.size(), nullptr, o2::base::Propagator::Instance());
324 auto tmpInputContainer = getRecoInputContainer(pc, &mChainTracking->mIOPtrs, &inputTracks, mUseMC);
325 auto tmpContainer = GPUWorkflowHelper::fillIOPtr(mChainTracking->mIOPtrs, inputTracks, mUseMC, nullptr, GTrackID::getSourcesMask("TRD"), mTrkMask, GTrackID::mask_t{GTrackID::MASK_NONE});
326 mTrackletsRaw = inputTracks.getTRDTracklets();
327 mTrackletsCalib = inputTracks.getTRDCalibratedTracklets();
328 mTPCTracksArray = inputTracks.getTPCTracks();
329 if (GTrackID::includesDet(GTrackID::DetID::ITS, mTrkMask)) {
330 // load ITS tracks and clusters needed for the refit
331 mITSTracksArray = inputTracks.getITSTracks();
332 mITSTrackClusIdx = inputTracks.getITSTracksClusterRefs();
333 mITSABRefsArray = inputTracks.getITSABRefs();
334 mITSABTrackClusIdx = inputTracks.getITSABClusterRefs();
335 int nLr = mDataRequest->getITSPerLayer() ? o2::globaltracking::MaxITSLayers : 1;
336 mITSClustersArray.init(nLr);
337 for (int lr = 0; lr < nLr; lr++) { // with a single (monolithic) input all clusters are in the layer slot 0
338 mITSClustersArray.beginLayer(lr);
339 const auto clusITS = inputTracks.getITSClusters(lr);
340 auto pattIt = inputTracks.getITSClustersPatterns(lr).begin();
341 mITSClustersArray.getClusters().reserve(mITSClustersArray.size() + clusITS.size());
342#ifdef ENABLE_UPGRADES
343 if (o2::GlobalParams::Instance().withITS3) {
344 o2::its3::ioutils::convertCompactClusters(clusITS, pattIt, mITSClustersArray.getClusters(), mIT3Dict);
345 } else {
346 o2::its::ioutils::convertCompactClusters(clusITS, pattIt, mITSClustersArray.getClusters(), mITSDict);
347 }
348#else
349 o2::its::ioutils::convertCompactClusters(clusITS, pattIt, mITSClustersArray.getClusters(), mITSDict);
350#endif
351 }
352 mITSClustersArray.finalize();
353 }
354
355 LOGF(info, "There are %i tracklets in total from %i trigger records", mChainTracking->mIOPtrs.nTRDTracklets, mChainTracking->mIOPtrs.nTRDTriggerRecords);
356 LOGF(info, "As input seeds are available: %i ITS-TPC matched tracks and %i TPC tracks", mChainTracking->mIOPtrs.nTracksTPCITSO2, mChainTracking->mIOPtrs.nOutputTracksTPCO2);
357
358 std::vector<o2::MCCompLabel> matchLabelsITSTPC;
359 std::vector<o2::MCCompLabel> trdLabelsITSTPC;
360 std::vector<o2::MCCompLabel> matchLabelsTPC;
361 std::vector<o2::MCCompLabel> trdLabelsTPC;
362 gsl::span<const o2::MCCompLabel> tpcTrackLabels;
363 gsl::span<const o2::MCCompLabel> itstpcTrackLabels;
364 if (mUseMC) {
365 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, mTrkMask)) {
366 itstpcTrackLabels = inputTracks.getTPCITSTracksMCLabels();
367 }
368 if (GTrackID::includesSource(GTrackID::Source::TPC, mTrkMask)) {
369 tpcTrackLabels = inputTracks.getTPCTracksMCLabels();
370 }
371 }
372 mTracker->Reset();
373 mRec->PrepareEvent();
374 mRec->SetupGPUProcessor(mTracker, true);
375
376 // check trigger record filter setting
377 bool foundFilteredTrigger = false;
378 for (unsigned int iTrig = 0; iTrig < mChainTracking->mIOPtrs.nTRDTriggerRecords; ++iTrig) {
379 if (mChainTracking->mIOPtrs.trdTrigRecMask[iTrig] == 0) {
380 foundFilteredTrigger = true;
381 }
382 LOGF(debug, "TRD trigger %u added with time %f", iTrig, mChainTracking->mIOPtrs.trdTriggerTimes[iTrig]);
383 }
384 if (!foundFilteredTrigger && mTrigRecFilter) {
385 static bool warningSent = false;
386 if (!warningSent) {
387 LOG(warning) << "Trigger filtering requested, but no TRD trigger is actually masked. Can be that none needed to be masked or that the setting was not active for the tracklet transformer";
388 warningSent = true;
389 }
390 } else if (foundFilteredTrigger && !mTrigRecFilter) {
391 LOG(error) << "Trigger filtering is not requested, but masked TRD triggers are found. Rerun tracklet transformer without trigger filtering";
392 }
393
394 // load input tracks
395 const auto& trackTune = TrackTuneParams::Instance();
396 LOG(debug) << "Start loading input seeds into TRD tracker";
397 int nTracksLoadedITSTPC = 0;
398 int nTracksLoadedTPC = 0;
399 // load ITS-TPC matched tracks
400 for (unsigned int iTrk = 0; iTrk < mChainTracking->mIOPtrs.nTracksTPCITSO2; ++iTrk) {
401 const auto& trkITSTPC = mChainTracking->mIOPtrs.tracksTPCITSO2[iTrk];
402 GPUTRDTracker::HelperTrackAttributes trkAttribs;
403 trkAttribs.mTime = trkITSTPC.getTimeMUS().getTimeStamp();
404 trkAttribs.mTimeAddMax = trkITSTPC.getTimeMUS().getTimeStampError() * mRec->GetParam().rec.trd.nSigmaTerrITSTPC + mRec->GetParam().rec.trd.addTimeRoadITSTPC;
405 trkAttribs.mTimeSubMax = trkITSTPC.getTimeMUS().getTimeStampError() * mRec->GetParam().rec.trd.nSigmaTerrITSTPC + mRec->GetParam().rec.trd.addTimeRoadITSTPC;
406 GPUTRDTrack trkLoad(trkITSTPC);
407 // no TrackTuneParams for outerParam of ITS-TPC tracks: if needed, they are corrected already in the ITS-TPC matching refit
408 auto trackGID = GTrackID(iTrk, GTrackID::ITSTPC);
409 if (mTracker->LoadTrack(trkLoad, trackGID.getRaw(), true, &trkAttribs)) {
410 continue;
411 }
412 ++nTracksLoadedITSTPC;
413 LOGF(debug, "Loaded ITS-TPC track %i with time %f. Window from %f to %f", nTracksLoadedITSTPC, trkAttribs.mTime, trkAttribs.mTime - trkAttribs.mTimeSubMax, trkAttribs.mTime + trkAttribs.mTimeAddMax);
414 }
415 // load TPC-only tracks
416 for (unsigned int iTrk = 0; iTrk < mChainTracking->mIOPtrs.nOutputTracksTPCO2; ++iTrk) {
417 if (mChainTracking->mIOPtrs.tpcLinkITS && mChainTracking->mIOPtrs.tpcLinkITS[iTrk] != -1) {
418 // this TPC tracks has already been matched to ITS and the ITS-TPC track has already been loaded in the tracker
419 continue;
420 }
421 const auto& trkTpc = mChainTracking->mIOPtrs.outputTracksTPCO2[iTrk];
422 GPUTRDTracker::HelperTrackAttributes trkAttribs;
423 trkAttribs.mTime = trkTpc.getTime0() * mTPCTBinMUS - mTPCTDriftOffset; // account for the eventual time bias for TPC tracks time
424 trkAttribs.mTimeAddMax = trkTpc.getDeltaTFwd() * mTPCTBinMUS;
425 trkAttribs.mTimeSubMax = trkTpc.getDeltaTBwd() * mTPCTBinMUS;
426 if (trkTpc.hasASideClustersOnly()) {
427 trkAttribs.mSide = -1;
428 } else if (trkTpc.hasCSideClustersOnly()) {
429 trkAttribs.mSide = 1;
430 }
431 GPUTRDTrack trkLoad(trkTpc);
432 if (!trackTune.sourceLevelTPC) { // correct TPC tracks only if they were not corrected on the source level
433 if (trackTune.useTPCOuterCorr) {
434 trkLoad.updateParams(trackTune.tpcParOuter);
435 }
436 if (trackTune.tpcCovOuterType != TrackTuneParams::AddCovType::Disable) {
437 trkLoad.updateCov(mCovDiagOuter, trackTune.tpcCovOuterType == TrackTuneParams::AddCovType::WithCorrelations);
438 }
439 }
440 auto trackGID = GTrackID(iTrk, GTrackID::TPC);
441 if (mTracker->LoadTrack(trkLoad, trackGID.getRaw(), true, &trkAttribs)) {
442 continue;
443 }
444 ++nTracksLoadedTPC;
445 LOGF(debug, "Loaded TPC track %i with time %f. Window from %f to %f", nTracksLoadedTPC, trkAttribs.mTime, trkAttribs.mTime - trkAttribs.mTimeSubMax, trkAttribs.mTime + trkAttribs.mTimeAddMax);
446 }
447 LOGF(info, "%i tracks are loaded into the TRD tracker. Out of those %i ITS-TPC tracks and %i TPC tracks", nTracksLoadedITSTPC + nTracksLoadedTPC, nTracksLoadedITSTPC, nTracksLoadedTPC);
448
449 // Load the FT0 triggered BCs if this is requested
450
451 if (mTrkMask[GTrackID::FT0]) { // pile-up tagging was requested
452 auto ft0recPoints = inputTracks.getFT0RecPoints();
453 uint32_t firstOrbit = 0;
454 for (size_t ft0id = 0; ft0id < ft0recPoints.size(); ft0id++) {
455 const auto& f0rec = ft0recPoints[ft0id];
456 if (ft0id == 0) {
457 firstOrbit = f0rec.getInteractionRecord().orbit;
458 }
459 if (o2::ft0::InteractionTag::Instance().isSelected(f0rec)) {
460 uint32_t currentOrbit = f0rec.getInteractionRecord().orbit;
461 mTriggeredBCFT0.push_back(f0rec.getInteractionRecord().bc + (currentOrbit - firstOrbit) * o2::constants::lhc::LHCMaxBunches);
462 }
463 }
464 }
465
466 mTracker->SetFT0TriggeredBC(mTriggeredBCFT0.data(), mTriggeredBCFT0.size());
467
468 // start the tracking
469 // mTracker->DumpTracks();
470 mChainTracking->DoTRDGPUTracking<GPUTRDTrackerKernels::o2Version>(mTracker);
471 // mTracker->DumpTracks();
472
473 // finished tracking, now collect the output
474 std::vector<TrackTRD> tracksOutITSTPC;
475 std::vector<TrackTRD> tracksOutTPC;
476 std::vector<TrackTriggerRecord> trackTrigRecITSTPC;
477 std::vector<TrackTriggerRecord> trackTrigRecTPC;
478 GPUTRDTrack* tracksOutRaw = mTracker->Tracks();
479 std::vector<unsigned int> trackIdxArray(mTracker->NTracks()); // track indices sorted by trigger record index
480 std::iota(trackIdxArray.begin(), trackIdxArray.end(), 0);
481 std::sort(trackIdxArray.begin(), trackIdxArray.end(), [tracksOutRaw](int lhs, int rhs) { return tracksOutRaw[lhs].getCollisionId() < tracksOutRaw[rhs].getCollisionId(); });
482
483 std::vector<std::pair<uint8_t, uint8_t>> pileUpDist;
484 bool ft0Seen = false;
485 if (mTrkMask[GTrackID::FT0]) { // pile-up tagging was requested
486 long maxDiffFwd = mTracker->Param().rec.trd.pileupFwdNBC;
487 long maxDiffBwd = mTracker->Param().rec.trd.pileupBwdNBC;
488 auto ft0recPoints = inputTracks.getFT0RecPoints();
489 auto trdTriggers = tmpInputContainer->mTriggerRecords;
490 ft0Seen = ft0recPoints.size() > 0;
491 pileUpDist.resize(trdTriggers.size(), {0, 0});
492 size_t curFT0 = 0;
493 for (size_t itrd = 0; itrd < trdTriggers.size(); itrd++) {
494 const auto& trig = trdTriggers[itrd];
495 uint8_t fwd = 0, bwd = 0;
496 for (size_t ft0id = curFT0; ft0id < ft0recPoints.size(); ft0id++) {
497 const auto& f0rec = ft0recPoints[ft0id];
498 if (o2::ft0::InteractionTag::Instance().isSelected(f0rec)) {
499 auto bcdiff = trig.getBCData().toLong() - f0rec.getInteractionRecord().toLong();
500 if (bcdiff > maxDiffBwd) {
501 curFT0 = ft0id + 1;
502 continue;
503 }
504 if (bcdiff > 0) { // pre-trigger pileup, maxDiffBwd is guaranteed to be < max uint8_t
505 if (bwd == 0) {
506 bwd = uint8_t(bcdiff);
507 }
508 } else {
509 if (bcdiff < -maxDiffFwd) {
510 break;
511 }
512 fwd = uint8_t(-bcdiff); // post-trigger pileup, maxDiffFwd is guaranteed to be < max uint8_t
513 }
514 }
515 }
516 pileUpDist[itrd] = {bwd, fwd};
517 }
518 }
519
520 int nTrackletsAttached = 0; // only used for debug information
521 int nTracksFailedTPCTRDRefit = 0;
522 int nTracksFailedITSTPCTRDRefit = 0;
523 for (int iTrk = 0; iTrk < mTracker->NTracks(); ++iTrk) {
524 const auto& trdTrack = mTracker->Tracks()[trackIdxArray[iTrk]];
525 if (trdTrack.getCollisionId() < 0) {
526 // skip tracks without TRD tracklets (the collision ID for the TRD tracks is initialized to -1 and only changed if a tracklet is attached to the track)
527 continue;
528 }
529 if (mStrict && (trdTrack.getIsAmbiguous() || trdTrack.getReducedChi2() > mTracker->Param().rec.trd.chi2StrictCut)) {
530 // skip tracks which have another hypothesis close to the best one or which do are above strict chi2 threshold
531 continue;
532 }
533 if (trdTrack.getNtracklets() < mTracker->Param().rec.trd.nTrackletsMin) {
534 continue;
535 }
536 if (trdTrack.getChi2() / trdTrack.getNtracklets() > mTracker->Param().rec.trd.maxChi2Red) {
537 continue;
538 }
539
540 // Find most probable BCs and RMS for pile-up correction and error. Same BC is assumed for all tracklets
541 float maxProb = 0.f;
542 // The uncertainty is the RMS wrt the default correction of all possible corrections weighted by their probability
543 float sumCorr = 0.f;
544 float sumCorr2 = 0.f;
545 float sumProb = 0.f;
546 mTCorrPileUp_weightedMean = 0.f;
547 for (int iBC = 0; iBC < mTriggeredBCFT0.size(); iBC++) {
548 int deltaBC = roundf(mTriggeredBCFT0[iBC] - mChainTracking->mIOPtrs.trdTriggerTimes[trdTrack.getCollisionId()] / o2::constants::lhc::LHCBunchSpacingMUS);
549 if (deltaBC <= mRecoParam.getPileUpRangeBefore() || deltaBC >= mRecoParam.getPileUpRangeAfter()) {
550 continue;
551 }
552 // collect the charges
553 std::array<int, 6> q0;
554 std::array<int, 6> q1;
555 for (int iLy = 0; iLy < NLAYER; iLy++) {
556 int trkltId = trdTrack.getTrackletIndex(iLy);
557 if (trkltId < 0) {
558 q0[iLy] = -1;
559 q1[iLy] = -1;
560 } else {
561 q0[iLy] = mTrackletsRaw[trkltId].getQ0();
562 q1[iLy] = mTrackletsRaw[trkltId].getQ1();
563 }
564 }
565 // get pile-up probability
566 float probBC = mRecoParam.getPileUpProbTrack(deltaBC, q0, q1);
567 sumCorr += probBC * deltaBC;
568 sumCorr2 += probBC * deltaBC * deltaBC;
569 sumProb += probBC;
570 mTCorrPileUp_weightedMean -= deltaBC * probBC;
571 if (probBC > maxProb) {
572 maxProb = probBC;
573 mTCorrPileUp = -deltaBC;
574 }
575 }
576 if (sumProb > 1e-6) {
577 mTErrPileUp2 = sumCorr2 / sumProb - 2 * mTCorrPileUp * sumCorr / sumProb + mTCorrPileUp * mTCorrPileUp;
578 mTCorrPileUp_weightedMean /= sumProb;
579 }
580
581 nTrackletsAttached += trdTrack.getNtracklets();
582 auto trackGID = trdTrack.getRefGlobalTrackId();
583 if (trackGID.includesDet(GTrackID::Source::ITS)) {
584 // this track is from an ITS-TPC seed
585 tracksOutITSTPC.push_back(trdTrack);
586 if (ft0Seen) {
587 tracksOutITSTPC.back().setPileUpDistance(pileUpDist[trdTrack.getCollisionId()].first, pileUpDist[trdTrack.getCollisionId()].second);
588 } else {
589 tracksOutITSTPC.back().setPileUpDistance(mTracker->Param().rec.trd.pileupBwdNBC, mTracker->Param().rec.trd.pileupFwdNBC);
590 }
591 if (!refitITSTPCTRDTrack(tracksOutITSTPC.back(), mChainTracking->mIOPtrs.trdTriggerTimes[trdTrack.getCollisionId()], &inputTracks) || std::isnan(tracksOutITSTPC.back().getSnp())) {
592 tracksOutITSTPC.pop_back();
593 ++nTracksFailedITSTPCTRDRefit;
594 continue;
595 }
596 if (mUseMC) {
597 fillMCTruthInfo(trdTrack, itstpcTrackLabels[trackGID], trdLabelsITSTPC, matchLabelsITSTPC, inputTracks.getTRDTrackletsMCLabels());
598 }
599 if (mWithPID) {
600 tracksOutITSTPC.back().setSignal(mBase->process(trdTrack, inputTracks, false));
601 }
602 } else {
603 // this track is from a TPC-only seed
604 tracksOutTPC.push_back(trdTrack);
605 if (ft0Seen) {
606 tracksOutTPC.back().setPileUpDistance(pileUpDist[trdTrack.getCollisionId()].first, pileUpDist[trdTrack.getCollisionId()].second);
607 } else {
608 tracksOutTPC.back().setPileUpDistance(mTracker->Param().rec.trd.pileupBwdNBC, mTracker->Param().rec.trd.pileupFwdNBC);
609 }
610 if (!refitTPCTRDTrack(tracksOutTPC.back(), mChainTracking->mIOPtrs.trdTriggerTimes[trdTrack.getCollisionId()] - mTCorrPileUp * o2::constants::lhc::LHCBunchSpacingMUS, &inputTracks) || std::isnan(tracksOutTPC.back().getSnp())) {
611 tracksOutTPC.pop_back();
612 ++nTracksFailedTPCTRDRefit;
613 continue;
614 }
615 if (mUseMC) {
616 fillMCTruthInfo(trdTrack, tpcTrackLabels[trackGID], trdLabelsTPC, matchLabelsTPC, inputTracks.getTRDTrackletsMCLabels());
617 }
618 if (mWithPID) {
619 tracksOutTPC.back().setSignal(mBase->process(trdTrack, inputTracks, true));
620 }
621 }
622 }
623
624 fillTrackTriggerRecord(tracksOutITSTPC, trackTrigRecITSTPC, tmpInputContainer->mTriggerRecords);
625 fillTrackTriggerRecord(tracksOutTPC, trackTrigRecTPC, tmpInputContainer->mTriggerRecords);
626
627 LOGF(info, "The TRD tracker found %lu tracks from TPC seeds and %lu tracks from ITS-TPC seeds and attached in total %i tracklets out of %i",
628 tracksOutTPC.size(), tracksOutITSTPC.size(), nTrackletsAttached, mChainTracking->mIOPtrs.nTRDTracklets);
629 LOGF(info, "Number of tracks failed in the refit: TPC-TRD (%i), ITS-TPC-TRD (%i)", nTracksFailedTPCTRDRefit, nTracksFailedITSTPCTRDRefit);
630
632 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, mTrkMask)) {
633 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MATCH_ITSTPC", 0}, tracksOutITSTPC);
634 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "TRGREC_ITSTPC", 0}, trackTrigRecITSTPC);
635 if (mUseMC) {
636 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MCLB_ITSTPC", 0}, matchLabelsITSTPC);
637 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MCLB_ITSTPC_TRD", 0}, trdLabelsITSTPC);
638 }
639 }
640 if (GTrackID::includesSource(GTrackID::Source::TPC, mTrkMask)) {
641 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MATCH_TPC", ss}, tracksOutTPC);
642 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "TRGREC_TPC", ss}, trackTrigRecTPC);
643 if (mUseMC) {
644 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MCLB_TPC", ss}, matchLabelsTPC);
645 pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MCLB_TPC_TRD", ss}, trdLabelsTPC);
646 }
647 }
648
649 mTimer.Stop();
650}
651
652void TRDGlobalTracking::storeConfigs(ProcessingContext& pc)
653{
654 static bool first = true;
655 if (first) {
656 first = false;
659 TMap md;
660 md.SetOwnerKeyValue();
661 md.Add(new TObjString(o2::gpu::internal::GPUConfigurableParamGPUSettingsRecTRD::Instance().getName().c_str()), new TObjString(o2::conf::ConfigurableParam::asJSON(o2::gpu::internal::GPUConfigurableParamGPUSettingsRecTRD::Instance().getName()).c_str()));
662 pc.outputs().snapshot(Output{"META", "TRDTRACKER", 0}, md);
663 }
664 }
665}
666
668{
669 auto propagator = o2::base::Propagator::Instance();
670
671 // refit ITS-TPC-TRD track outwards to outermost TRD space point (start with ITS outer track parameters)
672 auto& outerParam = trk.getOuterParam();
673 auto detRefs = recoCont->getSingleDetectorRefs(trk.getRefGlobalTrackId());
674 int nCl = -1, clEntry = -1, nClRefit = 0, clRefs[14];
675 float chi2Out = 0, timeZErr = 0.;
676 bool pileUpOn = trk.hasPileUpInfo(); // distance to farthest collision within the pileup integration time is set
678 auto matCorr = o2::base::Propagator::MatCorrType(mRec->GetParam().rec.trd.matCorrType);
679 if (detRefs[GTrackID::ITS].isIndexSet()) { // this is ITS track
680 const auto& trkITS = mITSTracksArray[detRefs[GTrackID::ITS]];
681 outerParam = trkITS.getParamOut();
682 outerParam.setPID(recoCont->getTPCITSTrack(trk.getRefGlobalTrackId()).getPID(), true);
683 nCl = trkITS.getNumberOfClusters();
684 clEntry = trkITS.getFirstClusterEntry();
685 chi2Out = trkITS.getChi2();
686 for (int icl = 0; icl < nCl; icl++) { // clusters are stored from outer to inner layers
687 clRefs[icl] = mITSTrackClusIdx[clEntry + icl]; // from outer to inner layer
688 }
689 } else { // this is ITS-AB track, will need to refit including the ITS part
690 const auto& trkITSABref = mITSABRefsArray[detRefs[GTrackID::ITSAB]];
691 nCl = trkITSABref.getNClusters();
692 clEntry = trkITSABref.getFirstEntry();
693 outerParam = recoCont->getTPCITSTrack(trk.getRefGlobalTrackId()); // start from the inner kinematics of ITS-TPC, no need to set PID, will be transferred from ITSTPC track
694 outerParam.resetCovariance(100); // reset covariance to something big
695 // refit
696 for (int icl = 0; icl < nCl; icl++) { // clusters are stored from inner to outer layers
697 const auto& clus = mITSClustersArray[clRefs[nCl - icl - 1] = mITSABTrackClusIdx[clEntry + icl]]; // register in clRefs from outer to inner layer
698 if (!outerParam.rotate(geom->getSensorRefAlpha(clus.getSensorID())) ||
699 !propagator->propagateToX(outerParam, clus.getX(), propagator->getNominalBz(), o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr)) {
700 break;
701 }
702 chi2Out += outerParam.getPredictedChi2(clus);
703 if (!outerParam.update(clus)) {
704 break;
705 }
706 nClRefit++;
707 }
708 if (nClRefit != nCl) {
709 LOG(debug) << "ITS-AB refit outward failed";
710 return false;
711 }
712 }
713 // propagate to TPC inner boundary
714 float xtogo = 0;
715 if (!outerParam.getXatLabR(o2::constants::geom::XTPCInnerRef, xtogo, propagator->getNominalBz(), o2::track::DirOutward) ||
716 !propagator->PropagateToXBxByBz(outerParam, xtogo, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr)) {
717 LOG(debug) << "Propagation to inner TPC boundary X=" << xtogo << " failed, Xtr=" << outerParam.getX() << " snp=" << outerParam.getSnp();
718 return false;
719 }
720 int retVal = mTPCRefitter->RefitTrackAsTrackParCov(outerParam, mTPCTracksArray[detRefs[GTrackID::TPC]].getClusterRef(), timeTRD * mTPCTBinMUSInv, &chi2Out, true, false); // outward refit
721 if (retVal < 0) {
722 LOG(debug) << "TPC refit outwards failed";
723 return false;
724 }
725
726 if (!refitTRDTrack(trk, chi2Out, false, false)) {
727 LOG(debug) << "TRD refit outwards failed";
728 return false;
729 }
730 // refit ITS-TPC-TRD track inwards to innermost ITS cluster
731 // here we also calculate the LT integral for matching to TOF
732 float chi2In = 0.f;
733 if (!refitTRDTrack(trk, chi2In, true, false)) {
734 LOG(debug) << "TRD refit inwards failed";
735 return false;
736 }
737 auto posStart = trk.getXYZGlo();
738 retVal = mTPCRefitter->RefitTrackAsTrackParCov(trk, mTPCTracksArray[detRefs[GTrackID::TPC]].getClusterRef(), timeTRD * mTPCTBinMUSInv, &chi2In, false, false); // inward refit
739 if (retVal < 0) {
740 LOG(debug) << "TPC refit inwards failed";
741 return false;
742 }
743 // if for some reason the track was overshoot over the inner field cage, bring it back w/o material correction and LTintegral update
744 if (trk.getX() < o2::constants::geom::XTPCInnerRef &&
745 !propagator->PropagateToXBxByBz(trk, o2::constants::geom::XTPCInnerRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, o2::base::Propagator::MatCorrType::USEMatCorrNONE)) {
746 LOG(debug) << "BACK-Propagationto inner boundary failed";
747 return false;
748 }
749 auto posEnd = trk.getXYZGlo();
750 auto lInt = propagator->estimateLTIncrement(trk, posStart, posEnd);
751 trk.getLTIntegralOut().addStep(lInt, trk.getQ2P2());
752 // trk.getLTIntegralOut().addX2X0(lInt * mTPCmeanX0Inv); // do we need to account for the material budget here? probably
753
754 const auto& trackTune = TrackTuneParams::Instance();
755 if (trackTune.tpcCovInnerType != TrackTuneParams::AddCovType::Disable || trackTune.useTPCInnerCorr) { // if needed, correct TPC track in the middle of TPC->ITS refit
756 if (!propagator->PropagateToXBxByBz(trk, o2::constants::geom::XTPCInnerRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr, &trk.getLTIntegralOut())) {
757 LOG(debug) << "Propagation to TPC inner reference X for ITS refit inwards failed";
758 return false;
759 }
760 if (!trackTune.useTPCInnerCorr) {
761 trk.updateParams(trackTune.tpcParInner);
762 }
763 if (trackTune.tpcCovInnerType != TrackTuneParams::AddCovType::Disable) {
764 trk.updateCov(mCovDiagInner, trackTune.tpcCovInnerType == TrackTuneParams::AddCovType::WithCorrelations);
765 }
766 }
767
768 nClRefit = 0;
769 for (int icl = 0; icl < nCl; icl++) {
770 const auto& clus = mITSClustersArray[clRefs[icl]];
771 if (!trk.rotate(geom->getSensorRefAlpha(clus.getSensorID())) ||
772 // note: here we also calculate the L,T integral (in the inward direction, but this is irrelevant)
773 // note: we should eventually use TPC pid in the refit (TODO)
774 // note: since we are at small R, we can use field BZ component at origin rather than 3D field
775 !propagator->propagateToX(trk, clus.getX(), propagator->getNominalBz(), o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr, &trk.getLTIntegralOut())) {
776 break;
777 }
778 chi2In += trk.getPredictedChi2(clus);
779 if (!trk.update(clus)) {
780 break;
781 }
782 nClRefit++;
783 }
784 if (nClRefit != nCl) {
785 LOG(debug) << "ITS refit inwards failed";
786 return false;
787 }
788 // We need to update the LTOF integral by the distance to the "primary vertex"
789 // We want to leave the track at the the position of its last update, so we do a fast propagation on the TrackPar copy of trfit,
790 // and since for the LTOF calculation the material effects are irrelevant, we skip material corrections
791 const o2::dataformats::VertexBase vtxDummy; // at the moment using dummy vertex: TODO use MeanVertex constraint instead
792 o2::track::TrackPar trkPar(trk);
793 if (!propagator->propagateToDCA(vtxDummy.getXYZ(), trkPar, propagator->getNominalBz(), o2::base::Propagator::MAX_STEP, matCorr, nullptr, &trk.getLTIntegralOut())) {
794 LOG(error) << "LTOF integral might be incorrect";
795 }
796 return true;
797}
798
800{
801 auto propagator = o2::base::Propagator::Instance();
802 auto matCorr = o2::base::Propagator::MatCorrType(mRec->GetParam().rec.trd.matCorrType);
803 // refit TPC-TRD track outwards toward outermost TRD space point
804 auto& outerParam = trk.getOuterParam();
805 auto detRefs = recoCont->getSingleDetectorRefs(trk.getRefGlobalTrackId());
806 outerParam = trk;
807 float chi2Out = 0, timeZErr = 0.;
808 bool pileUpOn = trk.hasPileUpInfo(); // distance to farthest collision within the pileup integration time is set
809 int retVal = mTPCRefitter->RefitTrackAsTrackParCov(outerParam, mTPCTracksArray[detRefs[GTrackID::TPC]].getClusterRef(), timeTRD * mTPCTBinMUSInv, &chi2Out, true, false); // outward refit
810 if (retVal < 0) {
811 LOG(debug) << "TPC refit outwards failed";
812 return false;
813 }
814 if (pileUpOn) { // account pileup time uncertainty in Z errors
815 // timeZErr = mTPCVdrift * trk.getPileUpTimeErrorMUS();
816 timeZErr = mTPCVdrift * mTPCVdrift * mTErrPileUp2;
817 outerParam.updateCov(timeZErr, o2::track::CovLabels::kSigZ2);
818 }
819 if (!refitTRDTrack(trk, chi2Out, false, true)) {
820 LOG(debug) << "TRD refit outwards failed";
821 return false;
822 }
823
824 // refit TPC-TRD track inwards toward inner TPC radius
825 float chi2In = 0.f;
826 if (!refitTRDTrack(trk, chi2In, true, true)) {
827 LOG(debug) << "TRD refit inwards failed";
828 return false;
829 }
830 auto posStart = trk.getXYZGlo();
831 retVal = mTPCRefitter->RefitTrackAsTrackParCov(trk, mTPCTracksArray[detRefs[GTrackID::TPC]].getClusterRef(), timeTRD * mTPCTBinMUSInv, &chi2In, false, false); // inward refit
832 if (retVal < 0) {
833 LOG(debug) << "TPC refit inwards failed";
834 return false;
835 }
836 if (pileUpOn) { // account pileup time uncertainty in Z errors
837 trk.updateCov(timeZErr, o2::track::CovLabels::kSigZ2);
838 }
839 // if for some reason the track was overshoot over the inner field cage, bring it back w/o material correction and LTintegral update
840 if (trk.getX() < o2::constants::geom::XTPCInnerRef &&
841 !propagator->PropagateToXBxByBz(trk, o2::constants::geom::XTPCInnerRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, o2::base::Propagator::MatCorrType::USEMatCorrNONE)) {
842 LOG(debug) << "BACK-Propagationto inner boundary failed";
843 return false;
844 }
845 auto posEnd = trk.getXYZGlo();
846 auto lInt = propagator->estimateLTIncrement(trk, posStart, posEnd);
847 trk.getLTIntegralOut().addStep(lInt, trk.getQ2P2());
848 // trk.getLTIntegralOut().addX2X0(lInt * mTPCmeanX0Inv); // do we need to account for the material budget here? probably?
849
850 if (!propagator->PropagateToXBxByBz(trk, o2::constants::geom::XTPCInnerRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr, &trk.getLTIntegralOut())) {
851 LOG(debug) << "Final propagation to inner TPC radius failed (not removing the track because of this)";
852 }
853
854 const auto& trackTune = TrackTuneParams::Instance(); // if needed, correct the track after inward TPC refit
855 if (!trackTune.useTPCInnerCorr) {
856 trk.updateParams(trackTune.tpcParInner);
857 }
858 if (trackTune.tpcCovInnerType != TrackTuneParams::AddCovType::Disable) {
859 trk.updateCov(mCovDiagInner, trackTune.tpcCovInnerType == TrackTuneParams::AddCovType::WithCorrelations);
860 }
861
862 propagator->estimateLTFast(trk.getLTIntegralOut(), trk); // guess about initial value for the track integral from the origin
863 return true;
864}
865
866bool TRDGlobalTracking::refitTRDTrack(TrackTRD& trk, float& chi2, bool inwards, bool tpcSA)
867{
868 auto propagator = o2::base::Propagator::Instance();
869
870 int lyStart = inwards ? NLAYER - 1 : 0;
871 int direction = inwards ? -1 : 1;
872 int lyEnd = inwards ? -1 : NLAYER;
873 o2::track::TrackParCov* trkParam = nullptr;
874 o2::track::TrackLTIntegral* tofL = nullptr;
875 auto matCorr = o2::base::Propagator::MatCorrType(mRec->GetParam().rec.trd.matCorrType);
876
877 if (inwards) {
878 trkParam = &trk;
879 tofL = &trk.getLTIntegralOut();
880 } else {
881 trkParam = &trk.getOuterParam();
882 trkParam->setUserField(trk.getUserField()); // pileup timing info
883
884 const auto& trackTune = TrackTuneParams::Instance();
885 if ((trackTune.useTPCOuterCorr || trackTune.tpcCovOuterType != TrackTuneParams::AddCovType::Disable) &&
886 (!tpcSA || !trackTune.sourceLevelTPC)) { // for TPC standalone make sure correction was not applied ad the source level
887 if (!propagator->PropagateToXBxByBz(*trkParam, o2::constants::geom::XTPCOuterRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr)) {
888 LOG(debug) << "Propagation to TPC outer reference X for TRD outward refit failed";
889 return false;
890 }
891 if (trackTune.useTPCOuterCorr) {
892 trkParam->updateParams(trackTune.tpcParOuter);
893 }
894 if (trackTune.tpcCovOuterType != TrackTuneParams::AddCovType::Disable) {
895 trkParam->updateCov(mCovDiagOuter, trackTune.tpcCovOuterType == TrackTuneParams::AddCovType::WithCorrelations);
896 }
897 }
898 }
899
900 if (inwards) {
901 // reset covariance to something big for inwards refit
902 trkParam->resetCovariance(100);
903 }
904 for (int iLy = lyStart; iLy != lyEnd; iLy += direction) {
905 int trkltId = trk.getTrackletIndex(iLy);
906 if (trkltId < 0) {
907 continue;
908 }
909 int trkltDet = mTrackletsRaw[trkltId].getDetector();
910 int trkltSec = trkltDet / (NLAYER * NSTACK);
911 if (trkltSec != o2::math_utils::angle2Sector(trkParam->getAlpha())) {
912 if (!trkParam->rotate(o2::math_utils::sector2Angle(trkltSec))) {
913 LOGF(debug, "Track at alpha=%.2f could not be rotated in tracklet coordinate system with alpha=%.2f", trkParam->getAlpha(), o2::math_utils::sector2Angle(trkltSec));
914 return false;
915 }
916 }
917 if (!propagator->PropagateToXBxByBz(*trkParam, mTrackletsCalib[trkltId].getX(), o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr, tofL)) {
918 LOGF(debug, "Track propagation failed in layer %i (pt=%f, xTrk=%f, xToGo=%f)", iLy, trkParam->getPt(), trkParam->getX(), mTrackletsCalib[trkltId].getX());
919 return false;
920 }
921 const PadPlane* pad = Geometry::instance()->getPadPlane(trkltDet);
922 float tilt = tan(TMath::DegToRad() * pad->getTiltingAngle()); // tilt is signed! and returned in degrees
923 float dyTiltCorr = tilt * trkParam->getTgl() * Geometry::instance()->cdrHght();
924 float tiltCorrUp = tilt * (mTrackletsCalib[trkltId].getZ() - trkParam->getZ());
925 float zPosCorrUp = mTrackletsCalib[trkltId].getZ() + mRecoParam.getZCorrCoeffNRC() * trkParam->getTgl();
926 float padLength = pad->getRowSize(mTrackletsRaw[trkltId].getPadRow());
927 if (!((trkParam->getSigmaZ2() < (padLength * padLength / 12.f)) && (std::fabs(mTrackletsCalib[trkltId].getZ() - trkParam->getZ()) < padLength))) {
928 tiltCorrUp = 0.f;
929 }
930
931 // conversion from slope in pad per time bin to slope in cm per BC = tracklets[trkltIdx].getSlopeFloat() * padWidth / BCperTimeBin
932 float slopeFactor = mTrackletsRaw[trkltId].getSlopeFloat() * pad->getWidthIPad() / 4.f;
933 // float yCorrPileUp = mTCorrPileUp * slopeFactor;
934 float yCorrPileUp = mTCorrPileUp_weightedMean * slopeFactor;
935 float yAddErrPileUp2 = mTErrPileUp2 * slopeFactor * slopeFactor;
936 float yPosCorrUp = mTrackletsCalib[trkltId].getY() - tiltCorrUp + yCorrPileUp;
937
938 int nTrackletsChamber = mTracker->GetNtrackletsChamber(trk.getCollisionId(), trkltDet);
939 float angularPull = (mTrackletsCalib[trkltId].getDy() + dyTiltCorr - mRecoParam.convertAngleToDy(trkParam->getSnp())) / std::sqrt(mRecoParam.getDyRes(trkParam->getSnp(), nTrackletsChamber));
940
941 // Correction of y position based on angular pull
942 if (mRec->GetParam().rec.trd.useAngularPull == 3 || mRec->GetParam().rec.trd.useAngularPull == 4) {
943 float corrPull = -angularPull * mRecoParam.getCorrYDy(trkParam->getSnp());
944 yPosCorrUp += corrPull;
945 }
946
947 std::array<float, 2> trkltPosUp{yPosCorrUp, zPosCorrUp};
948 std::array<float, 3> trkltCovUp;
949 mRecoParam.recalcTrkltCov(tilt, trkParam->getSnp(), pad->getRowSize(mTrackletsRaw[trkltId].getPadRow()), trkltCovUp, (mRec->GetParam().rec.trd.useAngularPull != 0 ? angularPull : 0.), nTrackletsChamber);
950 trkltCovUp[0] += yAddErrPileUp2;
951
952 chi2 += trkParam->getPredictedChi2(trkltPosUp, trkltCovUp);
953 if (!trkParam->update(trkltPosUp, trkltCovUp)) {
954 LOGF(debug, "Failed to update track with space point in layer %i", iLy);
955 return false;
956 }
957 }
958 if (!inwards) { // to make sure that the inward fit will start from the trkParam
959 ((o2::track::TrackParCov&)trk) = *trkParam;
960 } else { // propagate to the TPC outer reference
961 if (!propagator->PropagateToXBxByBz(*trkParam, o2::constants::geom::XTPCOuterRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr, tofL)) {
962 LOG(debug) << "Propagation to TPC outer reference X after TRD inward refit failed";
963 return false;
964 }
965 // make sure we are in the correct sector
966 int sector = o2::math_utils::angle2Sector(trkParam->getPhiPos());
967 if (sector != o2::math_utils::angle2Sector(trkParam->getAlpha()) &&
968 !trkParam->rotate(o2::math_utils::sector2Angle(sector)) &&
969 !propagator->PropagateToXBxByBz(*trkParam, o2::constants::geom::XTPCOuterRef, o2::base::Propagator::MAX_SIN_PHI, o2::base::Propagator::MAX_STEP, matCorr, tofL)) {
970 LOG(debug) << "Propagation/rotation to TPC outer reference X after TRD inward refit failed " << trkParam->asString();
971 return false;
972 }
973 }
974 return true;
975}
976
978{
979 LOGF(info, "TRD global tracking total timing: Cpu: %.3e Real: %.3e s in %d slots",
980 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
981}
982
983DataProcessorSpec getTRDGlobalTrackingSpec(bool useMC, GTrackID::mask_t src, bool trigRecFilterActive, bool strict, bool withPID, PIDPolicy policy, bool requestCTPLumi, bool itsStag)
984{
985 std::vector<OutputSpec> outputs;
987 std::shared_ptr<DataRequest> dataRequest = std::make_shared<DataRequest>();
988 dataRequest->setITSPerLayer(itsStag);
989 if (strict) {
990 dataRequest->setMatchingInputStrict();
991 }
992 auto trkSrc = src;
993 trkSrc |= GTrackID::getSourcesMask("TPC");
994 dataRequest->requestClusters(GTrackID::getSourcesMask("TRD"), useMC);
995 dataRequest->requestTPCClusters(false); // only needed for refit, don't care about labels
996 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, src)) {
997 // ITS clusters are only needed if we match to ITS-TPC tracks
998#ifdef ENABLE_UPGRADES
999 if (o2::GlobalParams::Instance().withITS3) {
1000 dataRequest->requestIT3Clusters(false); // only needed for refit, don't care about labels
1001 } else {
1002 dataRequest->requestITSClusters(false); // only needed for refit, don't care about labels
1003 }
1004#else
1005 dataRequest->requestITSClusters(false); // only needed for refit, don't care about labels
1006#endif
1007 trkSrc |= GTrackID::getSourcesMask("ITS");
1008 }
1009 dataRequest->requestTracks(trkSrc, useMC);
1010 auto& inputs = dataRequest->inputs;
1011 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
1012 false, // GRPECS=true
1013 false, // GRPLHCIF
1014 true, // GRPMagField
1015 true, // askMatLUT
1017 inputs,
1018 true);
1020 Options opts;
1021
1022 dataRequest->inputs.emplace_back("corrMap", o2::header::gDataOriginTPC, "TPCCORRMAP", 0, Lifetime::Timeframe);
1023
1024 if (requestCTPLumi) {
1025 dataRequest->inputs.emplace_back("lumiCTP", o2::header::gDataOriginCTP, "LUMICTP", 0, Lifetime::Timeframe);
1026 }
1027
1028 // Request PID policy data
1029 if (withPID) {
1030 // request policy
1031 switch (policy) {
1032 case PIDPolicy::LQ1D:
1033 inputs.emplace_back("lq1dlut", "TRD", "LQ1D", 0, Lifetime::Condition, ccdbParamSpec("TRD/PID/LQ1D"));
1034 break;
1035 case PIDPolicy::LQ2D:
1036 inputs.emplace_back("lq2dlut", "TRD", "LQ2D", 0, Lifetime::Condition, ccdbParamSpec("TRD/PID/LQ2D"));
1037 break;
1038 case PIDPolicy::LQ3D:
1039 inputs.emplace_back("lq3dlut", "TRD", "LQ3D", 0, Lifetime::Condition, ccdbParamSpec("TRD/PID/LQ3D"));
1040 break;
1041#ifdef TRDPID_WITH_ONNX
1042 case PIDPolicy::XGB:
1043 inputs.emplace_back("xgb", "TRD", "XGB", 0, Lifetime::Condition, ccdbParamSpec("TRD_test/PID_new/xgb"));
1044 break;
1045 case PIDPolicy::PY:
1046 inputs.emplace_back("py", "TRD", "py", 0, Lifetime::Condition, ccdbParamSpec("TRD_test/PID_new/py"));
1047 break;
1048#endif
1049 case PIDPolicy::Dummy:
1050 break;
1051 default:
1052 throw std::runtime_error("Unable to load requested PID policy data!");
1053 }
1054 // request calibration data
1055 inputs.emplace_back("localgainfactors", "TRD", "LOCALGAINFACTORS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/LocalGainFactor"));
1056 }
1057
1058 // request list of bad chambers and masked pads to estimate better the number of findable tracklets
1059 inputs.emplace_back("chamberstatus", "TRD", "CHAMBERSTATUS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/DCSDPsFedChamberStatus"));
1060 // inputs.emplace_back("padstatus", "TRD", "PADSTATUS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/PadStatus"));
1061
1062 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, src)) {
1063 outputs.emplace_back(o2::header::gDataOriginTRD, "MATCH_ITSTPC", 0, Lifetime::Timeframe);
1064 outputs.emplace_back(o2::header::gDataOriginTRD, "TRGREC_ITSTPC", 0, Lifetime::Timeframe);
1065 if (useMC) {
1066 outputs.emplace_back(o2::header::gDataOriginTRD, "MCLB_ITSTPC", 0, Lifetime::Timeframe);
1067 outputs.emplace_back(o2::header::gDataOriginTRD, "MCLB_ITSTPC_TRD", 0, Lifetime::Timeframe);
1068 }
1069 if (withPID) {
1070 outputs.emplace_back(o2::header::gDataOriginTRD, "TRDPID_ITSTPC", 0, Lifetime::Timeframe);
1071 }
1072 }
1073 if (GTrackID::includesSource(GTrackID::Source::TPC, src)) {
1074 outputs.emplace_back(o2::header::gDataOriginTRD, "MATCH_TPC", ss, Lifetime::Timeframe);
1075 outputs.emplace_back(o2::header::gDataOriginTRD, "TRGREC_TPC", ss, Lifetime::Timeframe);
1076 if (useMC) {
1077 outputs.emplace_back(o2::header::gDataOriginTRD, "MCLB_TPC", ss, Lifetime::Timeframe);
1078 outputs.emplace_back(o2::header::gDataOriginTRD, "MCLB_TPC_TRD", ss, Lifetime::Timeframe);
1079 }
1080 if (trigRecFilterActive) {
1081 LOG(info) << "Matching to TPC-only tracks requested, but IRs without ITS contribution are filtered out (used strict matching mode to constrain TPC tracks before matching to ITS)";
1082 }
1083 }
1084
1085 outputs.emplace_back("META", "TRDTRACKER", 0, Lifetime::Sporadic);
1086
1087 std::string processorName = o2::utils::Str::concat_string("trd-globaltracking", GTrackID::getSourcesNames(src));
1088 std::regex reg("[,\\[\\]]+");
1089 processorName = regex_replace(processorName, reg, "_");
1090
1091 return DataProcessorSpec{
1092 processorName,
1093 inputs,
1094 outputs,
1095 AlgorithmSpec{adaptFromTask<TRDGlobalTracking>(useMC, withPID, policy, dataRequest, ggRequest, src, trigRecFilterActive, strict, requestCTPLumi)},
1096 opts};
1097}
1098
1099} // namespace trd
1100} // namespace o2
std::string getName(const TDataMember *dm, int index, int size)
o2d::GlobalTrackID GTrackID
Definition of the ITSMFT cluster.
Global TRD definitions and constants.
Definition of the Names Generator class.
Definition of the GeometryManager class.
std::ostringstream debug
Definition of the FIT RecPoints class.
unsigned char uint8_t
unsigned int uint32_t
o2::raw::RawFileWriter * raw
int32_t retVal
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in tan(phi) dependence of tracklet error due to radial misalignment(centered at 0 angle)") AddOptionRTC(maxChi2Red
TRD Tracklet word for GPU tracker - 32bit tracklet info + half chamber ID + index.
Some ALICE geometry constants of common interest.
char error[CURL_ERROR_SIZE]
Definition of the GeometryTGeo class.
Definition of the ITS/MFT clusterer settings.
float chi2
std::vector< o2::its::TrackITS > tracks
Definition of the parameter class for the detector electronics.
Declarations of the helper class for clusters / roadwidth matching.
Struct for input data required by TRD tracking workflow.
class to create TPC fast transformation
Result of refitting TPC-ITS matched track.
Configurable params for tracks ad hoc tuning.
Helper class to obtain TPC clusters / digits / labels from DPL.
void clear()
Definition bitfield.h:54
void setFakeFlag(bool v=true)
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string getConfigOutputFileName(const std::string &procName, const std::string &confName="", bool json=true)
Definition NameConf.cxx:138
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:180
static std::string asJSON(std::string const &keyOnly="")
static void write(std::string const &filename, std::string const &keyOnly="")
static mask_t getSourcesMask(const std::string_view srcList)
static std::string getSourcesNames(mask_t srcm)
A container to hold and manage MC truth information/labels.
gsl::span< TruthElement > getLabels(uint32_t dataindex)
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void SetTRDGeometry(std::unique_ptr< o2::trd::GeometryFlat > &&geo)
void SetO2Propagator(const o2::base::Propagator *prop)
void SetTRDRecoParam(std::unique_ptr< GPUTRDRecoParam > &&par)
int32_t DoTRDGPUTracking(T *externalInstance=nullptr)
GPUTrackingInOutPointers & mIOPtrs
static float getNominalGPUBz(T &src)
void SetupGPUProcessor(T *proc, bool allocate)
void RegisterGPUProcessor(T *proc, bool deviceSlave)
void SetSettings(float solenoidBzNominalGPU, const GPURecoStepConfiguration *workflow=nullptr)
static GPUReconstruction * CreateInstance(const GPUSettingsDeviceBackend &cfg)
const GPUParam & GetParam() const
const GPUSettingsProcessing & GetProcessingSettings() const
void init(float bz, const GPUSettingsRec *rec=nullptr)
Load parameterization for given magnetic field.
void SetNCandidates(int32_t n)
static std::shared_ptr< const tmpDataContainer > fillIOPtr(GPUTrackingInOutPointers &ioPtr, const o2::globaltracking::RecoContainer &recoCont, bool useMC, const GPUCalibObjectsConst *calib=nullptr, GID::mask_t maskCl=GID::MASK_ALL, GID::mask_t maskTrk=GID::MASK_ALL, GID::mask_t maskMatch=GID::MASK_ALL)
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
void beginLayer(int lr)
to be called once all the layers were filled
void init(int nLr)
< prepare for filling nLr layer slots, discarding the previous content
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
static Geometry * instance()
Definition Geometry.h:33
void fillMCTruthInfo(const TrackTRD &trk, o2::MCCompLabel lblSeed, std::vector< o2::MCCompLabel > &lblContainerTrd, std::vector< o2::MCCompLabel > &lblContainerMatch, const o2::dataformats::MCTruthContainer< o2::MCCompLabel > *trkltLabels) const
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
bool refitTRDTrack(TrackTRD &trk, float &chi2, bool inwards, bool tpcSA)
void init(o2::framework::InitContext &ic) final
bool refitITSTPCTRDTrack(TrackTRD &trk, float timeTRD, o2::globaltracking::RecoContainer *recoCont)
void fillTrackTriggerRecord(const std::vector< TrackTRD > &tracks, std::vector< TrackTriggerRecord > &trigRec, const gsl::span< const o2::trd::TriggerRecord > &trackletTrigRec) const
bool refitTPCTRDTrack(TrackTRD &trk, float timeTRD, o2::globaltracking::RecoContainer *recoCont)
GLenum src
Definition glcorearb.h:1767
GLint GLsizei count
Definition glcorearb.h:399
GLint first
Definition glcorearb.h:399
constexpr o2::header::DataOrigin gDataOriginCTP
Definition DataHeader.h:567
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:579
constexpr o2::header::DataOrigin gDataOriginTRD
Definition DataHeader.h:580
constexpr float XTPCOuterRef
reference radius to propagate outer TPC track
constexpr float XTPCInnerRef
reference radius at which TPC provides the tracks
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
constexpr int MaxITSLayers
GPUTRDTracker_t< GPUTRDTrack, GPUTRDPropagator > GPUTRDTracker
Definition GPUTRDDef.h:58
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const o2::its3::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:25
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const itsmft::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:35
int angle2Sector(float phi)
Definition Utils.h:183
float sector2Angle(int sect)
Definition Utils.h:193
TrackParCovF TrackParCov
Definition Track.h:33
std::unique_ptr< PIDBase > getTRDPIDPolicy(PIDPolicy policy)
Factory function to create a PID policy.
Definition PIDBase.cxx:63
framework::DataProcessorSpec getTRDGlobalTrackingSpec(bool useMC, o2::dataformats::GlobalTrackID::mask_t src, bool trigRecFilterActive, bool strict, bool withPID, PIDPolicy policy, bool requestCTPLumi, bool itsStag)
create a processor spec
PIDPolicy
Option for available PID policies.
Definition PID.h:29
@ LQ3D
3-Dimensional Likelihood model
@ LQ2D
2-Dimensional Likelihood model
@ Dummy
Dummy object outputting -1.f.
@ LQ1D
1-Dimensional Likelihood model
auto getRecoInputContainer(o2::framework::ProcessingContext &pc, o2::gpu::GPUTrackingInOutPointers *ptrs, const o2::globaltracking::RecoContainer *inputTracks, bool mc=false)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string name
The name of the associated DataProcessorSpec.
Definition DeviceSpec.h:50
size_t inputTimesliceId
The time pipelining id of this particular device.
Definition DeviceSpec.h:68
GlobalIDSet getSingleDetectorRefs(GTrackID gidx) const
gsl::span< const o2::trd::CalibratedTracklet > getTRDCalibratedTracklets() const
auto getITSClustersPatterns(int layer=0) const
const o2::dataformats::MCTruthContainer< o2::MCCompLabel > * getTRDTrackletsMCLabels() const
gsl::span< const unsigned char > clusterShMapTPC
externally set TPC clusters sharing map
const o2::dataformats::TrackTPCITS & getTPCITSTrack(GTrackID gid) const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
std::unique_ptr< o2::tpc::internal::getWorkflowTPCInput_ret > inputsTPCclusters
gsl::span< const unsigned int > occupancyMapTPC
externally set TPC clusters occupancy map
auto getITSClusters(int layer=0) const
gsl::span< const o2::trd::Tracklet64 > getTRDTracklets() const
gpudatatypes::RecoStepField steps
gpudatatypes::InOutTypeField inputs
gpudatatypes::InOutTypeField outputs
const o2::dataformats::TrackTPCITS * tracksTPCITSO2
const o2::tpc::TrackTPC * outputTracksTPCO2
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"