Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 18 additions & 17 deletions PWGEM/Dilepton/Core/Dilepton.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
#include <utility>
#include <vector>

using namespace o2;

Check failure on line 63 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::aod;

Check failure on line 64 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::framework;

Check failure on line 65 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::framework::expressions;

Check failure on line 66 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::soa;

Check failure on line 67 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::aod::pwgem::dilepton::utils;

Check failure on line 68 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::aod::pwgem::dilepton::utils::emtrackutil;

Check failure on line 69 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.
using namespace o2::aod::pwgem::dilepton::utils::pairutil;

Check failure on line 70 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[using-directive]

Do not put using directives at global scope in headers.

using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMEventsQvec>;
using MyCollision = MyCollisions::iterator;
Expand Down Expand Up @@ -449,10 +449,10 @@
}

// In case override, don't proceed, please - no CCDB access required
if (d_bz_input > -990) {

Check failure on line 452 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
d_bz = d_bz_input;
o2::parameters::GRPMagField grpmag;
if (std::fabs(d_bz) > 1e-5) {

Check failure on line 455 in PWGEM/Dilepton/Core/Dilepton.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
grpmag.setL3Current(30000.f / (d_bz / 5.0f));
}
o2::base::Propagator::initFieldFromGRP(&grpmag);
Expand Down Expand Up @@ -510,8 +510,8 @@
delete emh_neg;
emh_neg = 0x0;

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

delete h2sp_resolution;
}
Expand Down Expand Up @@ -819,8 +819,8 @@
{
if constexpr (ev_id == 1) {
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
// bool is_found1 = std::find(t2.ambiguousElectronsIds.begin(), t2.ambiguousElectronsIds.end(), t1.globalIndex()) != t2.ambiguousElectronsIds.end(); //this does not work.
// bool is_found2 = std::find(t1.ambiguousElectronsIds.begin(), t1.ambiguousElectronsIds.end(), t2.globalIndex()) != t1.ambiguousElectronsIds.end(); //this does not work.
// bool is_found1 = std::find(t2.ambiguousElectronsIds.begin(), t2.ambiguousElectronsIds.end(), t1.globalIndex()) != t2.ambiguousElectronsIds.end(); // this does not work.
// bool is_found2 = std::find(t1.ambiguousElectronsIds.begin(), t1.ambiguousElectronsIds.end(), t2.globalIndex()) != t1.ambiguousElectronsIds.end(); // this does not work.
auto v1ambIds = t1.ambiguousElectronsIds();
auto v2ambIds = t2.ambiguousElectronsIds();

Expand All @@ -829,8 +829,8 @@
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) {
// bool is_found1 = std::find(t2.ambiguousMuonsIds.begin(), t2.ambiguousMuonsIds.end(), t1.globalIndex()) != t2.ambiguousMuonsIds.end(); //this does not work.
// bool is_found2 = std::find(t1.ambiguousMuonsIds.begin(), t1.ambiguousMuonsIds.end(), t2.globalIndex()) != t1.ambiguousMuonsIds.end(); //this does not work.
// bool is_found1 = std::find(t2.ambiguousMuonsIds.begin(), t2.ambiguousMuonsIds.end(), t1.globalIndex()) != t2.ambiguousMuonsIds.end(); // this does not work.
// bool is_found2 = std::find(t1.ambiguousMuonsIds.begin(), t1.ambiguousMuonsIds.end(), t2.globalIndex()) != t1.ambiguousMuonsIds.end(); // this does not work.
auto v1ambIds = t1.ambiguousMuonsIds();
auto v2ambIds = t2.ambiguousMuonsIds();

Expand Down Expand Up @@ -1066,8 +1066,6 @@
// store tracks for event mixing without double counting
if constexpr (ev_id == 0) {
std::pair<int, int> key_df_collision = std::make_pair(ndf, collision.globalIndex());
std::pair<int, int> pair_tmp_id1 = std::make_pair(ndf, t1.globalIndex());
std::pair<int, int> pair_tmp_id2 = std::make_pair(ndf, t2.globalIndex());

std::vector<int> possibleIds1;
std::vector<int> possibleIds2;
Expand All @@ -1076,8 +1074,8 @@
std::copy(t1.ambiguousElectronsIds().begin(), t1.ambiguousElectronsIds().end(), std::back_inserter(possibleIds1));
std::copy(t2.ambiguousElectronsIds().begin(), t2.ambiguousElectronsIds().end(), std::back_inserter(possibleIds2));

if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id1) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id1);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t1.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t1.globalIndex());
if (cfgDoMix) {
if (t1.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, t1.cYY(), t1.cZY(), t1.cZZ()));
Expand All @@ -1086,8 +1084,8 @@
}
}
}
if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id2);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t2.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t2.globalIndex());
if (cfgDoMix) {
if (t2.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, t2.cYY(), t2.cZY(), t2.cZZ()));
Expand All @@ -1100,8 +1098,8 @@
std::copy(t1.ambiguousMuonsIds().begin(), t1.ambiguousMuonsIds().end(), std::back_inserter(possibleIds1));
std::copy(t2.ambiguousMuonsIds().begin(), t2.ambiguousMuonsIds().end(), std::back_inserter(possibleIds2));

