Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 60 additions & 45 deletions PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@
/// \author Anton Riedel, TU München, anton.riedel@tum.de
/// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch

#include <vector>
#include <string>
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h"
#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h"

#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisTask.h"
#include "Framework/runDataProcessing.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Framework/runDataProcessing.h"
#include "ReconstructionDataFormats/PID.h"

#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h"
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCalculator.h"
#include <TFile.h>
#include <TH1.h>

#include <string>
#include <vector>

using namespace o2;
using namespace o2::analysis::femto_universe;
using namespace o2::analysis::femto_universe::efficiency;
using namespace o2::analysis::femto_universe::efficiency_correction;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::soa;
Expand Down Expand Up @@ -187,8 +189,10 @@ struct FemtoUniversePairTaskTrackPhi {

ColumnBinningPolicy<aod::collision::PosZ, aod::femtouniversecollision::MultNtr> colBinning{{ConfBinsVtx, ConfBinsMult}, true};

EfficiencyConfigurableGroup effConfGroup;
EfficiencyCalculator<TH1> efficiencyCalculator{&effConfGroup};
HistogramRegistry effCorrRegistry{"EfficiencyCorrection", {}, OutputObjHandlingPolicy::AnalysisObject};

EffCorConfigurableGroup effCorConfGroup;
EfficiencyCorrection effCorrection{&effCorConfGroup};

float weight = 1;

Expand Down Expand Up @@ -372,6 +376,12 @@ struct FemtoUniversePairTaskTrackPhi {
}
}

/// @returns 1 if positive, -1 if negative, 0 if zero
auto sign(auto number) -> int8_t
{
return (number > 0) - (number < 0);
}

void init(InitContext&)
{
if (ConfIsMC) {
Expand All @@ -383,7 +393,14 @@ struct FemtoUniversePairTaskTrackPhi {
registryMCpT.add("MCReco/C_p_pT", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}});
registryMCpT.add("MCReco/NC_p_pT", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}});
}
efficiencyCalculator.init();

effCorrection.init(
&effCorrRegistry,
{
static_cast<framework::AxisSpec>(ConfBinsTempFitVarpT),
{ConfBinsEta, -1, 1},
ConfBinsMult,
});

eventHisto.init(&qaRegistry);
qaRegistry.add("PhiDaugh_pos/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}});
Expand Down Expand Up @@ -467,7 +484,7 @@ struct FemtoUniversePairTaskTrackPhi {
}
}

template <typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t>
template <bool isMC, typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t>
void doSameEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr)
{
for (auto const& phicandidate : groupPartsPhi) {
Expand All @@ -493,6 +510,10 @@ struct FemtoUniversePairTaskTrackPhi {
qaRegistry.fill(HIST("PhiDaugh_neg/hDCAxy"), negChild.p(), negChild.tempFitVar());

trackHistoPartPhi.fillQA<false, false>(phicandidate);
if constexpr (isMC) {
// reco
effCorrection.fillRecoHist<ParticleNo::ONE, FilteredFDCollisions>(phicandidate, 333);
}
}

for (auto const& track : groupPartsTrack) {
Expand Down Expand Up @@ -529,6 +550,10 @@ struct FemtoUniversePairTaskTrackPhi {
qaRegistry.fill(HIST("Hadron_neg/nSigmaTOFPr"), track.p(), tofNSigmaPr);
}
trackHistoPartTrack.fillQA<false, false>(track);

if constexpr (isMC) {
effCorrection.fillRecoHist<ParticleNo::TWO, FilteredFDCollisions>(track, ConfTrackPDGCode);
}
}

/// Now build the combinations
Expand Down Expand Up @@ -556,13 +581,8 @@ struct FemtoUniversePairTaskTrackPhi {
if (!pairCleaner.isCleanPair(track, phicandidate, parts)) {
continue;
}

weight = efficiencyCalculator.getWeight(ParticleNo::ONE, phicandidate.pt()) * efficiencyCalculator.getWeight(ParticleNo::TWO, track.pt());

if constexpr (std::is_same<PartType, FemtoRecoParticles>::value)
sameEventCont.setPair<true>(track, phicandidate, multCol, ConfUse3D, weight);
else
sameEventCont.setPair<false>(track, phicandidate, multCol, ConfUse3D, weight);
weight = effCorrection.getWeight<FilteredFDCollisions>(ParticleNo::ONE, phicandidate) * effCorrection.getWeight<FilteredFDCollisions>(ParticleNo::TWO, track);
sameEventCont.setPair<isMC>(track, phicandidate, multCol, ConfUse3D, weight);
}

// // Used for better fitting of invariant mass background.
Expand Down Expand Up @@ -592,7 +612,7 @@ struct FemtoUniversePairTaskTrackPhi {
// }
}

template <typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t>
template <bool isMC, typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t>
void doMixedEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr)
{
for (auto const& [track, phicandidate] : combinations(CombinationsFullIndexPolicy(groupPartsTrack, groupPartsPhi))) {
Expand All @@ -612,31 +632,23 @@ struct FemtoUniversePairTaskTrackPhi {
continue;
}
}

weight = efficiencyCalculator.getWeight(ParticleNo::ONE, phicandidate.pt()) * efficiencyCalculator.getWeight(ParticleNo::TWO, track.pt());

if constexpr (std::is_same<PartType, FemtoRecoParticles>::value)
mixedEventCont.setPair<true>(track, phicandidate, multCol, ConfUse3D, weight);
else
mixedEventCont.setPair<false>(track, phicandidate, multCol, ConfUse3D, weight);
weight = effCorrection.getWeight<FilteredFDCollisions>(ParticleNo::ONE, phicandidate) * effCorrection.getWeight<FilteredFDCollisions>(ParticleNo::TWO, track);
mixedEventCont.setPair<isMC>(track, phicandidate, multCol, ConfUse3D, weight);
}
}

