Skip to content

Commit d9fa993

Browse files
authored
BC selection task and alias accounting added (#5757)
* BC selection task and alias accounting added * clang-format fixes * bcsel namespace removed. alias labels added. +bug fixes * clang-format fixes
1 parent be56bfe commit d9fa993

7 files changed

Lines changed: 96 additions & 24 deletions

File tree

Analysis/Core/include/AnalysisCore/TriggerAliases.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ enum triggerAliases {
3131
kNaliases
3232
};
3333

34+
static const std::string aliasLabels[kNaliases] = {
35+
"kINT7",
36+
"kEMC7",
37+
"kINT7inMUON",
38+
"kMuonSingleLowPt7",
39+
"kMuonSingleHighPt7",
40+
"kMuonUnlikeLowPt7",
41+
"kMuonLikeLowPt7",
42+
"kCUP8",
43+
"kCUP9",
44+
"kMUP10",
45+
"kMUP11"};
46+
3447
class TriggerAliases
3548
{
3649
public:

Analysis/Core/src/TriggerAliases.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ void TriggerAliases::AddClassIdToAlias(uint32_t aliasId, int classId)
1818
} else if (classId < 50) {
1919
mAliasToTriggerMask[aliasId] |= 1ull << classId;
2020
} else {
21-
mAliasToTriggerMaskNext50[aliasId] |= 1ull << classId;
21+
mAliasToTriggerMaskNext50[aliasId] |= 1ull << (classId - 50);
2222
}
2323
}

