36 mCosmicsProcessing =
false;
37 std::vector<VertexingParameters> vertParams;
38 std::vector<TrackingParameters> trackParams;
46 LOGP(info,
"Tracking mode not set, trying to fetch it from configurable params to: {}",
asString(mMode));
49 trackParams.resize(trackConf.doUPCIteration ? 4 : 3);
51 trackParams[1].TrackletMinPt = 0.2f;
52 trackParams[1].CellDeltaTanLambdaSigma *= 2.;
53 trackParams[2].TrackletMinPt = 0.1f;
54 trackParams[2].CellDeltaTanLambdaSigma *= 4.;
56 trackParams[0].MinPt[0] = 1.f / 12;
58 trackParams[1].MinPt[0] = 1.f / 12;
60 trackParams[2].MinTrackLength = 4;
61 trackParams[2].MinPt[0] = 1.f / 12;
62 trackParams[2].MinPt[1] = 1.f / 5;
63 trackParams[2].MinPt[2] = 1.f / 1;
64 trackParams[2].MinPt[3] = 1.f / 6;
66 trackParams[2].StartLayerMask = (1 << 6) + (1 << 3);
68 trackParams[3].MinTrackLength = 4;
69 trackParams[3].TrackletMinPt = 0.1f;
70 trackParams[3].CellDeltaTanLambdaSigma *= 4.;
71 trackParams[3].DeltaROF = 0;
73 for (
size_t ip = 0; ip < trackParams.size(); ip++) {
74 auto&
param = trackParams[ip];
77 param.CellsPerClusterLimit = 1.e3f;
78 param.TrackletsPerClusterLimit = 1.e3f;
80 if (ip < trackConf.MaxIter) {
81 if (trackConf.startLayerMask[ip] > 0) {
82 trackParams[2].StartLayerMask = trackConf.startLayerMask[ip];
84 if (trackConf.minTrackLgtIter[ip] > 0) {
85 param.MinTrackLength = trackConf.minTrackLgtIter[ip];
87 for (
int ilg = trackConf.MaxTrackLength; ilg >= trackConf.MinTrackLength; ilg--) {
88 int lslot0 = (trackConf.MaxTrackLength - ilg), lslot = lslot0 + ip * (trackConf.MaxTrackLength - trackConf.MinTrackLength + 1);
89 if (trackConf.minPtIterLgt[lslot] > 0.) {
90 param.MinPt[lslot0] = trackConf.minPtIterLgt[lslot];
95 LOGP(info,
"Initializing tracker in async. phase reconstruction with {} passes for tracking and {}/{} for vertexing", trackParams.size(),
o2::its::VertexerParamConfig::Instance().nIterations, vertParams.size());
96 vertParams[1].phiCut = 0.015f;
97 vertParams[1].tanLambdaCut = 0.015f;
98 vertParams[1].vertPerRofThreshold = 0;
99 vertParams[1].deltaRof = 0;
101 trackParams.resize(1);
102 trackParams[0].ZBins = 64;
103 trackParams[0].PhiBins = 32;
104 trackParams[0].MinTrackLength = 4;
105 LOGP(info,
"Initializing tracker in sync. phase reconstruction with {} passes", trackParams.size());
106 vertParams.resize(1);
108 mCosmicsProcessing =
true;
109 mRunVertexer =
false;
110 trackParams.resize(1);
111 trackParams[0].MinTrackLength = 4;
112 trackParams[0].CellDeltaTanLambdaSigma *= 10;
113 trackParams[0].PhiBins = 4;
114 trackParams[0].ZBins = 16;
115 trackParams[0].PVres = 1.e5f;
116 trackParams[0].MaxChi2ClusterAttachment = 60.;
117 trackParams[0].MaxChi2NDF = 40.;
118 trackParams[0].TrackletsPerClusterLimit = 100.;
119 trackParams[0].CellsPerClusterLimit = 100.;
120 LOGP(info,
"Initializing tracker in reconstruction for cosmics with {} passes", trackParams.size());
123 throw std::runtime_error(fmt::format(
"Unsupported ITS tracking mode {:s} ",
asString(mMode)));
126 for (
auto&
params : trackParams) {
130 for (
size_t ip = 0; ip < trackParams.size(); ip++) {
131 auto&
param = trackParams[ip];
132 param.TrackletMinPt *= bFactor;
133 for (
int ilg = trackConf.MaxTrackLength; ilg >= trackConf.MinTrackLength; ilg--) {
134 int lslot = trackConf.MaxTrackLength - ilg;
135 param.MinPt[lslot] *= bFactor;
138 mTracker->setParameters(trackParams);
139 mVertexer->setParameters(vertParams);
145 auto compClusters = pc.
inputs().
get<gsl::span<o2::itsmft::CompClusterExt>>(
"compClusters");
146 gsl::span<const unsigned char> patterns = pc.
inputs().
get<gsl::span<unsigned char>>(
"patterns");
147 gsl::span<const o2::itsmft::PhysTrigger> physTriggers;
148 std::vector<o2::itsmft::PhysTrigger> fromTRD;
149 if (mUseTriggers == 2) {
151 auto trdTriggers = pc.
inputs().
get<gsl::span<o2::trd::TriggerRecord>>(
"phystrig");
152 for (
const auto& trig : trdTriggers) {
153 if (trig.getBCData() >=
ir && trig.getNumberOfTracklets()) {
154 ir = trig.getBCData();
158 physTriggers = gsl::span<const o2::itsmft::PhysTrigger>(fromTRD.data(), fromTRD.size());
159 }
else if (mUseTriggers == 1) {
160 physTriggers = pc.
inputs().
get<gsl::span<o2::itsmft::PhysTrigger>>(
"phystrig");
163 auto rofsinput = pc.
inputs().
get<gsl::span<o2::itsmft::ROFRecord>>(
"ROframes");
164 auto& trackROFvec = pc.
outputs().
make<std::vector<o2::itsmft::ROFRecord>>(
Output{
"ITS",
"ITSTrackROF", 0}, rofsinput.begin(), rofsinput.end());
165 auto& irFrames = pc.
outputs().
make<std::vector<o2::dataformats::IRFrame>>(
Output{
"ITS",
"IRFRAMES", 0});
168 irFrames.reserve(trackROFvec.size());
169 int nBCPerTF = alpParams.roFrameLengthInBC;
171 LOGP(info,
"ITSTracker pulled {} clusters, {} RO frames", compClusters.size(), trackROFvec.size());
173 gsl::span<itsmft::MC2ROFRecord const> mc2rofs;
178 LOG(info) << labels->
getIndexedSize() <<
" MC label objects , in " << mc2rofs.size() <<
" MC events";
181 auto& allClusIdx = pc.
outputs().
make<std::vector<int>>(
Output{
"ITS",
"TRACKCLSID", 0});
182 auto& allTracks = pc.
outputs().
make<std::vector<o2::its::TrackITS>>(
Output{
"ITS",
"TRACKS", 0});
183 auto& vertROFvec = pc.
outputs().
make<std::vector<o2::itsmft::ROFRecord>>(
Output{
"ITS",
"VERTICESROF", 0});
184 auto& vertices = pc.
outputs().
make<std::vector<Vertex>>(
Output{
"ITS",
"VERTICES", 0});
189 auto& allTrackLabels = mIsMC ? pc.
outputs().
make<std::vector<o2::MCCompLabel>>(
Output{
"ITS",
"TRACKSMCTR", 0}) : dummyMCLabTracks;
190 auto& allVerticesLabels = mIsMC ? pc.
outputs().
make<std::vector<o2::MCCompLabel>>(
Output{
"ITS",
"VERTICESMCTR", 0}) : dummyMCLabVerts;
191 auto& allVerticesPurities = mIsMC ? pc.
outputs().
make<std::vector<float>>(
Output{
"ITS",
"VERTICESMCPUR", 0}) : dummyMCPurVerts;
193 std::uint32_t roFrame = 0;
196 LOG(info) <<
"ITSTracker RO: continuous=" << continuous;
198 if (mOverrideBeamEstimation) {
201 mMeanVertex->getSigmaY2(),
202 mTracker->getParameters()[0].LayerResolution[0],
203 mTracker->getParameters()[0].SystErrorY2[0]);
208 gsl::span<const unsigned char>::iterator pattIt = patterns.begin();
210 gsl::span<itsmft::ROFRecord> trackROFspan(trackROFvec);
211 loadROF(trackROFspan, compClusters, pattIt, labels);
212 pattIt = patterns.begin();
213 std::vector<int> savedROF;
214 auto logger = [&](std::string s) {
LOG(info) << s; };
215 auto fatalLogger = [&](std::string s) {
LOG(fatal) << s; };
216 auto errorLogger = [&](std::string s) {
LOG(error) << s; };
219 std::vector<uint8_t> processingMask, processUPCMask;
220 int cutVertexMult{0}, cutUPCVertex{0}, cutRandomMult =
int(trackROFvec.size()) - multEst.
selectROFs(trackROFvec, compClusters, physTriggers, processingMask);
221 processUPCMask.resize(processingMask.size(),
false);
223 float vertexerElapsedTime{0.f};
225 vertROFvec.reserve(trackROFvec.size());
227 if constexpr (isGPU) {
228 vertexerElapsedTime = mVertexer->clustersToVerticesHybrid(logger);
230 vertexerElapsedTime = mVertexer->clustersToVertices(logger);
236 gsl::span<const std::pair<MCCompLabel, float>> vMCRecInfo;
237 for (
auto iRof{0}; iRof < trackROFspan.size(); ++iRof) {
238 std::vector<Vertex> vtxVecLoc;
239 auto& vtxROF = vertROFvec.emplace_back(trackROFspan[iRof]);
240 vtxROF.setFirstEntry(vertices.size());
247 if (vtxSpan.size()) {
249 LOGP(
debug,
"ROF {} rejected as vertices are from the UPC iteration", iRof);
250 processUPCMask[iRof] =
true;
252 vtxROF.setFlag(o2::itsmft::ROFRecord::VtxUPCMode);
254 vtxROF.setFlag(o2::itsmft::ROFRecord::VtxStdMode);
257 vtxROF.setFlag(o2::itsmft::ROFRecord::VtxUPCMode);
260 vtxROF.setFlag(o2::itsmft::ROFRecord::VtxStdMode);
262 vtxROF.setNEntries(vtxSpan.size());
263 bool selROF = vtxSpan.size() == 0;
264 for (
auto iV{0}; iV < vtxSpan.size(); ++iV) {
265 auto&
v = vtxSpan[iV];
266 if (multEstConf.isVtxMultCutRequested() && !multEstConf.isPassingVtxMultCut(
v.getNContributors())) {
270 vertices.push_back(
v);
272 allVerticesLabels.push_back(vMCRecInfo[iV].
first);
273 allVerticesPurities.push_back(vMCRecInfo[iV].second);
276 if (processingMask[iRof] && !selROF) {
277 LOGP(info,
"ROF {} rejected by the vertex multiplicity selection [{},{}]", iRof, multEstConf.cutMultVtxLow, multEstConf.cutMultVtxHigh);
278 processingMask[iRof] = selROF;
282 vtxVecLoc.emplace_back(
Vertex());
283 vtxVecLoc.back().setNContributors(1);
284 vtxROF.setNEntries(vtxVecLoc.size());
285 for (
auto&
v : vtxVecLoc) {
286 vertices.push_back(
v);
292 LOG(info) << fmt::format(
" - Vertex seeding total elapsed time: {} ms for {} ({} + {}) vertices found in {}/{} ROFs",
298 trackROFspan.size());
299 LOG(info) << fmt::format(
"FastMultEst: rejected {}/{} ROFs: random/mult.sel:{} (seed {}), vtx.sel:{}", cutRandomMult + cutVertexMult, trackROFspan.size(), cutRandomMult, multEst.
lastRandomSeed, cutVertexMult);
301 if (mOverrideBeamEstimation) {
306 if (mCosmicsProcessing && compClusters.size() > 1500 * trackROFspan.size()) {
307 LOG(error) <<
"Cosmics processing was requested with an average detector occupancy exceeding 1.e-7, skipping TF processing.";
313 if constexpr (isGPU) {
315 mTracker->clustersToTracksHybrid(logger, fatalLogger);
317 mTracker->clustersToTracksHybrid(logger, errorLogger);
321 mTracker->clustersToTracks(logger, fatalLogger);
323 mTracker->clustersToTracks(logger, errorLogger);
327 allTracks.reserve(totTracks);
328 allClusIdx.reserve(totClusIDs);
331 LOG(warning) << fmt::format(
" - The processed timeframe had {} clusters with wild z coordinates, check the dictionaries",
mTimeFrame->
hasBogusClusters());
334 for (
unsigned int iROF{0}; iROF < trackROFvec.size(); ++iROF) {
335 auto& tracksROF{trackROFvec[iROF]};
336 auto& vtxROF = vertROFvec[iROF];
338 auto number{tracks.size()};
339 auto first{allTracks.size()};
340 int offset = -tracksROF.getFirstEntry();
341 tracksROF.setFirstEntry(
first);
342 tracksROF.setNEntries(number);
343 tracksROF.setFlags(vtxROF.getFlags());
344 if (processingMask[iROF]) {
345 irFrames.emplace_back(tracksROF.getBCData(), tracksROF.getBCData() + nBCPerTF - 1).info = tracks.size();
350 for (
unsigned int iTrk{0}; iTrk < tracks.size(); ++iTrk) {
351 auto& trc{tracks[iTrk]};
352 trc.setFirstClusterEntry(allClusIdx.size());
353 int ncl = trc.getNumberOfClusters(), nclf = 0;
355 auto clid = trc.getClusterIndex(ic);
358 allClusIdx.push_back(clid);
363 allTracks.emplace_back(trc);
366 LOGP(info,
"ITSTracker pushed {} tracks and {} vertices", allTracks.size(), vertices.size());
368 LOGP(info,
"ITSTracker pushed {} track labels", allTrackLabels.size());
369 LOGP(info,
"ITSTracker pushed {} vertex labels", allVerticesLabels.size());
370 LOGP(info,
"ITSTracker pushed {} vertex purities", allVerticesPurities.size());