Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PWGDQ] fix configQA option in analysis-event-selection #8903

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
106 changes: 59 additions & 47 deletions PWGDQ/Tasks/tableReader_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <iostream>

Check warning on line 18 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Including iostream is discouraged. Use O2 logging instead.
#include <numeric>
#include <vector>
#include <algorithm>
Expand Down Expand Up @@ -262,17 +262,23 @@

bool decision = false;
// Fill histograms in the class Event, before cuts
fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues);
if (fConfigQA) {
fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues);
}

// Apply event cuts and fill histograms after selection
if (fEventCut->IsSelected(VarManager::fgValues)) {
if (fConfigRunZorro) {
if (event.tag_bit(56)) { // This is the bit used for the software trigger event selections [TO BE DONE: find a more clear way to use it]
fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
if (fConfigQA) {
fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
}
decision = true;
}
} else {
fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
if (fConfigQA) {
fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
}
decision = true;
}
}
Expand Down Expand Up @@ -304,51 +310,57 @@
// key: event global index, value: whether pileup event is a possible splitting
std::map<int64_t, bool> collisionSplittingMap;

// Reset the fValues array and fill event observables
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
// loop over the BC map, get the collision vectors and make in-bunch and out of bunch 2-event correlations
for (auto bc1It = fBCCollMap.begin(); bc1It != fBCCollMap.end(); ++bc1It) {
uint64_t bc1 = bc1It->first;
auto bc1Events = bc1It->second;

// same bunch event correlations, if more than 1 collisions in this bunch
if (bc1Events.size() > 1) {
for (auto ev1It = bc1Events.begin(); ev1It != bc1Events.end(); ++ev1It) {
auto ev1 = events.rawIteratorAt(*ev1It);
for (auto ev2It = std::next(ev1It); ev2It != bc1Events.end(); ++ev2It) {
auto ev2 = events.rawIteratorAt(*ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
if (TMath::Abs(VarManager::fgValues[VarManager::kTwoEvDeltaZ]) < fConfigSplitCollisionsDeltaZ) { // this is a possible collision split
collisionSplittingMap[*ev1It] = true;
collisionSplittingMap[*ev2It] = true;
}
fHistMan->FillHistClass("SameBunchCorrelations", VarManager::fgValues);
} // end second event loop
} // end first event loop
} // end if BC1 events > 1

// loop over the following BCs in the TF
for (auto bc2It = std::next(bc1It); bc2It != fBCCollMap.end(); ++bc2It) {
uint64_t bc2 = bc2It->first;
if ((bc2 > bc1 ? bc2 - bc1 : bc1 - bc2) > fConfigSplitCollisionsDeltaBC) {
break;
}
auto bc2Events = bc2It->second;

// loop over events in the first BC
for (auto ev1It : bc1Events) {
auto ev1 = events.rawIteratorAt(ev1It);
// loop over events in the second BC
for (auto ev2It : bc2Events) {
auto ev2 = events.rawIteratorAt(ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
if (TMath::Abs(VarManager::fgValues[VarManager::kTwoEvDeltaZ]) < fConfigSplitCollisionsDeltaZ) { // this is a possible collision split
collisionSplittingMap[ev1It] = true;
collisionSplittingMap[ev2It] = true;
if (fConfigCheckSplitCollisions) {
// Reset the fValues array and fill event observables
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
// loop over the BC map, get the collision vectors and make in-bunch and out of bunch 2-event correlations
for (auto bc1It = fBCCollMap.begin(); bc1It != fBCCollMap.end(); ++bc1It) {
uint64_t bc1 = bc1It->first;
auto bc1Events = bc1It->second;

// same bunch event correlations, if more than 1 collisions in this bunch
if (bc1Events.size() > 1) {
for (auto ev1It = bc1Events.begin(); ev1It != bc1Events.end(); ++ev1It) {
auto ev1 = events.rawIteratorAt(*ev1It);
for (auto ev2It = std::next(ev1It); ev2It != bc1Events.end(); ++ev2It) {
auto ev2 = events.rawIteratorAt(*ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
if (TMath::Abs(VarManager::fgValues[VarManager::kTwoEvDeltaZ]) < fConfigSplitCollisionsDeltaZ) { // this is a possible collision split

Check warning on line 329 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
collisionSplittingMap[*ev1It] = true;
collisionSplittingMap[*ev2It] = true;
}
if (fConfigQA) {
fHistMan->FillHistClass("SameBunchCorrelations", VarManager::fgValues);
}
} // end second event loop
} // end first event loop
} // end if BC1 events > 1

// loop over the following BCs in the TF
for (auto bc2It = std::next(bc1It); bc2It != fBCCollMap.end(); ++bc2It) {
uint64_t bc2 = bc2It->first;
if ((bc2 > bc1 ? bc2 - bc1 : bc1 - bc2) > fConfigSplitCollisionsDeltaBC) {
break;
}
auto bc2Events = bc2It->second;

// loop over events in the first BC
for (auto ev1It : bc1Events) {
auto ev1 = events.rawIteratorAt(ev1It);
// loop over events in the second BC
for (auto ev2It : bc2Events) {
auto ev2 = events.rawIteratorAt(ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
if (TMath::Abs(VarManager::fgValues[VarManager::kTwoEvDeltaZ]) < fConfigSplitCollisionsDeltaZ) { // this is a possible collision split

Check warning on line 356 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
collisionSplittingMap[ev1It] = true;
collisionSplittingMap[ev2It] = true;
}
if (fConfigQA) {
fHistMan->FillHistClass("OutOfBunchCorrelations", VarManager::fgValues);
}
}
fHistMan->FillHistClass("OutOfBunchCorrelations", VarManager::fgValues);
}
}
}
Expand Down Expand Up @@ -1957,14 +1969,14 @@
}
}
// Check that the leg cut masks make sense
if (static_cast<int>(std::floor(TMath::Log2(fLegAFilterMask))) + 1 > objArray->GetEntries()) {

Check warning on line 1972 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
LOGF(fatal, "fConfigLegAFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast<int>(std::floor(TMath::Log2(fLegAFilterMask))) + 1, objArray->GetEntries());

Check warning on line 1973 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
}
if (static_cast<int>(std::floor(TMath::Log2(fLegBFilterMask))) + 1 > objArray->GetEntries()) {

Check warning on line 1975 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
LOGF(fatal, "fConfigLegBFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast<int>(std::floor(TMath::Log2(fLegBFilterMask))) + 1, objArray->GetEntries());

Check warning on line 1976 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
}
if (static_cast<int>(std::floor(TMath::Log2(fLegCFilterMask))) + 1 > objArray->GetEntries()) {

Check warning on line 1978 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
LOGF(fatal, "fConfigLegCFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast<int>(std::floor(TMath::Log2(fLegCFilterMask))) + 1, objArray->GetEntries());

Check warning on line 1979 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
}

// Get the cuts defining the legs
Expand Down Expand Up @@ -3030,7 +3042,7 @@
// The histogram classes and their components histograms are defined below depending on the name of the histogram class
//
std::unique_ptr<TObjArray> objArray(histClasses.Tokenize(";"));
for (Int_t iclass = 0; iclass < objArray->GetEntries(); ++iclass) {

Check warning on line 3045 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
TString classStr = objArray->At(iclass)->GetName();
histMan->AddHistClass(classStr.Data());

Expand Down
Loading