Skip to content

Commit 44a13ac

Browse files
authored
[PWGDQ] Write eventfilter to 32 highest bits of tag column in reducedEvents (#3922)
1 parent c979e36 commit 44a13ac

File tree

5 files changed

+67
-49
lines changed

5 files changed

+67
-49
lines changed

PWGDQ/Core/HistogramsLibrary.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h
152152
hm->AddHistogram(histClass, "R2EP_CentFT0C", "", true, 9, 0.0, 90.0, VarManager::kCentFT0C, 100, -1.0, 1.0, VarManager::kR2EP);
153153
hm->AddHistogram(histClass, "R3EP_CentFT0C", "", true, 9, 0.0, 90.0, VarManager::kCentFT0C, 100, -1.0, 1.0, VarManager::kR3EP);
154154
}
155+
if (subGroupStr.Contains("filter")) {
156+
hm->AddHistogram(histClass, "IsDoubleGap", "Is double gap", false, 2, -0.5, 1.5, VarManager::kIsDoubleGap);
157+
hm->AddHistogram(histClass, "IsSingleGapA", "Is single gap on side A", false, 2, -0.5, 1.5, VarManager::kIsSingleGapA);
158+
hm->AddHistogram(histClass, "IsSingleGapC", "Is single gap on side C", false, 2, -0.5, 1.5, VarManager::kIsSingleGapC);
159+
}
155160
}
156161

157162
if (groupStr.Contains("track")) {

PWGDQ/Core/VarManager.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,10 @@ void VarManager::SetDefaultVarNames()
660660
fgVariableUnits[kRapCharmHadron] = " ";
661661
fgVariableNames[kPhiCharmHadron] = "#varphi (charm hadron)";
662662
fgVariableUnits[kPhiCharmHadron] = "rad.";
663+
fgVariableNames[kIsDoubleGap] = "is double gap event";
664+
fgVariableUnits[kIsDoubleGap] = "";
665+
fgVariableNames[kIsSingleGapA] = "is single gap event side A";
666+
fgVariableUnits[kIsSingleGapA] = "";
667+
fgVariableNames[kIsSingleGapC] = "is single gap event side C";
668+
fgVariableUnits[kIsSingleGapC] = "";
663669
}

PWGDQ/Core/VarManager.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class VarManager : public TObject
8080
ReducedEventQvector = BIT(9),
8181
CollisionCent = BIT(10),
8282
CollisionMult = BIT(11),
83+
EventFilter = BIT(12),
8384
Track = BIT(0),
8485
TrackCov = BIT(1),
8586
TrackExtra = BIT(2),
@@ -193,6 +194,10 @@ class VarManager : public TObject
193194
kR3SP,
194195
kR2EP,
195196
kR3EP,
197+
kIsDoubleGap, // Double rapidity gap
198+
kIsSingleGapA, // Rapidity gap on side A
199+
kIsSingleGapC, // Rapidity gap on side C
200+
kIsSingleGap, // Rapidity gap on either side
196201
kNEventWiseVariables,
197202

198203
// Basic track/muon/pair wise variables
@@ -455,6 +460,12 @@ class VarManager : public TObject
455460
kD0barToKPi
456461
};
457462

463+
enum EventFilters {
464+
kDoubleGap = 1,
465+
kSingleGapA,
466+
kSingleGapC
467+
};
468+
458469
static TString fgVariableNames[kNVars]; // variable names
459470
static TString fgVariableUnits[kNVars]; // variable units
460471
static void SetDefaultVarNames();
@@ -1005,6 +1016,13 @@ void VarManager::FillEvent(T const& event, float* values)
10051016
values[kMCEventImpParam] = event.impactParameter();
10061017
}
10071018

1019+
if constexpr ((fillMap & EventFilter) > 0) {
1020+
values[kIsDoubleGap] = (event.eventFilter() & (uint64_t(1) << kDoubleGap)) > 0;
1021+
values[kIsSingleGapA] = (event.eventFilter() & (uint64_t(1) << kSingleGapA)) > 0;
1022+
values[kIsSingleGapC] = (event.eventFilter() & (uint64_t(1) << kSingleGapC)) > 0;
1023+
values[kIsSingleGap] = values[kIsSingleGapA] || values[kIsSingleGapC];
1024+
}
1025+
10081026
FillEventDerived(values);
10091027
}
10101028

