Skip to content

Commit

Permalink
PWGEM/Dilepton: add possibility to use DCAz
Browse files Browse the repository at this point in the history
  • Loading branch information
dsekihat committed Oct 29, 2024
1 parent f01452c commit eb0fb50
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 164 deletions.
164 changes: 13 additions & 151 deletions PWGEM/Dilepton/Core/Dilepton.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ using namespace o2::framework::expressions;
using namespace o2::soa;
using namespace o2::aod::pwgem::dilepton::utils;
using namespace o2::aod::pwgem::dilepton::utils::emtrackutil;
using namespace o2::aod::pwgem::dilepton::utils::pairutil;

using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMEventsQvec>;
using MyCollision = MyCollisions::iterator;
Expand Down Expand Up @@ -115,7 +116,7 @@ struct Dilepton {
Configurable<int> cfgNtracksPV08Min{"cfgNtracksPV08Min", -1, "min. multNTracksPV"};
Configurable<int> cfgNtracksPV08Max{"cfgNtracksPV08Max", static_cast<int>(1e+9), "max. multNTracksPV"};
Configurable<bool> cfgApplyWeightTTCA{"cfgApplyWeightTTCA", false, "flag to apply weighting by 1/N"};
Configurable<bool> cfgUseDCAxy{"cfgUseDCAxy", false, "flag to use DCAxy, instead of DCA3D"};
Configurable<uint8_t> cfgDCAType{"cfgDCAType", 0, "type of DCA for output. 0:3D, 1:XY, 2:Z, else:3D"};

ConfigurableAxis ConfMllBins{"ConfMllBins", {VARIABLE_WIDTH, 0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.75, 2.80, 2.85, 2.90, 2.95, 3.00, 3.05, 3.10, 3.15, 3.20, 3.25, 3.30, 3.35, 3.40, 3.45, 3.50, 3.55, 3.60, 3.65, 3.70, 3.75, 3.80, 3.85, 3.90, 3.95, 4.00}, "mll bins for output histograms"};
ConfigurableAxis ConfPtllBins{"ConfPtllBins", {VARIABLE_WIDTH, 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pTll bins for output histograms"};
Expand Down Expand Up @@ -459,11 +460,6 @@ struct Dilepton {
delete emh_neg;
emh_neg = 0x0;

// map_mixed_eventId_to_centrality.clear();
// map_mixed_eventId_to_occupancy.clear();
// map_mixed_eventId_to_qvector.clear();
// map_mixed_eventId_to_globalBC.clear();

used_trackIds.clear();
used_trackIds.shrink_to_fit();

Expand All @@ -484,8 +480,10 @@ struct Dilepton {
mass_axis_title = "m_{ee} (GeV/c^{2})";
pair_pt_axis_title = "p_{T,ee} (GeV/c)";
pair_dca_axis_title = "DCA_{ee}^{3D} (#sigma)";
if (cfgUseDCAxy) {
if (cfgDCAType == 1) {
pair_dca_axis_title = "DCA_{ee}^{XY} (#sigma)";
} else if (cfgDCAType == 2) {
pair_dca_axis_title = "DCA_{ee}^{Z} (#sigma)";
}
} else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
mass_axis_title = "m_{#mu#mu} (GeV/c^{2})";
Expand Down Expand Up @@ -532,9 +530,6 @@ struct Dilepton {
fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/");

fRegistry.add("Pair/mix/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true);
// fRegistry.add("Pair/mix/uls/hs_woEPmix", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true);
// fRegistry.add("Pair/mix/uls/hPrfUQCosDPhi", Form("dilepton <#vec{u}_{%d,l1} #upoint #vec{Q}_{%d,ev1}^{%s} cos(%d(#varphi_{l1} - #varphi_{ll}))> + <#vec{u}_{%d,l2} #upoint #vec{Q}_{%d,ev2}^{%s} cos(%d(#varphi_{l2} - #varphi_{ll}))>", nmod, nmod, qvec_det_names[cfgQvecEstimator].data(), nmod, nmod, nmod, qvec_det_names[cfgQvecEstimator].data(), nmod), kTProfile3D, {axis_mass, axis_pt, axis_dca}, true);
// fRegistry.add("Pair/mix/uls/hPrf2UQ1UQ2CosDPhi12", Form("dilepton <2 #vec{u}_{%d,l1} #upoint #vec{Q}_{%d,ev1}^{%s} #vec{u}_{%d,l2} #upoint #vec{Q}_{%d,ev2}^{%s} cos(%d(#varphi_{l1} - #varphi_{l2}))>", nmod, nmod, qvec_det_names[cfgQvecEstimator].data(), nmod, nmod, qvec_det_names[cfgQvecEstimator].data(), nmod), kTProfile3D, {axis_mass, axis_pt, axis_dca}, true);
fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lspp/");
fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lsmm/");

Expand Down Expand Up @@ -805,27 +800,23 @@ struct Dilepton {
ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), leptonM2);
ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;

float dca_t1 = 999.f, dca_t2 = 999.f, pair_dca = 999.f;
float pair_dca = 999.f;
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
dca_t1 = dca3DinSigma(t1);
dca_t2 = dca3DinSigma(t2);
pair_dca = std::sqrt((dca_t1 * dca_t1 + dca_t2 * dca_t2) / 2.);
if (cfgUseDCAxy) {
dca_t1 = t1.dcaXY() / std::sqrt(t1.cYY());
dca_t2 = t2.dcaXY() / std::sqrt(t2.cYY());
pair_dca = std::sqrt((dca_t1 * dca_t1 + dca_t2 * dca_t2) / 2.);
pair_dca = pairDCAQuadSum(dca3DinSigma(t1), dca3DinSigma(t2));
if (cfgDCAType == 1) {
pair_dca = pairDCAQuadSum(dcaXYinSigma(t1), dcaXYinSigma(t2));
} else if (cfgDCAType == 2) {
pair_dca = pairDCAQuadSum(dcaZinSigma(t1), dcaZinSigma(t2));
}
} else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
dca_t1 = fwdDcaXYinSigma(t1);
dca_t2 = fwdDcaXYinSigma(t2);
pair_dca = std::sqrt((dca_t1 * dca_t1 + dca_t2 * dca_t2) / 2.);
pair_dca = pairDCAQuadSum(fwdDcaXYinSigma(t1), fwdDcaXYinSigma(t2));
}
float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz);

if (cfgAnalysisType == static_cast<int>(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC)) {
float deta = v1.Eta() - v2.Eta();
float dphi = v1.Phi() - v2.Phi();
o2::math_utils::bringToPMPi(dphi);
float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz);
float opAng = o2::aod::pwgem::dilepton::utils::pairutil::getOpeningAngle(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz());

if (t1.sign() * t2.sign() < 0) { // ULS
Expand Down Expand Up @@ -1056,9 +1047,6 @@ struct Dilepton {

TEMH* emh_pos = nullptr;
TEMH* emh_neg = nullptr;
// std::map<std::pair<int, int>, std::vector<std::vector<std::array<float, 2>>>> map_mixed_eventId_to_qvector;
// std::map<std::pair<int, int>, float> map_mixed_eventId_to_centrality;
// std::map<std::pair<int, int>, int> map_mixed_eventId_to_occupancy;
std::map<std::pair<int, int>, uint64_t> map_mixed_eventId_to_globalBC;

std::vector<std::pair<int, int>> used_trackIds;
Expand Down Expand Up @@ -1249,68 +1237,7 @@ struct Dilepton {
}
} // end of loop over mixed event pool

// // run mixed event loop for flow measurement. Don't divide mixed-event categories by event planes, if you do flow measurement.
// if (cfgAnalysisType == static_cast<int>(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV2) || cfgAnalysisType == static_cast<int>(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV3)) {
// for (int epbin_tmp = 0; epbin_tmp < static_cast<int>(ep_bin_edges.size()) - 1; epbin_tmp++) {
// std::tuple<int, int, int, int> key_bin = std::make_tuple(zbin, centbin, epbin_tmp, occbin);
// auto collisionIds_in_mixing_pool = emh_pos->GetCollisionIdsFromEventPool(key_bin); // pos/neg does not matter.
// // LOGF(info, "collisionIds_in_mixing_pool.size() = %d", collisionIds_in_mixing_pool.size());

// for (auto& mix_dfId_collisionId : collisionIds_in_mixing_pool) {
// int mix_dfId = mix_dfId_collisionId.first;
// int mix_collisionId = mix_dfId_collisionId.second;
// if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection.
// continue;
// }

// auto centrality_mix = map_mixed_eventId_to_centrality[mix_dfId_collisionId];
// auto occupancy_mix = map_mixed_eventId_to_occupancy[mix_dfId_collisionId];
// auto qvectors_mix = map_mixed_eventId_to_qvector[mix_dfId_collisionId];
// auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId];
// uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix);
// if (diffBC < ndiff_bc_mix) {
// continue;
// }

// auto posTracks_from_event_pool = emh_pos->GetTracksPerCollision(mix_dfId_collisionId);
// auto negTracks_from_event_pool = emh_neg->GetTracksPerCollision(mix_dfId_collisionId);
// // LOGF(info, "Do event mixing: current event (%d, %d) | event pool (%d, %d), npos = %d , nneg = %d", ndf, collision.globalIndex(), mix_dfId, mix_collisionId, posTracks_from_event_pool.size(), negTracks_from_event_pool.size());

// for (auto& pos : selected_posTracks_in_this_event) { // ULS mix
// for (auto& neg : negTracks_from_event_pool) {
// fillMixedPairInfoForFlow(pos, neg, cut, qvectors, qvectors_mix, collision.centFT0C(), centrality_mix, collision.trackOccupancyInTimeRange(), occupancy_mix);
// }
// }

// for (auto& neg : selected_negTracks_in_this_event) { // ULS mix
// for (auto& pos : posTracks_from_event_pool) {
// fillMixedPairInfoForFlow(neg, pos, cut, qvectors, qvectors_mix, collision.centFT0C(), centrality_mix, collision.trackOccupancyInTimeRange(), occupancy_mix);
// }
// }

// for (auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix
// for (auto& pos2 : posTracks_from_event_pool) {
// fillMixedPairInfoForFlow(pos1, pos2, cut, qvectors, qvectors_mix, collision.centFT0C(), centrality_mix, collision.trackOccupancyInTimeRange(), occupancy_mix);
// }
// }

// for (auto& neg1 : selected_negTracks_in_this_event) { // LS-- mix
// for (auto& neg2 : negTracks_from_event_pool) {
// fillMixedPairInfoForFlow(neg1, neg2, cut, qvectors, qvectors_mix, collision.centFT0C(), centrality_mix, collision.trackOccupancyInTimeRange(), occupancy_mix);
// }
// }
// } // end of loop over mixed event pool

// } // end of ep bin loop

// } // end of mixing loop for flow

if (nuls > 0 || nlspp > 0 || nlsmm > 0) {
// if (nmod > 0) {
// map_mixed_eventId_to_qvector[key_df_collision] = qvectors;
// map_mixed_eventId_to_centrality[key_df_collision] = collision.centFT0C();
// map_mixed_eventId_to_occupancy[key_df_collision] = collision.trackOccupancyInTimeRange();
// }
map_mixed_eventId_to_globalBC[key_df_collision] = collision.globalBC();
emh_pos->AddCollisionIdAtLast(key_bin, key_df_collision);
emh_neg->AddCollisionIdAtLast(key_bin, key_df_collision);
Expand All @@ -1321,71 +1248,6 @@ struct Dilepton {
ndf++;
} // end of DF

// template <typename TTrack1, typename TTrack2, typename TCut, typename TQvectors, typename TMixedQvectors>
// bool fillMixedPairInfoForFlow(TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TQvectors const& qvectors, TMixedQvectors const& qvectors_mix, const float centrality, const float centrality_mix, const int occupancy, const int occupancy_mix)
// {
// if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
// auto v1ambIds = t1.ambiguousElectronsIds();
// auto v2ambIds = t2.ambiguousElectronsIds();
// if ((t1.dfId() == t2.dfId()) && std::find(v2ambIds.begin(), v2ambIds.end(), t1.globalIndex()) != v2ambIds.end() && std::find(v1ambIds.begin(), v1ambIds.end(), t2.globalIndex()) != v1ambIds.end()) {
// return false; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions.
// }
// } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
// auto v1ambIds = t1.ambiguousMuonsIds();
// auto v2ambIds = t2.ambiguousMuonsIds();
// if ((t1.dfId() == t2.dfId()) && std::find(v2ambIds.begin(), v2ambIds.end(), t1.globalIndex()) != v2ambIds.end() && std::find(v1ambIds.begin(), v1ambIds.end(), t2.globalIndex()) != v1ambIds.end()) {
// return false; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions.
// }
// }

// if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
// if (!cut.template IsSelectedPair(t1, t2, d_bz)) {
// return false;
// }
// } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
// if (!cut.template IsSelectedPair(t1, t2)) {
// return false;
// }
// }

// ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), leptonM1);
// ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), leptonM2);
// ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;

// float dca_t1 = 999.f, dca_t2 = 999.f, pair_dca = 999.f;
// if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
// dca_t1 = dca3DinSigma(t1);
// dca_t2 = dca3DinSigma(t2);
// pair_dca = std::sqrt((dca_t1 * dca_t1 + dca_t2 * dca_t2) / 2.);
// } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
// dca_t1 = fwdDcaXYinSigma(t1);
// dca_t2 = fwdDcaXYinSigma(t2);
// pair_dca = std::sqrt((dca_t1 * dca_t1 + dca_t2 * dca_t2) / 2.);
// }

// float sp1 = RecoDecay::dotProd(std::array<float, 2>{static_cast<float>(std::cos(nmod * v1.Phi())), static_cast<float>(std::sin(nmod * v1.Phi()))}, qvectors[nmod][cfgQvecEstimator]) / getSPresolution(centrality, occupancy);
// float sp2 = RecoDecay::dotProd(std::array<float, 2>{static_cast<float>(std::cos(nmod * v2.Phi())), static_cast<float>(std::sin(nmod * v2.Phi()))}, qvectors_mix[nmod][cfgQvecEstimator]) / getSPresolution(centrality_mix, occupancy_mix);
// float cos_dphi1 = std::cos(nmod * (v1.Phi() - v12.Phi()));
// float cos_dphi2 = std::cos(nmod * (v2.Phi() - v12.Phi()));
// float cos_dphi12 = std::cos(nmod * (v1.Phi() - v2.Phi()));
// const float weight = 1.f;

// if (t1.sign() * t2.sign() < 0) { // ULS
// fRegistry.fill(HIST("Pair/mix/uls/hs_woEPmix"), v12.M(), v12.Pt(), pair_dca, weight);
// fRegistry.fill(HIST("Pair/mix/uls/hPrfUQCosDPhi"), v12.M(), v12.Pt(), pair_dca, sp1 * cos_dphi1 + sp2 * cos_dphi2, weight);
// fRegistry.fill(HIST("Pair/mix/uls/hPrf2UQ1UQ2CosDPhi12"), v12.M(), v12.Pt(), pair_dca, 2.f * sp1 * sp2 * cos_dphi12, weight);
// } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++
// fRegistry.fill(HIST("Pair/mix/lspp/hs_woEPmix"), v12.M(), v12.Pt(), pair_dca, weight);
// fRegistry.fill(HIST("Pair/mix/lspp/hPrfUQCosDPhi"), v12.M(), v12.Pt(), pair_dca, sp1 * cos_dphi1 + sp2 * cos_dphi2, weight);
// fRegistry.fill(HIST("Pair/mix/lspp/hPrf2UQ1UQ2CosDPhi12"), v12.M(), v12.Pt(), pair_dca, 2.f * sp1 * sp2 * cos_dphi12, weight);
// } else if (t1.sign() < 0 && t2.sign() < 0) { // LS--
// fRegistry.fill(HIST("Pair/mix/lsmm/hs_woEPmix"), v12.M(), v12.Pt(), pair_dca, weight);
// fRegistry.fill(HIST("Pair/mix/lsmm/hPrfUQCosDPhi"), v12.M(), v12.Pt(), pair_dca, sp1 * cos_dphi1 + sp2 * cos_dphi2, weight);
// fRegistry.fill(HIST("Pair/mix/lsmm/hPrf2UQ1UQ2CosDPhi12"), v12.M(), v12.Pt(), pair_dca, 2.f * sp1 * sp2 * cos_dphi12, weight);
// }
// return true;
// }

template <typename TCollision, typename TTrack1, typename TTrack2, typename TCut>
bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut)
{
Expand Down
Loading

0 comments on commit eb0fb50

Please sign in to comment.