Skip to content

Commit 31493dc

Browse files
yelmardbYoussef El Mard Bouziani
andauthored
[PWGEM] Add optional PCM material-budget weights in PCMPCM (#15139)
Co-authored-by: Youssef El Mard Bouziani <youssef.el.mard.bouziani@cern.ch>
1 parent a42bf91 commit 31493dc

File tree

8 files changed

+184
-9
lines changed

8 files changed

+184
-9
lines changed
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_CORE_MATERIALBUDGETWEIGHTS_H_
20+
#define PWGEM_PHOTONMESON_CORE_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_CORE_MATERIALBUDGETWEIGHTS_H_

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h

Lines changed: 11 additions & 2 deletions
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;
@@ -910,7 +910,16 @@ struct Pi0EtaToGammaGamma {
910910
continue;
911911
}
912912

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

915924
if (std::find(used_photonIds_per_col.begin(), used_photonIds_per_col.end(), g1.globalIndex()) == used_photonIds_per_col.end()) {
916925
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
@@ -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;
@@ -702,6 +702,15 @@ struct Pi0EtaToGammaGammaMC {
702702
continue;
703703
}
704704

705+
float wpair = weight;
706+
707+
if constexpr (requires { g1.omegaMBWeight(); }) {
708+
wpair *= g1.omegaMBWeight();
709+
}
710+
if constexpr (requires { g2.omegaMBWeight(); }) {
711+
wpair *= g2.omegaMBWeight();
712+
}
713+
705714
if (pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kEMCEMC) {
706715
float openingAngle = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P()));
707716
if (openingAngle < emccuts.minOpenAngle) {
@@ -711,9 +720,9 @@ struct Pi0EtaToGammaGammaMC {
711720

712721
if (g1mc.globalIndex() == g2mc.globalIndex()) {
713722
if (o2::aod::pwgem::dilepton::utils::mcutil::getMotherPDGCode(g1mc, mcparticles) == 111)
714-
fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), weight);
723+
fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), wpair);
715724
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);
725+
fRegistry.fill(HIST("Pair/Eta/hs_FromSameGamma"), v12.M(), v12.Pt(), wpair);
717726
continue;
718727
}
719728

@@ -722,13 +731,13 @@ struct Pi0EtaToGammaGammaMC {
722731
if (cfgRequireTrueAssociation && (pi0mc.emmceventId() != collision.emmceventId())) {
723732
continue;
724733
}
725-
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
734+
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, wpair);
726735
} else if (etaid > 0) {
727736
auto etamc = mcparticles.iteratorAt(etaid);
728737
if (cfgRequireTrueAssociation && (etamc.emmceventId() != collision.emmceventId())) {
729738
continue;
730739
}
731-
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
740+
o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, wpair);
732741
}
733742
} // end of pairing loop
734743
} else if constexpr (pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kPCMDalitzEE) {

PWGEM/PhotonMeson/DataModel/gammaTables.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,14 @@ 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

724732
#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+
#include "PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h"
19+
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \brief This code loops over photons and makes pairs for neutral mesons analyses in MC for PCM-PCM.
1414
/// \author D. Sekihata, daiki.sekihata@cern.ch
1515

16+
#include "PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h"
1617
#include "PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h"
1718
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
1819
#include "PWGEM/PhotonMeson/Utils/PairUtilities.h"
@@ -26,7 +27,7 @@ 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
using MyMCV0Legs = soa::Join<aod::V0Legs, aod::V0LegMCLabels>;
3132

3233
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaPCMPCM.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \brief This code loops over photons and makes pairs for neutral mesons analyses for PCM-PCM.
1414
/// \author D. Sekihata, daiki.sekihata@cern.ch
1515

16+
#include "PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h"
1617
#include "PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h"
1718
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
1819
#include "PWGEM/PhotonMeson/Utils/PairUtilities.h"
@@ -26,7 +27,7 @@ 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
{

0 commit comments

Comments
 (0)