Skip to content

Commit 81cc8a7

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 322aa31 commit 81cc8a7

File tree

8 files changed

+188
-8
lines changed

8 files changed

+188
-8
lines changed

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ struct Pi0EtaToGammaGamma {
238238
//---------------------------------------------------------------------------
239239
// Preslices and partitions
240240
o2::framework::SliceCache cache;
241-
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>> perCollision_pcm = o2::aod::v0photonkf::pmeventId;
241+
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;
242242
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::EmEmcClusters, o2::aod::EMCEMEventIds>> perCollision_emc = o2::aod::emccluster::pmeventId;
243243
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::PHOSClusters, o2::aod::PHOSEMEventIds>> perCollision_phos = o2::aod::phoscluster::pmeventId;
244244
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::EMPrimaryElectronsFromDalitz, o2::aod::EMPrimaryElectronDaEMEventIds, o2::aod::EMPrimaryElectronsPrefilterBitDerived>>> perCollision_electron = o2::aod::emprimaryelectronda::pmeventId;
@@ -911,6 +911,16 @@ struct Pi0EtaToGammaGamma {
911911
}
912912

913913
fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), weight);
914+
float wpair = weight;
915+
916+
if constexpr (requires { g1.omegaMBWeight(); }) {
917+
wpair *= g1.omegaMBWeight();
918+
}
919+
if constexpr (requires { g2.omegaMBWeight(); }) {
920+
wpair *= g2.omegaMBWeight();
921+
}
922+
923+
fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), wpair);
914924

915925
if (std::find(used_photonIds_per_col.begin(), used_photonIds_per_col.end(), g1.globalIndex()) == used_photonIds_per_col.end()) {
916926
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: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ struct Pi0EtaToGammaGammaMC {
435435
}
436436

437437
o2::framework::SliceCache cache;
438-
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>> perCollision_pcm = o2::aod::v0photonkf::pmeventId;
438+
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;
439439
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::SkimEMCClusters, o2::aod::EMEMCClusterMCLabels, o2::aod::EMCEMEventIds>> perCollision_emc = o2::aod::emccluster::pmeventId;
440440
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::PHOSClusters, o2::aod::PHOSEMEventIds>> perCollision_phos = o2::aod::phoscluster::pmeventId;
441441
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;
@@ -700,6 +700,13 @@ struct Pi0EtaToGammaGammaMC {
700700
}
701701
if (alphaMeson > alphaCut) {
702702
continue;
703+
float wpair = weight;
704+
705+
if constexpr (requires { g1.omegaMBWeight(); }) {
706+
wpair *= g1.omegaMBWeight();
707+
}
708+
if constexpr (requires { g2.omegaMBWeight(); }) {
709+
wpair *= g2.omegaMBWeight();
703710
}
704711

705712
if (pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kEMCEMC) {
@@ -711,9 +718,9 @@ struct Pi0EtaToGammaGammaMC {
711718

712719
if (g1mc.globalIndex() == g2mc.globalIndex()) {
713720
if (o2::aod::pwgem::dilepton::utils::mcutil::getMotherPDGCode(g1mc, mcparticles) == 111)
714-
fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), weight);
721+
fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), wpair);
715722
else if (o2::aod::pwgem::dilepton::utils::mcutil::getMotherPDGCode(g1mc, mcparticles) == 221)
716-
fRegistry.fill(HIST("Pair/Eta/hs_FromSameGamma"), v12.M(), v12.Pt(), weight);
723+
fRegistry.fill(HIST("Pair/Eta/hs_FromSameGamma"), v12.M(), v12.Pt(), wpair);
717724
continue;
718725
}
719726

@@ -722,13 +729,13 @@ struct Pi0EtaToGammaGammaMC {
722729
if (cfgRequireTrueAssociation && (pi0mc.emmceventId() != collision.emmceventId())) {
723730
continue;
724731
}
725-
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
732+
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, wpair);
726733
} else if (etaid > 0) {
727734
auto etamc = mcparticles.iteratorAt(etaid);
728735
if (cfgRequireTrueAssociation && (etamc.emmceventId() != collision.emmceventId())) {
729736
continue;
730737
}
731-
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
738+
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, wpair);
732739
}
733740
} // end of pairing loop
734741
} 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)