Skip to content

Commit 5fd18ec

Browse files
author
Youssef El Mard Bouziani
committed
Add optional PCM material-budget weights in PCMPCM
Add a V0 photon material-budget weight table (Omega MB weights) and join it in the PCMPCM pi0/eta workflow. The weights are applied only when the joined column is available, using compile-time guarded access. Introduce a configurable switch (runWithMBWeights) in MaterialBudgetWeights: - false: no CCDB query, write weight=1 - true: require CCDB histogram and abort if missing
1 parent 30a9baf commit 5fd18ec

File tree

8 files changed

+190
-9
lines changed

8 files changed

+190
-9
lines changed

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct Pi0EtaToGammaGamma {
227227
//---------------------------------------------------------------------------
228228
// Preslices and partitions
229229
o2::framework::SliceCache cache;
230-
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>> perCollision_pcm = o2::aod::v0photonkf::pmeventId;
230+
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived, o2::aod::V0PhotonOmegaMBWeights>>> perCollision_pcm = o2::aod::v0photonkf::pmeventId;
231231
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::EmEmcClusters, o2::aod::EMCEMEventIds>> perCollision_emc = o2::aod::emccluster::pmeventId;
232232
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::PHOSClusters, o2::aod::PHOSEMEventIds>> perCollision_phos = o2::aod::phoscluster::pmeventId;
233233
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::EMPrimaryElectronsFromDalitz, o2::aod::EMPrimaryElectronDaEMEventIds, o2::aod::EMPrimaryElectronsPrefilterBitDerived>>> perCollision_electron = o2::aod::emprimaryelectronda::pmeventId;
@@ -880,7 +880,16 @@ struct Pi0EtaToGammaGamma {
880880
continue;
881881
}
882882

883-
fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), weight);
883+
float wpair = weight;
884+
885+
if constexpr (requires { g1.omegaMBWeight(); }) {
886+
wpair *= g1.omegaMBWeight();
887+
}
888+
if constexpr (requires { g2.omegaMBWeight(); }) {
889+
wpair *= g2.omegaMBWeight();
890+
}
891+
892+
fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), wpair);
884893

885894
if (std::find(used_photonIds_per_col.begin(), used_photonIds_per_col.end(), g1.globalIndex()) == used_photonIds_per_col.end()) {
886895
emh1->AddTrackToEventPool(key_df_collision, o2::aod::pwgem::dilepton::utils::EMTrack(g1.pt(), g1.eta(), g1.phi(), 0));

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ struct Pi0EtaToGammaGammaMC {
424424
}
425425

426426
o2::framework::SliceCache cache;
427-
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>> perCollision_pcm = o2::aod::v0photonkf::pmeventId;
427+
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived, o2::aod::V0PhotonOmegaMBWeights>>> perCollision_pcm = o2::aod::v0photonkf::pmeventId;
428428
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::SkimEMCClusters, o2::aod::EMEMCClusterMCLabels, o2::aod::EMCEMEventIds>> perCollision_emc = o2::aod::emccluster::pmeventId;
429429
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::PHOSClusters, o2::aod::PHOSEMEventIds>> perCollision_phos = o2::aod::phoscluster::pmeventId;
430430
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::EMPrimaryElectronsFromDalitz, o2::aod::EMPrimaryElectronDaEMEventIds, o2::aod::EMPrimaryElectronsPrefilterBitDerived, o2::aod::EMPrimaryElectronMCLabels>>> perCollision_electron = o2::aod::emprimaryelectronda::pmeventId;
@@ -672,6 +672,15 @@ struct Pi0EtaToGammaGammaMC {
672672
continue;
673673
}
674674

675+
float wpair = weight;
676+
677+
if constexpr (requires { g1.omegaMBWeight(); }) {
678+
wpair *= g1.omegaMBWeight();
679+
}
680+
if constexpr (requires { g2.omegaMBWeight(); }) {
681+
wpair *= g2.omegaMBWeight();
682+
}
683+
675684
if (pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kEMCEMC) {
676685
float openingAngle = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P()));
677686
if (openingAngle < emccuts.minOpenAngle) {
@@ -681,9 +690,9 @@ struct Pi0EtaToGammaGammaMC {
681690

682691
if (g1mc.globalIndex() == g2mc.globalIndex()) {
683692
if (o2::aod::pwgem::dilepton::utils::mcutil::getMotherPDGCode(g1mc, mcparticles) == 111)
684-
fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), weight);
693+
fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), wpair);
685694
else if (o2::aod::pwgem::dilepton::utils::mcutil::getMotherPDGCode(g1mc, mcparticles) == 221)
686-
fRegistry.fill(HIST("Pair/Eta/hs_FromSameGamma"), v12.M(), v12.Pt(), weight);
695+
fRegistry.fill(HIST("Pair/Eta/hs_FromSameGamma"), v12.M(), v12.Pt(), wpair);
687696
continue;
688697
}
689698