PWGDQ/TableProducer/tableMaker.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ DECLARE_SOA_TABLE(AmbiguousTracksFwd, "AOD", "AMBIGUOUSFWDTR", //! Table for Fwd
108108

109109
constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision;
110110
constexpr static uint32_t gkEventFillMapWithMult = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult;
111+
constexpr static uint32_t gkEventFillMapWithMultsAndEventFilter = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::EventFilter;
111112
constexpr static uint32_t gkEventFillMapWithCent = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent;
112113
constexpr static uint32_t gkEventFillMapWithCentAndMults = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent | VarManager::CollisionMult;
113114
// constexpr static uint32_t gkEventFillMapWithCentRun2 = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCentRun2; // Unused variable
@@ -368,7 +369,10 @@ struct TableMaker {
368369
if (collision.sel7()) {
369370
tag |= (uint64_t(1) << evsel::kNsel); //! SEL7 stored at position kNsel in the tag bit map
370371
}
371-
// TODO: Add the event level decisions from the filtering task into the tag
372+
// Put the 32 first bits of the event filter in the last 32 bits of the tag
373+
if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0) {
374+
tag |= (collision.eventFilter() << 32);
375+
}
372376

373377
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
374378
// TODO: These variables cannot be filled in the VarManager for the moment as long as BCsWithTimestamps are used.
@@ -1208,7 +1212,7 @@ struct TableMaker {
12081212
}
12091213
(reinterpret_cast<TH2I*>(fStatsList->At(0)))->Fill(1.0, static_cast<float>(kNaliases));
12101214
if (collision.eventFilter()) {
1211-
fullSkimming<gkEventFillMapWithMult, gkTrackFillMap, 0u>(collision, bcs, tracksBarrel, nullptr, nullptr, nullptr);
1215+
fullSkimming<gkEventFillMapWithMultsAndEventFilter, gkTrackFillMap, 0u>(collision, bcs, tracksBarrel, nullptr, nullptr, nullptr);
12121216
}
12131217
}
12141218

