255 static int TFCount = 0;
256 int nv = vtxRefs.size();
259 std::vector<o2::dataformats::PrimaryVertexExt> pveVec(nv);
260 std::vector<float> tpcOccAftV, tpcOccBefV;
261 pveVec.back() = vtxDummy;
265 std::vector<o2::dataformats::TrackInfoExt> trcExtVec;
266 std::vector<o2::trackstudy::TrackPairInfo> trcPairsVec;
269 int groupOcc = std::ceil(maxDriftTB / mNOccBinsDrift / mNTPCOccBinLength);
278 uint8_t clSect = 0, clRow = 0, clRowP = -1;
280 for (
int ic = 0; ic < trc.getNClusterReferences(); ic++) {
281 trc.getClusterReference(clRefs, ic, clSect, clRow, clIdx);
282 if (clRow != clRowP) {
286 unsigned int absoluteIndex = tpcClusAcc.clusterOffset[clSect][clRow] + clIdx;
288 trExt.nClTPCShared++;
291 trc.getClusterReference(clRefs, trc.getNClusterReferences() - 1, clSect, clRow, clIdx);
292 trExt.rowMinTPC = clRow;
293 const auto& clus = tpcClusAcc.clusters[clSect][clRow][clIdx];
294 trExt.padFromEdge = uint8_t(clus.getPad());
295 int npads = o2::gpu::GPUTPCGeometry::NPads(clRow);
296 if (trExt.padFromEdge > npads / 2) {
297 trExt.padFromEdge = npads - 1 - trExt.padFromEdge;
299 this->mTPCCorrMapsLoader.Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos0[0], trExt.innerTPCPos0[1], trExt.innerTPCPos0[2], trc.getTime0());
300 if (timestampTB > -1e8) {
301 this->mTPCCorrMapsLoader.Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos[0], trExt.innerTPCPos[1], trExt.innerTPCPos[2], timestampTB);
303 trExt.innerTPCPos = trExt.innerTPCPos0;
305 trc.getClusterReference(clRefs, 0, clSect, clRow, clIdx);
306 trExt.rowMaxTPC = clRow;
312 uint8_t nsh = 0, nshRows = 0, lastSharedRow = -1;
314 uint8_t clSect0 = 0, clRow0 = 0, clSect1 = 0, clRow1 = 0;
315 uint32_t clIdx0 = 0, clIdx1 = 0;
317 for (
int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) {
318 trc0.getClusterReference(clRefs, ic0, clSect0, clRow0, clIdx0);
319 for (
int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) {
320 trc1.getClusterReference(clRefs, ic1, clSect1, clRow1, clIdx1);
321 if (clRow1 > clRow0) {
325 if (clRow1 == clRow0) {
326 if (clSect0 == clSect1 && clIdx0 == clIdx1) {
328 if (lastSharedRow != clRow0) {
329 lastSharedRow = clRow0;
339 return std::make_pair(nsh, nshRows);
345 dst.ts.setTimeStamp(
src.ttime);
346 dst.ts.setTimeStampError(
src.ttimeE);
349 dst.pattITS =
src.pattITS;
350 if (
src.q2ptITS == 0. &&
dst.nClITS > 0) {
351 dst.pattITS |= 0x1 << 7;
353 dst.lowestPadRow =
src.rowMinTPC;
359 auto msk =
src.gid.getSourceDetectorsMask();
363 if (lblITS.isFake()) {
384 tpcOccAftV.resize(mNOccBinsDrift);
385 tpcOccBefV.resize(mNOccBinsDrift);
387 for (
int iv = 0; iv < nv; iv++) {
388 LOGP(
debug,
"processing PV {} of {}", iv, nv);
389 const auto& vtref = vtxRefs[iv];
391 auto& pve = pveVec[iv];
394 float bestTimeDiff = 1000, bestTime = -999;
398 const auto& ft0 = FITInfo[trackIndex[ift0]];
400 auto fitTime = ft0.getInteractionRecord().differenceInBCMUS(recoData.
startIR);
401 if (std::abs(fitTime - pve.getTimeStamp().getTimeStamp()) < bestTimeDiff) {
402 bestTimeDiff = fitTime - pve.getTimeStamp().getTimeStamp();
403 bestFTID = trackIndex[ift0];
408 LOGP(warn,
"FT0 is not requested, cannot set complete vertex info");
411 pve.FT0A = FITInfo[bestFTID].getTrigger().getAmplA();
412 pve.FT0C = FITInfo[bestFTID].getTrigger().getAmplC();
413 pve.FT0Time = double(FITInfo[bestFTID].getInteractionRecord().differenceInBCMUS(recoData.
startIR)) + FITInfo[bestFTID].getCollisionTimeMean() * 1e-6;
419 float q2ptITS, q2ptTPC, q2ptITSTPC, q2ptITSTPCTRD;
423 int idMin = vtref.getFirstEntryOfSource(is), idMax = idMin + vtref.getEntriesOfSource(is);
424 for (
int i = idMin;
i < idMax;
i++) {
425 auto vid = trackIndex[
i];
426 bool pvCont = vid.isPVContributor();
428 pveVec[iv].nSrc[is]++;
439 nclTPC = tpcTr->getNClusters();
440 if (nclTPC < mMinTPCClusters) {
444 bool ambig = vid.isAmbiguous();
446 if (abs(trc.getEta()) > mMaxEta) {
449 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
450 float corz = vdrift * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
451 if (tpcTr->hasASideClustersOnly()) {
454 trc.setZ(trc.getZ() + corz);
456 float xmin = trc.getX();
458 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], trc, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &dca)) {
461 bool hasITS = GTrackID::getSourceDetectorsMask(is)[
GTrackID::ITS];
462 if (std::abs(dca.getY()) > (hasITS ? getDCAYCut(trc.getPt()) : mTPCDCAYCut) ||
463 std::abs(dca.getZ()) > (hasITS ? getDCAZCut(trc.getPt()) : mTPCDCAZCut)) {
466 if (trc.getPt() < mMinPt) {
470 pveVec[iv].nSrcA[is]++;
472 pveVec[iv].nSrcAU[is]++;
475 if (!hasITS && mStoreWithITSOnly) {
479 auto& trcExt = trcExtVec.emplace_back();
480 recoData.
getTrackTime(vid, trcExt.ttime, trcExt.ttimeE);
485 trcExt.dcaTPC.set(-999.f, -999.f);
494 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
495 float corz = vdrift * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
496 if (tpcTr->hasASideClustersOnly()) {
499 tmpTPC.setZ(tmpTPC.getZ() + corz);
501 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], tmpTPC, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &trcExt.dcaTPC)) {
502 trcExt.dcaTPC.set(-999.f, -999.f);
505 fillTPCClInfo(*tpcTr, trcExt, tsuse);
506 trcExt.chi2TPC = tpcTr->getChi2();
511 trcExt.q2ptITS = itsTr.getQ2Pt();
512 trcExt.nClITS = itsTr.getNClusters();
513 for (
int il = 0; il < 7; il++) {
514 if (itsTr.hasHitOnLayer(il)) {
515 trcExt.pattITS |= 0x1 << il;
520 trcExt.nClITS = itsTrf.getNClusters();
521 for (
int il = 0; il < 7; il++) {
522 if (itsTrf.hasHitOnLayer(il)) {
523 trcExt.pattITS |= 0x1 << il;
529 trcExt.nClTPC = nclTPC;
533 trcExt.q2ptITSTPC = trTPCITS.getQ2Pt();
534 trcExt.chi2ITSTPC = trTPCITS.getChi2Match();
545 float tpcOccBef = 0., tpcOccAft = 0.;
547 int tb = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv;
548 tpcOccBef = tb < 0 ? mTBinClOccBef[0] : (tb >= mTBinClOccBef.size() ? mTBinClOccBef.back() : mTBinClOccBef[tb]);
549 tpcOccAft = tb < 0 ? mTBinClOccAft[0] : (tb >= mTBinClOccAft.size() ? mTBinClOccAft.back() : mTBinClOccAft[tb]);
550 int tbc = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv - groupOcc / 2.;
551 for (
int iob = 0; iob < mNOccBinsDrift; iob++) {
553 for (
int ig = 0; ig < groupOcc; ig++) {
554 int ocb = tbc + ig + groupOcc * iob;
555 if (ocb < 0 || ocb >= (
int)mMltHistTB.size()) {
559 sm += mMltHistTB[ocb];
561 tpcOccAftV[iob] = sm;
564 for (
int ig = 0; ig < groupOcc; ig++) {
565 int ocb = tbc + ig - groupOcc * iob;
566 if (ocb < 0 || ocb >= (
int)mMltHistTB.size()) {
570 sm += mMltHistTB[ocb];
572 tpcOccBefV[iob] = sm;
576 <<
"orbit=" << recoData.
startIR.
orbit <<
"tfID=" << TFCount
577 <<
"tpcOccBef=" << tpcOccBef <<
"tpcOccAft=" << tpcOccAft
578 <<
"tpcOccBefV=" << tpcOccBefV <<
"tpcOccAftV=" << tpcOccAftV
579 <<
"pve=" << pveVec[iv] <<
"trc=" << trcExtVec <<
"\n";
582 for (
int it0 = 0; it0 < (
int)trcExtVec.size(); it0++) {
583 const auto& tr0 = trcExtVec[it0];
584 if (tr0.nClTPC < 1) {
587 for (
int it1 = it0 + 1; it1 < (
int)trcExtVec.size(); it1++) {
588 const auto& tr1 = trcExtVec[it1];
589 if (tr1.nClTPC < 1) {
593 if (std::abs(tr0.track.getTgl() - tr1.track.getTgl()) > 0.25) {
596 auto dphi = tr0.track.getPhi() - tr1.track.getPhi();
602 if (std::abs(dphi) > 0.25) {
605 auto& pr = trcPairsVec.emplace_back();
606 assignRecTrack(tr0, pr.tr0);
607 assignRecTrack(tr1, pr.tr1);
609 pr.nshTPC = shinfo.first;
610 pr.nshTPCRow = shinfo.second;
613 (*mDBGOut) <<
"pairs" <<
"pr=" << trcPairsVec <<
"\n";
617 int nvtot = mMaxNeighbours < 0 ? -1 : (
int)pveVec.size();
619 auto insSlot = [maxSlots = mMaxNeighbours](std::vector<float>& vc,
float v,
int slot, std::vector<int>& vid,
int id) {
620 for (
int i = maxSlots - 1;
i > slot;
i--) {
621 std::swap(vc[
i], vc[
i - 1]);
622 std::swap(vid[
i], vid[
i - 1]);
628 for (
int cnt = 0; cnt < nvtot; cnt++) {
629 const auto& pve = pveVec[cnt];
630 float tv = pve.getTimeStamp().getTimeStamp();
631 std::vector<o2::dataformats::PrimaryVertexExt> pveT(mMaxNeighbours);
632 std::vector<o2::dataformats::PrimaryVertexExt> pveZ(mMaxNeighbours);
633 std::vector<int> idT(mMaxNeighbours), idZ(mMaxNeighbours);
634 std::vector<float> dT(mMaxNeighbours), dZ(mMaxNeighbours);
635 for (
int i = 0;
i < mMaxNeighbours;
i++) {
636 idT[
i] = idZ[
i] = -1;
637 dT[
i] = mMaxVTTimeDiff;
640 int cntM = cnt - 1, cntP = cnt + 1;
641 for (; cntM >= 0; cntM--) {
642 const auto& vt = pveVec[cntM];
643 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
644 if (dtime > mMaxVTTimeDiff) {
647 for (
int i = 0;
i < mMaxNeighbours;
i++) {
649 insSlot(dT, dtime,
i, idT, cntM);
653 auto dz = std::abs(pve.getZ() - vt.getZ());
654 for (
int i = 0;
i < mMaxNeighbours;
i++) {
656 insSlot(dZ, dz,
i, idZ, cntM);
661 for (; cntP < nvtot; cntP++) {
662 const auto& vt = pveVec[cntP];
663 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
664 if (dtime > mMaxVTTimeDiff) {
667 for (
int i = 0;
i < mMaxNeighbours;
i++) {
669 insSlot(dT, dtime,
i, idT, cntP);
673 auto dz = std::abs(pve.getZ() - vt.getZ());
674 for (
int i = 0;
i < mMaxNeighbours;
i++) {
676 insSlot(dZ, dz,
i, idZ, cntP);
681 for (
int i = 0;
i < mMaxNeighbours;
i++) {
683 pveT[
i] = pveVec[idT[
i]];
688 for (
int i = 0;
i < mMaxNeighbours;
i++) {
690 pveZ[
i] = pveVec[idZ[
i]];
695 (*mDBGOutVtx) <<
"pvExt"
699 <<
"tfID=" << TFCount
744 std::vector<OutputSpec> outputs;
745 auto dataRequest = std::make_shared<DataRequest>();
747 dataRequest->requestTracks(srcTracks, useMC);
748 dataRequest->requestClusters(srcClusters, useMC);
749 dataRequest->requestPrimaryVertices(useMC);
750 dataRequest->inputs.emplace_back(
"meanvtx",
"GLO",
"MEANVERTEX", 0, Lifetime::Condition,
ccdbParamSpec(
"GLO/Calib/MeanVertex", {}, 1));
751 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
761 {
"max-vtx-neighbours", VariantType::Int, 3, {
"Max PV neighbours fill, no PV study if < 0"}},
762 {
"max-vtx-timediff", VariantType::Float, 90.f, {
"Max PV time difference to consider"}},
763 {
"dcay-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
764 {
"dcaz-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
765 {
"min-tpc-clusters", VariantType::Int, 60, {
"Cut on TPC clusters"}},
766 {
"max-tpc-dcay", VariantType::Float, 5.f, {
"Cut on TPC dcaY"}},
767 {
"max-tpc-dcaz", VariantType::Float, 5.f, {
"Cut on TPC dcaZ"}},
768 {
"max-eta", VariantType::Float, 1.0f, {
"Cut on track eta"}},
769 {
"min-pt", VariantType::Float, 0.1f, {
"Cut on track pT"}},
770 {
"with-its-only", VariantType::Bool,
false, {
"Store tracks with ITS only"}},
771 {
"pair-correlations", VariantType::Bool,
false, {
"Do pairs correlation"}},
772 {
"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"}},
773 {
"noccbins", VariantType::Int, 10, {
"Number of occupancy bins per full drift time"}},
774 {
"min-x-prop", VariantType::Float, 100.f, {
"track should be propagated to this X at least"}},
783 AlgorithmSpec{adaptFromTask<TrackingStudySpec>(dataRequest, ggRequest, srcTracks, useMC, sclOpts)},