if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id1) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id1);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t1.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t1.globalIndex());
if (cfgDoMix) {
if (t1.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1,
Expand All @@ -1112,8 +1110,8 @@
}
}
}
if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id2);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t2.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t2.globalIndex());
if (cfgDoMix) {
if (t2.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2,
Expand Down Expand Up @@ -1170,7 +1168,7 @@
TEMH* emh_neg = nullptr;
std::map<std::pair<int, int>, uint64_t> map_mixed_eventId_to_globalBC;

std::vector<std::pair<int, int>> used_trackIds;
std::vector<int> used_trackIds_per_col;
int ndf = 0;

template <bool isTriggerAnalysis, typename TCollisions, typename TLeptons, typename TPresilce, typename TCut, typename TAllTracks>
Expand Down Expand Up @@ -1252,6 +1250,7 @@
auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache);
// LOGF(info, "collision.globalIndex() = %d , collision.posZ() = %f , collision.numContrib() = %d, centrality = %f , posTracks_per_coll.size() = %d, negTracks_per_coll.size() = %d", collision.globalIndex(), collision.posZ(), collision.numContrib(), centralities[cfgCentEstimator], posTracks_per_coll.size(), negTracks_per_coll.size());

used_trackIds_per_col.reserve(posTracks_per_coll.size() + negTracks_per_coll.size());
int nuls = 0, nlspp = 0, nlsmm = 0;
for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS
bool is_pair_ok = fillPairInfo<0>(collision, pos, neg, cut, tracks);
Expand All @@ -1271,6 +1270,8 @@
nlsmm++;
}
}
used_trackIds_per_col.clear();
used_trackIds_per_col.shrink_to_fit();

if (!cfgDoMix || !(nuls > 0 || nlspp > 0 || nlsmm > 0)) {
continue;
Expand Down
29 changes: 15 additions & 14 deletions PWGEM/Dilepton/Core/DileptonHadronMPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ struct DileptonHadronMPC {
delete emh_ref;
emh_ref = 0x0;

used_trackIds.clear();
used_trackIds.shrink_to_fit();
used_trackIds_per_col.clear();
used_trackIds_per_col.shrink_to_fit();
}

void addhistograms()
Expand Down Expand Up @@ -786,8 +786,6 @@ struct DileptonHadronMPC {
// store tracks for event mixing without double counting
if constexpr (ev_id == 0) {
std::pair<int, int> key_df_collision = std::make_pair(ndf, collision.globalIndex());
std::pair<int, int> pair_tmp_id1 = std::make_pair(ndf, t1.globalIndex());
std::pair<int, int> pair_tmp_id2 = std::make_pair(ndf, t2.globalIndex());

std::vector<int> possibleIds1;
std::vector<int> possibleIds2;
Expand All @@ -796,8 +794,8 @@ struct DileptonHadronMPC {
std::copy(t1.ambiguousElectronsIds().begin(), t1.ambiguousElectronsIds().end(), std::back_inserter(possibleIds1));
std::copy(t2.ambiguousElectronsIds().begin(), t2.ambiguousElectronsIds().end(), std::back_inserter(possibleIds2));

if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id1) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id1);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t1.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t1.globalIndex());
if (cfgDoMix) {
if (t1.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, t1.cYY(), t1.cZY(), t1.cZZ()));
Expand All @@ -806,8 +804,8 @@ struct DileptonHadronMPC {
}
}
}
if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id2);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t2.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t2.globalIndex());
if (cfgDoMix) {
if (t2.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, t2.cYY(), t2.cZY(), t2.cZZ()));
Expand All @@ -820,8 +818,8 @@ struct DileptonHadronMPC {
std::copy(t1.ambiguousMuonsIds().begin(), t1.ambiguousMuonsIds().end(), std::back_inserter(possibleIds1));
std::copy(t2.ambiguousMuonsIds().begin(), t2.ambiguousMuonsIds().end(), std::back_inserter(possibleIds2));

if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id1) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id1);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t1.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t1.globalIndex());
if (cfgDoMix) {
if (t1.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1,
Expand All @@ -832,8 +830,8 @@ struct DileptonHadronMPC {
}
}
}
if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) {
used_trackIds.emplace_back(pair_tmp_id2);
if (std::find(used_trackIds_per_col.begin(), used_trackIds_per_col.end(), t2.globalIndex()) == used_trackIds_per_col.end()) {
used_trackIds_per_col.emplace_back(t2.globalIndex());
if (cfgDoMix) {
if (t2.sign() > 0) {
emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2,
Expand Down Expand Up @@ -1082,7 +1080,7 @@ struct DileptonHadronMPC {
MyEMH_track* emh_ref = nullptr; // for reference flow
std::map<std::pair<int, int>, uint64_t> map_mixed_eventId_to_globalBC;

std::vector<std::pair<int, int>> used_trackIds;
std::vector<int> used_trackIds_per_col;
int ndf = 0;

template <bool isTriggerAnalysis, typename TCollisions, typename TLeptons, typename TPresilce, typename TCut, typename TAllTracks, typename TRefTracks>
Expand Down Expand Up @@ -1120,8 +1118,9 @@ struct DileptonHadronMPC {
auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache);
auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache);

int nuls = 0, nlspp = 0, nlsmm = 0;
used_trackIds_per_col.reserve(posTracks_per_coll.size() + negTracks_per_coll.size());

int nuls = 0, nlspp = 0, nlsmm = 0;
for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS
bool is_pair_ok = fillDilepton<0>(collision, pos, neg, cut, tracks);
if (is_pair_ok) {
Expand Down Expand Up @@ -1149,6 +1148,8 @@ struct DileptonHadronMPC {
}
}
}
used_trackIds_per_col.clear();
used_trackIds_per_col.shrink_to_fit();

std::pair<int, int> key_df_collision = std::make_pair(ndf, collision.globalIndex());

Expand Down
Loading