234 static int TFCount = 0;
235 int nv = vtxRefs.size();
238 std::vector<o2::dataformats::PrimaryVertexExt> pveVec(nv);
239 std::vector<float> tpcOccAftV, tpcOccBefV;
240 pveVec.back() = vtxDummy;
244 std::vector<o2::dataformats::TrackInfoExt> trcExtVec;
245 std::vector<o2::trackstudy::TrackPairInfo> trcPairsVec;
248 int groupOcc = std::ceil(maxDriftTB / mNOccBinsDrift / mNTPCOccBinLength);
258 uint8_t clSect = 0, clRow = 0, lowestR = -1;
260 for (
int ic = 0; ic < trc.getNClusterReferences(); ic++) {
261 trc.getClusterReference(clRefs, ic, clSect, clRow, clIdx);
262 if (clRow < lowestR) {
266 unsigned int absoluteIndex = tpcClusAcc.clusterOffset[clSect][clRow] + clIdx;
268 trExt.nClTPCShared++;
271 trExt.rowMinTPC = lowestR;
272 const auto& clus = tpcClusAcc.clusters[clSect][clRow][clIdx];
273 trExt.padFromEdge = uint8_t(clus.getPad());
274 int npads = o2::gpu::GPUTPCGeometry::NPads(lowestR);
275 if (trExt.padFromEdge > npads / 2) {
276 trExt.padFromEdge = npads - 1 - trExt.padFromEdge;
278 this->mTPCCorrMaps->Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos0[0], trExt.innerTPCPos0[1], trExt.innerTPCPos0[2], trc.getTime0());
279 if (timestampTB > -1e8) {
280 this->mTPCCorrMaps->Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos[0], trExt.innerTPCPos[1], trExt.innerTPCPos[2], timestampTB);
282 trExt.innerTPCPos = trExt.innerTPCPos0;
284 trc.getClusterReference(clRefs, 0, clSect, clRow, clIdx);
285 trExt.rowMaxTPC = clRow;
291 uint8_t nsh = 0, nshRows = 0, lastSharedRow = -1;
293 uint8_t clSect0 = 0, clRow0 = 0, clSect1 = 0, clRow1 = 0;
294 uint32_t clIdx0 = 0, clIdx1 = 0;
296 for (
int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) {
297 trc0.getClusterReference(clRefs, ic0, clSect0, clRow0, clIdx0);
298 for (
int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) {
299 trc1.getClusterReference(clRefs, ic1, clSect1, clRow1, clIdx1);
300 if (clRow1 > clRow0) {
304 if (clRow1 == clRow0) {
305 if (clSect0 == clSect1 && clIdx0 == clIdx1) {
307 if (lastSharedRow != clRow0) {
308 lastSharedRow = clRow0;
318 return std::make_pair(nsh, nshRows);
324 dst.ts.setTimeStamp(
src.ttime);
325 dst.ts.setTimeStampError(
src.ttimeE);
328 dst.pattITS =
src.pattITS;
329 if (
src.q2ptITS == 0. &&
dst.nClITS > 0) {
330 dst.pattITS |= 0x1 << 7;
332 dst.lowestPadRow =
src.rowMinTPC;
338 auto msk =
src.gid.getSourceDetectorsMask();
342 if (lblITS.isFake()) {
363 tpcOccAftV.resize(mNOccBinsDrift);
364 tpcOccBefV.resize(mNOccBinsDrift);
366 for (
int iv = 0; iv < nv; iv++) {
367 LOGP(
debug,
"processing PV {} of {}", iv, nv);
368 const auto& vtref = vtxRefs[iv];
370 auto& pve = pveVec[iv];
373 float bestTimeDiff = 1000, bestTime = -999;
377 const auto& ft0 = FITInfo[trackIndex[ift0]];
379 auto fitTime = ft0.getInteractionRecord().differenceInBCMUS(recoData.
startIR);
380 if (std::abs(fitTime - pve.getTimeStamp().getTimeStamp()) < bestTimeDiff) {
381 bestTimeDiff = fitTime - pve.getTimeStamp().getTimeStamp();
382 bestFTID = trackIndex[ift0];
387 LOGP(warn,
"FT0 is not requested, cannot set complete vertex info");
390 pve.FT0A = FITInfo[bestFTID].getTrigger().getAmplA();
391 pve.FT0C = FITInfo[bestFTID].getTrigger().getAmplC();
392 pve.FT0Time = double(FITInfo[bestFTID].getInteractionRecord().differenceInBCMUS(recoData.
startIR)) + FITInfo[bestFTID].getCollisionTimeMean() * 1e-6;
398 float q2ptITS, q2ptTPC, q2ptITSTPC, q2ptITSTPCTRD;
402 int idMin = vtref.getFirstEntryOfSource(is), idMax = idMin + vtref.getEntriesOfSource(is);
403 for (
int i = idMin;
i < idMax;
i++) {
404 auto vid = trackIndex[
i];
405 bool pvCont = vid.isPVContributor();
407 pveVec[iv].nSrc[is]++;
418 nclTPC = tpcTr->getNClusters();
419 if (nclTPC < mMinTPCClusters) {
423 bool ambig = vid.isAmbiguous();
425 if (fabs(trc.getEta()) > mMaxEta) {
428 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
429 float corz = vdrift * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
430 if (tpcTr->hasASideClustersOnly()) {
433 trc.setZ(trc.getZ() + corz);
435 float xmin = trc.getX();
437 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], trc, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &dca)) {
440 bool hasITS = GTrackID::getSourceDetectorsMask(is)[
GTrackID::ITS];
441 if (std::abs(dca.getY()) > (hasITS ? getDCAYCut(trc.getPt()) : mTPCDCAYCut) ||
442 std::abs(dca.getZ()) > (hasITS ? getDCAZCut(trc.getPt()) : mTPCDCAZCut)) {
445 if (trc.getPt() < mMinPt) {
449 pveVec[iv].nSrcA[is]++;
451 pveVec[iv].nSrcAU[is]++;
454 if (!hasITS && mStoreWithITSOnly) {
458 auto& trcExt = trcExtVec.emplace_back();
459 recoData.
getTrackTime(vid, trcExt.ttime, trcExt.ttimeE);
461 trcExt.hashIU = trc.hash();
465 trcExt.dcaTPC.set(-999.f, -999.f);
469 if (tpcTr->hasASideClusters()) {
472 if (tpcTr->hasCSideClusters()) {
480 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
481 float corz = vdrift * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
482 if (tpcTr->hasASideClustersOnly()) {
485 tmpTPC.setZ(tmpTPC.getZ() + corz);
487 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], tmpTPC, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &trcExt.dcaTPC)) {
488 trcExt.dcaTPC.set(-999.f, -999.f);
491 fillTPCClInfo(*tpcTr, trcExt, tsuse);
492 trcExt.chi2TPC = tpcTr->getChi2();
497 trcExt.q2ptITS = itsTr.getQ2Pt();
498 trcExt.nClITS = itsTr.getNClusters();
499 for (
int il = 0; il < 7; il++) {
500 if (itsTr.hasHitOnLayer(il)) {
501 trcExt.pattITS |= 0x1 << il;
506 trcExt.nClITS = itsTrf.getNClusters();
507 for (
int il = 0; il < 7; il++) {
508 if (itsTrf.hasHitOnLayer(il)) {
509 trcExt.pattITS |= 0x1 << il;
515 trcExt.nClTPC = nclTPC;
519 trcExt.q2ptITSTPC = trTPCITS.getQ2Pt();
520 trcExt.chi2ITSTPC = trTPCITS.getChi2Match();
531 float tpcOccBef = 0., tpcOccAft = 0.;
533 int tb = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv;
534 tpcOccBef = tb < 0 ? mTBinClOccBef[0] : (tb >= mTBinClOccBef.size() ? mTBinClOccBef.back() : mTBinClOccBef[tb]);
535 tpcOccAft = tb < 0 ? mTBinClOccAft[0] : (tb >= mTBinClOccAft.size() ? mTBinClOccAft.back() : mTBinClOccAft[tb]);
536 int tbc = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv - groupOcc / 2.;
537 for (
int iob = 0; iob < mNOccBinsDrift; iob++) {
539 for (
int ig = 0; ig < groupOcc; ig++) {
540 int ocb = tbc + ig + groupOcc * iob;
541 if (ocb < 0 || ocb >= (
int)mMltHistTB.size()) {
545 sm += mMltHistTB[ocb];
547 tpcOccAftV[iob] = sm;
550 for (
int ig = 0; ig < groupOcc; ig++) {
551 int ocb = tbc + ig - groupOcc * iob;
552 if (ocb < 0 || ocb >= (
int)mMltHistTB.size()) {
556 sm += mMltHistTB[ocb];
558 tpcOccBefV[iob] = sm;
562 <<
"orbit=" << recoData.
startIR.
orbit <<
"tfID=" << TFCount
563 <<
"tpcOccBef=" << tpcOccBef <<
"tpcOccAft=" << tpcOccAft
564 <<
"tpcOccBefV=" << tpcOccBefV <<
"tpcOccAftV=" << tpcOccAftV
565 <<
"pve=" << pveVec[iv] <<
"trc=" << trcExtVec <<
"\n";
568 for (
int it0 = 0; it0 < (
int)trcExtVec.size(); it0++) {
569 const auto& tr0 = trcExtVec[it0];
570 if (tr0.nClTPC < 1) {
573 for (
int it1 = it0 + 1; it1 < (
int)trcExtVec.size(); it1++) {
574 const auto& tr1 = trcExtVec[it1];
575 if (tr1.nClTPC < 1) {
579 if (std::abs(tr0.track.getTgl() - tr1.track.getTgl()) > 0.25) {
582 auto dphi = tr0.track.getPhi() - tr1.track.getPhi();
588 if (std::abs(dphi) > 0.25) {
591 auto& pr = trcPairsVec.emplace_back();
592 assignRecTrack(tr0, pr.tr0);
593 assignRecTrack(tr1, pr.tr1);
595 pr.nshTPC = shinfo.first;
596 pr.nshTPCRow = shinfo.second;
599 (*mDBGOut) <<
"pairs" <<
"pr=" << trcPairsVec <<
"\n";
603 int nvtot = mMaxNeighbours < 0 ? -1 : (
int)pveVec.size();
605 auto insSlot = [maxSlots = mMaxNeighbours](std::vector<float>& vc,
float v,
int slot, std::vector<int>& vid,
int id) {
606 for (
int i = maxSlots - 1;
i > slot;
i--) {
607 std::swap(vc[
i], vc[
i - 1]);
608 std::swap(vid[
i], vid[
i - 1]);
614 for (
int cnt = 0; cnt < nvtot; cnt++) {
615 const auto& pve = pveVec[cnt];
616 float tv = pve.getTimeStamp().getTimeStamp();
617 std::vector<o2::dataformats::PrimaryVertexExt> pveT(mMaxNeighbours);
618 std::vector<o2::dataformats::PrimaryVertexExt> pveZ(mMaxNeighbours);
619 std::vector<int> idT(mMaxNeighbours), idZ(mMaxNeighbours);
620 std::vector<float> dT(mMaxNeighbours), dZ(mMaxNeighbours);
621 for (
int i = 0;
i < mMaxNeighbours;
i++) {
622 idT[
i] = idZ[
i] = -1;
623 dT[
i] = mMaxVTTimeDiff;
626 int cntM = cnt - 1, cntP = cnt + 1;
627 for (; cntM >= 0; cntM--) {
628 const auto& vt = pveVec[cntM];
629 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
630 if (dtime > mMaxVTTimeDiff) {
633 for (
int i = 0;
i < mMaxNeighbours;
i++) {
635 insSlot(dT, dtime,
i, idT, cntM);
639 auto dz = std::abs(pve.getZ() - vt.getZ());
640 for (
int i = 0;
i < mMaxNeighbours;
i++) {
642 insSlot(dZ, dz,
i, idZ, cntM);
647 for (; cntP < nvtot; cntP++) {
648 const auto& vt = pveVec[cntP];
649 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
650 if (dtime > mMaxVTTimeDiff) {
653 for (
int i = 0;
i < mMaxNeighbours;
i++) {
655 insSlot(dT, dtime,
i, idT, cntP);
659 auto dz = std::abs(pve.getZ() - vt.getZ());
660 for (
int i = 0;
i < mMaxNeighbours;
i++) {
662 insSlot(dZ, dz,
i, idZ, cntP);
667 for (
int i = 0;
i < mMaxNeighbours;
i++) {
669 pveT[
i] = pveVec[idT[
i]];
674 for (
int i = 0;
i < mMaxNeighbours;
i++) {
676 pveZ[
i] = pveVec[idZ[
i]];
681 (*mDBGOutVtx) <<
"pvExt"
685 <<
"tfID=" << TFCount
727 std::vector<OutputSpec> outputs;
728 auto dataRequest = std::make_shared<DataRequest>();
730 dataRequest->requestTracks(srcTracks, useMC);
731 dataRequest->requestClusters(srcClusters, useMC);
732 dataRequest->requestPrimaryVertices(useMC);
733 dataRequest->inputs.emplace_back(
"meanvtx",
"GLO",
"MEANVERTEX", 0, Lifetime::Condition,
ccdbParamSpec(
"GLO/Calib/MeanVertex", {}, 1));
734 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
744 {
"max-vtx-neighbours", VariantType::Int, 3, {
"Max PV neighbours fill, no PV study if < 0"}},
745 {
"max-vtx-timediff", VariantType::Float, 90.f, {
"Max PV time difference to consider"}},
746 {
"dcay-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
747 {
"dcaz-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
748 {
"min-tpc-clusters", VariantType::Int, 60, {
"Cut on TPC clusters"}},
749 {
"max-tpc-dcay", VariantType::Float, 5.f, {
"Cut on TPC dcaY"}},
750 {
"max-tpc-dcaz", VariantType::Float, 5.f, {
"Cut on TPC dcaZ"}},
751 {
"max-eta", VariantType::Float, 1.0f, {
"Cut on track eta"}},
752 {
"min-pt", VariantType::Float, 0.1f, {
"Cut on track pT"}},
753 {
"with-its-only", VariantType::Bool,
false, {
"Store tracks with ITS only"}},
754 {
"pair-correlations", VariantType::Bool,
false, {
"Do pairs correlation"}},
755 {
"occ-weight-fun", VariantType::String,
"(x>=-40&&x<-5) ? (1./1225*pow(x+40,2)) : ((x>-5&&x<15) ? 1. : ((x>=15&&x<40) ? (-0.4/25*x+1.24 ) : ( (x>40&&x<100) ? -0.4/60*x+0.6+0.8/3 : 0)))", {
"Occupancy weighting f-n vs time in musec"}},
756 {
"noccbins", VariantType::Int, 10, {
"Number of occupancy bins per full drift time"}},
757 {
"min-x-prop", VariantType::Float, 100.f, {
"track should be propagated to this X at least"}},
766 AlgorithmSpec{adaptFromTask<TrackingStudySpec>(dataRequest, ggRequest, srcTracks, useMC)},