Skip to content

Commit 0edf272

Browse files
committed
Use metadata to get the correct number of orbits per TF for MC
1 parent 5e4b5b9 commit 0edf272

3 files changed

Lines changed: 42 additions & 14 deletions

File tree

PWGDQ/Core/VarManager.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,8 @@ void VarManager::SetDefaultVarNames()
756756
fgVariableUnits[kMultMCNParticlesEta05] = "Multiplicity_eta05";
757757
fgVariableUnits[kMultMCNParticlesEta08] = "Multiplicity_eta08";
758758
fgVariableUnits[kMultMCNParticlesEta10] = "Multiplicity_eta10";
759-
fgVariableNames[kMCIsNoTFBorder] = "MC Is not TF border";
760-
fgVariableUnits[kMCIsNoTFBorder] = "";
761759
fgVariableNames[kMCIsNoTFBorderRecomputed] = "MC Is not TF border";
762760
fgVariableUnits[kMCIsNoTFBorderRecomputed] = "";
763-
fgVariableNames[kMCIsNoITSROFBorder] = "MC Is not ITS ROF border";
764-
fgVariableUnits[kMCIsNoITSROFBorder] = "";
765761
fgVariableNames[kMCIsNoITSROFBorderRecomputed] = "MC Is not ITS ROF border";
766762
fgVariableUnits[kMCIsNoITSROFBorderRecomputed] = "";
767763
fgVariableNames[kTwoEvPosZ1] = "vtx-z_{1}";
@@ -1927,6 +1923,8 @@ void VarManager::SetDefaultVarNames()
19271923
fgVarNamesMap["kIsNoTFBorderRecomputed"] = kIsNoTFBorderRecomputed;
19281924
fgVarNamesMap["kIsNoITSROFBorder"] = kIsNoITSROFBorder;
19291925
fgVarNamesMap["kIsNoITSROFBorderRecomputed"] = kIsNoITSROFBorderRecomputed;
1926+
fgVarNamesMap["kMCIsNoTFBorderRecomputed"] = kMCIsNoTFBorderRecomputed;
1927+
fgVarNamesMap["kMCIsNoITSROFBorderRecomputed"] = kMCIsNoITSROFBorderRecomputed;
19301928
fgVarNamesMap["kIsNoSameBunch"] = kIsNoSameBunch;
19311929
fgVarNamesMap["kIsGoodZvtxFT0vsPV"] = kIsGoodZvtxFT0vsPV;
19321930
fgVarNamesMap["kIsVertexITSTPC"] = kIsVertexITSTPC;

PWGDQ/Core/VarManager.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ class VarManager : public TObject
15451545
static int fgITSROFBorderMarginLow; // ITS ROF border low margin
15461546
static int fgITSROFBorderMarginHigh; // ITS ROF border high margin
15471547
static int64_t fgBCSOR; // BC for start of run
1548-
static int64_t fgNBCsPerTF; // duration of TF in bcs, should be 128*3564 or 32*3564
1548+
static int64_t fgNBCsPerTF; // duration of TF in bcs, should be 128*3564 or 32*3564
15491549
static int fgTFBorderMarginLow; // TF border low margin
15501550
static int fgTFBorderMarginHigh; // TF border high margin
15511551
static uint64_t fgSOR; // Timestamp for start of run
@@ -2403,14 +2403,10 @@ void VarManager::FillEvent(T const& event, float* values)
24032403
values[kMultMCNParticlesEta05] = event.multMCNParticlesEta05();
24042404
values[kMultMCNParticlesEta08] = event.multMCNParticlesEta08();
24052405
values[kMultMCNParticlesEta10] = event.multMCNParticlesEta10();
2406-
if (fgUsedVars[kMCIsNoITSROFBorderRecomputed]) {
2407-
uint16_t bcInITSROF = (event.globalBC() + o2::constants::lhc::LHCMaxBunches - fgITSROFbias) % fgITSROFlength;
2408-
values[kMCIsNoITSROFBorderRecomputed] = bcInITSROF > fgITSROFBorderMarginLow && bcInITSROF < fgITSROFlength - fgITSROFBorderMarginHigh ? 1.0 : 0.0;
2409-
}
2410-
if (fgUsedVars[kMCIsNoTFBorderRecomputed]) {
2411-
int64_t bcInTF = (event.globalBC() - fgBCSOR) % fgNBCsPerTF;
2412-
values[kMCIsNoTFBorderRecomputed] = bcInTF > fgTFBorderMarginLow && bcInTF < fgNBCsPerTF - fgTFBorderMarginHigh ? 1.0 : 0.0;
2413-
}
2406+
uint16_t bcInITSROF = (event.globalBC() + o2::constants::lhc::LHCMaxBunches - fgITSROFbias) % fgITSROFlength;
2407+
values[kMCIsNoITSROFBorderRecomputed] = bcInITSROF > fgITSROFBorderMarginLow && bcInITSROF < fgITSROFlength - fgITSROFBorderMarginHigh ? 1.0 : 0.0;
2408+
int64_t bcInTF = (event.globalBC() - fgBCSOR) % fgNBCsPerTF;
2409+
values[kMCIsNoTFBorderRecomputed] = bcInTF > fgTFBorderMarginLow && bcInTF < fgNBCsPerTF - fgTFBorderMarginHigh ? 1.0 : 0.0;
24142410
}
24152411

