Skip to content

Commit f37b741

Browse files
committed
[PWGEM,Photon] Adding EMCal ML response plus initCCDB bugfix
- Add EMCal ML response which can be used to identify conversion cluster pairs - Fix a bug in the initCCDB function in multiple files where the member variable that stores the run number was not updated triggering the update of the CCDB for every collision including logging - Update `TruthClass` in `emcalPhotonMcTask.cxx` - Update `MCUtilities.h` the get Origin functions to use `TMCProcess` enums from ROOT - Add `GetMesonInChain` function which uses `FindMotherInChain` but instead of returning the ID of the daughter of the meson it returns the meson ID - Fix clang-tidy warnings and errors
1 parent 7e877ef commit f37b741

14 files changed

Lines changed: 711 additions & 187 deletions
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 EMCConversionCandidate.h
13+
/// \brief Header file that defines EMCConversionCandidate, a struct to be used with the EMCConversion ML model
14+
/// \author Marvin Hemmer <marvin.hemmer@cern.ch>
15+
16+
#ifndef PWGEM_PHOTONMESON_CORE_EMCCONVERSIONCANDIDATE_H_
17+
#define PWGEM_PHOTONMESON_CORE_EMCCONVERSIONCANDIDATE_H_
18+
19+
#include <concepts>
20+
21+
namespace o2::analysis::em
22+
{
23+
24+
// Requires T to expose the specific named getters getInputFeatures() needs,
25+
// each returning something convertible to float.
26+
template <typename T>
27+
concept IsEmcConversionCandidate = requires(T const& c) {
28+
{ c.minv() } -> std::convertible_to<float>;
29+
{ c.deltaEta() } -> std::convertible_to<float>;
30+
{ c.deltaR() } -> std::convertible_to<float>;
31+
{ c.phiv() } -> std::convertible_to<float>;
32+
{ c.rConv() } -> std::convertible_to<float>;
33+
{ c.totE() } -> std::convertible_to<float>;
34+
{ c.e2() } -> std::convertible_to<float>;
35+
{ c.e1() } -> std::convertible_to<float>;
36+
{ c.deltaPhi() } -> std::convertible_to<float>;
37+
};
38+
39+
struct EMCConversionCandidate {
40+
float mMinv;
41+
float mDeltaEta;
42+
float mDeltaR;
43+
float mPhiv;
44+
float mRConv;
45+
float mTotE;
46+
float mE2;
47+
float mE1;
48+
float mDeltaPhi;
49+
50+
[[nodiscard]] float minv() const { return mMinv; }
51+
[[nodiscard]] float deltaEta() const { return mDeltaEta; }
52+
[[nodiscard]] float deltaR() const { return mDeltaR; }
53+
[[nodiscard]] float phiv() const { return mPhiv; }
54+
[[nodiscard]] float rConv() const { return mRConv; }
55+
[[nodiscard]] float totE() const { return mTotE; }
56+
[[nodiscard]] float e2() const { return mE2; }
57+
[[nodiscard]] float e1() const { return mE1; }
58+
[[nodiscard]] float deltaPhi() const { return mDeltaPhi; }
59+
};
60+
61+
} // namespace o2::analysis::em
62+
63+
#endif // PWGEM_PHOTONMESON_CORE_EMCCONVERSIONCANDIDATE_H_

