Skip to content

Commit

Permalink
PWGEM/Dilepton: add protection against double counting of generad info
Browse files Browse the repository at this point in the history
  • Loading branch information
dsekihat committed Oct 13, 2024
1 parent f5c6fc0 commit 206e5a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion PWGEM/Dilepton/Core/DileptonMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -988,13 +988,22 @@ struct DileptonMC {
// loop over mc stack and fill histograms for pure MC truth signals
// all MC tracks which belong to the MC event corresponding to the current reconstructed event

std::vector<int> used_mccollisionIds; // used mc collisionIds
used_mccollisionIds.reserve(collisions.size());

for (auto& collision : collisions) {
auto mccollision = collision.template emmcevent_as<TMCCollisions>();
if (std::find(used_mccollisionIds.begin(), used_mccollisionIds.end(), mccollision.globalIndex()) != used_mccollisionIds.end()) {
// LOGF(info, "same mc collision is repeated. continue;");
continue;
}
used_mccollisionIds.emplace_back(mccollision.globalIndex());

float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()};
if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) {
continue;
}

auto mccollision = collision.template emmcevent_as<TMCCollisions>();
if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) {
continue;
}
Expand Down Expand Up @@ -1485,6 +1494,8 @@ struct DileptonMC {
}
} // end of true LS++ pair loop
} // end of collision loop
used_mccollisionIds.clear();
used_mccollisionIds.shrink_to_fit();
}

template <typename TCollision, typename TTrack1, typename TTrack2, typename TCut>
Expand Down
13 changes: 12 additions & 1 deletion PWGEM/Dilepton/Core/SingleTrackQCMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,22 @@ struct SingleTrackQCMC {
// loop over mc stack and fill histograms for pure MC truth signals
// all MC tracks which belong to the MC event corresponding to the current reconstructed event

std::vector<int> used_mccollisionIds; // used mc collisionIds
used_mccollisionIds.reserve(collisions.size());

for (auto& collision : collisions) {
auto mccollision = collision.template emmcevent_as<TMCCollisions>();
if (std::find(used_mccollisionIds.begin(), used_mccollisionIds.end(), mccollision.globalIndex()) != used_mccollisionIds.end()) {
// LOGF(info, "same mc collision is repeated. continue;");
continue;
}
used_mccollisionIds.emplace_back(mccollision.globalIndex());

float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()};
if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) {
continue;
}

auto mccollision = collision.template emmcevent_as<TMCCollisions>();
// LOGF(info, "mccollision.getGeneratorId() = %d", mccollision.getGeneratorId());
// LOGF(info, "mccollision.getSubGeneratorId() = %d", mccollision.getSubGeneratorId());
// LOGF(info, "mccollision.getSourceId() = %d", mccollision.getSourceId());
Expand Down Expand Up @@ -792,6 +801,8 @@ struct SingleTrackQCMC {
}

} // end of collision loop
used_mccollisionIds.clear();
used_mccollisionIds.shrink_to_fit();
}

std::unordered_map<int, float> map_weight; // map of track global index -> weight
Expand Down

0 comments on commit 206e5a6

Please sign in to comment.