diff --git a/PWGUD/DataModel/UDTables.h b/PWGUD/DataModel/UDTables.h index 1b422e138d2e1..7c7fcd931bbfd 100644 --- a/PWGUD/DataModel/UDTables.h +++ b/PWGUD/DataModel/UDTables.h @@ -9,8 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#ifndef O2PHYSICS_UDTABLES_H -#define O2PHYSICS_UDTABLES_H +#ifndef PWGUD_DATAMODEL_UDTABLES_H_ +#define PWGUD_DATAMODEL_UDTABLES_H_ + +#include #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" @@ -18,7 +20,6 @@ #include "MathUtils/Utils.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" -#include namespace o2::aod { @@ -170,16 +171,18 @@ using UDCollisionsSel = UDCollisionsSels::iterator; namespace udtrack { -DECLARE_SOA_INDEX_COLUMN(UDCollision, udCollision); //! -DECLARE_SOA_COLUMN(Px, px, float); //! -DECLARE_SOA_COLUMN(Py, py, float); //! -DECLARE_SOA_COLUMN(Pz, pz, float); //! -DECLARE_SOA_COLUMN(Sign, sign, int); //! -DECLARE_SOA_COLUMN(GlobalBC, globalBC, uint64_t); //! -DECLARE_SOA_COLUMN(TrackTime, trackTime, double); //! -DECLARE_SOA_COLUMN(TrackTimeRes, trackTimeRes, float); //! time resolution -DECLARE_SOA_COLUMN(DetectorMap, detectorMap, uint8_t); //! -DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! +DECLARE_SOA_INDEX_COLUMN(UDCollision, udCollision); //! +DECLARE_SOA_COLUMN(Px, px, float); //! +DECLARE_SOA_COLUMN(Py, py, float); //! +DECLARE_SOA_COLUMN(Pz, pz, float); //! +DECLARE_SOA_COLUMN(Sign, sign, int); //! +DECLARE_SOA_COLUMN(GlobalBC, globalBC, uint64_t); //! +DECLARE_SOA_COLUMN(TrackTime, trackTime, double); //! +DECLARE_SOA_COLUMN(TrackTimeRes, trackTimeRes, float); //! time resolution +DECLARE_SOA_COLUMN(DetectorMap, detectorMap, uint8_t); //! +DECLARE_SOA_COLUMN(IsAmbiguous, isAmbiguous, bool); //! +DECLARE_SOA_COLUMN(IsPVContributor, isPVContributor, bool); //! +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! [](float px, float py) -> float { return std::sqrt(px * px + py * py); }); @@ -234,10 +237,15 @@ DECLARE_SOA_TABLE(UDTracksDCA, "AOD", "UDTRACKDCA", track::DcaZ, track::DcaXY) +DECLARE_SOA_TABLE(UDTracksFlags, "AOD", "UDTRACKFLAG", + udtrack::IsAmbiguous, + udtrack::IsPVContributor); + using UDTrack = UDTracks::iterator; using UDTrackCov = UDTracksCov::iterator; using UDTrackExtra = UDTracksExtra::iterator; using UDTrackDCA = UDTracksDCA::iterator; +using UDTrackFlags = UDTracksFlags::iterator; namespace udmctracklabel { @@ -313,4 +321,4 @@ using UDMcFwdTrackLabel = UDMcFwdTrackLabels::iterator; } // namespace o2::aod -#endif // O2PHYSICS_UDTABLES_H +#endif // PWGUD_DATAMODEL_UDTABLES_H_ diff --git a/PWGUD/TableProducer/UPCCandidateProducer.cxx b/PWGUD/TableProducer/UPCCandidateProducer.cxx index b68e569f89392..707b8c51680c6 100644 --- a/PWGUD/TableProducer/UPCCandidateProducer.cxx +++ b/PWGUD/TableProducer/UPCCandidateProducer.cxx @@ -40,6 +40,7 @@ struct UpcCandProducer { Produces udTracksDCA; Produces udTracksPID; Produces udTrackLabels; + Produces udTracksFlags; Produces eventCandidates; Produces eventCandidatesSels; @@ -58,7 +59,8 @@ struct UpcCandProducer { // candidate producer flags Configurable fCheckTPCPID{"checkTPCPID", 0, "Check TPC PID. Useful for central selection -- see `tpcPIDSwitch` option"}; Configurable fTPCPIDSwitch{"tpcPIDSwitch", 0, "PID switch: 0 -- two muons/pions, 1 -- two electrons, 2 -- electron + muon/pion"}; - Configurable fFilterFT0{"filterFT0", 0, "Filter candidates by FT0 signals at the same BC"}; + Configurable fFilterFT0{"filterFT0", 0, "Filter candidates by FT0 signals"}; + Configurable fFilterRangeFT0{"filterRangeFT0", 0, "BC range (+/-) for filtration by FT0 signals"}; Configurable fNFwdProngs{"nFwdProngs", 2, "Matched forward tracks per candidate"}; Configurable fNBarProngs{"nBarProngs", 0, "Matched barrel tracks per candidate"}; @@ -81,7 +83,7 @@ struct UpcCandProducer { upcCuts = (UPCCutparHolder)inputCuts; - const AxisSpec axisSelFwd{upchelpers::kNFwdSels, 0., double(upchelpers::kNFwdSels), ""}; + const AxisSpec axisSelFwd{upchelpers::kNFwdSels, 0., static_cast(upchelpers::kNFwdSels), ""}; histRegistry.add("MuonsSelCounter", "", kTH1F, {axisSelFwd}); histRegistry.get(HIST("MuonsSelCounter"))->GetXaxis()->SetBinLabel(upchelpers::kFwdSelAll + 1, "All"); histRegistry.get(HIST("MuonsSelCounter"))->GetXaxis()->SetBinLabel(upchelpers::kFwdSelPt + 1, "Pt"); @@ -90,7 +92,7 @@ struct UpcCandProducer { histRegistry.get(HIST("MuonsSelCounter"))->GetXaxis()->SetBinLabel(upchelpers::kFwdSelpDCA + 1, "pDCA"); histRegistry.get(HIST("MuonsSelCounter"))->GetXaxis()->SetBinLabel(upchelpers::kFwdSelChi2 + 1, "Chi2"); - const AxisSpec axisSelBar{upchelpers::kNBarrelSels, 0., double(upchelpers::kNBarrelSels), ""}; + const AxisSpec axisSelBar{upchelpers::kNBarrelSels, 0., static_cast(upchelpers::kNBarrelSels), ""}; histRegistry.add("BarrelsSelCounter", "", kTH1F, {axisSelBar}); histRegistry.get(HIST("BarrelsSelCounter"))->GetXaxis()->SetBinLabel(upchelpers::kBarrelSelAll + 1, "All"); histRegistry.get(HIST("BarrelsSelCounter"))->GetXaxis()->SetBinLabel(upchelpers::kBarrelSelHasTOF + 1, "HasTOF"); @@ -449,11 +451,16 @@ struct UpcCandProducer { std::vector const& trackIDs, int32_t candID, uint64_t bc, - TMcTrackLabels* mcTrackLabels) + TMcTrackLabels* mcTrackLabels, + std::unordered_map& ambBarrelTrIds) { for (int32_t trackID : trackIDs) { const auto& track = tracks->iteratorAt(trackID); double trTime = track.trackTime() - std::round(track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS) * o2::constants::lhc::LHCBunchSpacingNS; + bool isAmbiguous = false; + if (upcCuts.getAmbigSwitch() != 1) { + isAmbiguous = ambBarrelTrIds.find(trackID) != ambBarrelTrIds.end(); + } udTracks(candID, track.px(), track.py(), track.pz(), track.sign(), bc, trTime, track.trackTimeRes()); udTracksExtra(track.itsClusterMap(), track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), track.trdPattern(), track.itsChi2NCl(), track.tpcChi2NCl(), track.trdChi2(), track.tofChi2(), @@ -461,6 +468,7 @@ struct UpcCandProducer { udTracksPID(track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()); udTracksDCA(track.dcaZ(), track.dcaXY()); + udTracksFlags(isAmbiguous, track.isPVContributor()); // fill MC labels and masks if needed if (fDoMC) { const auto& label = mcTrackLabels->iteratorAt(trackID); @@ -547,19 +555,22 @@ struct UpcCandProducer { bool checkFT0(upchelpers::FITInfo& info, bool isCentral) { const uint64_t presBitNum = 16; - const float ft0DummyTime = 32.767f; - const float ft0DefaultTime = -999; - const float fT0CBBlower = -1.0; // ns - const float fT0CBBupper = 1.0; // ns - bool hasNoFT0 = false; - if (isCentral) { - bool isBB = TESTBIT(info.BBFT0Apf, presBitNum) || TESTBIT(info.BBFT0Cpf, presBitNum); - bool isBG = TESTBIT(info.BGFT0Apf, presBitNum) || TESTBIT(info.BGFT0Cpf, presBitNum); - hasNoFT0 = !isBB && !isBG; - } else { - bool checkA = std::abs(info.timeFT0A - ft0DummyTime) < 1e-3 || std::abs(info.timeFT0A - ft0DefaultTime) < 1e-3; // dummy or default time - bool checkC = info.timeFT0C > fT0CBBlower && info.timeFT0C < fT0CBBupper; - hasNoFT0 = checkA && checkC; + bool hasNoFT0 = true; + for (uint64_t ibit = presBitNum - fFilterRangeFT0; ibit <= presBitNum + fFilterRangeFT0; ibit++) { + bool check = false; + if (isCentral) { + bool isBB = TESTBIT(info.BBFT0Apf, ibit) || TESTBIT(info.BBFT0Cpf, ibit); + bool isBG = TESTBIT(info.BGFT0Apf, ibit) || TESTBIT(info.BGFT0Cpf, ibit); + check = !isBB && !isBG; + } else { + bool checkA = TESTBIT(info.BGFT0Apf, ibit); + bool checkC = TESTBIT(info.BBFT0Cpf, ibit); + check = checkA && checkC; + } + if (!check) { + hasNoFT0 = false; + break; + } } return hasNoFT0; } @@ -787,7 +798,7 @@ struct UpcCandProducer { // central barrel tracks if (barrelTracks != nullptr) { - if (upcCuts.getAmbigSwitch() != 1) { + if (upcCuts.getAmbigSwitch() != 1 || fCollectBTracksQA) { for (const auto& ambTr : *ambBarrelTracks) { auto trId = ambTr.trackId(); ambBarrelTrIds[trId] = ambTr.globalIndex(); @@ -852,7 +863,7 @@ struct UpcCandProducer { RgtrwTOF++; } } - RgtrwTOF = nBarTracks != 0 ? RgtrwTOF / (float)nBarTracks : 0.; + RgtrwTOF = nBarTracks != 0 ? RgtrwTOF / static_cast(nBarTracks) : 0.; if (RgtrwTOF == 0 && fNBarProngs != 0) { // require at least 1 TOF track in central and semiforward cases continue; } @@ -874,7 +885,7 @@ struct UpcCandProducer { } // store used tracks fillFwdTracks(fwdTracks, fwdTrackIDs, candID, bc, mcFwdTrackLabels); - fillBarrelTracks(barrelTracks, barrelTrackIDs, candID, bc, mcBarrelTrackLabels); + fillBarrelTracks(barrelTracks, barrelTrackIDs, candID, bc, mcBarrelTrackLabels, ambBarrelTrIds); eventCandidates(bc, runNumber, dummyX, dummyY, dummyZ, numContrib, netCharge, RgtrwTOF); eventCandidatesSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, fitInfo.triggerMaskFDD, @@ -906,7 +917,7 @@ struct UpcCandProducer { { fDoMC = false; fDoSemiFwd = false; - createCandidates(&fwdTracks, (BarrelTracks*)nullptr, + createCandidates(&fwdTracks, static_cast(nullptr), &ambFwdTracks, (o2::aod::AmbiguousTracks*)nullptr, bcs, collisions, ft0s, fdds, fv0as, @@ -944,7 +955,7 @@ struct UpcCandProducer { { fDoMC = false; fDoSemiFwd = false; - createCandidates((ForwardTracks*)nullptr, &barrelTracks, + createCandidates(static_cast(nullptr), &barrelTracks, (o2::aod::AmbiguousFwdTracks*)nullptr, &ambBarrelTracks, bcs, collisions, ft0s, fdds, fv0as, @@ -968,7 +979,7 @@ struct UpcCandProducer { fDoMC = true; fDoSemiFwd = false; skimMCInfo(mcCollisions, mcParticles, bcs); - createCandidates(&fwdTracks, (BarrelTracks*)nullptr, + createCandidates(&fwdTracks, static_cast(nullptr), &ambFwdTracks, (o2::aod::AmbiguousTracks*)nullptr, bcs, collisions, ft0s, fdds, fv0as, @@ -1014,7 +1025,7 @@ struct UpcCandProducer { fDoMC = true; fDoSemiFwd = false; skimMCInfo(mcCollisions, mcParticles, bcs); - createCandidates((ForwardTracks*)nullptr, &barrelTracks, + createCandidates(static_cast(nullptr), &barrelTracks, (o2::aod::AmbiguousFwdTracks*)nullptr, &ambBarrelTracks, bcs, collisions, ft0s, fdds, fv0as,