void processSameEvent(FilteredFDCollision const& col, FilteredFemtoFullParticles const& parts)
{
auto thegroupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
auto thegroupPartsPhi = partsPhi->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
// auto thegroupPartsPhiDaugh = partsPhiDaugh->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
// auto thegroupPartsKaons = partsKaons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
eventHisto.fillQA(col);
doSameEvent(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField(), col.multNtr());
doSameEvent<false>(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField(), col.multNtr());
}
PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processSameEvent, "Enable processing same event", true);

void processMixedEvent(FilteredFDCollisions const& cols, FilteredFemtoFullParticles const& parts)
{
for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) {

const int multiplicityCol = collision1.multNtr();
mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol}));

Expand All @@ -650,20 +662,19 @@ struct FemtoUniversePairTaskTrackPhi {
continue;
}

doMixedEvent(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol);
doMixedEvent<false>(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol);
}
}
PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processMixedEvent, "Enable processing mixed events", true);

///--------------------------------------------MC-------------------------------------------------///
void processSameEventMCReco(FilteredFDCollision const& col, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts)
{
eventHisto.fillQA(col);
// Reco
auto thegroupPartsTrack = partsTrackMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
auto thegroupPartsPhi = partsPhiMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
// auto thegroupPartsPhiDaugh = partsPhiDaugh->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
// auto thegroupPartsKaons = partsKaons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
eventHisto.fillQA(col);
doSameEvent(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField(), col.multNtr(), mcparts);
doSameEvent<true>(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField(), col.multNtr(), mcparts);
}
PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processSameEventMCReco, "Enable processing same event for MC Reco", true);

Expand All @@ -684,7 +695,7 @@ struct FemtoUniversePairTaskTrackPhi {
auto groupPartsTrack = partsTrackMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache);
auto groupPartsPhi = partsPhiMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache);

doMixedEvent(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts);
doMixedEvent<true>(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts);
}
}
PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processMixedEventMCReco, "Enable processing mixed events for MC Reco", false);
Expand All @@ -702,6 +713,10 @@ struct FemtoUniversePairTaskTrackPhi {
continue;
}

if (pdgCode == ConfTrackPDGCode) {
effCorrection.fillTruthHist<ParticleNo::TWO, FilteredFDCollisions>(part);
}

// charge +
if (pdgParticle->Charge() > 0.0) {
registryMCtruth.fill(HIST("MCtruthAllPositivePt"), part.pt());
Expand All @@ -719,6 +734,7 @@ struct FemtoUniversePairTaskTrackPhi {
if (pdgCode == 333) {
registryMCtruth.fill(HIST("MCtruthPhi"), part.pt(), part.eta());
registryMCtruth.fill(HIST("MCtruthPhiPt"), part.pt());
effCorrection.fillTruthHist<ParticleNo::ONE, FilteredFDCollisions>(part);
continue;
}

Expand Down Expand Up @@ -750,12 +766,12 @@ struct FemtoUniversePairTaskTrackPhi {

if (mcpart.pdgMCTruth() == ConfTrackPDGCode && (part.pt() > ConfTrackPtLow) && (part.pt() < ConfTrackPtHigh) && isParticleNSigmaAccepted(part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) {
registryMCpT.fill(HIST("MCReco/NC_p_pT"), part.pt());
float weightTrack = efficiencyCalculator.getWeight(ParticleNo::TWO, part.pt());
float weightTrack = effCorrection.getWeight<FilteredFDCollisions>(ParticleNo::TWO, part);
registryMCpT.fill(HIST("MCReco/C_p_pT"), part.pt(), weightTrack);
}
if ((mcpart.pdgMCTruth() == 333) && (part.partType() == aod::femtouniverseparticle::ParticleType::kPhi) && (part.pt() > ConfPhiPtLow) && (part.pt() < ConfPhiPtHigh)) {
registryMCpT.fill(HIST("MCReco/NC_phi_pT"), part.pt());
float weightPhi = efficiencyCalculator.getWeight(ParticleNo::ONE, part.pt());
float weightPhi = effCorrection.getWeight<FilteredFDCollisions>(ParticleNo::ONE, part);
registryMCpT.fill(HIST("MCReco/C_phi_pT"), part.pt(), weightPhi);
}

Expand All @@ -778,7 +794,6 @@ struct FemtoUniversePairTaskTrackPhi {
registryMCreco.fill(HIST("MCrecoPnegPt"), mcpart.pt());
}
}

} // partType kTrack
}
}
Expand Down
Loading