Skip to content

Commit 5179f01

Browse files
authored
[PWGJE,EMCAL-670] Add BC selection to EMCal QA task (#10847)
1 parent c0e8ef5 commit 5179f01

File tree

2 files changed

+217
-1
lines changed

2 files changed

+217
-1
lines changed

PWGJE/Core/utilsBcSelEMC.h

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file utilsBcSelEMC.h
13+
/// \brief BC selection utilities for EMCal QA
14+
/// \author Marvin Hemmer <marvin.hemmer@cern.ch>, Goethe-University
15+
16+
#ifndef PWGJE_CORE_UTILSBCSELEMC_H_
17+
#define PWGJE_CORE_UTILSBCSELEMC_H_
18+
19+
#include <memory> // std::shared_ptr
20+
#include <string> // std::string
21+
22+
#include "Framework/Configurable.h"
23+
#include "Framework/HistogramRegistry.h"
24+
#include "Framework/HistogramSpec.h"
25+
#include "Framework/OutputObjHeader.h"
26+
27+
#include "Common/CCDB/EventSelectionParams.h"
28+
29+
namespace o2::emc_evsel
30+
{
31+
// event rejection types
32+
enum EventRejection {
33+
None = 0,
34+
Trigger,
35+
TvxTrigger,
36+
TimeFrameBorderCut,
37+
ItsRofBorderCut,
38+
IsGoodZvtxFT0vsPV,
39+
NoSameBunchPileup,
40+
NoCollInTimeRangeNarrow,
41+
NoCollInTimeRangeStandard,
42+
NoCollInRofStandard,
43+
NEventRejection
44+
};
45+
46+
o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""};
47+
48+
/// \brief Function to put labels on monitoring histogram
49+
/// \param hRejection monitoring histogram
50+
template <typename Histo>
51+
void setEventRejectionLabels(Histo& hRejection)
52+
{
53+
// Puts labels on the bc monitoring histogram.
54+
hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All");
55+
hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Sel8");
56+
hRejection->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger");
57+
hRejection->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border");
58+
hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITS ROF border");
59+
hRejection->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing");
60+
hRejection->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up");
61+
hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInTimeRangeNarrow + 1, "No coll timerange narrow");
62+
hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInTimeRangeStandard + 1, "No coll timerange strict");
63+
hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInRofStandard + 1, "No coll in ROF std");
64+
}
65+
66+
struct EMCEventSelection : o2::framework::ConfigurableGroup {
67+
std::string prefix = "emcBcSel"; // JSON group name
68+
// event selection parameters (in chronological order of application)
69+
o2::framework::Configurable<bool> useSel8Trigger{"useSel8Trigger", true, "Apply the sel8 event selection"};
70+
o2::framework::Configurable<int> triggerClass{"triggerClass", -1, "Trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false"};
71+
o2::framework::Configurable<bool> useTvxTrigger{"useTvxTrigger", true, "Apply TVX trigger sel"};
72+
o2::framework::Configurable<bool> useTimeFrameBorderCut{"useTimeFrameBorderCut", true, "Apply TF border cut"};
73+
o2::framework::Configurable<bool> useItsRofBorderCut{"useItsRofBorderCut", true, "Apply ITS ROF border cut"};
74+
o2::framework::Configurable<bool> useIsGoodZvtxFT0vsPV{"useIsGoodZvtxFT0vsPV", false, "Check consistency between PVz from central barrel with that from FT0 timing"};
75+
o2::framework::Configurable<bool> useNoSameBunchPileup{"useNoSameBunchPileup", false, "Exclude collisions in bunches with more than 1 reco. PV"};
76+
o2::framework::Configurable<bool> useNoCollInTimeRangeNarrow{"useNoCollInTimeRangeNarrow", false, "Reject collisions in time range narrow"};
77+
o2::framework::Configurable<bool> useNoCollInTimeRangeStandard{"useNoCollInTimeRangeStandard", false, "Reject collisions in time range strict"};
78+
o2::framework::Configurable<bool> useNoCollInRofStandard{"useNoCollInRofStandard", false, "Reject collisions in ROF standard"};
79+
80+
// histogram names
81+
static constexpr char NameHistBCs[] = "hBCs";
82+
83+
std::shared_ptr<TH1> hBCs;
84+
85+
int currentRun{-1};
86+
87+
/// \brief Adds bc monitoring histograms in the histogram registry.
88+
/// \param registry reference to the histogram registry
89+
void addHistograms(o2::framework::HistogramRegistry& registry)
90+
{
91+
hBCs = registry.add<TH1>(NameHistBCs, "EMC event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}});
92+
setEventRejectionLabels(hBCs);
93+
}
94+
95+
/// \brief Applies event selection.
96+
/// \tparam useEvSel use information from the EvSel table
97+
/// \param bc bc to test against the selection criteria
98+
/// \return bitmask with the event selection criteria not satisfied by the bc
99+
template <bool useEvSel, typename Bc>
100+
uint16_t getEMCCollisionRejectionMask(const Bc& bc)
101+
{
102+
uint16_t rejectionMask{0}; // 16 bits, in case new ev. selections will be added
103+
104+
if constexpr (useEvSel) {
105+
/// trigger condition
106+
bool sel8 = bc.selection_bit(o2::aod::evsel::kIsBBT0A) && bc.selection_bit(o2::aod::evsel::kIsBBT0C);
107+
if ((useSel8Trigger && sel8) || (!useSel8Trigger && triggerClass > -1 && !bc.alias_bit(triggerClass))) {
108+
SETBIT(rejectionMask, EventRejection::Trigger);
109+
}
110+
/// TVX trigger selection
111+
if (useTvxTrigger && !bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) {
112+
SETBIT(rejectionMask, EventRejection::TvxTrigger);
113+
}
114+
/// time frame border cut
115+
if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
116+
SETBIT(rejectionMask, EventRejection::TimeFrameBorderCut);
117+
}
118+
/// ITS rof border cut
119+
if (useItsRofBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) {
120+
SETBIT(rejectionMask, EventRejection::ItsRofBorderCut);
121+
}
122+
/// PVz consistency tracking - FT0 timing
123+
if (useIsGoodZvtxFT0vsPV && !bc.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) {
124+
SETBIT(rejectionMask, EventRejection::IsGoodZvtxFT0vsPV);
125+
}
126+
/// remove collisions in bunches with more than 1 reco bc
127+
/// POTENTIALLY BAD FOR BEAUTY ANALYSES
128+
if (useNoSameBunchPileup && !bc.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) {
129+
SETBIT(rejectionMask, EventRejection::NoSameBunchPileup);
130+
}
131+
/// No collisions in time range narrow
132+
if (useNoCollInTimeRangeNarrow && !bc.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) {
133+
SETBIT(rejectionMask, EventRejection::NoCollInTimeRangeNarrow);
134+
}
135+
/// No collisions in time range strict
136+
if (useNoCollInTimeRangeStandard && !bc.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) {
137+
SETBIT(rejectionMask, EventRejection::NoCollInTimeRangeStandard);
138+
}
139+
/// No collisions in ROF standard
140+
if (useNoCollInRofStandard && !bc.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) {
141+
SETBIT(rejectionMask, EventRejection::NoCollInRofStandard);
142+
}
143+
}
144+
return rejectionMask;
145+
}
146+
147+
/// \brief Fills histograms for monitoring event selections satisfied by the bc.
148+
/// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the bc
149+
void fillHistograms(const uint16_t rejectionMask)
150+
{
151+
hBCs->Fill(EventRejection::None);
152+
for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) {
153+
if (TESTBIT(rejectionMask, reason)) {
154+
return;
155+
}
156+
hBCs->Fill(reason);
157+
}
158+
}
159+
};
160+
161+
struct EMCEventSelectionMc {
162+
// event selection parameters (in chronological order of application)
163+
bool useSel8Trigger{false}; // Apply the Sel8 selection
164+
bool useTvxTrigger{false}; // Apply the TVX trigger
165+
bool useTimeFrameBorderCut{true}; // Apply TF border cut
166+
bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut
167+
168+
void configureFromDevice(const o2::framework::DeviceSpec& device)
169+
{
170+
for (const auto& option : device.options) {
171+
if (option.name.compare("emcEvSel.useSel8Trigger") == 0) {
172+
useSel8Trigger = option.defaultValue.get<bool>();
173+
} else if (option.name.compare("emcEvSel.useTvxTrigger") == 0) {
174+
useTvxTrigger = option.defaultValue.get<bool>();
175+
} else if (option.name.compare("emcEvSel.useTimeFrameBorderCut") == 0) {
176+
useTimeFrameBorderCut = option.defaultValue.get<bool>();
177+
} else if (option.name.compare("emcEvSel.useItsRofBorderCut") == 0) {
178+
useItsRofBorderCut = option.defaultValue.get<bool>();
179+
}
180+
}
181+
}
182+
};
183+
} // namespace o2::emc_evsel
184+
185+
#endif // PWGJE_CORE_UTILSBCSELEMC_H_

