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
31 changes: 0 additions & 31 deletions PWGDQ/Core/MixingHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,6 @@ void MixingHandler::AddMixingVariable(int var, const std::vector<float>& binLims
VarManager::SetUseVariable(var);
}

/*
//_________________________________________________________________________
int MixingHandler::GetMixingVariable(VarManager::Variables var)
{
int i = 0;
for (auto v = fVariables.begin(); v != fVariables.end(); v++, i++) {
if (*v == var) {
return i;
}
}
return -1;
}
*/

/*
//_________________________________________________________________________
std::vector<float> MixingHandler::GetMixingVariableLimits(VarManager::Variables var)
{
std::vector<float> binLimits;
int i = 0;
for (auto v = fVariables.begin(); v != fVariables.end(); v++, i++) {
if (*v == var) {
for (int iBin = 0; iBin < fVariableLimits[i].GetSize(); ++iBin) {
binLimits.push_back(fVariableLimits[i].At(iBin));
}
break;
}
}
return binLimits;
}*/

//_________________________________________________________________________
void MixingHandler::Init()
{
Expand Down
3 changes: 3 additions & 0 deletions PWGDQ/Core/MixingHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class MixingHandler : public TNamed
// An event is defined as two vectors of tracks (typically the legs of a two-body
// decay or the two-particles in a correlation analysis)
struct MixingEvent {
// vectors of tracks for each of the two track types
std::vector<MixingTrack> tracks1;
std::vector<MixingTrack> tracks2;
// event Q-vector (flow vector)
std::array<float, 2> qVector = {0.0f, 0.0f};
// bit map for active filtering bits of all the tracks
uint32_t filteringMask = 0;
// counters to keep track of how many times the event was used for mixing (for each track cut separately)
Expand Down
38 changes: 28 additions & 10 deletions PWGDQ/Core/VarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,8 @@ class VarManager : public TObject
static void FillEventFlowResoFactor(T const& hs_sp, T const& hs_ep, float* values = nullptr);
template <typename T>
static void FillTwoEvents(T const& ev1, T const& ev2, float* values = nullptr);
template <uint32_t fillMap, typename T1, typename T2>
static void FillTwoMixEvents(T1 const& ev1, T1 const& ev2, T2 const& tracks1, T2 const& tracks2, float* values = nullptr);
template <uint32_t fillMap, typename T1>
static void FillTwoMixEvents(T1 const& ev1, T1 const& ev2, float* values = nullptr);
template <typename T>
static void FillTwoMixEventsFlowResoFactor(T const& hs_sp, T const& hs_ep, float* values = nullptr);
template <typename T, typename T1, typename T2>
Expand Down Expand Up @@ -2982,18 +2982,28 @@ void VarManager::FillTwoEvents(T const& ev1, T const& ev2, float* values)
values[kTwoEvDeltaR] = std::sqrt(values[kTwoEvDeltaX] * values[kTwoEvDeltaX] + values[kTwoEvDeltaY] * values[kTwoEvDeltaY]);
}

template <uint32_t fillMap, typename T1, typename T2>
void VarManager::FillTwoMixEvents(T1 const& ev1, T1 const& ev2, T2 const& /*tracks1*/, T2 const& /*tracks2*/, float* values)
template <uint32_t fillMap, typename T1>
void VarManager::FillTwoMixEvents(T1 const& ev1, T1 const& ev2, float* values)
{
if (!values) {
values = static_cast<float*>(fgValues);
}
values[kTwoEvPosZ1] = ev1.posZ();
values[kTwoEvPosZ2] = ev2.posZ();
values[kTwoEvPosR1] = std::sqrt(ev1.posX() * ev1.posX() + ev1.posY() * ev1.posY());
values[kTwoEvPosR2] = std::sqrt(ev2.posX() * ev2.posX() + ev2.posY() * ev2.posY());
values[kTwoEvPVcontrib1] = ev1.numContrib();
values[kTwoEvPVcontrib2] = ev2.numContrib();

if constexpr (requires { ev1.qVector(); }) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qVector is is an std::array and not a member function, does this actually works? I think this line is always false

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it seems that this works like this (tested), see the other places where we use this

values[kQ2X0C1] = ev1.qVector()[0];
values[kQ2Y0C1] = ev1.qVector()[1];
values[kQ2X0C2] = ev2.qVector()[0];
values[kQ2Y0C2] = ev2.qVector()[1];
}

if constexpr (requires { ev1.posZ(); }) {
values[kTwoEvPosZ1] = ev1.posZ();
values[kTwoEvPosZ2] = ev2.posZ();
values[kTwoEvPosR1] = std::sqrt(ev1.posX() * ev1.posX() + ev1.posY() * ev1.posY());
values[kTwoEvPosR2] = std::sqrt(ev2.posX() * ev2.posX() + ev2.posY() * ev2.posY());
values[kTwoEvPVcontrib1] = ev1.numContrib();
values[kTwoEvPVcontrib2] = ev2.numContrib();
}
/*
uint32_t Track1Filter = 0;
uint32_t Track2Filter = 0;
Expand Down Expand Up @@ -4834,6 +4844,14 @@ void VarManager::FillPairMEAcrossTFs(T const& t1, T const& t2, float* values)
values[kPt2] = t2.pt;
values[kEta2] = t2.eta;
values[kPhi2] = t2.phi;
// Compute the two-track flow for mixed-event across TFs
if (fgUsedVars[kV2ME_SP]) {
// Note: here we use the Q-vector from the FT0C. Add more variables if you need it for a different reference detector
double u2q2_t1 = std::cos(2.0 * (t1.phi - values[kPhi])) * (std::cos(2.0 * t1.phi) * values[kQ2X0C1] + std::sin(2.0 * t1.phi) * values[kQ2Y0C1]);
double u2q2_t2 = std::cos(2.0 * (t2.phi - values[kPhi])) * (std::cos(2.0 * t2.phi) * values[kQ2X0C2] + std::sin(2.0 * t2.phi) * values[kQ2Y0C2]);
values[kV2ME_SP] = u2q2_t1 + u2q2_t2;
values[kWV2ME_SP] = 1.0 + u2q2_t1 * u2q2_t2 * std::cos(2.0 * (t1.phi - t2.phi));
}
if (fgUsedVars[kDeltaPhiPair2]) {
values[kDeltaPhiPair2] = RecoDecay::constrainAngle(v1.Phi() - v2.Phi(), -o2::constants::math::PIHalf);
}
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Tasks/tableReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ struct AnalysisEventMixing {
auto tracks2 = tracks.sliceBy(preSlice, event2.globalIndex());
tracks2.bindExternalIndices(&events);

VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2, tracks1, tracks2);
VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2);
if (fConfigFlowReso) {
VarManager::FillTwoMixEventsFlowResoFactor(ResoFlowSP, ResoFlowEP);
}
Expand Down
11 changes: 8 additions & 3 deletions PWGDQ/Tasks/tableReader_withAssoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ using MyEventsVtxCovGlobalMult = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::
using MyEventsVtxCovGlobalMultSelected = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsVtxCov, o2::aod::ReducedEventsGlobalTrk, o2::aod::EventCuts>;
using MyEventsVtxCovSelected = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsVtxCov, o2::aod::EventCuts>;
using MyEventsVtxCovSelectedInfo = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsVtxCov, o2::aod::EventCuts, o2::aod::ReducedEventsInfo>;
using MyEventsVtxCovSelectedQvector = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsMultPV, o2::aod::ReducedEventsMultAll, o2::aod::ReducedEventsVtxCov, o2::aod::EventCuts, o2::aod::ReducedEventsQvectorCentr, o2::aod::ReducedEventsQvectorCentrExtra>;
using MyEventsVtxCovSelectedQvector = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsMultPV, o2::aod::ReducedEventsMultAll, o2::aod::ReducedEventsVtxCov, o2::aod::EventCuts, o2::aod::ReducedEventsQvectorCentr, o2::aod::ReducedEventsQvectorCentrExtra, o2::aod::ReducedEventsMergingTable>;
using MyEventsVtxCovSelectedQvectorWithHash = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsMultPV, o2::aod::ReducedEventsMultAll, o2::aod::ReducedEventsVtxCov, o2::aod::EventCuts, o2::aod::ReducedEventsQvectorCentr, o2::aod::ReducedEventsQvectorCentrExtra, o2::aod::MixingHashes>;
using MyEventsVtxCovZdcFitSelected = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsVtxCov, o2::aod::ReducedZdcs, o2::aod::ReducedFITs, o2::aod::EventCuts>;
using MyEventsVtxCovZdcFitSelectedMultExtra = o2::soa::Join<o2::aod::ReducedEvents, o2::aod::ReducedEventsExtended, o2::aod::ReducedEventsVtxCov, o2::aod::ReducedZdcs, o2::aod::ReducedFITs, o2::aod::EventCuts, o2::aod::ReducedEventsMultPV, o2::aod::ReducedEventsMultAll>;
Expand Down Expand Up @@ -369,7 +369,7 @@ struct AnalysisEventSelection {
// TODO: Provide the mixing variables and binning directly via configurables (e.g. vectors of float)
o2::framework::Configurable<std::string> fConfigMixingVariables{"cfgMixingVars", "", "Mixing configs separated by a comma, default no mixing"};
o2::framework::Configurable<std::string> fConfigMixingVariablesJson{"cfgMixingVarsJSON", "", "Mixing configs in JSON format"};
o2::framework::Configurable<std::string> fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"};
o2::framework::Configurable<std::string> fConfigEventCuts{"cfgEventCuts", "", "Event selection"};
o2::framework::Configurable<std::string> fConfigEventCutsJSON{"cfgEventCutsJSON", "", "Additional event cuts specified in JSON format"};
o2::framework::Configurable<std::string> fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"};
o2::framework::Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Add event histograms defined via JSON formatting (see HistogramsLibrary)"};
Expand Down Expand Up @@ -2695,6 +2695,9 @@ struct AnalysisSameEventPairing {
}
// 1) create a MixingEvent and fill it with the relevant tracks
MixingHandler::MixingEvent mixingEvent;
if constexpr (eventHasQvector) {
mixingEvent.qVector = {event.q2x0c(), event.q2y0c()};
}
uint32_t trackFilterForMixing = 0;
for (auto const& assoc : groupedAssocs) {
if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi || TPairType == VarManager::kDecayToKchKch || TPairType == VarManager::kDecayToPrAPr) {
Expand All @@ -2718,6 +2721,8 @@ struct AnalysisSameEventPairing {
auto& pool = fMixingHandler.GetPool(mixingCategory);
int nMEPairs = 0;
for (auto const& poolEvent : pool.GetEvents()) {
// fill the two event quantities
VarManager::FillTwoMixEvents<0u>(mixingEvent, poolEvent, dqtablereader_helpers::varValues());
for (auto const& t1 : mixingEvent.tracks1) {
// run +- pairing
for (auto const& t2 : poolEvent.tracks2) {
Expand Down Expand Up @@ -3062,7 +3067,7 @@ struct AnalysisSameEventPairing {
assocs2.bindExternalIndices(&events);

fNPairPerEvent = 0;
VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2, assocs1, assocs2);
VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2);
if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi || TPairType == VarManager::kDecayToKchKch || TPairType == VarManager::kDecayToPrAPr) {
int nSel1 = 0; // number of tracks of event1 passing the pairing filter
for (auto const& a : assocs1) {
Expand Down
2 changes: 1 addition & 1 deletion PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ struct AnalysisEventMixing {
auto tracks2 = tracks.sliceBy(preSlice, event2.globalIndex());
tracks2.bindExternalIndices(&events);

VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2, tracks1, tracks2);
VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2);
runMixedPairing<TEventFillMap, TPairType>(tracks1, tracks2);
} // end event loop
}
Expand Down
Loading