Skip to content

Commit 48a19f9

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 07baa23 commit 48a19f9

File tree

6 files changed

+154
-7
lines changed

6 files changed

+154
-7
lines changed

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ struct Pi0EtaToGammaGamma {
226226
//---------------------------------------------------------------------------
227227
// Preslices and partitions
228228
o2::framework::SliceCache cache;
229-
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived>>> perCollision_pcm = o2::aod::v0photonkf::emphotoneventId;
230-
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::EmEmcClusters, o2::aod::EMCEMEventIds>> perCollision_emc = o2::aod::emccluster::emphotoneventId;
231-
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::PHOSClusters, o2::aod::PHOSEMEventIds>> perCollision_phos = o2::aod::phoscluster::emphotoneventId;
232-
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::EMPrimaryElectronsFromDalitz, o2::aod::EMPrimaryElectronDaEMEventIds, o2::aod::EMPrimaryElectronsPrefilterBitDerived>>> perCollision_electron = o2::aod::emprimaryelectronda::emphotoneventId;
233-
229+
o2::framework::PresliceOptional<
230+
o2::soa::Filtered<o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds, o2::aod::V0PhotonsKFPrefilterBitDerived, o2::aod::V0PhotonOmegaMBWeights>>> perCollision_pcm = o2::aod::v0photonkf::emeventId;
231+
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::EmEmcClusters, o2::aod::EMCEMEventIds>> perCollision_emc = o2::aod::emccluster::emeventId;
232+
o2::framework::PresliceOptional<o2::soa::Join<o2::aod::PHOSClusters, o2::aod::PHOSEMEventIds>> perCollision_phos = o2::aod::phoscluster::emeventId;
233+
o2::framework::PresliceOptional<o2::soa::Filtered<o2::soa::Join<o2::aod::EMPrimaryElectronsFromDalitz, o2::aod::EMPrimaryElectronEMEventIds, o2::aod::EMPrimaryElectronsPrefilterBitDerived>>> perCollision_electron = o2::aod::emprimaryelectron::emeventId;
234234
o2::framework::PresliceOptional<o2::aod::EmEmcMTracks> perEMCClusterMT = o2::aod::trackmatching::emEmcClusterId;
235235
o2::framework::PresliceOptional<o2::aod::EmEmcMSTracks> perEMCClusterMS = o2::aod::trackmatching::emEmcClusterId;
236236

@@ -879,7 +879,16 @@ struct Pi0EtaToGammaGamma {
879879
continue;
880880
}
881881

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

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

PWGEM/PhotonMeson/DataModel/gammaTables.h

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

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

733+
734+
725735
#endif // PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_

PWGEM/PhotonMeson/TableProducer/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ o2physics_add_dpl_workflow(non-lin-producer
7070
SOURCES nonLinProducer.cxx
7171
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore
7272
COMPONENT_NAME Analysis)
73+
o2physics_add_dpl_workflow(material-budget-weights
74+
SOURCES materialBudgetWeights.cxx
75+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::CCDB ROOT::Hist ROOT::Core
76+
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/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: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
#include <CCDB/BasicCCDBManager.h>
24+
25+
#include "Framework/ASoAHelpers.h"
26+
#include "Framework/AnalysisDataModel.h"
27+
#include "Framework/AnalysisTask.h"
28+
#include "Framework/Logger.h"
29+
#include <Framework/Configurable.h>
30+
#include <Framework/InitContext.h>
31+
32+
33+
using namespace o2;
34+
using namespace o2::soa;
35+
using namespace o2::framework;
36+
37+
using MyV0PhotonsMB = o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds>;
38+
using MyV0PhotonMB = MyV0PhotonsMB::iterator;
39+
40+
struct MaterialBudgetWeights {
41+
Produces<aod::V0PhotonOmegaMBWeights> omegaMBWeight;
42+
43+
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "CCDB url"};
44+
Configurable<std::string> mbWeightsPath{"mbWeightsPath", "Users/y/yelmard/MaterialBudget/OmegaMBWeights", "Path of the mb weights"};
45+
Configurable<bool> runWithMBWeights{"runWithMBWeights", false, "Run task using material-budget weights for PCM photons"};
46+
47+
o2::ccdb::CcdbApi ccdbApi;
48+
TH1F* hOmegaMBFromCCDB = nullptr;
49+
50+
void init(InitContext&)
51+
{
52+
if (!runWithMBWeights) {
53+
LOG(info) << "MaterialBudgetWeights: runWithMBWeights=false -> no CCDB query, will write weight=1";
54+
return;
55+
}
56+
57+
ccdbApi.init(ccdbUrl.value);
58+
std::map<std::string, std::string> metadata;
59+
LOG(info) << "MaterialBudgetWeights: loading Omega MB histogram from CCDB at path: " << mbWeightsPath.value;
60+
61+
hOmegaMBFromCCDB = ccdbApi.retrieveFromTFileAny<TH1F>(mbWeightsPath, metadata, -1);
62+
63+
if (!hOmegaMBFromCCDB) {
64+
LOG(fatal) << "MaterialBudgetWeights: runWithMBWeights=true but CCDB object is missing. Path=" << mbWeightsPath.value;
65+
}
66+
}
67+
68+
float computeMBWeight(float v0Rxy)
69+
{
70+
if (!hOmegaMBFromCCDB) {
71+
LOG(fatal) << "MaterialBudgetWeights: internal error: histogram nullptr while runWithMBWeights=true";
72+
}
73+
74+
int binMBWeight = hOmegaMBFromCCDB->FindBin(v0Rxy);
75+
if (binMBWeight < 1 || binMBWeight > hOmegaMBFromCCDB->GetNbinsX()) {
76+
LOG(debug) << "MaterialBudgetWeights: v0Rxy out of histogram range, returning 1";
77+
return 1.f;
78+
}
79+
80+
return hOmegaMBFromCCDB->GetBinContent(binMBWeight);
81+
}
82+
83+
void process(MyV0PhotonMB const& v0)
84+
{
85+
if (!runWithMBWeights) {
86+
omegaMBWeight(1.f);
87+
return;
88+
}
89+
90+
omegaMBWeight(computeMBWeight(v0.v0radius()));
91+
}
92+
};
93+
94+
95+
#endif // PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_

0 commit comments

Comments
 (0)