268 static int TFCount = 0;
269 int nv = vtxRefs.size();
272 std::vector<o2::dataformats::PrimaryVertexExt> pveVec(nv);
273 pveVec.back() = vtxDummy;
277 std::vector<o2::dataformats::TrackInfoExt> trcExtVec;
278 std::vector<o2::trackstudy::TrackPairInfo> trcPairsVec;
287 uint8_t clSect = 0, clRow = 0, clRowP = -1;
289 for (
int ic = 0; ic < trc.getNClusterReferences(); ic++) {
290 trc.getClusterReference(clRefs, ic, clSect, clRow, clIdx);
291 if (clRow != clRowP) {
295 unsigned int absoluteIndex = tpcClusAcc.clusterOffset[clSect][clRow] + clIdx;
297 trExt.nClTPCShared++;
300 trc.getClusterReference(clRefs, trc.getNClusterReferences() - 1, clSect, clRow, clIdx);
301 trExt.rowMinTPC = clRow;
302 const auto& clus = tpcClusAcc.clusters[clSect][clRow][clIdx];
303 trExt.padFromEdge = uint8_t(clus.getPad());
304 int npads = mTPCRefitter->getParam()->tpcGeometry.NPads(clRow);
305 if (trExt.padFromEdge > npads / 2) {
306 trExt.padFromEdge = npads - 1 - trExt.padFromEdge;
308 this->mTPCCorrMapsLoader.Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos0[0], trExt.innerTPCPos0[1], trExt.innerTPCPos0[2], trc.getTime0());
309 if (timestampTB > -1e8) {
310 this->mTPCCorrMapsLoader.Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos[0], trExt.innerTPCPos[1], trExt.innerTPCPos[2], timestampTB);
312 trExt.innerTPCPos = trExt.innerTPCPos0;
314 trc.getClusterReference(clRefs, 0, clSect, clRow, clIdx);
315 trExt.rowMaxTPC = clRow;
321 uint8_t nsh = 0, nshRows = 0, lastSharedRow = -1;
323 uint8_t clSect0 = 0, clRow0 = 0, clSect1 = 0, clRow1 = 0;
324 uint32_t clIdx0 = 0, clIdx1 = 0;
326 for (
int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) {
327 trc0.getClusterReference(clRefs, ic0, clSect0, clRow0, clIdx0);
328 for (
int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) {
329 trc1.getClusterReference(clRefs, ic1, clSect1, clRow1, clIdx1);
330 if (clRow1 > clRow0) {
334 if (clRow1 == clRow0) {
335 if (clSect0 == clSect1 && clIdx0 == clIdx1) {
337 if (lastSharedRow != clRow0) {
338 lastSharedRow = clRow0;
348 return std::make_pair(nsh, nshRows);
354 dst.ts.setTimeStamp(
src.ttime);
355 dst.ts.setTimeStampError(
src.ttimeE);
358 dst.pattITS =
src.pattITS;
359 if (
src.q2ptITS == 0. &&
dst.nClITS > 0) {
360 dst.pattITS |= 0x1 << 7;
362 dst.lowestPadRow =
src.rowMinTPC;
368 auto msk =
src.gid.getSourceDetectorsMask();
372 if (lblITS.isFake()) {
394 for (
int iv = 0; iv < nv; iv++) {
395 LOGP(
debug,
"processing PV {} of {}", iv, nv);
396 const auto& vtref = vtxRefs[iv];
398 auto& pve = pveVec[iv];
401 float bestTimeDiff = 1000, bestTime = -999;
405 const auto& ft0 = FITInfo[trackIndex[ift0]];
407 auto fitTime = ft0.getInteractionRecord().differenceInBCMUS(recoData.
startIR);
408 if (std::abs(fitTime - pve.getTimeStamp().getTimeStamp()) < bestTimeDiff) {
409 bestTimeDiff = fitTime - pve.getTimeStamp().getTimeStamp();
410 bestFTID = trackIndex[ift0];
415 LOGP(warn,
"FT0 is not requested, cannot set complete vertex info");
418 pve.FT0A = FITInfo[bestFTID].getTrigger().getAmplA();
419 pve.FT0C = FITInfo[bestFTID].getTrigger().getAmplC();
420 pve.FT0Time = double(FITInfo[bestFTID].getInteractionRecord().differenceInBCMUS(recoData.
startIR)) + FITInfo[bestFTID].getCollisionTimeMean() * 1e-6;
426 float q2ptITS, q2ptTPC, q2ptITSTPC, q2ptITSTPCTRD;
430 int idMin = vtref.getFirstEntryOfSource(is), idMax = idMin + vtref.getEntriesOfSource(is);
431 for (
int i = idMin;
i < idMax;
i++) {
432 auto vid = trackIndex[
i];
433 bool pvCont = vid.isPVContributor();
435 pveVec[iv].nSrc[is]++;
446 nclTPC = tpcTr->getNClusters();
447 if (nclTPC < mMinTPCClusters) {
451 bool ambig = vid.isAmbiguous();
453 if (abs(trc.getEta()) > mMaxEta) {
456 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
457 float corz = vdrit * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
458 if (tpcTr->hasASideClustersOnly()) {
461 trc.setZ(trc.getZ() + corz);
463 float xmin = trc.getX();
465 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], trc, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &dca)) {
468 bool hasITS = GTrackID::getSourceDetectorsMask(is)[
GTrackID::ITS];
469 if (std::abs(dca.getY()) > (hasITS ? getDCAYCut(trc.getPt()) : mTPCDCAYCut) ||
470 std::abs(dca.getZ()) > (hasITS ? getDCAZCut(trc.getPt()) : mTPCDCAZCut)) {
473 if (trc.getPt() < mMinPt) {
477 pveVec[iv].nSrcA[is]++;
479 pveVec[iv].nSrcAU[is]++;
482 if (!hasITS && mStoreWithITSOnly) {
486 auto& trcExt = trcExtVec.emplace_back();
487 recoData.
getTrackTime(vid, trcExt.ttime, trcExt.ttimeE);
492 trcExt.dcaTPC.set(-999.f, -999.f);
501 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
502 float corz = vdrit * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
503 if (tpcTr->hasASideClustersOnly()) {
506 tmpTPC.setZ(tmpTPC.getZ() + corz);
508 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], tmpTPC, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &trcExt.dcaTPC)) {
509 trcExt.dcaTPC.set(-999.f, -999.f);
512 fillTPCClInfo(*tpcTr, trcExt, tsuse);
517 trcExt.q2ptITS = itsTr.getQ2Pt();
518 trcExt.nClITS = itsTr.getNClusters();
519 for (
int il = 0; il < 7; il++) {
520 if (itsTr.hasHitOnLayer(il)) {
521 trcExt.pattITS |= 0x1 << il;
526 trcExt.nClITS = itsTrf.getNClusters();
527 for (
int il = 0; il < 7; il++) {
528 if (itsTrf.hasHitOnLayer(il)) {
529 trcExt.pattITS |= 0x1 << il;
535 trcExt.nClTPC = nclTPC;
539 trcExt.q2ptITSTPC = trTPCITS.getQ2Pt();
540 trcExt.chi2ITSTPC = trTPCITS.getChi2Match();
551 float tpcOccBef = 0., tpcOccAft = 0.;
553 int tb = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv;
554 tpcOccBef = tb < 0 ? mTBinClOccBef[0] : (tb >= mTBinClOccBef.size() ? mTBinClOccBef.back() : mTBinClOccBef[tb]);
555 tpcOccAft = tb < 0 ? mTBinClOccAft[0] : (tb >= mTBinClOccAft.size() ? mTBinClOccAft.back() : mTBinClOccAft[tb]);
558 <<
"orbit=" << recoData.
startIR.
orbit <<
"tfID=" << TFCount
559 <<
"tpcOccBef=" << tpcOccBef <<
"tpcOccAft=" << tpcOccAft
560 <<
"pve=" << pveVec[iv] <<
"trc=" << trcExtVec <<
"\n";
563 for (
int it0 = 0; it0 < (
int)trcExtVec.size(); it0++) {
564 const auto& tr0 = trcExtVec[it0];
565 if (tr0.nClTPC < 1) {
568 for (
int it1 = it0 + 1; it1 < (
int)trcExtVec.size(); it1++) {
569 const auto& tr1 = trcExtVec[it1];
570 if (tr1.nClTPC < 1) {
574 if (std::abs(tr0.track.getTgl() - tr1.track.getTgl()) > 0.25) {
577 auto dphi = tr0.track.getPhi() - tr1.track.getPhi();
583 if (std::abs(dphi) > 0.25) {
586 auto& pr = trcPairsVec.emplace_back();
587 assignRecTrack(tr0, pr.tr0);
588 assignRecTrack(tr1, pr.tr1);
590 pr.nshTPC = shinfo.first;
591 pr.nshTPCRow = shinfo.second;
595 (*mDBGOut) <<
"pairs"
596 <<
"pr=" << trcPairsVec <<
"\n";
599 int nvtot = mMaxNeighbours < 0 ? -1 : (
int)pveVec.size();
601 auto insSlot = [maxSlots = mMaxNeighbours](std::vector<float>& vc,
float v,
int slot, std::vector<int>& vid,
int id) {
602 for (
int i = maxSlots - 1;
i > slot;
i--) {
603 std::swap(vc[
i], vc[
i - 1]);
604 std::swap(vid[
i], vid[
i - 1]);
610 for (
int cnt = 0; cnt < nvtot; cnt++) {
611 const auto& pve = pveVec[cnt];
612 float tv = pve.getTimeStamp().getTimeStamp();
613 std::vector<o2::dataformats::PrimaryVertexExt> pveT(mMaxNeighbours);
614 std::vector<o2::dataformats::PrimaryVertexExt> pveZ(mMaxNeighbours);
615 std::vector<int> idT(mMaxNeighbours), idZ(mMaxNeighbours);
616 std::vector<float> dT(mMaxNeighbours), dZ(mMaxNeighbours);
617 for (
int i = 0;
i < mMaxNeighbours;
i++) {
618 idT[
i] = idZ[
i] = -1;
619 dT[
i] = mMaxVTTimeDiff;
622 int cntM = cnt - 1, cntP = cnt + 1;
623 for (; cntM >= 0; cntM--) {
624 const auto& vt = pveVec[cntM];
625 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
626 if (dtime > mMaxVTTimeDiff) {
629 for (
int i = 0;
i < mMaxNeighbours;
i++) {
631 insSlot(dT, dtime,
i, idT, cntM);
635 auto dz = std::abs(pve.getZ() - vt.getZ());
636 for (
int i = 0;
i < mMaxNeighbours;
i++) {
638 insSlot(dZ, dz,
i, idZ, cntM);
643 for (; cntP < nvtot; cntP++) {
644 const auto& vt = pveVec[cntP];
645 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
646 if (dtime > mMaxVTTimeDiff) {
649 for (
int i = 0;
i < mMaxNeighbours;
i++) {
651 insSlot(dT, dtime,
i, idT, cntP);
655 auto dz = std::abs(pve.getZ() - vt.getZ());
656 for (
int i = 0;
i < mMaxNeighbours;
i++) {
658 insSlot(dZ, dz,
i, idZ, cntP);
663 for (
int i = 0;
i < mMaxNeighbours;
i++) {
665 pveT[
i] = pveVec[idT[
i]];
670 for (
int i = 0;
i < mMaxNeighbours;
i++) {
672 pveZ[
i] = pveVec[idZ[
i]];
677 (*mDBGOutVtx) <<
"pvExt"
681 <<
"tfID=" << TFCount
726 std::vector<OutputSpec> outputs;
727 auto dataRequest = std::make_shared<DataRequest>();
729 dataRequest->requestTracks(srcTracks, useMC);
730 dataRequest->requestClusters(srcClusters, useMC);
731 dataRequest->requestPrimaryVertices(useMC);
732 dataRequest->inputs.emplace_back(
"meanvtx",
"GLO",
"MEANVERTEX", 0, Lifetime::Condition,
ccdbParamSpec(
"GLO/Calib/MeanVertex", {}, 1));
733 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
743 {
"max-vtx-neighbours", VariantType::Int, 3, {
"Max PV neighbours fill, no PV study if < 0"}},
744 {
"max-vtx-timediff", VariantType::Float, 90.f, {
"Max PV time difference to consider"}},
745 {
"dcay-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
746 {
"dcaz-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
747 {
"min-tpc-clusters", VariantType::Int, 60, {
"Cut on TPC clusters"}},
748 {
"max-tpc-dcay", VariantType::Float, 5.f, {
"Cut on TPC dcaY"}},
749 {
"max-tpc-dcaz", VariantType::Float, 5.f, {
"Cut on TPC dcaZ"}},
750 {
"max-eta", VariantType::Float, 1.0f, {
"Cut on track eta"}},
751 {
"min-pt", VariantType::Float, 0.1f, {
"Cut on track pT"}},
752 {
"with-its-only", VariantType::Bool,
false, {
"Store tracks with ITS only"}},
753 {
"pair-correlations", VariantType::Bool,
false, {
"Do pairs correlation"}},
754 {
"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"}},
755 {
"min-x-prop", VariantType::Float, 100.f, {
"track should be propagated to this X at least"}},
764 AlgorithmSpec{adaptFromTask<TrackingStudySpec>(dataRequest, ggRequest, srcTracks, useMC, sclOpts)},