Skip to content

Commit fc2c09d

Browse files
committed
commit
1 parent 5af6631 commit fc2c09d

2 files changed

Lines changed: 110 additions & 16 deletions

File tree

‎PWGDQ/Core/VarManager.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ class VarManager : public TObject
525525
kA2EPME_FT0C, // A2 of VM to FT0C event plane for ME technique
526526
kA2EPME_FT0A, // A2 of VM to FT0A event plane for ME technique
527527
kNPairsPerEvent, // number of pairs per event in same-event or mixed-event pairing
528+
kNSelTracksForPairing,// number of tracks in the event passing the pairing track filter (barrel); in ME = that of the first event
528529
kInteractionRate,
529530
kMuPerBc,
530531

@@ -4822,6 +4823,15 @@ void VarManager::FillPairMEAcrossTFs(T const& t1, T const& t2, float* values)
48224823
values[kEta] = v12.Eta();
48234824
values[kPhi] = RecoDecay::constrainAngle(v12.Phi());
48244825
values[kRap] = -v12.Rapidity();
4826+
values[kPt1] = t1.pt;
4827+
values[kEta1] = t1.eta;
4828+
values[kPhi1] = t1.phi;
4829+
values[kPt2] = t2.pt;
4830+
values[kEta2] = t2.eta;
4831+
values[kPhi2] = t2.phi;
4832+
if (fgUsedVars[kDeltaPhiPair2]) {
4833+
values[kDeltaPhiPair2] = RecoDecay::constrainAngle(v1.Phi() - v2.Phi(), -o2::constants::math::PIHalf);
4834+
}
48254835