PWGJE/Tasks/emcEventSelectionQA.cxx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@
2222
#include "Framework/HistogramRegistry.h"
2323

2424
#include "Common/DataModel/EventSelection.h"
25+
#include "PWGJE/Core/utilsBcSelEMC.h"
2526

2627
using namespace o2;
2728
using namespace o2::framework;
2829
using namespace o2::framework::expressions;
30+
using namespace o2::emc_evsel;
2931

3032
using BCEvSels = o2::soa::Join<o2::aod::BCs, o2::aod::BcSels>;
3133
using CollEventSels = o2::soa::Join<o2::aod::Collisions, o2::aod::EvSels>;
3234
using FilteredCells = o2::soa::Filtered<aod::Calos>;
3335

3436
struct EmcEventSelectionQA {
37+
38+
EMCEventSelection emcEvSel; // event selection and monitoring
3539
o2::framework::HistogramRegistry mHistManager{"EMCALEventSelectionQAHistograms"};
3640

3741
// Require EMCAL cells (CALO type 1)
@@ -81,6 +85,8 @@ struct EmcEventSelectionQA {
8185
mHistManager.add("hBCCollisionCounter_TVX", "Number of BCs with a certain number of rec. colls", O2HistType::kTH2F, {bcAxis, matchingAxis});
8286
mHistManager.add("hBCEMCalReadoutAndEmcalCellContent", "Bunch crossings with EMCAL trigger from CTP and non-0 EMCAL cell content", O2HistType::kTH1F, {bcAxis});
8387
mHistManager.add("hBCNotEMCalReadoutButEmcalCellContent", "Bunch crossings without EMCAL trigger from CTP but with non-0 EMCAL cell content", O2HistType::kTH1F, {bcAxis});
88+
mHistManager.add("hBCNotAcceptedButEMCalReadout", "Bunch crossings with EMCAL trigger from CTP but not accpeted due to BC selection", O2HistType::kTH1F, {bcAxis});
89+
mHistManager.add("hBCNotAcceptedButEmcalCellContent", "Bunch crossings with non-0 EMCAL cell content but not accpeted due to BC selection", O2HistType::kTH1F, {bcAxis});
8490
mHistManager.add("hAmplitudevsCellTimeNoReadout", "Amplitude vs cell time for bunch crossings without EMCAL trigger from CTP but with non-0 EMCAL cell content", O2HistType::kTH2D, {timeAxisLarge, amplitudeAxisLarge});
8591

8692
initCollisionHistogram(mHistManager.get<TH1>(HIST("hCollisionMatching")).get());
@@ -96,6 +102,8 @@ struct EmcEventSelectionQA {
96102
initCollisionHistogram(mHistManager.get<TH1>(HIST("hCollisionMatchingDJ1")).get());
97103
initCollisionHistogram(mHistManager.get<TH1>(HIST("hCollisionMatchingEJ2")).get());
98104
initCollisionHistogram(mHistManager.get<TH1>(HIST("hCollisionMatchingDJ2")).get());
105+
106+
emcEvSel.addHistograms(mHistManager); // collision monitoring
99107
}
100108

101109
PresliceUnsorted<CollEventSels> perFoundBC = aod::evsel::foundBCId;
@@ -120,6 +128,11 @@ struct EmcEventSelectionQA {
120128
bool isEMCALreadout = false;
121129
auto bcID = bc.globalBC() % 3564;
122130

131+
// get bitmask with bc selection info
132+
const auto rejectionMask = emcEvSel.getEMCCollisionRejectionMask<true, BCEvSels::iterator>(bc);
133+
// monitor the satisfied event selections
134+
emcEvSel.fillHistograms(rejectionMask);
135+
123136
if (bc.runNumber() > mRun3MinNumber) {
124137
// in case of run3 not all BCs contain EMCAL data, require trigger selection also for min. bias
125138
// in addition select also L0/L1 triggers as triggers with EMCAL in reaodut
@@ -134,6 +147,25 @@ struct EmcEventSelectionQA {
134147
}
135148
}
136149

150+
// lookup number of cells for global BC of this BC
151+
// avoid iteration over cell table for speed reason
152+
auto found = cellGlobalBCs.find(bc.globalBC());
153+
154+
if (rejectionMask != 0) {
155+
// at least one event selection not satisfied --> reject the candidate
156+
continue;
157+
} else {
158+
if (isEMCALreadout) {
159+
mHistManager.fill(HIST("hBCNotAcceptedButEMCalReadout"), bcID);
160+
}
161+
if (found != cellGlobalBCs.end()) {
162+
// require at least 1 cell for global BC
163+
if (found->second > 0) {
164+
mHistManager.fill(HIST("hBCNotAcceptedButEmcalCellContent"), bcID);
165+
}
166+
}
167+
}
168+
137169
// Monitoring BCs with EMCAL trigger / readout / FIT trigger
138170
if (isEMCALreadout) {
139171
mHistManager.fill(HIST("hBCEmcalReadout"), bcID);
@@ -175,7 +207,6 @@ struct EmcEventSelectionQA {
175207

176208
// lookup number of cells for global BC of this BC
177209
// avoid iteration over cell table for speed reason
178-
auto found = cellGlobalBCs.find(bc.globalBC());
179210
if (found != cellGlobalBCs.end()) {
180211
// require at least 1 cell for global BC
181212
if (found->second > 0) {

0 commit comments

Comments
 (0)