PWGDQ/Tasks/filterPbPb.cxx

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses);
4848
struct DQFilterPbPbTask {
4949
Produces<aod::DQEventFilter> eventFilter;
5050
OutputObj<TH1I> fStats{"Statistics"};
51-
OutputObj<TH1F> fIsEventDGOutcome{TH1F("Filter outcome", "Filter outcome", 14, -1.5, 6.5)};
51+
OutputObj<TH1F> fIsEventDGOutcome{TH1F("Filter outcome", "Filter outcome", 7, -0.5, 6.5)};
5252

5353
Configurable<std::string> fConfigBarrelSelections{"cfgBarrelSels", "jpsiPID1:2:5", "<track-cut>:<nmin>:<nmax>,[<track-cut>:<nmin>:<nmax>],..."};
5454
Configurable<int> fConfigNDtColl{"cfgNDtColl", 4, "Number of standard deviations to consider in BC range"};
@@ -64,7 +64,6 @@ struct DQFilterPbPbTask {
6464
Configurable<bool> fConfigUseFV0{"cfgUseFV0", true, "Whether to use FV0 for veto"};
6565
Configurable<bool> fConfigUseFT0{"cfgUseFT0", true, "Whether to use FT0 for veto"};
6666
Configurable<bool> fConfigUseFDD{"cfgUseFDD", true, "Whether to use FDD for veto"};
67-
Configurable<std::string> fConfigFITSides{"cfgFITSides", "both", "both, either, A, C, neither"};
6867
Configurable<bool> fConfigVetoForward{"cfgVetoForward", true, "Whether to veto on forward tracks"};
6968
Configurable<bool> fConfigVetoBarrel{"cfgVetoBarrel", false, "Whether to veto on barrel tracks"};
7069

@@ -74,15 +73,12 @@ struct DQFilterPbPbTask {
7473
std::vector<int> fBarrelNminTracks; // minimal number of tracks in barrel
7574
std::vector<int> fBarrelNmaxTracks; // maximal number of tracks in barrel
7675

77-
int FITVetoSides = -1; // Integer to encode which side(s) of the FIT to use for veto
78-
std::vector<std::string> FITVetoSidesOptions = {"both", "either", "A", "C", "neither"};
79-
8076
// Helper function for selecting DG events
8177
template <typename TEvent, typename TBCs, typename TTracks, typename TMuons>
82-
int isEventDG(TEvent const& collision, TBCs const& bcs, TTracks const& tracks, TMuons const& muons,
83-
aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds,
84-
std::vector<float> FITAmpLimits, int nDtColl, int minNBCs, int minNPVCs, int maxNPVCs, float maxFITTime,
85-
bool useFV0, bool useFT0, bool useFDD, int FITSide, bool doVetoFwd, bool doVetoBarrel)
78+
uint64_t isEventDG(TEvent const& collision, TBCs const& bcs, TTracks const& tracks, TMuons const& muons,
79+
aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds,
80+
std::vector<float> FITAmpLimits, int nDtColl, int minNBCs, int minNPVCs, int maxNPVCs, float maxFITTime,
81+
bool useFV0, bool useFT0, bool useFDD, bool doVetoFwd, bool doVetoBarrel)
8682
{
8783
fIsEventDGOutcome->Fill(0., 1.);
8884
// Find BC associated with collision
@@ -210,51 +206,54 @@ struct DQFilterPbPbTask {
210206
}
211207

212208
// Compute FIT decision
213-
bool FITDecision = 0;
214-
if (FITSide == 0) {
215-
FITDecision = isSideAClean && isSideCClean;
216-
} else if (FITSide == 1) {
217-
FITDecision = isSideAClean ^ isSideCClean;
218-
} else if (FITSide == 2) {
219-
FITDecision = isSideAClean;
220-
} else if (FITSide == 3) {
221-
FITDecision = isSideCClean;
222-
} else if (FITSide == 4) {
223-
FITDecision = 1;
209+
uint64_t FITDecision = 0;
210+
if (isSideAClean && isSideCClean) {
211+
FITDecision |= (uint64_t(1) << VarManager::kDoubleGap);
212+
} else if (isSideAClean && !isSideCClean) {
213+
FITDecision |= (uint64_t(1) << VarManager::kSingleGapA);
214+
} else if (!isSideAClean && isSideCClean) {
215+
FITDecision |= (uint64_t(1) << VarManager::kSingleGapC);
224216
}
225217
if (!FITDecision) {
226-
return 1;
218+
fIsEventDGOutcome->Fill(2, 1);
219+
return 0;
227220
}
228221

229222
// Veto on activiy in either forward or barrel region
230223
if (doVetoFwd) {
231224
for (auto& muon : muons) {
232225
// Only care about muons with good timing (MID)
233226
if (muon.trackType() == 0 || muon.trackType() == 3) {
234-
return 2;
227+
fIsEventDGOutcome->Fill(3, 1);
228+
return 0;
235229
}
236230
}
237231
}
238232
if (doVetoBarrel) {
239233
if (tracks.size() > 0) {
240-
return 3;
234+
fIsEventDGOutcome->Fill(4, 1);
235+
return 0;
241236
}
242237
}
243238

244239
// No global tracks which are not vtx tracks
245240
for (auto& track : tracks) {
246241
if (track.isGlobalTrack() && !track.isPVContributor()) {
247-
return 4;
242+
fIsEventDGOutcome->Fill(5, 1);
243+
return 0;
248244
}
249245
}
250246

251247
// Number of primary vertex contributors
252248
if (collision.numContrib() < minNPVCs || collision.numContrib() > maxNPVCs) {
253-
return 5;
249+
fIsEventDGOutcome->Fill(6, 1);
250+
return 0;
254251
}
255252

256253
// If we made it here, the event passed
257-
return 0;
254+
fIsEventDGOutcome->Fill(1, 1);
255+
// Return filter bitmap corresponding to FIT decision
256+
return FITDecision;
258257
}
259258

260259
void DefineCuts()
@@ -290,15 +289,6 @@ struct DQFilterPbPbTask {
290289
void init(o2::framework::InitContext&)
291290
{
292291
DefineCuts();
293-
294-
for (int i = 0; i < 5; i++) {
295-
if (fConfigFITSides.value == FITVetoSidesOptions[i]) {
296-
FITVetoSides = i;
297-
}
298-
}
299-
if (FITVetoSides == -1) {
300-
LOGF(fatal, "Invalid choice of FIT side(s) for veto: %s", fConfigFITSides.value);
301-
}
302292
}
303293

304294
template <uint32_t TEventFillMap>
@@ -308,18 +298,13 @@ struct DQFilterPbPbTask {
308298
fStats->Fill(-2.0);
309299

310300
std::vector<float> FITAmpLimits = {fConfigFV0AmpLimit, fConfigFT0AAmpLimit, fConfigFT0CAmpLimit, fConfigFDDAAmpLimit, fConfigFDDCAmpLimit};
311-
int filterOutcome = isEventDG(collision, bcs, tracks, muons, ft0s, fv0as, fdds,
312-
FITAmpLimits, fConfigNDtColl, fConfigMinNBCs, fConfigMinNPVCs, fConfigMaxNPVCs, fConfigMaxFITTime,
313-
fConfigUseFV0, fConfigUseFT0, fConfigUseFDD, FITVetoSides, fConfigVetoForward, fConfigVetoBarrel);
314-
fIsEventDGOutcome->Fill(filterOutcome + 1, 1);
315-
316-
// Don't need info on filter outcome anymore; reduce to a boolean
317-
bool isDG = !filterOutcome;
318-
fStats->Fill(-1.0, isDG);
319-
320-
// Compute event filter
321-
uint64_t filter = 0;
322-
filter |= isDG;
301+
uint64_t filter = isEventDG(collision, bcs, tracks, muons, ft0s, fv0as, fdds,
302+
FITAmpLimits, fConfigNDtColl, fConfigMinNBCs, fConfigMinNPVCs, fConfigMaxNPVCs, fConfigMaxFITTime,
303+
fConfigUseFV0, fConfigUseFT0, fConfigUseFDD, fConfigVetoForward, fConfigVetoBarrel);
304+
305+
bool isSelected = filter;
306+
fStats->Fill(-1.0, isSelected);
307+
323308
eventFilter(filter);
324309
}
325310

0 commit comments

Comments
 (0)