24162412
if constexpr ((fillMap & EventFilter) > 0 || (fillMap & RapidityGapFilter) > 0) {

PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ using namespace o2::framework::expressions;
7979
using namespace o2::aod;
8080
using namespace o2::common::core;
8181

82+
o2::common::core::MetadataHelper metadataInfo;
83+
8284
// Some definitions
8385
namespace o2::aod
8486
{
@@ -400,7 +402,7 @@ struct AnalysisEventSelection {
400402

401403
int timeFrameStartBorderMargin = fConfigTFStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : fConfigTFStartBorderMargin;
402404
int timeFrameEndBorderMargin = fConfigTFEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : fConfigTFEndBorderMargin;
403-
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber());
405+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber(), metadataInfo.get("LPMProductionTag"));
404406
int64_t bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches;
405407
int64_t nBCsPerTF = fConfigNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches : fConfigNumberOfOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
406408
VarManager::SetTFBorderselection(bcSOR, nBCsPerTF, timeFrameStartBorderMargin, timeFrameEndBorderMargin);
@@ -3187,6 +3189,13 @@ struct AnalysisAsymmetricPairing {
31873189
std::vector<TString> fCommonCutNames;
31883190
std::vector<TString> fRecMCSignalNames;
31893191

3192+
// Parameters for TF and ITSROF border checks to be fetched from the event selection task
3193+
int fITSROFrameStartBorderMargin;
3194+
int fITSROFrameEndBorderMargin;
3195+
int fTFStartBorderMargin;
3196+
int fTFEndBorderMargin;
3197+
int fNumberOfOrbitsPerTF;
3198+
31903199
Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast<uint32_t>(0);
31913200

31923201
Preslice<soa::Join<aod::ReducedTracksAssoc, aod::BarrelTrackCuts>> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId;
@@ -3211,6 +3220,12 @@ struct AnalysisAsymmetricPairing {
32113220
fHistMan->SetUseDefaultVariableNames(kTRUE);
32123221
fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits);
32133222

3223+
getTaskOptionValue<int>(context, "analysis-event-selection", "cfgITSROFrameStartBorderMargin", fITSROFrameStartBorderMargin, false);
3224+
getTaskOptionValue<int>(context, "analysis-event-selection", "cfgITSROFrameEndBorderMargin", fITSROFrameEndBorderMargin, false);
3225+
getTaskOptionValue<int>(context, "analysis-event-selection", "cfgTFStartBorderMargin", fTFStartBorderMargin, false);
3226+
getTaskOptionValue<int>(context, "analysis-event-selection", "cfgTFEndBorderMargin", fTFEndBorderMargin, false);
3227+
getTaskOptionValue<int>(context, "analysis-event-selection", "cfgNumberOfOrbitsPerTF", fNumberOfOrbitsPerTF, false);
3228+
32143229
// Get the leg cut filter masks
32153230
fLegAFilterMask = fConfigLegAFilterMask.value;
32163231
fLegBFilterMask = fConfigLegBFilterMask.value;
@@ -3592,6 +3607,24 @@ struct AnalysisAsymmetricPairing {
35923607
template <bool TTwoProngFitter, int TPairType, uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvents, typename TTrackAssocs, typename TTracks>
35933608
void runAsymmetricPairing(TEvents const& events, Preslice<TTrackAssocs>& preslice, TTrackAssocs const& /*assocs*/, TTracks const& /*tracks*/, ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& /*mcTracks*/)
35943609
{
3610+
if (events.size() > 0 && events.begin().runNumber() != fCurrentRun) {
3611+
// Set the TF and ITSROF border configuration to the same values used in the event selection task
3612+
auto alppar = fCCDB->getForTimeStamp<o2::itsmft::DPLAlpideParam<0>>("ITS/Config/AlpideParam", events.begin().timestamp());
3613+
EventSelectionParams* par = fCCDB->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", events.begin().timestamp());
3614+
int itsROFrameStartBorderMargin = fITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fITSROFrameStartBorderMargin;
3615+
int itsROFrameEndBorderMargin = fITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fITSROFrameEndBorderMargin;
3616+
VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin);
3617+
3618+
int timeFrameStartBorderMargin = fTFStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : fTFStartBorderMargin;
3619+
int timeFrameEndBorderMargin = fTFEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : fTFEndBorderMargin;
3620+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), events.begin().runNumber(), metadataInfo.get("LPMProductionTag"));
3621+
int64_t bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches;
3622+
int64_t nBCsPerTF = fNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches : fNumberOfOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
3623+
VarManager::SetTFBorderselection(bcSOR, nBCsPerTF, timeFrameStartBorderMargin, timeFrameEndBorderMargin);
3624+
3625+
fCurrentRun = events.begin().runNumber();
3626+
}
3627+
35953628
fPairCount.clear();
35963629

35973630
if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber()
@@ -5153,6 +5186,7 @@ struct AnalysisDileptonTrack {
51535186

51545187
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
51555188
{
5189+
metadataInfo.initMetadata(cfgc);
51565190
return WorkflowSpec{
51575191
adaptAnalysisTask<AnalysisEventSelection>(cfgc),
51585192
adaptAnalysisTask<AnalysisTrackSelection>(cfgc),

0 commit comments

Comments
 (0)