diff --git a/Analysis/Core/include/AnalysisCore/TriggerAliases.h b/Analysis/Core/include/AnalysisCore/TriggerAliases.h index 8aa88c10b78e1..2a5db96497d1a 100644 --- a/Analysis/Core/include/AnalysisCore/TriggerAliases.h +++ b/Analysis/Core/include/AnalysisCore/TriggerAliases.h @@ -31,6 +31,19 @@ enum triggerAliases { kNaliases }; +static const std::string aliasLabels[kNaliases] = { + "kINT7", + "kEMC7", + "kINT7inMUON", + "kMuonSingleLowPt7", + "kMuonSingleHighPt7", + "kMuonUnlikeLowPt7", + "kMuonLikeLowPt7", + "kCUP8", + "kCUP9", + "kMUP10", + "kMUP11"}; + class TriggerAliases { public: diff --git a/Analysis/Core/src/TriggerAliases.cxx b/Analysis/Core/src/TriggerAliases.cxx index b4525a84fe186..85e10392daf68 100644 --- a/Analysis/Core/src/TriggerAliases.cxx +++ b/Analysis/Core/src/TriggerAliases.cxx @@ -18,6 +18,6 @@ void TriggerAliases::AddClassIdToAlias(uint32_t aliasId, int classId) } else if (classId < 50) { mAliasToTriggerMask[aliasId] |= 1ull << classId; } else { - mAliasToTriggerMaskNext50[aliasId] |= 1ull << classId; + mAliasToTriggerMaskNext50[aliasId] |= 1ull << (classId - 50); } } diff --git a/Analysis/DataModel/include/AnalysisDataModel/EventSelection.h b/Analysis/DataModel/include/AnalysisDataModel/EventSelection.h index ffe5af699d1dd..6b100004de17d 100644 --- a/Analysis/DataModel/include/AnalysisDataModel/EventSelection.h +++ b/Analysis/DataModel/include/AnalysisDataModel/EventSelection.h @@ -15,6 +15,7 @@ namespace o2::aod { +// collision-joinable event selection decisions namespace evsel { // 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 DECLARE_SOA_TABLE(EvSels, "AOD", "EVSEL", evsel::Alias, evsel::BBT0A, evsel::BBT0C, - evsel::BBV0A, evsel::BBV0C, evsel::BGV0A, evsel::BGV0C, evsel::BBZNA, evsel::BBZNC, + evsel::BBV0A, evsel::BBV0C, evsel::BGV0A, evsel::BGV0C, + evsel::BBZNA, evsel::BBZNC, evsel::BBFDA, evsel::BBFDC, evsel::BGFDA, evsel::BGFDC, evsel::SEL7, evsel::SEL8, evsel::FoundFT0); using EvSel = EvSels::iterator; + +DECLARE_SOA_TABLE(BcSels, "AOD", "BCSEL", + evsel::Alias, + evsel::BBT0A, evsel::BBT0C, + evsel::BBV0A, evsel::BBV0C, evsel::BGV0A, evsel::BGV0C, + evsel::BBZNA, evsel::BBZNC, + evsel::BBFDA, evsel::BBFDC, evsel::BGFDA, evsel::BGFDC); +using BcSel = BcSels::iterator; } // namespace o2::aod #endif // O2_ANALYSIS_EVENTSELECTION_H_ diff --git a/Analysis/Tasks/eventSelection.cxx b/Analysis/Tasks/eventSelection.cxx index 7bf0601b8e08e..bcced7989de2a 100644 --- a/Analysis/Tasks/eventSelection.cxx +++ b/Analysis/Tasks/eventSelection.cxx @@ -67,13 +67,10 @@ struct EvSelParameters { float fT0CBBupper = 2.0; // ns }; -struct EventSelectionTask { - Produces evsel; +struct BcSelectionTask { + Produces bcsel; Service ccdb; - Configurable isMC{"isMC", 0, "0 - data, 1 - MC"}; - EvSelParameters par; - void init(InitContext&) { ccdb->setURL("http://ccdb-test.cern.ch:8080"); @@ -81,17 +78,16 @@ struct EventSelectionTask { ccdb->setLocalObjectValidityChecking(); } - using BCsWithTimestampsAndRun2Infos = soa::Join; + using BCsWithRun2InfosTimestampsAndMatches = soa::Join; + void process( - aod::Run2MatchedSparse::iterator const& col, - BCsWithTimestampsAndRun2Infos const& bcs, + BCsWithRun2InfosTimestampsAndMatches::iterator const& bc, aod::Zdcs const& zdcs, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::FT0s const& ft0s, aod::FDDs const& fdds) { - auto bc = col.bc_as(); TriggerAliases* aliases = ccdb->getForTimeStamp("Trigger/TriggerAliases", bc.timestamp()); if (!aliases) { 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 { alias[al.first] |= (triggerMaskNext50 & al.second) > 0; } - float timeZNA = col.has_zdc() ? col.zdc().timeZNA() : -999.f; - float timeZNC = col.has_zdc() ? col.zdc().timeZNC() : -999.f; - float timeV0A = col.has_fv0a() ? col.fv0a().time() : -999.f; - float timeV0C = col.has_fv0c() ? col.fv0c().time() : -999.f; - float timeT0A = col.has_ft0() ? col.ft0().timeA() : -999.f; - float timeT0C = col.has_ft0() ? col.ft0().timeC() : -999.f; - float timeFDA = col.has_fdd() ? col.fdd().timeA() : -999.f; - float timeFDC = col.has_fdd() ? col.fdd().timeC() : -999.f; + float timeZNA = bc.has_zdc() ? bc.zdc().timeZNA() : -999.f; + float timeZNC = bc.has_zdc() ? bc.zdc().timeZNC() : -999.f; + float timeV0A = bc.has_fv0a() ? bc.fv0a().time() : -999.f; + float timeV0C = bc.has_fv0c() ? bc.fv0c().time() : -999.f; + float timeT0A = bc.has_ft0() ? bc.ft0().timeA() : -999.f; + float timeT0C = bc.has_ft0() ? bc.ft0().timeC() : -999.f; + float timeFDA = bc.has_fdd() ? bc.fdd().timeA() : -999.f; + float timeFDC = bc.has_fdd() ? bc.fdd().timeC() : -999.f; LOGF(debug, "timeZNA=%f timeZNC=%f", timeZNA, timeZNC); LOGF(debug, "timeV0A=%f timeV0C=%f", timeV0A, timeV0C); @@ -135,11 +131,41 @@ struct EventSelectionTask { bool bbT0A = timeT0A > par.fT0ABBlower && timeT0A < par.fT0ABBupper; bool bbT0C = timeT0C > par.fT0CBBlower && timeT0C < par.fT0CBBupper; + // Fill bc selection columns + bcsel(alias, bbT0A, bbT0C, bbV0A, bbV0C, bgV0A, bgV0C, bbZNA, bbZNC, bbFDA, bbFDC, bgFDA, bgFDC); + } +}; + +struct EventSelectionTask { + Produces evsel; + Configurable isMC{"isMC", 0, "0 - data, 1 - MC"}; + + using BCsWithBcSels = soa::Join; + + void process(aod::Collision const& col, BCsWithBcSels const& bcs) + { + auto bc = col.bc_as(); + int32_t alias[kNaliases]; + for (int i = 0; i < kNaliases; i++) { + alias[i] = bc.alias()[i]; + } + bool bbZNA = bc.bbZNA(); + bool bbZNC = bc.bbZNC(); + bool bbV0A = bc.bbV0A(); + bool bbV0C = bc.bbV0C(); + bool bgV0A = bc.bgV0A(); + bool bgV0C = bc.bgV0C(); + bool bbFDA = bc.bbFDA(); + bool bbFDC = bc.bbFDC(); + bool bgFDA = bc.bgFDA(); + bool bgFDC = bc.bgFDC(); + bool bbT0A = bc.bbT0A(); + bool bbT0C = bc.bbT0C(); + if (isMC) { bbZNA = 1; bbZNC = 1; } - // Fill event selection columns int64_t foundFT0 = -1; // this column is not used in run2 analysis evsel(alias, bbT0A, bbT0C, bbV0A, bbV0C, bgV0A, bgV0C, bbZNA, bbZNC, bbFDA, bbFDC, bgFDA, bgFDC, foundFT0); @@ -220,7 +246,9 @@ struct EventSelectionTaskRun3 { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { if (cfgc.options().get("selection-run") == 2) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } else { return WorkflowSpec{ adaptAnalysisTask(cfgc)}; diff --git a/Analysis/Tasks/eventSelectionQa.cxx b/Analysis/Tasks/eventSelectionQa.cxx index af62185cf8fb0..f31f0e36080a3 100644 --- a/Analysis/Tasks/eventSelectionQa.cxx +++ b/Analysis/Tasks/eventSelectionQa.cxx @@ -11,14 +11,26 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "AnalysisDataModel/EventSelection.h" +#include "AnalysisCore/TriggerAliases.h" +#include "TH1F.h" using namespace o2; using namespace o2::framework; struct EventSelectionQaPerBc { + // TODO fill class names in axis labels OutputObj hFiredClasses{TH1F("hFiredClasses", "", 100, -0.5, 99.5)}; - void process(soa::Join::iterator const& bc) + OutputObj hFiredAliases{TH1F("hFiredAliases", "", kNaliases, -0.5, kNaliases - 0.5)}; + void init(InitContext&) { + for (int i = 0; i < kNaliases; i++) { + hFiredAliases->GetXaxis()->SetBinLabel(i + 1, aliasLabels[i].data()); + } + } + + void process(soa::Join::iterator const& bc) + { + // Fill fired trigger classes uint64_t triggerMask = bc.triggerMask(); uint64_t triggerMaskNext50 = bc.triggerMaskNext50(); for (int i = 0; i < 50; i++) { @@ -29,6 +41,13 @@ struct EventSelectionQaPerBc { hFiredClasses->Fill(i + 50); } } + + // Fill fired aliases + for (int i = 0; i < kNaliases; i++) { + if (bc.alias()[i]) { + hFiredAliases->Fill(i); + } + } } }; diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index b314cb9203877..62d315d053d04 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -808,6 +808,8 @@ DECLARE_SOA_INDEX_TABLE(MatchedBCCollisionsSparse, BCs, "MA_BCCOL_SP", indices:: DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(Run3MatchedToBCExclusive, BCs, "MA_RN3_BC_EX", indices::BCId, indices::ZdcId, indices::FT0Id, indices::FV0AId, indices::FDDId); DECLARE_SOA_INDEX_TABLE(Run3MatchedToBCSparse, BCs, "MA_RN3_BC_SP", indices::BCId, indices::ZdcId, indices::FT0Id, indices::FV0AId, indices::FDDId); +DECLARE_SOA_INDEX_TABLE(Run2MatchedToBCSparse, BCs, "MA_RN2_BC_SP", indices::BCId, indices::ZdcId, indices::FT0Id, indices::FV0AId, indices::FV0CId, indices::FDDId); + // Joins with collisions (only for sparse ones) // NOTE: index table needs to be always last argument using CollisionMatchedRun2Sparse = soa::Join::iterator; diff --git a/Framework/Core/src/AODReaderHelpers.cxx b/Framework/Core/src/AODReaderHelpers.cxx index a317209e7ee30..70727052e247e 100644 --- a/Framework/Core/src/AODReaderHelpers.cxx +++ b/Framework/Core/src/AODReaderHelpers.cxx @@ -86,7 +86,6 @@ static inline auto extractOriginalsTuple(framework::pack, ProcessingConte AlgorithmSpec AODReaderHelpers::indexBuilderCallback(std::vector requested) { return AlgorithmSpec::InitCallback{[requested](InitContext& ic) { - return [requested](ProcessingContext& pc) { auto outputs = pc.outputs(); // spawn tables @@ -135,6 +134,8 @@ AlgorithmSpec AODReaderHelpers::indexBuilderCallback(std::vector requ outputs.adopt(Output{origin, description}, maker(o2::aod::Run3MatchedToBCSparseMetadata{})); } else if (description == header::DataDescription{"MA_RN3_BC_EX"}) { outputs.adopt(Output{origin, description}, maker(o2::aod::Run3MatchedToBCExclusiveMetadata{})); + } else if (description == header::DataDescription{"MA_RN2_BC_SP"}) { + outputs.adopt(Output{origin, description}, maker(o2::aod::Run2MatchedToBCSparseMetadata{})); } else { throw std::runtime_error("Not an index table"); } @@ -146,7 +147,6 @@ AlgorithmSpec AODReaderHelpers::indexBuilderCallback(std::vector requ AlgorithmSpec AODReaderHelpers::aodSpawnerCallback(std::vector requested) { return AlgorithmSpec::InitCallback{[requested](InitContext& ic) { - return [requested](ProcessingContext& pc) { auto outputs = pc.outputs(); // spawn tables