Analysis/DataModel/include/AnalysisDataModel/EventSelection.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace o2::aod
1717
{
18+
// collision-joinable event selection decisions
1819
namespace evsel
1920
{
2021
// TODO bool arrays are not supported? Storing in int32 for the moment
@@ -38,12 +39,21 @@ DECLARE_SOA_DYNAMIC_COLUMN(SEL8, sel8, [](bool bbT0A, bool bbT0C, bool bbZNA, bo
3839
DECLARE_SOA_TABLE(EvSels, "AOD", "EVSEL",
3940
evsel::Alias,
4041
evsel::BBT0A, evsel::BBT0C,
41-
evsel::BBV0A, evsel::BBV0C, evsel::BGV0A, evsel::BGV0C, evsel::BBZNA, evsel::BBZNC,
42+
evsel::BBV0A, evsel::BBV0C, evsel::BGV0A, evsel::BGV0C,
43+
evsel::BBZNA, evsel::BBZNC,
4244
evsel::BBFDA, evsel::BBFDC, evsel::BGFDA, evsel::BGFDC,
4345
evsel::SEL7<evsel::BBV0A, evsel::BBV0C, evsel::BBZNA, evsel::BBZNC>,
4446
evsel::SEL8<evsel::BBT0A, evsel::BBT0C, evsel::BBZNA, evsel::BBZNC>,
4547
evsel::FoundFT0);
4648
using EvSel = EvSels::iterator;
49+
50+
DECLARE_SOA_TABLE(BcSels, "AOD", "BCSEL",
51+
evsel::Alias,
52+
evsel::BBT0A, evsel::BBT0C,
53+
evsel::BBV0A, evsel::BBV0C, evsel::BGV0A, evsel::BGV0C,
54+
evsel::BBZNA, evsel::BBZNC,
55+
evsel::BBFDA, evsel::BBFDC, evsel::BGFDA, evsel::BGFDC);
56+
using BcSel = BcSels::iterator;
4757
} // namespace o2::aod
4858

4959
#endif // O2_ANALYSIS_EVENTSELECTION_H_

Analysis/Tasks/eventSelection.cxx

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,27 @@ struct EvSelParameters {
6767
float fT0CBBupper = 2.0; // ns
6868
};
6969

70-
struct EventSelectionTask {
71-
Produces<aod::EvSels> evsel;
70+
struct BcSelectionTask {
71+
Produces<aod::BcSels> bcsel;
7272
Service<o2::ccdb::BasicCCDBManager> ccdb;
73-
Configurable<bool> isMC{"isMC", 0, "0 - data, 1 - MC"};
74-
7573
EvSelParameters par;
76-
7774
void init(InitContext&)
7875
{
7976
ccdb->setURL("http://ccdb-test.cern.ch:8080");
8077
ccdb->setCaching(true);
8178
ccdb->setLocalObjectValidityChecking();
8279
}
8380

84-
using BCsWithTimestampsAndRun2Infos = soa::Join<aod::BCsWithTimestamps, aod::Run2BCInfos>;
81+
using BCsWithRun2InfosTimestampsAndMatches = soa::Join<aod::BCs, aod::Run2BCInfos, aod::Timestamps, aod::Run2MatchedToBCSparse>;
82+
8583
void process(
86-
aod::Run2MatchedSparse::iterator const& col,
87-
BCsWithTimestampsAndRun2Infos const& bcs,
84+
BCsWithRun2InfosTimestampsAndMatches::iterator const& bc,
8885
aod::Zdcs const& zdcs,
8986
aod::FV0As const& fv0as,
9087
aod::FV0Cs const& fv0cs,
9188
aod::FT0s const& ft0s,
9289
aod::FDDs const& fdds)
9390
{
94-
auto bc = col.bc_as<BCsWithTimestampsAndRun2Infos>();
9591
TriggerAliases* aliases = ccdb->getForTimeStamp<TriggerAliases>("Trigger/TriggerAliases", bc.timestamp());
9692
if (!aliases) {
9793
LOGF(fatal, "Trigger aliases are not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp());
@@ -108,14 +104,14 @@ struct EventSelectionTask {
108104
alias[al.first] |= (triggerMaskNext50 & al.second) > 0;
109105
}
110106

111-
float timeZNA = col.has_zdc() ? col.zdc().timeZNA() : -999.f;
112-
float timeZNC = col.has_zdc() ? col.zdc().timeZNC() : -999.f;
113-
float timeV0A = col.has_fv0a() ? col.fv0a().time() : -999.f;
114-
float timeV0C = col.has_fv0c() ? col.fv0c().time() : -999.f;
115-
float timeT0A = col.has_ft0() ? col.ft0().timeA() : -999.f;
116-
float timeT0C = col.has_ft0() ? col.ft0().timeC() : -999.f;
117-
float timeFDA = col.has_fdd() ? col.fdd().timeA() : -999.f;
118-
float timeFDC = col.has_fdd() ? col.fdd().timeC() : -999.f;
107+
float timeZNA = bc.has_zdc() ? bc.zdc().timeZNA() : -999.f;
108+
float timeZNC = bc.has_zdc() ? bc.zdc().timeZNC() : -999.f;
109+
float timeV0A = bc.has_fv0a() ? bc.fv0a().time() : -999.f;
110+
float timeV0C = bc.has_fv0c() ? bc.fv0c().time() : -999.f;
111+
float timeT0A = bc.has_ft0() ? bc.ft0().timeA() : -999.f;
112+
float timeT0C = bc.has_ft0() ? bc.ft0().timeC() : -999.f;
113+
float timeFDA = bc.has_fdd() ? bc.fdd().timeA() : -999.f;
114+
float timeFDC = bc.has_fdd() ? bc.fdd().timeC() : -999.f;
119115

120116
LOGF(debug, "timeZNA=%f timeZNC=%f", timeZNA, timeZNC);
121117
LOGF(debug, "timeV0A=%f timeV0C=%f", timeV0A, timeV0C);
@@ -135,11 +131,41 @@ struct EventSelectionTask {
135131
bool bbT0A = timeT0A > par.fT0ABBlower && timeT0A < par.fT0ABBupper;
136132
bool bbT0C = timeT0C > par.fT0CBBlower && timeT0C < par.fT0CBBupper;
137133

134+
// Fill bc selection columns
135+
bcsel(alias, bbT0A, bbT0C, bbV0A, bbV0C, bgV0A, bgV0C, bbZNA, bbZNC, bbFDA, bbFDC, bgFDA, bgFDC);
136+
}
137+
};
138+
139+
struct EventSelectionTask {
140+
Produces<aod::EvSels> evsel;
141+
Configurable<bool> isMC{"isMC", 0, "0 - data, 1 - MC"};
142+
143+
using BCsWithBcSels = soa::Join<aod::BCs, aod::BcSels>;
144+
145+
void process(aod::Collision const& col, BCsWithBcSels const& bcs)
146+
{
147+
auto bc = col.bc_as<BCsWithBcSels>();
148+
int32_t alias[kNaliases];
149+
for (int i = 0; i < kNaliases; i++) {
150+
alias[i] = bc.alias()[i];
151+
}
152+
bool bbZNA = bc.bbZNA();
153+
bool bbZNC = bc.bbZNC();
154+
bool bbV0A = bc.bbV0A();
155+
bool bbV0C = bc.bbV0C();
156+
bool bgV0A = bc.bgV0A();
157+
bool bgV0C = bc.bgV0C();
158+
bool bbFDA = bc.bbFDA();
159+
bool bbFDC = bc.bbFDC();
160+
bool bgFDA = bc.bgFDA();
161+
bool bgFDC = bc.bgFDC();
162+
bool bbT0A = bc.bbT0A();
163+
bool bbT0C = bc.bbT0C();
164+
138165
if (isMC) {
139166
bbZNA = 1;
140167
bbZNC = 1;
141168
}
142-
143169
// Fill event selection columns
144170
int64_t foundFT0 = -1; // this column is not used in run2 analysis
145171
evsel(alias, bbT0A, bbT0C, bbV0A, bbV0C, bgV0A, bgV0C, bbZNA, bbZNC, bbFDA, bbFDC, bgFDA, bgFDC, foundFT0);
@@ -220,7 +246,9 @@ struct EventSelectionTaskRun3 {
220246
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
221247
{
222248
if (cfgc.options().get<int>("selection-run") == 2) {
223-
return WorkflowSpec{adaptAnalysisTask<EventSelectionTask>(cfgc)};
249+
return WorkflowSpec{
250+
adaptAnalysisTask<BcSelectionTask>(cfgc),
251+
adaptAnalysisTask<EventSelectionTask>(cfgc)};
224252
} else {
225253
return WorkflowSpec{
226254
adaptAnalysisTask<EventSelectionTaskRun3>(cfgc)};

Analysis/Tasks/eventSelectionQa.cxx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,26 @@
1111
#include "Framework/AnalysisTask.h"
1212
#include "Framework/AnalysisDataModel.h"
1313
#include "AnalysisDataModel/EventSelection.h"
14+
#include "AnalysisCore/TriggerAliases.h"
15+
#include "TH1F.h"
1416

1517
using namespace o2;
1618
using namespace o2::framework;
1719

1820
struct EventSelectionQaPerBc {
21+
// TODO fill class names in axis labels
1922
OutputObj<TH1F> hFiredClasses{TH1F("hFiredClasses", "", 100, -0.5, 99.5)};
20-
void process(soa::Join<aod::BCs, aod::Run2BCInfos>::iterator const& bc)
23+
OutputObj<TH1F> hFiredAliases{TH1F("hFiredAliases", "", kNaliases, -0.5, kNaliases - 0.5)};
24+
void init(InitContext&)
2125
{
26+
for (int i = 0; i < kNaliases; i++) {
27+
hFiredAliases->GetXaxis()->SetBinLabel(i + 1, aliasLabels[i].data());
28+
}
29+
}
30+
31+
void process(soa::Join<aod::BCs, aod::Run2BCInfos, aod::BcSels>::iterator const& bc)
32+
{
33+
// Fill fired trigger classes
2234
uint64_t triggerMask = bc.triggerMask();
2335
uint64_t triggerMaskNext50 = bc.triggerMaskNext50();
2436
for (int i = 0; i < 50; i++) {
@@ -29,6 +41,13 @@ struct EventSelectionQaPerBc {
2941
hFiredClasses->Fill(i + 50);
3042
}
3143
}
44+
45+
// Fill fired aliases
46+
for (int i = 0; i < kNaliases; i++) {
47+
if (bc.alias()[i]) {
48+
hFiredAliases->Fill(i);
49+
}
50+
}
3251
}
3352
};
3453

Framework/Core/include/Framework/AnalysisDataModel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,8 @@ DECLARE_SOA_INDEX_TABLE(MatchedBCCollisionsSparse, BCs, "MA_BCCOL_SP", indices::
808808
DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(Run3MatchedToBCExclusive, BCs, "MA_RN3_BC_EX", indices::BCId, indices::ZdcId, indices::FT0Id, indices::FV0AId, indices::FDDId);
809809
DECLARE_SOA_INDEX_TABLE(Run3MatchedToBCSparse, BCs, "MA_RN3_BC_SP", indices::BCId, indices::ZdcId, indices::FT0Id, indices::FV0AId, indices::FDDId);
810810

811+
DECLARE_SOA_INDEX_TABLE(Run2MatchedToBCSparse, BCs, "MA_RN2_BC_SP", indices::BCId, indices::ZdcId, indices::FT0Id, indices::FV0AId, indices::FV0CId, indices::FDDId);
812+
811813
// Joins with collisions (only for sparse ones)
812814
// NOTE: index table needs to be always last argument
813815
using CollisionMatchedRun2Sparse = soa::Join<Collisions, Run2MatchedSparse>::iterator;

Framework/Core/src/AODReaderHelpers.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ static inline auto extractOriginalsTuple(framework::pack<Os...>, ProcessingConte
8686
AlgorithmSpec AODReaderHelpers::indexBuilderCallback(std::vector<InputSpec> requested)
8787
{
8888
return AlgorithmSpec::InitCallback{[requested](InitContext& ic) {
89-
9089
return [requested](ProcessingContext& pc) {
9190
auto outputs = pc.outputs();
9291
// spawn tables
@@ -135,6 +134,8 @@ AlgorithmSpec AODReaderHelpers::indexBuilderCallback(std::vector<InputSpec> requ
135134
outputs.adopt(Output{origin, description}, maker(o2::aod::Run3MatchedToBCSparseMetadata{}));
136135
} else if (description == header::DataDescription{"MA_RN3_BC_EX"}) {
137136
outputs.adopt(Output{origin, description}, maker(o2::aod::Run3MatchedToBCExclusiveMetadata{}));
137+
} else if (description == header::DataDescription{"MA_RN2_BC_SP"}) {
138+
outputs.adopt(Output{origin, description}, maker(o2::aod::Run2MatchedToBCSparseMetadata{}));
138139
} else {
139140
throw std::runtime_error("Not an index table");
140141
}
@@ -146,7 +147,6 @@ AlgorithmSpec AODReaderHelpers::indexBuilderCallback(std::vector<InputSpec> requ
146147
AlgorithmSpec AODReaderHelpers::aodSpawnerCallback(std::vector<InputSpec> requested)
147148
{
148149
return AlgorithmSpec::InitCallback{[requested](InitContext& ic) {
149-
150150
return [requested](ProcessingContext& pc) {
151151
auto outputs = pc.outputs();
152152
// spawn tables

0 commit comments

Comments
 (0)