PWGEM/PhotonMeson/Core/EMCPhotonCut.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ class EMCPhotonCut
443443
/// \return true if cluster survives cut else false
444444
bool IsSelectedEMCalRunning(const EMCPhotonCuts& cut, o2::soa::is_iterator auto const& cluster, IsFullTrackIterator auto& matchedTrackIter, int64_t const nMatchedTracks, o2::framework::HistogramRegistry* fRegistry = nullptr) const
445445
{
446+
if (nMatchedTracks == 0) {
447+
// there are not tracks to match with, so its true
448+
return true;
449+
}
446450
switch (cut) {
447451
case EMCPhotonCuts::kTM:
448452
return checkTrackMatching(cluster, matchedTrackIter, nMatchedTracks, true, [this](float pt) { return GetTrackMatchingEta(pt); }, [this](float pt) { return GetTrackMatchingPhi(pt); }, fRegistry, TrackType::kPrimary);
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 EmMlResponseEMCConversion.h
13+
/// \brief Class to compute the ML response for EMC conversion selections
14+
/// \author Marvin Hemmer <marvin.hemmer@cern.ch>
15+
16+
#ifndef PWGEM_PHOTONMESON_CORE_EMMLRESPONSEEMCCONVERSION_H_
17+
#define PWGEM_PHOTONMESON_CORE_EMMLRESPONSEEMCCONVERSION_H_
18+
19+
#include "PWGEM/PhotonMeson/Core/EMCConversionCandidate.h"
20+
21+
#include "Tools/ML/MlResponse.h"
22+
23+
#include <cstdint>
24+
#include <vector>
25+
26+
// Fill the map of available input features
27+
// the key is the feature's name (std::string)
28+
// the value is the corresponding value in EnumInputFeatures
29+
#define FILL_MAP_EMC_CONV(FEATURE) \
30+
{ \
31+
#FEATURE, static_cast<uint8_t>(InputFeaturesEMCConversion::FEATURE)}
32+
33+
// Check if the index of mCachedIndices (index associated to a FEATURE)
34+
// matches the entry in EnumInputFeatures associated to this FEATURE
35+
// if so, the inputFeatures vector is filled with the FEATURE's value
36+
// by calling the corresponding GETTER from OBJECT
37+
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
38+
#define CHECK_AND_FILL_VEC_EMC_CONV(GETTER) \
39+
case static_cast<uint8_t>(InputFeaturesEMCConversion::GETTER): { \
40+
inputFeatures.emplace_back(candidate.GETTER()); \
41+
break; \
42+
}
43+
44+
namespace o2::analysis::em::emcconv
45+
{
46+
47+
// input feature used in the ml model
48+
enum class InputFeaturesEMCConversion : uint8_t {
49+
minv,
50+
deltaEta,
51+
deltaR,
52+
phiv,
53+
rConv,
54+
totE,
55+
e2,
56+
e1,
57+
deltaPhi
58+
};
59+
60+
template <typename TypeOutputScore = float>
61+
class EmMlResponseEMCConversion : public MlResponse<TypeOutputScore>
62+
{
63+
public:
64+
EmMlResponseEMCConversion() = default;
65+
virtual ~EmMlResponseEMCConversion() = default;
66+
67+
template <o2::analysis::em::IsEmcConversionCandidate TCandidate>
68+
std::vector<float> getInputFeatures(TCandidate const& candidate)
69+
{
70+
std::vector<float> inputFeatures;
71+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
72+
switch (idx) {
73+
CHECK_AND_FILL_VEC_EMC_CONV(minv)
74+
CHECK_AND_FILL_VEC_EMC_CONV(deltaEta)
75+
CHECK_AND_FILL_VEC_EMC_CONV(deltaR)
76+
CHECK_AND_FILL_VEC_EMC_CONV(phiv)
77+
CHECK_AND_FILL_VEC_EMC_CONV(rConv)
78+
CHECK_AND_FILL_VEC_EMC_CONV(totE)
79+
CHECK_AND_FILL_VEC_EMC_CONV(e2)
80+
CHECK_AND_FILL_VEC_EMC_CONV(e1)
81+
CHECK_AND_FILL_VEC_EMC_CONV(deltaPhi)
82+
}
83+
}
84+
return inputFeatures;
85+
}
86+
87+
protected:
88+
void setAvailableInputFeatures()
89+
{
90+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
91+
FILL_MAP_EMC_CONV(minv), FILL_MAP_EMC_CONV(deltaEta), FILL_MAP_EMC_CONV(deltaR),
92+
FILL_MAP_EMC_CONV(phiv), FILL_MAP_EMC_CONV(rConv), FILL_MAP_EMC_CONV(totE),
93+
FILL_MAP_EMC_CONV(e2), FILL_MAP_EMC_CONV(e1), FILL_MAP_EMC_CONV(deltaPhi)};
94+
}
95+
};
96+
97+
} // namespace o2::analysis::em::emcconv
98+
99+
#undef FILL_MAP_EMC_CONV
100+
#undef CHECK_AND_FILL_VEC_EMC_CONV
101+
102+
#endif // PWGEM_PHOTONMESON_CORE_EMMLRESPONSEEMCCONVERSION_H_

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,8 @@ struct Pi0EtaToGammaGamma {
458458
if (mRunNumber == collision.runNumber()) {
459459
return;
460460
}
461+
mRunNumber = collision.runNumber();
461462

462-
if (mRunNumber == collision.runNumber()) {
463-
return;
464-
}
465463
// In case override, don't proceed, please - no CCDB access required
466464
if (d_bz_input > -990) { // o2-linter: disable=magic-number (override value)
467465
d_bz = d_bz_input;
@@ -470,7 +468,6 @@ struct Pi0EtaToGammaGamma {
470468
grpmag.setL3Current(30000.f / (d_bz / 5.0f)); // o2-linter: disable=magic-number (override value)
471469
}
472470
o2::base::Propagator::initFieldFromGRP(&grpmag);
473-
mRunNumber = collision.runNumber();
474471
return;
475472
}
476473

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,8 @@ struct Pi0EtaToGammaGammaMC {
313313
if (mRunNumber == collision.runNumber()) {
314314
return;
315315
}
316+
mRunNumber = collision.runNumber();
316317

317-
if (mRunNumber == collision.runNumber()) {
318-
return;
319-
}
320318
// In case override, don't proceed, please - no CCDB access required
321319
if (d_bz_input > -990) { // o2-linter: disable=magic-number (override value)
322320
d_bz = d_bz_input;
@@ -325,7 +323,6 @@ struct Pi0EtaToGammaGammaMC {
325323
grpmag.setL3Current(30000.f / (d_bz / 5.0f)); // o2-linter: disable=magic-number (override value)
326324
}
327325
o2::base::Propagator::initFieldFromGRP(&grpmag);
328-
mRunNumber = collision.runNumber();
329326
return;
330327
}
331328

PWGEM/PhotonMeson/DataModel/gammaTables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,10 @@ DECLARE_SOA_INDEX_COLUMN(EmEmcCluster, emEmcCluster); //!
647647
} // namespace trackmatching
648648

649649
DECLARE_SOA_TABLE(EmEmcMTracks, "AOD", "EMEMCMTRACK", //!
650-
trackmatching::EmEmcClusterId, emctm::DeltaPhi, emctm::DeltaEta, emctm::TrackP, emctm::TrackPt);
650+
o2::soa::Index<>, trackmatching::EmEmcClusterId, emctm::DeltaPhi, emctm::DeltaEta, emctm::TrackP, emctm::TrackPt);
651651

652652
DECLARE_SOA_TABLE(EmEmcMSTracks, "AOD", "EMEMCMSTRACK", //!
653-
trackmatching::EmEmcClusterId, emctm::DeltaPhi, emctm::DeltaEta, emctm::TrackP, emctm::TrackPt);
653+
o2::soa::Index<>, trackmatching::EmEmcClusterId, emctm::DeltaPhi, emctm::DeltaEta, emctm::TrackP, emctm::TrackPt);
654654

655655
DECLARE_SOA_TABLE(EMCEMEventIds_000, "AOD", "EMCEMEVENTID", emccluster::EMEventId); // To be joined with SkimEMCClusters table at analysis level.
656656
DECLARE_SOA_TABLE_VERSIONED(EMCEMEventIds_001, "AOD", "EMCEMEVENTID", 1, emccluster::PMEventId); // To be joined with SkimEMCClusters table at analysis level.

PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ struct PhotonConversionBuilder {
468468
if (mRunNumber == bc.runNumber()) {
469469
return;
470470
}
471+
mRunNumber = bc.runNumber();
471472
// In case override, don't proceed, please - no CCDB access required
472473
if (d_bz_input > -990) { // o2-linter: disable=magic-number (override value)
473474
d_bz = d_bz_input;
@@ -476,7 +477,7 @@ struct PhotonConversionBuilder {
476477
grpmag.setL3Current(30000.f / (d_bz / 5.0f)); // o2-linter: disable=magic-number (override value)
477478
}
478479
o2::base::Propagator::initFieldFromGRP(&grpmag);
479-
mRunNumber = bc.runNumber();
480+
480481
return;
481482
}
482483

@@ -485,7 +486,6 @@ struct PhotonConversionBuilder {
485486
// Fetch magnetic field from ccdb for current collision
486487
d_bz = bc.grpMagField().getNominalL3Field();
487488
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG";
488-
mRunNumber = bc.runNumber();
489489

490490
if (useMatCorrType == 2) { // o2-linter: disable=magic-number (material budget correction)
491491
// setMatLUT only after magfield has been initalized (setMatLUT has implicit and problematic init field call if not)

PWGEM/PhotonMeson/Tasks/MaterialBudgetMC.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct MaterialBudgetMC {
131131
auto* list_pair_subsys_photoncut = dynamic_cast<THashList*>(list_pair_subsys->FindObject(photon_cut_name.data()));
132132

133133
for (const auto& cut3 : cuts3) {
134-
std::string pair_cut_name = cut3.getName();
134+
std::string const& pair_cut_name = cut3.getName();
135135
o2::aod::pwgem::photon::histogram::AddHistClass(list_pair_subsys_photoncut, pair_cut_name.data());
136136
auto* list_pair_subsys_paircut = dynamic_cast<THashList*>(list_pair_subsys_photoncut->FindObject(pair_cut_name.data()));
137137
o2::aod::pwgem::photon::histogram::DefineHistograms(list_pair_subsys_paircut, "material_budget_study", "Pair");

PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
#include "PWGEM/Dilepton/Utils/MCUtilities.h"
1919
#include "PWGEM/PhotonMeson/Core/CutsLibrary.h"
20-
#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h"
2120
#include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h"
22-
#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h"
2321
#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h"
2422
#include "PWGEM/PhotonMeson/DataModel/EventTables.h"
2523
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"

PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct TagAndProbe {
140140
THashList* list_pair_subsys_photoncut = o2::aod::pwgem::photon::histogram::AddHistClass(list_pair, photon_cut_name.data());
141141

142142
for (auto& cut3 : paircuts) {
143-
std::string pair_cut_name = cut3.getName();
143+
std::string const& pair_cut_name = cut3.getName();
144144
o2::aod::pwgem::photon::histogram::AddHistClass(list_pair_subsys_photoncut, pair_cut_name.data());
145145
auto* list_pair_subsys_paircut = dynamic_cast<THashList*>(list_pair_subsys_photoncut->FindObject(pair_cut_name.data()));
146146
o2::aod::pwgem::photon::histogram::DefineHistograms(list_pair_subsys_paircut, "tag_and_probe", pairname.data());

0 commit comments

Comments
 (0)