@@ -692,13 +701,13 @@ struct Pi0EtaToGammaGammaMC {
692701
if (cfgRequireTrueAssociation && (pi0mc.emmceventId() != collision.emmceventId())) {
693702
continue;
694703
}
695-
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
704+
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, wpair);
696705
} else if (etaid > 0) {
697706
auto etamc = mcparticles.iteratorAt(etaid);
698707
if (cfgRequireTrueAssociation && (etamc.emmceventId() != collision.emmceventId())) {
699708
continue;
700709
}
701-
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
710+
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, wpair);
702711
}
703712
} // end of pairing loop
704713
} else if constexpr (pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kPCMDalitzEE) {

PWGEM/PhotonMeson/DataModel/gammaTables.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,16 @@ DECLARE_SOA_TABLE(NonLinV0s, "AOD", "NONLINV0", //! table of non lin corrected v
719719
DECLARE_SOA_TABLE(NonLinEmcClusters, "AOD", "NONLINEMCCLUSTER", //! table of non lin corrected values for EMCal Photons (so far only E and pT)
720720
nonlin::CorrE, nonlin::CorrPt); //!
721721

722+
namespace v0photonMBweights
723+
{
724+
DECLARE_SOA_COLUMN(OmegaMBWeight, omegaMBWeight, float);
725+
}
726+
727+
DECLARE_SOA_TABLE(V0PhotonOmegaMBWeights, "AOD", "V0PHOTONMBW", v0photonMBweights::OmegaMBWeight); // store MB weights. To be joined with V0PhotonsKF table at analysis level.
728+
729+
using V0PhotonOmegaMBWeight = V0PhotonOmegaMBWeights::iterator;
722730
} // namespace o2::aod
723731

732+
733+
724734
#endif // PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_

PWGEM/PhotonMeson/TableProducer/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ o2physics_add_dpl_workflow(pm-qvector-dummy-otf
7575
SOURCES pmQvectorDummyOtf.cxx
7676
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore
7777
COMPONENT_NAME Analysis)
78+
79+
o2physics_add_dpl_workflow(material-budget-weights
80+
SOURCES materialBudgetWeights.cxx
81+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::CCDB ROOT::Hist ROOT::Core
82+
COMPONENT_NAME Analysis)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 MaterialBudgetWeights.h
13+
///
14+
/// \brief This code produces a table to retrieve material budget weights. The table is to be join with V0PhotonKF
15+
///
16+
/// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch)
17+
18+
19+
#include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h"
20+
#include "Framework/runDataProcessing.h"
21+
22+
using namespace o2::framework;
23+
24+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
25+
{
26+
return WorkflowSpec{adaptAnalysisTask<MaterialBudgetWeights>(cfgc)};
27+
}

PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCPCMPCM.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h"
1717
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
1818
#include "PWGEM/PhotonMeson/Utils/PairUtilities.h"
19+
#include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h"
20+
1921

2022
#include <Framework/ASoA.h>
2123
#include <Framework/AnalysisTask.h>
@@ -26,12 +28,14 @@ using namespace o2::aod;
2628
using namespace o2::framework;
2729
using namespace o2::aod::pwgem::photonmeson::photonpair;
2830

29-
using MyV0Photons = o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>;
31+
using MyV0Photons = o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonOmegaMBWeights>>;
3032
using MyMCV0Legs = soa::Join<aod::V0Legs, aod::V0LegMCLabels>;
3133

3234
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
3335
{
3436
return WorkflowSpec{
37+
adaptAnalysisTask<MaterialBudgetWeights>(cfgc),
3538
adaptAnalysisTask<Pi0EtaToGammaGammaMC<PairType::kPCMPCM, MyV0Photons, MyMCV0Legs>>(cfgc, TaskName{"pi0eta-to-gammagamma-mc-pcmpcm"}),
3639
};
3740
}
41+

PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h"
1717
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
1818
#include "PWGEM/PhotonMeson/Utils/PairUtilities.h"
19+
#include "PWGEM/PhotonMeson/Utils/MaterialBudgetWeights.h"
1920

2021
#include <Framework/AnalysisDataModel.h>
2122
#include <Framework/AnalysisTask.h>
@@ -26,11 +27,12 @@ using namespace o2::aod;
2627
using namespace o2::framework;
2728
using namespace o2::aod::pwgem::photonmeson::photonpair;
2829

29-
using MyV0Photons = o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>;
30+
using MyV0Photons = o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived, o2::aod::V0PhotonOmegaMBWeights>>;
3031

3132
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
3233
{
3334
return WorkflowSpec{
35+
adaptAnalysisTask<MaterialBudgetWeights>(cfgc),
3436
adaptAnalysisTask<Pi0EtaToGammaGamma<PairType::kPCMPCM, MyV0Photons, aod::V0Legs>>(cfgc, TaskName{"pi0eta-to-gammagamma-pcmpcm"}),
3537
};
3638
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 materialBudgetWeights.cxx
13+
///
14+
/// \brief This code produces a table to retrieve material budget weights. The table is to be join with V0PhotonKF
15+
///
16+
/// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch)
17+
///
18+
19+
#ifndef PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_
20+
#define PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_
21+
22+
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
23+
24+
#include "Framework/ASoAHelpers.h"
25+
#include "Framework/AnalysisDataModel.h"
26+
#include "Framework/AnalysisTask.h"
27+
#include "Framework/Logger.h"
28+
#include <CCDB/BasicCCDBManager.h>
29+
#include <Framework/Configurable.h>
30+
#include <Framework/InitContext.h>
31+
32+
#include <map>
33+
#include <string>
34+
35+
using namespace o2;
36+
using namespace o2::soa;
37+
using namespace o2::framework;
38+
39+
using MyV0PhotonsMB = o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds>;
40+
using MyV0PhotonMB = MyV0PhotonsMB::iterator;
41+
42+
struct MaterialBudgetWeights {
43+
Produces<aod::V0PhotonOmegaMBWeights> omegaMBWeight;
44+
45+
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "CCDB url"};
46+
Configurable<std::string> mbWeightsPath{"mbWeightsPath", "Users/y/yelmard/MaterialBudget/OmegaMBWeights", "Path of the mb weights"};
47+
48+
o2::ccdb::CcdbApi ccdbApi;
49+
TH1F* hOmegaMBFromCCDB = nullptr;
50+
51+
void init(InitContext&)
52+
{
53+
// Load CCDB object only when the real process is enabled
54+
if (!doprocessMC) {
55+
LOG(info) << "MaterialBudgetWeights: dummy mode enabled -> no CCDB query, will write weight=1";
56+
return;
57+
}
58+
59+
ccdbApi.init(ccdbUrl.value);
60+
std::map<std::string, std::string> metadata;
61+
LOG(info) << "MaterialBudgetWeights: loading Omega MB histogram from CCDB at path: " << mbWeightsPath.value;
62+
63+
hOmegaMBFromCCDB = ccdbApi.retrieveFromTFileAny<TH1F>(mbWeightsPath, metadata, -1);
64+
65+
if (!hOmegaMBFromCCDB) {
66+
LOG(fatal) << "MaterialBudgetWeights: CCDB object is missing. Path=" << mbWeightsPath.value;
67+
}
68+
}
69+
70+
float computeMBWeight(float v0Rxy)
71+
{
72+
if (!hOmegaMBFromCCDB) {
73+
return 1.f;
74+
}
75+
76+
int binMBWeight = hOmegaMBFromCCDB->FindBin(v0Rxy);
77+
if (binMBWeight < 1 || binMBWeight > hOmegaMBFromCCDB->GetNbinsX()) {
78+
LOG(debug) << "MaterialBudgetWeights: v0Rxy out of histogram range, returning 1";
79+
return 1.f;
80+
}
81+
82+
return hOmegaMBFromCCDB->GetBinContent(binMBWeight);
83+
}
84+
85+
// real process (weights from CCDB)
86+
void processMC(MyV0PhotonMB const& v0)
87+
{
88+
static bool once = false;
89+
if (!once) {
90+
LOG(info) << "MaterialBudgetWeights: standard process running";
91+
once = true;
92+
}
93+
if (!hOmegaMBFromCCDB) { // histogram not loaded => behave like dummy
94+
omegaMBWeight(1.f);
95+
return;
96+
}
97+
omegaMBWeight(computeMBWeight(v0.v0radius()));
98+
}
99+
100+
// dummy process (always weight = 1)
101+
void processDummy(MyV0PhotonMB const&)
102+
{
103+
static bool once = false;
104+
if (!once) {
105+
LOG(info) << "MaterialBudgetWeights: processDummy running";
106+
once = true;
107+
}
108+
omegaMBWeight(1.f);
109+
}
110+
111+
PROCESS_SWITCH(MaterialBudgetWeights, processMC, "Fill MB weights from CCDB", false);
112+
PROCESS_SWITCH(MaterialBudgetWeights, processDummy, "Fill dummy MB weights (=1)", true);
113+
};
114+
115+
#endif // PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_

0 commit comments

Comments
 (0)