256 static int TFCount = 0;
257 int nv = vtxRefs.size();
260 std::vector<o2::dataformats::PrimaryVertexExt> pveVec(nv);
261 std::vector<float> tpcOccAftV, tpcOccBefV;
262 pveVec.back() = vtxDummy;
266 std::vector<o2::dataformats::TrackInfoExt> trcExtVec;
267 std::vector<o2::trackstudy::TrackPairInfo> trcPairsVec;
270 int groupOcc = std::ceil(maxDriftTB / mNOccBinsDrift / mNTPCOccBinLength);
280 uint8_t clSect = 0, clRow = 0, lowestR = -1;
282 for (
int ic = 0; ic < trc.getNClusterReferences(); ic++) {
283 trc.getClusterReference(clRefs, ic, clSect, clRow, clIdx);
284 if (clRow < lowestR) {
288 unsigned int absoluteIndex = tpcClusAcc.clusterOffset[clSect][clRow] + clIdx;
290 trExt.nClTPCShared++;
293 trExt.rowMinTPC = lowestR;
294 const auto& clus = tpcClusAcc.clusters[clSect][clRow][clIdx];
295 trExt.padFromEdge = uint8_t(clus.getPad());
296 int npads = o2::gpu::GPUTPCGeometry::NPads(lowestR);
297 if (trExt.padFromEdge > npads / 2) {
298 trExt.padFromEdge = npads - 1 - trExt.padFromEdge;
300 this->mTPCCorrMapsLoader.Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos0[0], trExt.innerTPCPos0[1], trExt.innerTPCPos0[2], trc.getTime0());
301 if (timestampTB > -1e8) {
302 this->mTPCCorrMapsLoader.Transform(clSect, clRow, clus.getPad(), clus.getTime(), trExt.innerTPCPos[0], trExt.innerTPCPos[1], trExt.innerTPCPos[2], timestampTB);
304 trExt.innerTPCPos = trExt.innerTPCPos0;
306 trc.getClusterReference(clRefs, 0, clSect, clRow, clIdx);
307 trExt.rowMaxTPC = clRow;
313 uint8_t nsh = 0, nshRows = 0, lastSharedRow = -1;
315 uint8_t clSect0 = 0, clRow0 = 0, clSect1 = 0, clRow1 = 0;
316 uint32_t clIdx0 = 0, clIdx1 = 0;
318 for (
int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) {
319 trc0.getClusterReference(clRefs, ic0, clSect0, clRow0, clIdx0);
320 for (
int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) {
321 trc1.getClusterReference(clRefs, ic1, clSect1, clRow1, clIdx1);
322 if (clRow1 > clRow0) {
326 if (clRow1 == clRow0) {
327 if (clSect0 == clSect1 && clIdx0 == clIdx1) {
329 if (lastSharedRow != clRow0) {
330 lastSharedRow = clRow0;
340 return std::make_pair(nsh, nshRows);
346 dst.ts.setTimeStamp(
src.ttime);
347 dst.ts.setTimeStampError(
src.ttimeE);
350 dst.pattITS =
src.pattITS;
351 if (
src.q2ptITS == 0. &&
dst.nClITS > 0) {
352 dst.pattITS |= 0x1 << 7;
354 dst.lowestPadRow =
src.rowMinTPC;
360 auto msk =
src.gid.getSourceDetectorsMask();
364 if (lblITS.isFake()) {
385 tpcOccAftV.resize(mNOccBinsDrift);
386 tpcOccBefV.resize(mNOccBinsDrift);
388 for (
int iv = 0; iv < nv; iv++) {
389 LOGP(
debug,
"processing PV {} of {}", iv, nv);
390 const auto& vtref = vtxRefs[iv];
392 auto& pve = pveVec[iv];
395 float bestTimeDiff = 1000, bestTime = -999;
399 const auto& ft0 = FITInfo[trackIndex[ift0]];
401 auto fitTime = ft0.getInteractionRecord().differenceInBCMUS(recoData.
startIR);
402 if (std::abs(fitTime - pve.getTimeStamp().getTimeStamp()) < bestTimeDiff) {
403 bestTimeDiff = fitTime - pve.getTimeStamp().getTimeStamp();
404 bestFTID = trackIndex[ift0];
409 LOGP(warn,
"FT0 is not requested, cannot set complete vertex info");
412 pve.FT0A = FITInfo[bestFTID].getTrigger().getAmplA();
413 pve.FT0C = FITInfo[bestFTID].getTrigger().getAmplC();
414 pve.FT0Time = double(FITInfo[bestFTID].getInteractionRecord().differenceInBCMUS(recoData.
startIR)) + FITInfo[bestFTID].getCollisionTimeMean() * 1e-6;
420 float q2ptITS, q2ptTPC, q2ptITSTPC, q2ptITSTPCTRD;
424 int idMin = vtref.getFirstEntryOfSource(is), idMax = idMin + vtref.getEntriesOfSource(is);
425 for (
int i = idMin;
i < idMax;
i++) {
426 auto vid = trackIndex[
i];
427 bool pvCont = vid.isPVContributor();
429 pveVec[iv].nSrc[is]++;
440 nclTPC = tpcTr->getNClusters();
441 if (nclTPC < mMinTPCClusters) {
445 bool ambig = vid.isAmbiguous();
447 if (abs(trc.getEta()) > mMaxEta) {
450 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
451 float corz = vdrift * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
452 if (tpcTr->hasASideClustersOnly()) {
455 trc.setZ(trc.getZ() + corz);
457 float xmin = trc.getX();
459 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], trc, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &dca)) {
462 bool hasITS = GTrackID::getSourceDetectorsMask(is)[
GTrackID::ITS];
463 if (std::abs(dca.getY()) > (hasITS ? getDCAYCut(trc.getPt()) : mTPCDCAYCut) ||
464 std::abs(dca.getZ()) > (hasITS ? getDCAZCut(trc.getPt()) : mTPCDCAZCut)) {
467 if (trc.getPt() < mMinPt) {
471 pveVec[iv].nSrcA[is]++;
473 pveVec[iv].nSrcAU[is]++;
476 if (!hasITS && mStoreWithITSOnly) {
480 auto& trcExt = trcExtVec.emplace_back();
481 recoData.
getTrackTime(vid, trcExt.ttime, trcExt.ttimeE);
483 trcExt.hashIU = trc.hash();
487 trcExt.dcaTPC.set(-999.f, -999.f);
491 if (tpcTr->hasASideClusters()) {
494 if (tpcTr->hasCSideClusters()) {
502 if (iv < nv - 1 && is == GTrackID::TPC && tpcTr && !tpcTr->hasBothSidesClusters()) {
503 float corz = vdrift * (tpcTr->getTime0() * mTPCTBinMUS - pvvec[iv].getTimeStamp().getTimeStamp());
504 if (tpcTr->hasASideClustersOnly()) {
507 tmpTPC.setZ(tmpTPC.getZ() + corz);
509 if (!prop->propagateToDCA(iv == nv - 1 ? vtxDummy : pvvec[iv], tmpTPC, prop->getNominalBz(), 2., o2::base::PropagatorF::MatCorrType::USEMatCorrLUT, &trcExt.dcaTPC)) {
510 trcExt.dcaTPC.set(-999.f, -999.f);
513 fillTPCClInfo(*tpcTr, trcExt, tsuse);
514 trcExt.chi2TPC = tpcTr->getChi2();
519 trcExt.q2ptITS = itsTr.getQ2Pt();
520 trcExt.nClITS = itsTr.getNClusters();
521 for (
int il = 0; il < 7; il++) {
522 if (itsTr.hasHitOnLayer(il)) {
523 trcExt.pattITS |= 0x1 << il;
528 trcExt.nClITS = itsTrf.getNClusters();
529 for (
int il = 0; il < 7; il++) {
530 if (itsTrf.hasHitOnLayer(il)) {
531 trcExt.pattITS |= 0x1 << il;
537 trcExt.nClTPC = nclTPC;
541 trcExt.q2ptITSTPC = trTPCITS.getQ2Pt();
542 trcExt.chi2ITSTPC = trTPCITS.getChi2Match();
553 float tpcOccBef = 0., tpcOccAft = 0.;
555 int tb = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv;
556 tpcOccBef = tb < 0 ? mTBinClOccBef[0] : (tb >= mTBinClOccBef.size() ? mTBinClOccBef.back() : mTBinClOccBef[tb]);
557 tpcOccAft = tb < 0 ? mTBinClOccAft[0] : (tb >= mTBinClOccAft.size() ? mTBinClOccAft.back() : mTBinClOccAft[tb]);
558 int tbc = pveVec[iv].getTimeStamp().getTimeStamp() * mTPCTBinMUSInv * mNTPCOccBinLengthInv - groupOcc / 2.;
559 for (
int iob = 0; iob < mNOccBinsDrift; iob++) {
561 for (
int ig = 0; ig < groupOcc; ig++) {
562 int ocb = tbc + ig + groupOcc * iob;
563 if (ocb < 0 || ocb >= (
int)mMltHistTB.size()) {
567 sm += mMltHistTB[ocb];
569 tpcOccAftV[iob] = sm;
572 for (
int ig = 0; ig < groupOcc; ig++) {
573 int ocb = tbc + ig - groupOcc * iob;
574 if (ocb < 0 || ocb >= (
int)mMltHistTB.size()) {
578 sm += mMltHistTB[ocb];
580 tpcOccBefV[iob] = sm;
584 <<
"orbit=" << recoData.
startIR.
orbit <<
"tfID=" << TFCount
585 <<
"tpcOccBef=" << tpcOccBef <<
"tpcOccAft=" << tpcOccAft
586 <<
"tpcOccBefV=" << tpcOccBefV <<
"tpcOccAftV=" << tpcOccAftV
587 <<
"pve=" << pveVec[iv] <<
"trc=" << trcExtVec <<
"\n";
590 for (
int it0 = 0; it0 < (
int)trcExtVec.size(); it0++) {
591 const auto& tr0 = trcExtVec[it0];
592 if (tr0.nClTPC < 1) {
595 for (
int it1 = it0 + 1; it1 < (
int)trcExtVec.size(); it1++) {
596 const auto& tr1 = trcExtVec[it1];
597 if (tr1.nClTPC < 1) {
601 if (std::abs(tr0.track.getTgl() - tr1.track.getTgl()) > 0.25) {
604 auto dphi = tr0.track.getPhi() - tr1.track.getPhi();
610 if (std::abs(dphi) > 0.25) {
613 auto& pr = trcPairsVec.emplace_back();
614 assignRecTrack(tr0, pr.tr0);
615 assignRecTrack(tr1, pr.tr1);
617 pr.nshTPC = shinfo.first;
618 pr.nshTPCRow = shinfo.second;
621 (*mDBGOut) <<
"pairs" <<
"pr=" << trcPairsVec <<
"\n";
625 int nvtot = mMaxNeighbours < 0 ? -1 : (
int)pveVec.size();
627 auto insSlot = [maxSlots = mMaxNeighbours](std::vector<float>& vc,
float v,
int slot, std::vector<int>& vid,
int id) {
628 for (
int i = maxSlots - 1;
i > slot;
i--) {
629 std::swap(vc[
i], vc[
i - 1]);
630 std::swap(vid[
i], vid[
i - 1]);
636 for (
int cnt = 0; cnt < nvtot; cnt++) {
637 const auto& pve = pveVec[cnt];
638 float tv = pve.getTimeStamp().getTimeStamp();
639 std::vector<o2::dataformats::PrimaryVertexExt> pveT(mMaxNeighbours);
640 std::vector<o2::dataformats::PrimaryVertexExt> pveZ(mMaxNeighbours);
641 std::vector<int> idT(mMaxNeighbours), idZ(mMaxNeighbours);
642 std::vector<float> dT(mMaxNeighbours), dZ(mMaxNeighbours);
643 for (
int i = 0;
i < mMaxNeighbours;
i++) {
644 idT[
i] = idZ[
i] = -1;
645 dT[
i] = mMaxVTTimeDiff;
648 int cntM = cnt - 1, cntP = cnt + 1;
649 for (; cntM >= 0; cntM--) {
650 const auto& vt = pveVec[cntM];
651 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
652 if (dtime > mMaxVTTimeDiff) {
655 for (
int i = 0;
i < mMaxNeighbours;
i++) {
657 insSlot(dT, dtime,
i, idT, cntM);
661 auto dz = std::abs(pve.getZ() - vt.getZ());
662 for (
int i = 0;
i < mMaxNeighbours;
i++) {
664 insSlot(dZ, dz,
i, idZ, cntM);
669 for (; cntP < nvtot; cntP++) {
670 const auto& vt = pveVec[cntP];
671 auto dtime = std::abs(tv - vt.getTimeStamp().getTimeStamp());
672 if (dtime > mMaxVTTimeDiff) {
675 for (
int i = 0;
i < mMaxNeighbours;
i++) {
677 insSlot(dT, dtime,
i, idT, cntP);
681 auto dz = std::abs(pve.getZ() - vt.getZ());
682 for (
int i = 0;
i < mMaxNeighbours;
i++) {
684 insSlot(dZ, dz,
i, idZ, cntP);
689 for (
int i = 0;
i < mMaxNeighbours;
i++) {
691 pveT[
i] = pveVec[idT[
i]];
696 for (
int i = 0;
i < mMaxNeighbours;
i++) {
698 pveZ[
i] = pveVec[idZ[
i]];
703 (*mDBGOutVtx) <<
"pvExt"
707 <<
"tfID=" << TFCount
752 std::vector<OutputSpec> outputs;
753 auto dataRequest = std::make_shared<DataRequest>();
755 dataRequest->requestTracks(srcTracks, useMC);
756 dataRequest->requestClusters(srcClusters, useMC);
757 dataRequest->requestPrimaryVertices(useMC);
758 dataRequest->inputs.emplace_back(
"meanvtx",
"GLO",
"MEANVERTEX", 0, Lifetime::Condition,
ccdbParamSpec(
"GLO/Calib/MeanVertex", {}, 1));
759 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
769 {
"max-vtx-neighbours", VariantType::Int, 3, {
"Max PV neighbours fill, no PV study if < 0"}},
770 {
"max-vtx-timediff", VariantType::Float, 90.f, {
"Max PV time difference to consider"}},
771 {
"dcay-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
772 {
"dcaz-vs-pt", VariantType::String,
"0.0105 + 0.0350 / pow(x, 1.1)", {
"Formula for global tracks DCAy vs pT cut"}},
773 {
"min-tpc-clusters", VariantType::Int, 60, {
"Cut on TPC clusters"}},
774 {
"max-tpc-dcay", VariantType::Float, 5.f, {
"Cut on TPC dcaY"}},
775 {
"max-tpc-dcaz", VariantType::Float, 5.f, {
"Cut on TPC dcaZ"}},
776 {
"max-eta", VariantType::Float, 1.0f, {
"Cut on track eta"}},
777 {
"min-pt", VariantType::Float, 0.1f, {
"Cut on track pT"}},
778 {
"with-its-only", VariantType::Bool,
false, {
"Store tracks with ITS only"}},
779 {
"pair-correlations", VariantType::Bool,
false, {
"Do pairs correlation"}},
780 {
"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"}},
781 {
"noccbins", VariantType::Int, 10, {
"Number of occupancy bins per full drift time"}},
782 {
"min-x-prop", VariantType::Float, 100.f, {
"track should be propagated to this X at least"}},
791 AlgorithmSpec{adaptFromTask<TrackingStudySpec>(dataRequest, ggRequest, srcTracks, useMC, sclOpts)},