48264836
if (fgUsedVars[kCosThetaStarRandom] || fgUsedVars[kCosThetaStarFT0C]) {
48274837
ROOT::Math::Boost boostv12{v12.BoostToCM()};

‎PWGDQ/Tasks/tableReader_withAssoc.h‎

Lines changed: 100 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,7 @@ struct AnalysisSameEventPairing {
15111511
o2::framework::Configurable<std::string> fConfigMixingVariables{"cfgMixingVars", "", "Mixing configs separated by a comma, default no mixing"};
15121512
o2::framework::Configurable<std::string> fConfigMixingVariablesJson{"cfgMixingVarsJSON", "", "Mixing configs in JSON format"};
15131513
o2::framework::Configurable<bool> fConfigRunMixingAcrossTFs{"cfgRunMixingAcrossTFs", false, "If true, run event mixing using the MixingHandler which accumulates events across multiple TFs"};
1514+
o2::framework::Configurable<std::string> fConfigMixingNSelEdges{"cfgMixingNSelEdges", "", "Comma separated class edges in the number of selected pairing tracks per event"};
15141515
// o2::framework::Configurable<std::string> fConfigAddEventMixingHistogram{"cfgAddEventMixingHistogram", "", "Comma separated list of histograms"};
15151516
o2::framework::Configurable<std::string> fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"};
15161517
o2::framework::Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
@@ -1587,6 +1588,7 @@ struct AnalysisSameEventPairing {
15871588
int fNCutsMuon = 0;
15881589
int fNPairCuts = 0;
15891590
int fNPairPerEvent = 0;
1591+
std::vector<int> fMixNSelEdges;
15901592

15911593
bool fEnableBarrelMixingHistos = false;
15921594
bool fEnableBarrelHistos = false;
@@ -1606,6 +1608,9 @@ struct AnalysisSameEventPairing {
16061608
{
16071609
fEnableBarrelHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmed") || context.mOptions.get<bool>("processBarrelOnlyWithCollSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmedNoCov") || context.mOptions.get<bool>("processBarrelOnlySkimmedNoCovWithMultExtra") || context.mOptions.get<bool>("processBarrelOnlyWithQvectorCentrSkimmedNoCov") || context.mOptions.get<bool>("processBarrelOnlyWithQvectorCentrSkimmed") || context.mOptions.get<bool>("processBarrelOnlyWithQvectorCentrVtxCovSkimmed") || context.mOptions.get<bool>("processBarrelOnlyDiKaons") || context.mOptions.get<bool>("processBarrelOnlyDiProtons") || context.mOptions.get<bool>("processBarrelOnlySkimmedWithGlobalMult");
16081610
fEnableBarrelMixingHistos = context.mOptions.get<bool>("processMixingAllSkimmed") || context.mOptions.get<bool>("processMixingBarrelSkimmed") || context.mOptions.get<bool>("processMixingBarrelSkimmedFlow") || context.mOptions.get<bool>("processMixingBarrelWithQvectorCentrSkimmedNoCov") || context.mOptions.get<bool>("processMixingBarrelSkimmedGlobalMult");
1611+
if (fEnableBarrelMixingHistos && fConfigRunMixingAcrossTFs) {
1612+
LOG(fatal) << "cfgRunMixingAcrossTFs is on together with an in-TF processMixing* function";
1613+
}
16091614
fEnableBarrelMixingHistos |= fConfigRunMixingAcrossTFs;
16101615
fEnableMuonHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processMuonOnlySkimmed") || context.mOptions.get<bool>("processMuonOnlySkimmedMultExtra") || context.mOptions.get<bool>("processMuonOnlySkimmedFlow") || context.mOptions.get<bool>("processMuonOnlyVertexingSkimmed");
16111616
fEnableMuonMixingHistos = context.mOptions.get<bool>("processMixingAllSkimmed") || context.mOptions.get<bool>("processMixingMuonSkimmed") || context.mOptions.get<bool>("processMixingMuonSkimmedFlow");
@@ -1856,6 +1861,14 @@ struct AnalysisSameEventPairing {
18561861
}
18571862
}
18581863

1864+
fMixNSelEdges.clear();
1865+
if (!fConfigMixingNSelEdges.value.empty()) {
1866+
std::unique_ptr<TObjArray> edgeArr(TString(fConfigMixingNSelEdges.value).Tokenize(","));
1867+
for (int ie = 0; ie < edgeArr->GetEntries(); ++ie) {
1868+
fMixNSelEdges.push_back(static_cast<TObjString*>(edgeArr->At(ie))->GetString().Atoi());
1869+
}
1870+
LOGF(info, "Event mixing restricted to classes of selected pairing tracks per event: %s", fConfigMixingNSelEdges.value.c_str());
1871+
}
18591872
if (fConfigRunMixingAcrossTFs) {
18601873
if (fNCutsBarrel > MixingHandler::NMaxCuts) {
18611874
LOGF(fatal, "Across-TF mixing supports at most %d barrel track-cut bits, got %d", MixingHandler::NMaxCuts, fNCutsBarrel);
@@ -2142,6 +2155,16 @@ struct AnalysisSameEventPairing {
21422155
if (groupedAssocs.size() == 0) {
21432156
continue;
21442157
}
2158+
if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi || TPairType == VarManager::kDecayToKchKch || TPairType == VarManager::kDecayToPrAPr) {
2159+
// number of tracks passing the pairing filter
2160+
int nSel = 0;
2161+
for (auto const& a : groupedAssocs) {
2162+
if (a.isBarrelSelected_raw() & a.isBarrelSelectedPrefilter_raw() & fTrackFilterMask) {
2163+
nSel++;
2164+
}
2165+
}
2166+
VarManager::fgValues[VarManager::kNSelTracksForPairing] = nSel;
2167+
}
21452168

21462169
if (fConfigOptions.useFlowReso) {
21472170
if (ResoFlowSP == nullptr || ResoFlowEP == nullptr) {
@@ -2152,6 +2175,13 @@ struct AnalysisSameEventPairing {
21522175
int mixingCategory = -1;
21532176
if (fConfigRunMixingAcrossTFs) {
21542177
mixingCategory = fMixingHandler.FindEventCategory(dqtablereader_helpers::varValues());
2178+
// mix only events in the same class of cfgMixingNSelEdges
2179+
if (mixingCategory >= 0 && !fMixNSelEdges.empty()) {
2180+
const int nSel = static_cast<int>(VarManager::fgValues[VarManager::kNSelTracksForPairing]);
2181+
const int nSelClassIndex = static_cast<int>(std::upper_bound(fMixNSelEdges.begin(), fMixNSelEdges.end(), nSel) - fMixNSelEdges.begin()) - 1;
2182+
const int nNSelClasses = static_cast<int>(fMixNSelEdges.size()) - 1;
2183+
mixingCategory = (nSelClassIndex >= 0 && nSelClassIndex < nNSelClasses) ? mixingCategory * nNSelClasses + nSelClassIndex : -1;
2184+
}
21552185
}
21562186

21572187
fNPairPerEvent = 0;
@@ -2675,6 +2705,7 @@ struct AnalysisSameEventPairing {
26752705
}
26762706
// 2) run the mixing with the events in the pool corresponding to this event
26772707
auto& pool = fMixingHandler.GetPool(mixingCategory);
2708+
int nMEPairs = 0;
26782709
for (auto const& poolEvent : pool.GetEvents()) {
26792710
for (auto const& t1 : mixingEvent.tracks1) {
26802711
// run +- pairing
@@ -2685,6 +2716,7 @@ struct AnalysisSameEventPairing {
26852716
continue;
26862717
}
26872718
VarManager::FillPairMEAcrossTFs(t1, t2);
2719+
nMEPairs++;
26882720
for (int icut = 0; icut < ncuts; icut++) {
26892721
if (mixedTwoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
26902722
if (fConfigQA) {
@@ -2715,6 +2747,7 @@ struct AnalysisSameEventPairing {
27152747
continue;
27162748
}
27172749
VarManager::FillPairMEAcrossTFs(t1, t2);
2750+
nMEPairs++;
27182751
for (int icut = 0; icut < ncuts; icut++) {
27192752
if (mixedTwoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
27202753
if (fConfigQA) {
@@ -2733,6 +2766,7 @@ struct AnalysisSameEventPairing {
27332766
continue;
27342767
}
27352768
VarManager::FillPairMEAcrossTFs(t1, t2);
2769+
nMEPairs++;
27362770
for (int icut = 0; icut < ncuts; icut++) {
27372771
if (mixedTwoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
27382772
if (fConfigQA) {
@@ -2762,6 +2796,7 @@ struct AnalysisSameEventPairing {
27622796
continue;
27632797
}
27642798
VarManager::FillPairMEAcrossTFs(t1, t2);
2799+
nMEPairs++;
27652800
for (int icut = 0; icut < ncuts; icut++) {
27662801
if (mixedTwoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
27672802
if (fConfigQA) {
@@ -2772,6 +2807,10 @@ struct AnalysisSameEventPairing {
27722807
}
27732808
}
27742809
}
2810+
if (fEnableBarrelMixingHistos && fConfigQA) {
2811+
VarManager::fgValues[VarManager::kNPairsPerEvent] = nMEPairs;
2812+
fHistMan->FillHistClass("PairingMEQA", dqtablereader_helpers::varValues());
2813+
}
27752814
// 3) add the current event to the pool
27762815
pool.UpdatePool(mixingEvent, fMixingHandler.GetPoolDepth(), mixingEvent.filteringMask);
27772816
// pool.Print();
@@ -2964,27 +3003,72 @@ struct AnalysisSameEventPairing {
29643003
events.bindExternalIndices(&assocs);
29653004
int mixingDepth = fConfigMixingDepth.value;
29663005
fAmbiguousPairs.clear();
3006+
if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi || TPairType == VarManager::kDecayToKchKch || TPairType == VarManager::kDecayToPrAPr) {
3007+
if (!fMixNSelEdges.empty()) {
3008+
// mix only events in the same class of cfgMixingNSelEdges
3009+
const int nNSelClasses = static_cast<int>(fMixNSelEdges.size()) - 1;
3010+
std::map<int, std::vector<std::decay_t<decltype(events.begin())>>> nSelPools;
3011+
// fill the pools with events
3012+
for (auto const& event : events) {
3013+
int nSel = 0;
3014+
for (auto const& a : assocs.sliceBy(preSlice, event.globalIndex())) {
3015+
if (a.isBarrelSelected_raw() & a.isBarrelSelectedPrefilter_raw() & fTrackFilterMask) {
3016+
nSel++;
3017+
}
3018+
}
3019+
const int nSelClassIndex = static_cast<int>(std::upper_bound(fMixNSelEdges.begin(), fMixNSelEdges.end(), nSel) - fMixNSelEdges.begin()) - 1;
3020+
if (nSelClassIndex >= 0 && nSelClassIndex < nNSelClasses && event.mixingHash() >= 0) {
3021+
nSelPools[event.mixingHash() * nNSelClasses + nSelClassIndex].push_back(event);
3022+
}
3023+
}
3024+
// same sliding window as selfCombinations
3025+
for (auto const& [key, poolEvents] : nSelPools) {
3026+
for (size_t i = 0; i < poolEvents.size(); i++) {
3027+
for (size_t j = i + 1; j < poolEvents.size() && j <= i + static_cast<size_t>(mixingDepth); j++) {
3028+
mixTwoEvents<TPairType, TEventFillMap>(poolEvents[i], poolEvents[j], events, assocs, tracks, preSlice);
3029+
}
3030+
}
3031+
}
3032+
return;
3033+
}
3034+
}
29673035
for (auto const& [event1, event2] : selfCombinations(hashBin, mixingDepth, -1, events, events)) {
2968-
VarManager::ResetValues(0, VarManager::kNVars);
2969-
VarManager::FillEvent<TEventFillMap>(event1, dqtablereader_helpers::varValues());
3036+
mixTwoEvents<TPairType, TEventFillMap>(event1, event2, events, assocs, tracks, preSlice);
3037+
}
3038+
}
29703039

2971-
auto assocs1 = assocs.sliceBy(preSlice, event1.globalIndex());
2972-
assocs1.bindExternalIndices(&events);
3040+
// mix one pair of events
3041+
template <int TPairType, uint32_t TEventFillMap, typename TEvent, typename TEvents, typename TAssocs, typename TTracks>
3042+
void mixTwoEvents(TEvent const& event1, TEvent const& event2, TEvents& events, TAssocs const& assocs, TTracks const& tracks, o2::framework::Preslice<TAssocs>& preSlice)
3043+
{
3044+
VarManager::ResetValues(0, VarManager::kNVars);
3045+
VarManager::FillEvent<TEventFillMap>(event1, dqtablereader_helpers::varValues());
29733046

2974-
auto assocs2 = assocs.sliceBy(preSlice, event2.globalIndex());
2975-
assocs2.bindExternalIndices(&events);
3047+
auto assocs1 = assocs.sliceBy(preSlice, event1.globalIndex());
3048+
assocs1.bindExternalIndices(&events);
29763049

2977-
fNPairPerEvent = 0;
2978-
VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2, assocs1, assocs2);
2979-
if (fConfigOptions.useFlowReso) {
2980-
VarManager::FillTwoMixEventsFlowResoFactor(ResoFlowSP, ResoFlowEP);
2981-
}
2982-
runMixedPairing<TPairType, TEventFillMap>(assocs1, assocs2, tracks, tracks);
2983-
VarManager::fgValues[VarManager::kNPairsPerEvent] = fNPairPerEvent;
2984-
if (fEnableBarrelMixingHistos && fConfigQA) {
2985-
fHistMan->FillHistClass("PairingMEQA", dqtablereader_helpers::varValues());
3050+
auto assocs2 = assocs.sliceBy(preSlice, event2.globalIndex());
3051+
assocs2.bindExternalIndices(&events);
3052+
3053+
fNPairPerEvent = 0;
3054+
VarManager::FillTwoMixEvents<TEventFillMap>(event1, event2, assocs1, assocs2);
3055+
if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi || TPairType == VarManager::kDecayToKchKch || TPairType == VarManager::kDecayToPrAPr) {
3056+
int nSel1 = 0; // number of tracks of event1 passing the pairing filter
3057+
for (auto const& a : assocs1) {
3058+
if (a.isBarrelSelected_raw() & a.isBarrelSelectedPrefilter_raw() & fTrackFilterMask) {
3059+
nSel1++;
3060+
}
29863061
}
2987-
} // end event loop
3062+
VarManager::fgValues[VarManager::kNSelTracksForPairing] = nSel1;
3063+
}
3064+
if (fConfigOptions.useFlowReso) {
3065+
VarManager::FillTwoMixEventsFlowResoFactor(ResoFlowSP, ResoFlowEP);
3066+
}
3067+
runMixedPairing<TPairType, TEventFillMap>(assocs1, assocs2, tracks, tracks);
3068+
VarManager::fgValues[VarManager::kNPairsPerEvent] = fNPairPerEvent;
3069+
if (fEnableBarrelMixingHistos && fConfigQA) {
3070+
fHistMan->FillHistClass("PairingMEQA", dqtablereader_helpers::varValues());
3071+
}
29883072
}
29893073

29903074
template <bool TTwoProngFitter, int TPairType, uint32_t TEventFillMap, uint32_t TTrackFillMap, uint32_t TMuonFillMap, typename TEvents, typename TTrackAssocs, typename TTracks, typename TMuonAssocs, typename TMuons>

0 commit comments

Comments
 (0)