From 2e138350da86f3f2c5c6f18d365e481afda7cf06 Mon Sep 17 00:00:00 2001 From: sigurd Date: Tue, 5 May 2026 15:56:16 +0200 Subject: [PATCH 1/7] Add globalBc to reducedMcEvents and use it in MC TF and ROF border calculations --- PWGDQ/Core/VarManager.cxx | 8 +++++++ PWGDQ/Core/VarManager.h | 10 ++++++++ PWGDQ/DataModel/ReducedInfoTables.h | 9 +++++++- PWGDQ/TableProducer/tableMakerMC.cxx | 6 +++-- .../TableProducer/tableMakerMC_withAssoc.cxx | 3 ++- PWGDQ/Tasks/dqEfficiency_withAssoc.cxx | 23 +++++++++++++++++++ 6 files changed, 55 insertions(+), 4 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 1d5bd30e476..2d6bbf189a6 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -744,6 +744,14 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMultMCNParticlesEta05] = "Multiplicity_eta05"; fgVariableUnits[kMultMCNParticlesEta08] = "Multiplicity_eta08"; fgVariableUnits[kMultMCNParticlesEta10] = "Multiplicity_eta10"; + fgVariableNames[kMCIsNoTFBorder] = "MC Is not TF border"; + fgVariableUnits[kMCIsNoTFBorder] = ""; + fgVariableNames[kMCIsNoTFBorderRecomputed] = "MC Is not TF border"; + fgVariableUnits[kMCIsNoTFBorderRecomputed] = ""; + fgVariableNames[kMCIsNoITSROFBorder] = "MC Is not ITS ROF border"; + fgVariableUnits[kMCIsNoITSROFBorder] = ""; + fgVariableNames[kMCIsNoITSROFBorderRecomputed] = "MC Is not ITS ROF border"; + fgVariableUnits[kMCIsNoITSROFBorderRecomputed] = ""; fgVariableNames[kTwoEvPosZ1] = "vtx-z_{1}"; fgVariableUnits[kTwoEvPosZ1] = "cm"; fgVariableNames[kTwoEvPosZ2] = "vtx-z_{2}"; diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 9287ef77749..f4d72e2b2c7 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -342,6 +342,8 @@ class VarManager : public TObject kMultMCNParticlesEta10, kMultMCNParticlesEta08, kMultMCNParticlesEta05, + kMCIsNoITSROFBorderRecomputed, + kMCIsNoTFBorderRecomputed, kQ1ZNAX, kQ1ZNAY, kQ1ZNCX, @@ -2384,6 +2386,14 @@ void VarManager::FillEvent(T const& event, float* values) values[kMultMCNParticlesEta05] = event.multMCNParticlesEta05(); values[kMultMCNParticlesEta08] = event.multMCNParticlesEta08(); values[kMultMCNParticlesEta10] = event.multMCNParticlesEta10(); + if (fgUsedVars[kMCIsNoITSROFBorderRecomputed]) { + uint16_t bcInITSROF = (event.globalBC() + o2::constants::lhc::LHCMaxBunches - fgITSROFbias) % fgITSROFlength; + values[kMCIsNoITSROFBorderRecomputed] = bcInITSROF > fgITSROFBorderMarginLow && bcInITSROF < fgITSROFlength - fgITSROFBorderMarginHigh ? 1.0 : 0.0; + } + if (fgUsedVars[kMCIsNoTFBorderRecomputed]) { + int64_t bcInTF = (event.globalBC() - fgBCSOR) % fgNBCsPerTF; + values[kMCIsNoTFBorderRecomputed] = bcInTF > fgTFBorderMarginLow && bcInTF < fgNBCsPerTF - fgTFBorderMarginHigh ? 1.0 : 0.0; + } } if constexpr ((fillMap & EventFilter) > 0 || (fillMap & RapidityGapFilter) > 0) { diff --git a/PWGDQ/DataModel/ReducedInfoTables.h b/PWGDQ/DataModel/ReducedInfoTables.h index 71a15a1ddbd..43b5d1ab01f 100644 --- a/PWGDQ/DataModel/ReducedInfoTables.h +++ b/PWGDQ/DataModel/ReducedInfoTables.h @@ -252,7 +252,14 @@ DECLARE_SOA_TABLE_VERSIONED(ReducedMCEvents_001, "AOD", "REDUCEDMCEVENT", 1, //! mccollision::T, mccollision::Weight, mccollision::ImpactParameter, cent::CentFT0C, mult::MultMCNParticlesEta05, mult::MultMCNParticlesEta08, mult::MultMCNParticlesEta10); -using ReducedMCEvents = ReducedMCEvents_001; +DECLARE_SOA_TABLE_VERSIONED(ReducedMCEvents_002, "AOD", "REDUCEDMCEVENT", 2, //! Event level MC truth information + o2::soa::Index<>, + bc::GlobalBC, + mccollision::GeneratorsID, reducedevent::MCPosX, reducedevent::MCPosY, reducedevent::MCPosZ, + mccollision::T, mccollision::Weight, mccollision::ImpactParameter, cent::CentFT0C, + mult::MultMCNParticlesEta05, mult::MultMCNParticlesEta08, mult::MultMCNParticlesEta10); + +using ReducedMCEvents = ReducedMCEvents_002; using ReducedEvent = ReducedEvents::iterator; using StoredReducedEvent = StoredReducedEvents::iterator; diff --git a/PWGDQ/TableProducer/tableMakerMC.cxx b/PWGDQ/TableProducer/tableMakerMC.cxx index 8a2d93f9f89..20745032933 100644 --- a/PWGDQ/TableProducer/tableMakerMC.cxx +++ b/PWGDQ/TableProducer/tableMakerMC.cxx @@ -474,7 +474,8 @@ struct TableMakerMC { eventInfo(collision.globalIndex()); // make an entry for this MC event only if it was not already added to the table if (!(fEventLabels.find(mcCollision.globalIndex()) != fEventLabels.end())) { - eventMC(mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), + auto mcBc = mcCollision.template bc_as(); + eventMC(mcBc.globalBC(), mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.t(), mcCollision.weight(), mcCollision.impactParameter(), 1, 1, 1, 1); fEventLabels[mcCollision.globalIndex()] = fCounters[1]; fCounters[1]++; @@ -1109,7 +1110,8 @@ struct TableMakerMC { eventInfo(collision.globalIndex()); // make an entry for this MC event only if it was not already added to the table if (!(fEventLabels.find(mcCollision.globalIndex()) != fEventLabels.end())) { - eventMC(mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), + auto mcBc = mcCollision.template bc_as(); + eventMC(mcBc.globalBC(), mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.t(), mcCollision.weight(), mcCollision.impactParameter(), 1, 1, 1, 1); fEventLabels[mcCollision.globalIndex()] = fCounters[1]; fCounters[1]++; diff --git a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx index ab35ad8b31f..d50bf08f81d 100644 --- a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx @@ -526,12 +526,13 @@ struct TableMakerMC { // Loop over MC collisions for (auto& mcCollision : mcCollisions) { + auto bc = mcCollision.template bc_as(); // Get MC collision information into the VarManager VarManager::FillEvent(mcCollision); // Fill histograms fHistMan->FillHistClass("Event_MCTruth", VarManager::fgValues); // Create the skimmed table entry for this collision - eventMC(mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), + eventMC(bc.globalBC(), mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.t(), mcCollision.weight(), mcCollision.impactParameter(), mcCollision.bestCollisionCentFT0C(), mcCollision.multMCNParticlesEta05(), mcCollision.multMCNParticlesEta08(), mcCollision.multMCNParticlesEta10()); } diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index ebeb6b0399a..6838d99fcd1 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -297,6 +299,12 @@ struct AnalysisEventSelection { Configurable fConfigAddEventMCHistogram{"cfgAddEventMCHistogram", "generator", "Comma separated list of histograms"}; Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Add event histograms defined via JSON formatting (see HistogramsLibrary)"}; + Configurable fConfigITSROFrameStartBorderMargin{"cfgITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; + Configurable fConfigITSROFrameEndBorderMargin{"cfgITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; + Configurable fConfigTFStartBorderMargin{"cfgTFStartBorderMargin", -1, "Number of bcs at the start of TF border. Take from CCDB if -1"}; + Configurable fConfigTFEndBorderMargin{"cfgTFEndBorderMargin", -1, "Number of bcs at the end of TF border. Take from CCDB if -1"}; + Configurable fConfigNumberOfOrbitsPerTF{"cfgNumberOfOrbitsPerTF", -1, "Number of orbits per Time Frame. Take from CCDB if -1"}; + Configurable fConfigSplitCollisionsDeltaZ{"splitCollisionsDeltaZ", 1.0, "maximum delta-z (cm) between two collisions to consider them as split candidates"}; Configurable fConfigSplitCollisionsDeltaBC{"splitCollisionsDeltaBC", 100, "maximum delta-BC between two collisions to consider them as split candidates; do not apply if value is negative"}; Configurable fConfigCheckSplitCollisions{"checkSplitCollisions", false, "If true, run the split collision check and fill histograms"}; @@ -383,6 +391,21 @@ struct AnalysisEventSelection { uint64_t sor = std::atol(fHeader["SOR"].c_str()); uint64_t eor = std::atol(fHeader["EOR"].c_str()); VarManager::SetSORandEOR(sor, eor); + + auto alppar = fCCDB->getForTimeStamp>("ITS/Config/AlpideParam", events.begin().timestamp()); + EventSelectionParams* par = fCCDB->getForTimeStamp("EventSelection/EventSelectionParams", events.begin().timestamp()); + int itsROFrameStartBorderMargin = fConfigITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fConfigITSROFrameStartBorderMargin; + int itsROFrameEndBorderMargin = fConfigITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fConfigITSROFrameEndBorderMargin; + VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); + + int timeFrameStartBorderMargin = fConfigTFStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : fConfigTFStartBorderMargin; + int timeFrameEndBorderMargin = fConfigTFEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : fConfigTFEndBorderMargin; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber()); + int64_t bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; + int64_t nBCsPerTF = fConfigNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches : fConfigNumberOfOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; + VarManager::SetTFBorderselection(bcSOR, nBCsPerTF, timeFrameStartBorderMargin, timeFrameEndBorderMargin); + + fCurrentRun = events.begin().runNumber(); } fSelMap.clear(); From e702ca63a1cc604e3d0c844f97221257516d64e7 Mon Sep 17 00:00:00 2001 From: sigurd Date: Thu, 30 Apr 2026 11:51:50 +0200 Subject: [PATCH 2/7] Add calculation of TF border check in VarManager --- PWGDQ/Core/VarManager.cxx | 13 +++++++++++++ PWGDQ/Core/VarManager.h | 21 +++++++++++++++++++-- PWGDQ/Tasks/tableReader_withAssoc.cxx | 12 ++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 2d6bbf189a6..898c709fd85 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -60,6 +60,10 @@ int VarManager::fgITSROFbias = 0; int VarManager::fgITSROFlength = 100; int VarManager::fgITSROFBorderMarginLow = 0; int VarManager::fgITSROFBorderMarginHigh = 0; +int64_t VarManager::fgBCSOR = -1; +int64_t VarManager::fgNBCsPerTF = -1; +int VarManager::fgTFBorderMarginLow = 300; +int VarManager::fgTFBorderMarginHigh = 4000; uint64_t VarManager::fgSOR = 0; uint64_t VarManager::fgEOR = 0; ROOT::Math::PxPyPzEVector VarManager::fgBeamA(0, 0, 6799.99, 6800); // GeV, beam from A-side 4-momentum vector @@ -718,6 +722,14 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMultDimuonsME] = ""; fgVariableNames[kCentFT0C] = "Centrality FT0C"; fgVariableUnits[kCentFT0C] = "%"; + fgVariableNames[kIsNoTFBorder] = "Is not TF border"; + fgVariableUnits[kIsNoTFBorder] = ""; + fgVariableNames[kIsNoTFBorderRecomputed] = "Is not TF border"; + fgVariableUnits[kIsNoTFBorderRecomputed] = ""; + fgVariableNames[kIsNoITSROFBorder] = "Is not ITS ROF border"; + fgVariableUnits[kIsNoITSROFBorder] = ""; + fgVariableNames[kIsNoITSROFBorderRecomputed] = "Is not ITS ROF border"; + fgVariableUnits[kIsNoITSROFBorderRecomputed] = ""; fgVariableNames[kMCEventGeneratorId] = "MC Generator ID"; fgVariableNames[kMCEventSubGeneratorId] = "MC SubGenerator ID"; fgVariableNames[kMCVtxX] = "MC Vtx X"; @@ -1912,6 +1924,7 @@ void VarManager::SetDefaultVarNames() fgVarNamesMap["kIsPhysicsSelection"] = kIsPhysicsSelection; fgVarNamesMap["kIsTVXTriggered"] = kIsTVXTriggered; fgVarNamesMap["kIsNoTFBorder"] = kIsNoTFBorder; + fgVarNamesMap["kIsNoTFBorderRecomputed"] = kIsNoTFBorderRecomputed; fgVarNamesMap["kIsNoITSROFBorder"] = kIsNoITSROFBorder; fgVarNamesMap["kIsNoITSROFBorderRecomputed"] = kIsNoITSROFBorderRecomputed; fgVarNamesMap["kIsNoSameBunch"] = kIsNoSameBunch; diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index f4d72e2b2c7..5d63e55fa02 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -218,7 +218,8 @@ class VarManager : public TObject kCollisionRandom, // random number generated per collision (if required, can be used to perform random selections at the collision level) kIsPhysicsSelection, kIsTVXTriggered, // Is trigger TVX - kIsNoTFBorder, // No time frame border + kIsNoTFBorder, // No time frame border (from event selection) + kIsNoTFBorderRecomputed, // No time frame border, computed here kIsNoITSROFBorder, // No ITS read out frame border (from event selection) kIsNoITSROFBorderRecomputed, // No ITS read out frame border, computed here kIsNoSameBunch, // No collisions with same T0 BC @@ -1506,6 +1507,14 @@ class VarManager : public TObject fgITSROFBorderMarginHigh = marginHigh; } + static void SetTFBorderselection(int64_t bcSOR, int64_t nBCsPerTF, int marginLow, int marginHigh) + { + fgBCSOR = bcSOR; + fgNBCsPerTF = nBCsPerTF; + fgTFBorderMarginLow = marginLow; + fgTFBorderMarginHigh = marginHigh; + } + static void SetSORandEOR(uint64_t sor, uint64_t eor) { fgSOR = sor; @@ -1535,6 +1544,10 @@ class VarManager : public TObject static int fgITSROFlength; // ITS ROF length (from ALPIDE parameters) static int fgITSROFBorderMarginLow; // ITS ROF border low margin static int fgITSROFBorderMarginHigh; // ITS ROF border high margin + static int64_t fgBCSOR; // BC for start of run + static int64_t fgNBCsPerTF; // duration of TF in bcs, should be 128*3564 or 32*3564 + static int fgTFBorderMarginLow; // TF border low margin + static int fgTFBorderMarginHigh; // TF border high margin static uint64_t fgSOR; // Timestamp for start of run static uint64_t fgEOR; // Timestamp for end of run static ROOT::Math::PxPyPzEVector fgBeamA; // beam from A-side 4-momentum vector @@ -2118,7 +2131,7 @@ void VarManager::FillEvent(T const& event, float* values) values[kCentVZERO] = event.centRun2V0M(); values[kCentFT0C] = event.centFT0C(); if (fgUsedVars[kIsNoITSROFBorderRecomputed]) { - uint16_t bcInITSROF = (event.globalBC() + 3564 - fgITSROFbias) % fgITSROFlength; + uint16_t bcInITSROF = (event.globalBC() + o2::constants::lhc::LHCMaxBunches - fgITSROFbias) % fgITSROFlength; values[kIsNoITSROFBorderRecomputed] = bcInITSROF > fgITSROFBorderMarginLow && bcInITSROF < fgITSROFlength - fgITSROFBorderMarginHigh ? 1.0 : 0.0; } if (fgUsedVars[kIsNoITSROFBorder]) { @@ -2127,6 +2140,10 @@ void VarManager::FillEvent(T const& event, float* values) if (fgUsedVars[kIsTVXTriggered]) { values[kIsTVXTriggered] = (event.selection_bit(o2::aod::evsel::kIsTriggerTVX) > 0); } + if (fgUsedVars[kIsNoTFBorderRecomputed]) { + int64_t bcInTF = (event.globalBC() - fgBCSOR) % fgNBCsPerTF; + values[kIsNoTFBorderRecomputed] = bcInTF > fgTFBorderMarginLow && bcInTF < fgNBCsPerTF - fgTFBorderMarginHigh ? 1.0 : 0.0; + } if (fgUsedVars[kIsNoTFBorder]) { values[kIsNoTFBorder] = (event.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) > 0); } diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index 40450cdb4a8..20100231d36 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -314,6 +315,9 @@ struct AnalysisEventSelection { Configurable fConfigITSROFrameStartBorderMargin{"cfgITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; Configurable fConfigITSROFrameEndBorderMargin{"cfgITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; + Configurable fConfigTFStartBorderMargin{"cfgTFStartBorderMargin", -1, "Number of bcs at the start of TF border. Take from CCDB if -1"}; + Configurable fConfigTFEndBorderMargin{"cfgTFEndBorderMargin", -1, "Number of bcs at the end of TF border. Take from CCDB if -1"}; + Configurable fConfigNumberOfOrbitsPerTF{"cfgNumberOfOrbitsPerTF", -1, "Number of orbits per Time Frame. Take from CCDB if -1"}; Configurable fConfigSplitCollisionsDeltaZ{"cfgSplitCollisionsDeltaZ", 1.0, "maximum delta-z (cm) between two collisions to consider them as split candidates"}; Configurable fConfigSplitCollisionsDeltaBC{"cfgSplitCollisionsDeltaBC", 100, "maximum delta-BC between two collisions to consider them as split candidates; do not apply if value is negative"}; @@ -424,6 +428,14 @@ struct AnalysisEventSelection { int itsROFrameStartBorderMargin = fConfigITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fConfigITSROFrameStartBorderMargin; int itsROFrameEndBorderMargin = fConfigITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fConfigITSROFrameEndBorderMargin; VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); + + int timeFrameStartBorderMargin = fConfigTFStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : fConfigTFStartBorderMargin; + int timeFrameEndBorderMargin = fConfigTFEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : fConfigTFEndBorderMargin; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber()); + int64_t bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; + int64_t nBCsPerTF = fConfigNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches : fConfigNumberOfOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; + VarManager::SetTFBorderselection(bcSOR, nBCsPerTF, timeFrameStartBorderMargin, timeFrameEndBorderMargin); + fCurrentRun = events.begin().runNumber(); } From 5e4b5b9f5d389b491071ae49c18d4f53869e2f33 Mon Sep 17 00:00:00 2001 From: sigurd Date: Wed, 6 May 2026 14:39:50 +0200 Subject: [PATCH 3/7] Add a converter for version 002 of reduced MC events --- PWGDQ/Tasks/CMakeLists.txt | 5 ++ .../ModelConverterReducedMCEventsV002.cxx | 70 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx diff --git a/PWGDQ/Tasks/CMakeLists.txt b/PWGDQ/Tasks/CMakeLists.txt index 4bb0cf6d714..97821bf2f72 100644 --- a/PWGDQ/Tasks/CMakeLists.txt +++ b/PWGDQ/Tasks/CMakeLists.txt @@ -144,6 +144,11 @@ o2physics_add_dpl_workflow(model-converter-mc-reduced-event PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(model-converter-mc-reduced-event-002 + SOURCES ModelConverterReducedMCEventsV002.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(tag-and-probe SOURCES TagAndProbe.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGDQCore diff --git a/PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx b/PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx new file mode 100644 index 00000000000..a139e1c8c7a --- /dev/null +++ b/PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx @@ -0,0 +1,70 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no +// +// Task used to convert the data model from the old format to the new format. To avoid +// the conflict with the old data model. + +#include "PWGDQ/DataModel/ReducedInfoTables.h" + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod; + +struct reducedMCeventConverter002 { + Produces reducedMCevent_002; + + void init(InitContext const&) + { + if (doprocessV000ToV002 == false && doprocessV001ToV002 == false) { + LOGF(fatal, "Neither processV000ToV002 nor processV001ToV002 is enabled. Please choose one!"); + } + if (doprocessV000ToV002 == true && doprocessV001ToV002 == true) { + LOGF(fatal, "Both processV000ToV002 and processV001ToV002 are enabled. Please choose only one!"); + } + } + + void processV000ToV002(aod::ReducedMCEvents_000 const& events) + { + for (const auto& event : events) { + uint64_t globalBc = 0; + reducedMCevent_002(globalBc, event.generatorsID(), event.mcPosX(), event.mcPosY(), event.mcPosZ(), + event.t(), event.weight(), event.impactParameter(), + -1.0f, -1.0f, -1.0f, -1.0f); + } + } + PROCESS_SWITCH(reducedMCeventConverter002, processV000ToV002, "process v000-to-v002 conversion", false); + + void processV001ToV002(aod::ReducedMCEvents_001 const& events) + { + for (const auto& event : events) { + uint64_t globalBc = 0; + reducedMCevent_002(globalBc, event.generatorsID(), event.mcPosX(), event.mcPosY(), event.mcPosZ(), + event.t(), event.weight(), event.impactParameter(), + event.centFT0C(), event.multMCNParticlesEta05(), event.multMCNParticlesEta08(), event.multMCNParticlesEta10()); + } + } + PROCESS_SWITCH(reducedMCeventConverter002, processV001ToV002, "process v001-to-v002 conversion", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} From 0edf2723e329e03f87536fc7e5d7e1c98aea24d7 Mon Sep 17 00:00:00 2001 From: sigurd Date: Tue, 26 May 2026 15:47:54 +0200 Subject: [PATCH 4/7] Use metadata to get the correct number of orbits per TF for MC --- PWGDQ/Core/VarManager.cxx | 6 ++--- PWGDQ/Core/VarManager.h | 14 ++++------ PWGDQ/Tasks/dqEfficiency_withAssoc.cxx | 36 +++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 898c709fd85..8937b51c379 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -756,12 +756,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMultMCNParticlesEta05] = "Multiplicity_eta05"; fgVariableUnits[kMultMCNParticlesEta08] = "Multiplicity_eta08"; fgVariableUnits[kMultMCNParticlesEta10] = "Multiplicity_eta10"; - fgVariableNames[kMCIsNoTFBorder] = "MC Is not TF border"; - fgVariableUnits[kMCIsNoTFBorder] = ""; fgVariableNames[kMCIsNoTFBorderRecomputed] = "MC Is not TF border"; fgVariableUnits[kMCIsNoTFBorderRecomputed] = ""; - fgVariableNames[kMCIsNoITSROFBorder] = "MC Is not ITS ROF border"; - fgVariableUnits[kMCIsNoITSROFBorder] = ""; fgVariableNames[kMCIsNoITSROFBorderRecomputed] = "MC Is not ITS ROF border"; fgVariableUnits[kMCIsNoITSROFBorderRecomputed] = ""; fgVariableNames[kTwoEvPosZ1] = "vtx-z_{1}"; @@ -1927,6 +1923,8 @@ void VarManager::SetDefaultVarNames() fgVarNamesMap["kIsNoTFBorderRecomputed"] = kIsNoTFBorderRecomputed; fgVarNamesMap["kIsNoITSROFBorder"] = kIsNoITSROFBorder; fgVarNamesMap["kIsNoITSROFBorderRecomputed"] = kIsNoITSROFBorderRecomputed; + fgVarNamesMap["kMCIsNoTFBorderRecomputed"] = kMCIsNoTFBorderRecomputed; + fgVarNamesMap["kMCIsNoITSROFBorderRecomputed"] = kMCIsNoITSROFBorderRecomputed; fgVarNamesMap["kIsNoSameBunch"] = kIsNoSameBunch; fgVarNamesMap["kIsGoodZvtxFT0vsPV"] = kIsGoodZvtxFT0vsPV; fgVarNamesMap["kIsVertexITSTPC"] = kIsVertexITSTPC; diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 5d63e55fa02..b0f3c957cbc 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -1545,7 +1545,7 @@ class VarManager : public TObject static int fgITSROFBorderMarginLow; // ITS ROF border low margin static int fgITSROFBorderMarginHigh; // ITS ROF border high margin static int64_t fgBCSOR; // BC for start of run - static int64_t fgNBCsPerTF; // duration of TF in bcs, should be 128*3564 or 32*3564 + static int64_t fgNBCsPerTF; // duration of TF in bcs, should be 128*3564 or 32*3564 static int fgTFBorderMarginLow; // TF border low margin static int fgTFBorderMarginHigh; // TF border high margin static uint64_t fgSOR; // Timestamp for start of run @@ -2403,14 +2403,10 @@ void VarManager::FillEvent(T const& event, float* values) values[kMultMCNParticlesEta05] = event.multMCNParticlesEta05(); values[kMultMCNParticlesEta08] = event.multMCNParticlesEta08(); values[kMultMCNParticlesEta10] = event.multMCNParticlesEta10(); - if (fgUsedVars[kMCIsNoITSROFBorderRecomputed]) { - uint16_t bcInITSROF = (event.globalBC() + o2::constants::lhc::LHCMaxBunches - fgITSROFbias) % fgITSROFlength; - values[kMCIsNoITSROFBorderRecomputed] = bcInITSROF > fgITSROFBorderMarginLow && bcInITSROF < fgITSROFlength - fgITSROFBorderMarginHigh ? 1.0 : 0.0; - } - if (fgUsedVars[kMCIsNoTFBorderRecomputed]) { - int64_t bcInTF = (event.globalBC() - fgBCSOR) % fgNBCsPerTF; - values[kMCIsNoTFBorderRecomputed] = bcInTF > fgTFBorderMarginLow && bcInTF < fgNBCsPerTF - fgTFBorderMarginHigh ? 1.0 : 0.0; - } + uint16_t bcInITSROF = (event.globalBC() + o2::constants::lhc::LHCMaxBunches - fgITSROFbias) % fgITSROFlength; + values[kMCIsNoITSROFBorderRecomputed] = bcInITSROF > fgITSROFBorderMarginLow && bcInITSROF < fgITSROFlength - fgITSROFBorderMarginHigh ? 1.0 : 0.0; + int64_t bcInTF = (event.globalBC() - fgBCSOR) % fgNBCsPerTF; + values[kMCIsNoTFBorderRecomputed] = bcInTF > fgTFBorderMarginLow && bcInTF < fgNBCsPerTF - fgTFBorderMarginHigh ? 1.0 : 0.0; } if constexpr ((fillMap & EventFilter) > 0 || (fillMap & RapidityGapFilter) > 0) { diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index 6838d99fcd1..f0e007216e3 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -79,6 +79,8 @@ using namespace o2::framework::expressions; using namespace o2::aod; using namespace o2::common::core; +o2::common::core::MetadataHelper metadataInfo; + // Some definitions namespace o2::aod { @@ -400,7 +402,7 @@ struct AnalysisEventSelection { int timeFrameStartBorderMargin = fConfigTFStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : fConfigTFStartBorderMargin; int timeFrameEndBorderMargin = fConfigTFEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : fConfigTFEndBorderMargin; - auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber()); + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber(), metadataInfo.get("LPMProductionTag")); int64_t bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; int64_t nBCsPerTF = fConfigNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches : fConfigNumberOfOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; VarManager::SetTFBorderselection(bcSOR, nBCsPerTF, timeFrameStartBorderMargin, timeFrameEndBorderMargin); @@ -3187,6 +3189,13 @@ struct AnalysisAsymmetricPairing { std::vector fCommonCutNames; std::vector fRecMCSignalNames; + // Parameters for TF and ITSROF border checks to be fetched from the event selection task + int fITSROFrameStartBorderMargin; + int fITSROFrameEndBorderMargin; + int fTFStartBorderMargin; + int fTFEndBorderMargin; + int fNumberOfOrbitsPerTF; + Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(0); Preslice> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; @@ -3211,6 +3220,12 @@ struct AnalysisAsymmetricPairing { fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); + getTaskOptionValue(context, "analysis-event-selection", "cfgITSROFrameStartBorderMargin", fITSROFrameStartBorderMargin, false); + getTaskOptionValue(context, "analysis-event-selection", "cfgITSROFrameEndBorderMargin", fITSROFrameEndBorderMargin, false); + getTaskOptionValue(context, "analysis-event-selection", "cfgTFStartBorderMargin", fTFStartBorderMargin, false); + getTaskOptionValue(context, "analysis-event-selection", "cfgTFEndBorderMargin", fTFEndBorderMargin, false); + getTaskOptionValue(context, "analysis-event-selection", "cfgNumberOfOrbitsPerTF", fNumberOfOrbitsPerTF, false); + // Get the leg cut filter masks fLegAFilterMask = fConfigLegAFilterMask.value; fLegBFilterMask = fConfigLegBFilterMask.value; @@ -3592,6 +3607,24 @@ struct AnalysisAsymmetricPairing { template void runAsymmetricPairing(TEvents const& events, Preslice& preslice, TTrackAssocs const& /*assocs*/, TTracks const& /*tracks*/, ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& /*mcTracks*/) { + if (events.size() > 0 && events.begin().runNumber() != fCurrentRun) { + // Set the TF and ITSROF border configuration to the same values used in the event selection task + auto alppar = fCCDB->getForTimeStamp>("ITS/Config/AlpideParam", events.begin().timestamp()); + EventSelectionParams* par = fCCDB->getForTimeStamp("EventSelection/EventSelectionParams", events.begin().timestamp()); + int itsROFrameStartBorderMargin = fITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fITSROFrameStartBorderMargin; + int itsROFrameEndBorderMargin = fITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fITSROFrameEndBorderMargin; + VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); + + int timeFrameStartBorderMargin = fTFStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : fTFStartBorderMargin; + int timeFrameEndBorderMargin = fTFEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : fTFEndBorderMargin; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber(), metadataInfo.get("LPMProductionTag")); + int64_t bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; + int64_t nBCsPerTF = fNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches : fNumberOfOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; + VarManager::SetTFBorderselection(bcSOR, nBCsPerTF, timeFrameStartBorderMargin, timeFrameEndBorderMargin); + + fCurrentRun = events.begin().runNumber(); + } + fPairCount.clear(); if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber() @@ -5153,6 +5186,7 @@ struct AnalysisDileptonTrack { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + metadataInfo.initMetadata(cfgc); return WorkflowSpec{ adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), From 50e01f66c87ce94ccef4f8e8b3e347bfb780d4cf Mon Sep 17 00:00:00 2001 From: sigurd Date: Tue, 26 May 2026 16:43:00 +0200 Subject: [PATCH 5/7] Fix template type --- PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx index d50bf08f81d..3c3b46f3c74 100644 --- a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx @@ -526,7 +526,7 @@ struct TableMakerMC { // Loop over MC collisions for (auto& mcCollision : mcCollisions) { - auto bc = mcCollision.template bc_as(); + auto bc = mcCollision.template bc_as(); // Get MC collision information into the VarManager VarManager::FillEvent(mcCollision); // Fill histograms From 84e1ee3026d00cebceabb272f46ebb79c42d9344 Mon Sep 17 00:00:00 2001 From: sigurd Date: Tue, 26 May 2026 17:07:43 +0200 Subject: [PATCH 6/7] clang --- ...ucedMCEventsV002.cxx => ModelConverterReducedMCEvents002.cxx} | 1 - 1 file changed, 1 deletion(-) rename PWGDQ/Tasks/{ModelConverterReducedMCEventsV002.cxx => ModelConverterReducedMCEvents002.cxx} (99%) diff --git a/PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx b/PWGDQ/Tasks/ModelConverterReducedMCEvents002.cxx similarity index 99% rename from PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx rename to PWGDQ/Tasks/ModelConverterReducedMCEvents002.cxx index a139e1c8c7a..cfb3b6348e1 100644 --- a/PWGDQ/Tasks/ModelConverterReducedMCEventsV002.cxx +++ b/PWGDQ/Tasks/ModelConverterReducedMCEvents002.cxx @@ -20,7 +20,6 @@ #include #include #include -#include using namespace o2; using namespace o2::framework; From 8d566f4a9bdcca4dd0b9338e86bdec6a9ecd01fc Mon Sep 17 00:00:00 2001 From: sigurd Date: Tue, 26 May 2026 17:23:39 +0200 Subject: [PATCH 7/7] Fix filename --- PWGDQ/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGDQ/Tasks/CMakeLists.txt b/PWGDQ/Tasks/CMakeLists.txt index 97821bf2f72..05704584010 100644 --- a/PWGDQ/Tasks/CMakeLists.txt +++ b/PWGDQ/Tasks/CMakeLists.txt @@ -145,7 +145,7 @@ o2physics_add_dpl_workflow(model-converter-mc-reduced-event COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(model-converter-mc-reduced-event-002 - SOURCES ModelConverterReducedMCEventsV002.cxx + SOURCES ModelConverterReducedMCEvents002.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis)