Skip to content

Commit a09fa00

Browse files
committed
[PWGEM/Dilepton] add a task for SCT
1 parent 3b01a89 commit a09fa00

8 files changed

Lines changed: 117 additions & 30 deletions

File tree

PWGEM/Dilepton/Core/Dilepton.h

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ using MyElectron = MyElectrons::iterator;
9494
using FilteredMyElectrons = o2::soa::Filtered<MyElectrons>;
9595
using FilteredMyElectron = FilteredMyElectrons::iterator;
9696

97+
using MyElectronsSCT = o2::soa::Join<o2::aod::EMPrimaryElectrons, o2::aod::EMPrimaryElectronEMEventIds, o2::aod::EMAmbiguousElectronSelfIds, o2::aod::EMPrimaryElectronsPrefilterBit, o2::aod::EMPrimaryElectronsPrefilterBitDerived, o2::aod::EMPrimaryElectronsBDTSCT>;
98+
using MyElectronSCT = MyElectronsSCT::iterator;
99+
using FilteredMyElectronsSCT = o2::soa::Filtered<MyElectronsSCT>;
100+
using FilteredMyElectronSCT = FilteredMyElectronsSCT::iterator;
101+
97102
using MyMuons = o2::soa::Join<o2::aod::EMPrimaryMuons, o2::aod::EMPrimaryMuonEMEventIds, o2::aod::EMAmbiguousMuonSelfIds, o2::aod::EMGlobalMuonSelfIds, o2::aod::EMPrimaryMuonsPrefilterBitDerived>;
98103
using MyMuon = MyMuons::iterator;
99104
using FilteredMyMuons = o2::soa::Filtered<MyMuons>;
@@ -102,7 +107,7 @@ using FilteredMyMuon = FilteredMyMuons::iterator;
102107
using MyEMH_electron = o2::aod::pwgem::dilepton::utils::EventMixingHandler<std::tuple<int, int, int, int>, std::pair<int, int>, o2::aod::pwgem::dilepton::utils::EMTrack>;
103108
using MyEMH_muon = o2::aod::pwgem::dilepton::utils::EventMixingHandler<std::tuple<int, int, int, int>, std::pair<int, int>, o2::aod::pwgem::dilepton::utils::EMFwdTrack>;
104109

105-
template <o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType pairtype, typename TEMH, typename... Types>
110+
template <o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType pairtype, bool withSCT, typename TEMH, typename... Types>
106111
struct Dilepton {
107112

108113
// Configurables
@@ -257,15 +262,20 @@ struct Dilepton {
257262
o2::framework::Configurable<bool> enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"};
258263

259264
// configuration for PID ML
260-
o2::framework::Configurable<std::vector<std::string>> onnxFileNames{"onnxFileNames", std::vector<std::string>{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"};
261-
o2::framework::Configurable<std::vector<std::string>> onnxPathsCCDB{"onnxPathsCCDB", std::vector<std::string>{"path"}, "Paths of models on CCDB"};
262-
o2::framework::Configurable<std::vector<double>> binsMl{"binsMl", std::vector<double>{0.1, 0.15, 0.2, 0.25, 0.4, 0.8, 1.6, 2.0, 20.f}, "Bin limits for ML application"};
263-
o2::framework::Configurable<std::vector<double>> cutsMl{"cutsMl", std::vector<double>{0.98, 0.98, 0.9, 0.9, 0.95, 0.95, 0.8, 0.8}, "ML cuts per bin"};
264-
o2::framework::Configurable<std::vector<std::string>> namesInputFeatures{"namesInputFeatures", std::vector<std::string>{"feature"}, "Names of ML model input features"};
265-
o2::framework::Configurable<std::string> nameBinningFeature{"nameBinningFeature", "pt", "Names of ML model binning feature"};
266-
o2::framework::Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"};
267-
o2::framework::Configurable<bool> loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"};
268-
o2::framework::Configurable<bool> enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"};
265+
// o2::framework::Configurable<std::vector<std::string>> onnxFileNames{"onnxFileNames", std::vector<std::string>{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"};
266+
// o2::framework::Configurable<std::vector<std::string>> onnxPathsCCDB{"onnxPathsCCDB", std::vector<std::string>{"path"}, "Paths of models on CCDB"};
267+
o2::framework::Configurable<std::vector<double>> binsMLPID{"binsMLPID", std::vector<double>{0.1, 0.15, 0.2, 0.25, 0.4, 0.8, 1.6, 2.0, 20.f}, "Bin limits for ML application"};
268+
o2::framework::Configurable<std::vector<double>> cutsMLPID{"cutsMLPID", std::vector<double>{0.97, 0.97, 0.97, 0.8, 0.95, 0.95, 0.8, 0.8}, "ML cuts per bin"};
269+
// o2::framework::Configurable<std::vector<std::string>> namesInputFeatures{"namesInputFeatures", std::vector<std::string>{"feature"}, "Names of ML model input features"};
270+
// o2::framework::Configurable<std::string> nameBinningFeature{"nameBinningFeature", "pt", "Names of ML model binning feature"};
271+
// o2::framework::Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"};
272+
// o2::framework::Configurable<bool> loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"};
273+
// o2::framework::Configurable<bool> enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"};
274+
275+
o2::framework::Configurable<std::vector<double>> binsMLSCT{"binsMLSCT", std::vector<double>{0.1, 0.4, 0.6, 0.8, 1, 2, 4, 20.f}, "Bin limits for ML application"};
276+
o2::framework::Configurable<std::vector<double>> cutsMLSCTeT_prompt_hc{"cutsMLSCTeT_prompt_hc", std::vector<double>{0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8}, "ML cuts per bin for prompt hc"};
277+
o2::framework::Configurable<std::vector<double>> cutsMLSCTeT_nonprompt_hc{"cutsMLSCTeT_nonprompt_hc", std::vector<double>{0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8}, "ML cuts per bin for nonprompt hc"};
278+
o2::framework::Configurable<std::vector<double>> cutsMLSCTeT_hb{"cutsMLSCTeT_hb", std::vector<double>{0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8}, "ML cuts per bin for hb"};
269279
} dielectroncuts;
270280

271281
DimuonCut fDimuonCut;
@@ -328,8 +338,8 @@ struct Dilepton {
328338
o2::aod::rctsel::RCTFlagsChecker rctChecker;
329339
// o2::ccdb::CcdbApi ccdbApi;
330340
o2::framework::Service<o2::ccdb::BasicCCDBManager> ccdb;
331-
int mRunNumber;
332-
float d_bz;
341+
int mRunNumber{0};
342+
float d_bz{0};
333343

334344
o2::framework::HistogramRegistry fRegistry{"output", {}, o2::framework::OutputObjHandlingPolicy::AnalysisObject, false, false};
335345
// static constexpr std::string_view event_cut_types[2] = {"before/", "after/"};
@@ -793,14 +803,14 @@ struct Dilepton {
793803

794804
if (dielectroncuts.cfg_pid_scheme == static_cast<int>(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut
795805
std::vector<float> binsML{};
796-
binsML.reserve(dielectroncuts.binsMl.value.size());
797-
for (size_t i = 0; i < dielectroncuts.binsMl.value.size(); i++) {
798-
binsML.emplace_back(dielectroncuts.binsMl.value[i]);
806+
binsML.reserve(dielectroncuts.binsMLPID.value.size());
807+
for (size_t i = 0; i < dielectroncuts.binsMLPID.value.size(); i++) {
808+
binsML.emplace_back(dielectroncuts.binsMLPID.value[i]);
799809
}
800810
std::vector<float> thresholdsML{};
801-
thresholdsML.reserve(dielectroncuts.cutsMl.value.size());
802-
for (size_t i = 0; i < dielectroncuts.cutsMl.value.size(); i++) {
803-
thresholdsML.emplace_back(dielectroncuts.cutsMl.value[i]);
811+
thresholdsML.reserve(dielectroncuts.cutsMLPID.value.size());
812+
for (size_t i = 0; i < dielectroncuts.cutsMLPID.value.size(); i++) {
813+
thresholdsML.emplace_back(dielectroncuts.cutsMLPID.value[i]);
804814
}
805815
fDielectronCut.SetMLThresholds(binsML, thresholdsML);
806816
} // end of PID ML
@@ -837,6 +847,26 @@ struct Dilepton {
837847
fDimuonCut.EnableTTCA(dimuoncuts.enableTTCA);
838848
}
839849

850+
template <typename TTrack>
851+
bool foundHFSV(TTrack const& track)
852+
{
853+
int ptbin = lower_bound(dielectroncuts.binsMLSCT.value.begin(), dielectroncuts.binsMLSCT.value.end(), track.pt()) - dielectroncuts.binsMLSCT.value.begin() - 1;
854+
if (ptbin < 0) {
855+
ptbin = 0;
856+
} else if (static_cast<int>(dielectroncuts.binsMLSCT.value.size()) - 2 < ptbin) {
857+
ptbin = static_cast<int>(dielectroncuts.binsMLSCT.value.size()) - 2;
858+
}
859+
860+
for (int i = 0; i < static_cast<int>(track.nSV()); i++) {
861+
auto probaSCT = track.probaSCT(i);
862+
// LOGF(info, "track.globalIndex() = %d, pt = %f, i = %d, probaSCT[0] = %f, probaSCT[1] = %f, probaSCT[2] = %f, probaSCT[3] = %f", track.globalIndex(), track.pt(), i, probaSCT[0], probaSCT[1], probaSCT[2], probaSCT[3]);
863+
if (probaSCT[1] > dielectroncuts.cutsMLSCTeT_prompt_hc.value[ptbin] || probaSCT[2] > dielectroncuts.cutsMLSCTeT_nonprompt_hc.value[ptbin] || probaSCT[3] > dielectroncuts.cutsMLSCTeT_hb.value[ptbin]) {
864+
return true;
865+
}
866+
}
867+
return false;
868+
}
869+
840870
template <typename TQvectors>
841871
bool isGoodQvector(TQvectors const& qvectors)
842872
{
@@ -889,6 +919,11 @@ struct Dilepton {
889919
return false;
890920
}
891921
}
922+
if constexpr (withSCT) {
923+
if (foundHFSV(t1) || foundHFSV(t2)) {
924+
return false;
925+
}
926+
}
892927
} else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
893928
if (!cut.template IsSelectedTrack<false>(t1) || !cut.template IsSelectedTrack<false>(t2)) {
894929
return false;
@@ -1244,7 +1279,8 @@ struct Dilepton {
12441279
using FilteredMyCollisions = o2::soa::Filtered<MyCollisions>;
12451280

12461281
o2::framework::SliceCache cache;
1247-
o2::framework::Preslice<MyElectrons> perCollision_electron = o2::aod::emprimaryelectron::emeventId;
1282+
// o2::framework::Preslice<MyElectrons> perCollision_electron = o2::aod::emprimaryelectron::emeventId;
1283+
o2::framework::Preslice<o2::aod::EMPrimaryElectronEMEventIds> perCollision_electron = o2::aod::emprimaryelectron::emeventId;
12481284
o2::framework::expressions::Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc;
12491285
o2::framework::expressions::Filter pidFilter_electron = dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl;
12501286
o2::framework::expressions::Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), true, o2::aod::emprimaryelectron::isAssociatedToMPC == true);
@@ -1266,10 +1302,15 @@ struct Dilepton {
12661302
ifnode((dielectroncuts.cfg_prefilter_bits.node() & static_cast<uint16_t>(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_140MeV))) > static_cast<uint16_t>(0), (o2::aod::emprimaryelectron::pfb & static_cast<uint8_t>(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_140MeV))) <= static_cast<uint8_t>(0), true),
12671303
o2::aod::emprimaryelectron::pfb >= static_cast<uint8_t>(0));
12681304

1269-
o2::framework::Partition<FilteredMyElectrons> positive_electrons = o2::aod::emprimaryelectron::sign > int8_t(0);
1270-
o2::framework::Partition<FilteredMyElectrons> negative_electrons = o2::aod::emprimaryelectron::sign < int8_t(0);
12711305

1272-
o2::framework::Preslice<MyMuons> perCollision_muon = o2::aod::emprimarymuon::emeventId;
1306+
// o2::framework::Partition<FilteredMyElectrons> positive_electrons = o2::aod::emprimaryelectron::sign > int8_t(0);
1307+
// o2::framework::Partition<FilteredMyElectrons> negative_electrons = o2::aod::emprimaryelectron::sign < int8_t(0);
1308+
using TElectronType = std::tuple_element_t<0, std::tuple<Types...>>;
1309+
o2::framework::Partition<TElectronType> positive_electrons = o2::aod::emprimaryelectron::sign > int8_t(0);
1310+
o2::framework::Partition<TElectronType> negative_electrons = o2::aod::emprimaryelectron::sign < int8_t(0);
1311+
1312+
// o2::framework::Preslice<MyMuons> perCollision_muon = o2::aod::emprimarymuon::emeventId;
1313+
o2::framework::Preslice<o2::aod::EMPrimaryMuonEMEventIds> perCollision_muon = o2::aod::emprimarymuon::emeventId;
12731314
o2::framework::expressions::Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_pt_track < o2::aod::fwdtrack::pt && o2::aod::fwdtrack::pt < dimuoncuts.cfg_max_pt_track && dimuoncuts.cfg_min_eta_track < o2::aod::fwdtrack::eta && o2::aod::fwdtrack::eta < dimuoncuts.cfg_max_eta_track;
12741315
o2::framework::expressions::Filter ttcaFilter_muon = ifnode(dimuoncuts.enableTTCA.node(), true, o2::aod::emprimarymuon::isAssociatedToMPC == true);
12751316
o2::framework::expressions::Filter prefilter_derived_muon = ifnode(dimuoncuts.cfg_apply_cuts_from_prefilter_derived.node() && dimuoncuts.cfg_prefilter_bits_derived.node() >= static_cast<uint16_t>(1),
@@ -1545,6 +1586,13 @@ struct Dilepton {
15451586
return false;
15461587
}
15471588
}
1589+
1590+
if constexpr (withSCT) {
1591+
if (foundHFSV(t1) || foundHFSV(t2)) {
1592+
return false;
1593+
}
1594+
}
1595+
15481596
} else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
15491597
if (!cut.IsSelectedTrack(t1) || !cut.IsSelectedTrack(t2)) {
15501598
return false;

PWGEM/Dilepton/DataModel/dileptonTables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,15 @@ DECLARE_SOA_COLUMN(BDTScoreNonpromptHcUINT8, bdtScoreNonpromptHcUINT8, std::vect
697697
DECLARE_SOA_COLUMN(BDTScoreHbUINT8, bdtScoreHbUINT8, std::vector<uint8_t>); //! scaling factor is 255.
698698
DECLARE_SOA_COLUMN(HadronType, hadronType, std::vector<uint8_t>); //! 0:track, 1:K0S, 2:Lambda, 3:AntiLambda, 4:XiMinus, 5:XiPlus, 6:OmegaMinus, 7:OmegaPlus
699699

700-
DECLARE_SOA_DYNAMIC_COLUMN(ProbaSCT, probaSCT, [](std::vector<uint8_t> p0, std::vector<uint8_t> p1, std::vector<uint8_t> p2, std::vector<uint8_t> p3, std::vector<uint8_t> type, int index) -> std::array<float, 5> {
700+
DECLARE_SOA_DYNAMIC_COLUMN(ProbaSCT, probaSCT, [](gsl::span<const uint8_t> p0, gsl::span<const uint8_t> p1, gsl::span<const uint8_t> p2, gsl::span<const uint8_t> p3, gsl::span<const uint8_t> type, const int index) -> std::array<float, 5> {
701701
return std::array<float, 5>{
702702
std::nextafter(p0[index] / 255.f, std::numeric_limits<float>::infinity()),
703703
std::nextafter(p1[index] / 255.f, std::numeric_limits<float>::infinity()),
704704
std::nextafter(p2[index] / 255.f, std::numeric_limits<float>::infinity()),
705705
std::nextafter(p3[index] / 255.f, std::numeric_limits<float>::infinity()),
706706
static_cast<float>(type[index])};
707707
});
708-
DECLARE_SOA_DYNAMIC_COLUMN(NSV, nSV, [](std::vector<uint8_t> type) -> size_t { return type.size(); });
708+
DECLARE_SOA_DYNAMIC_COLUMN(NSV, nSV, [](gsl::span<const uint8_t> type) -> size_t { return type.size(); });
709709

710710
DECLARE_SOA_COLUMN(ITSNSigmaEl, itsNSigmaEl, float); //!
711711
DECLARE_SOA_COLUMN(ITSNSigmaMu, itsNSigmaMu, float); //!

PWGEM/Dilepton/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ o2physics_add_dpl_workflow(dielectron-mc
9090
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore
9191
COMPONENT_NAME Analysis)
9292

93+
o2physics_add_dpl_workflow(dielectron-sct
94+
SOURCES dielectronSCT.cxx
95+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore O2Physics::EventFilteringUtils
96+
COMPONENT_NAME Analysis)
97+
9398
o2physics_add_dpl_workflow(dimuon
9499
SOURCES dimuon.cxx
95100
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore O2Physics::EventFilteringUtils

PWGEM/Dilepton/Tasks/dielectron.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ using namespace o2::framework;
2525
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
2626
{
2727
return WorkflowSpec{
28-
adaptAnalysisTask<Dilepton<o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron, MyEMH_electron, FilteredMyElectrons>>(cfgc, TaskName{"dielectron"})};
28+
adaptAnalysisTask<Dilepton<o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron, false, MyEMH_electron, FilteredMyElectrons>>(cfgc, TaskName{"dielectron"})};
2929
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
// ========================
13+
//
14+
// This code is for dielectron analyses.
15+
// Please write to: daiki.sekihata@cern.ch
16+
17+
#include "PWGEM/Dilepton/Core/Dilepton.h"
18+
#include "PWGEM/Dilepton/Utils/PairUtilities.h"
19+
20+
#include <Framework/AnalysisTask.h>
21+
#include <Framework/runDataProcessing.h>
22+
23+
using namespace o2::framework;
24+
25+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
26+
{
27+
return WorkflowSpec{
28+
adaptAnalysisTask<Dilepton<o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron, true, MyEMH_electron, FilteredMyElectronsSCT>>(cfgc, TaskName{"dielectron-sct"})};
29+
}

PWGEM/Dilepton/Tasks/dimuon.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ using namespace o2::framework;
2525
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
2626
{
2727
return WorkflowSpec{
28-
adaptAnalysisTask<Dilepton<o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon, MyEMH_muon, FilteredMyMuons>>(cfgc, TaskName{"dimuon"})};
28+
adaptAnalysisTask<Dilepton<o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon, false, MyEMH_muon, FilteredMyMuons>>(cfgc, TaskName{"dimuon"})};
2929
}

0 commit comments

Comments
 (0)