diff --git a/PWGJE/DataModel/Jet.h b/PWGJE/DataModel/Jet.h index 176aaa02920..f25777969b3 100644 --- a/PWGJE/DataModel/Jet.h +++ b/PWGJE/DataModel/Jet.h @@ -160,6 +160,21 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! absolute p DECLARE_JETMATCHING_TABLE(_jet_type_##MCDetectorLevel, _jet_type_##MCDetectorLevelEventWiseSubtracted, _shortname_ "DJET2DEWS") \ DECLARE_JETMATCHING_TABLE(_jet_type_##MCDetectorLevelEventWiseSubtracted, _jet_type_##MCDetectorLevel, _shortname_ "JETDEWS2D") \ DECLARE_JET_TABLES(JMcCollision, _jet_type_##MCParticleLevelEventWiseSubtracted, _subtracted_track_type_, _hfparticle_type_, _shortname_ "PJETEWS") + +#define STRINGIFY(x) #x + +// add duplicate tables for each predefined jet table so that the same jets can be run with multiple settings +#define DECLARE_JET_DUPLICATE_TABLES_LEVELS(_jet_type_, _subtracted_track_type_, _hfcand_type_, _hfparticle_type_, _shortname_, _duplicatenumber_) \ + DECLARE_JET_TABLES_LEVELS(_jet_type_##_duplicatenumber_, _subtracted_track_type_, _hfcand_type_, _hfparticle_type_, _shortname_ STRINGIFY(_duplicatenumber_)) \ + DECLARE_JETMATCHING_TABLE(_jet_type_, _jet_type_##_duplicatenumber_, _shortname_ "JET2" STRINGIFY(_duplicatenumber_)) \ + DECLARE_JETMATCHING_TABLE(_jet_type_##_duplicatenumber_, _jet_type_, _shortname_ "JET" STRINGIFY(_duplicatenumber_) "2") \ + DECLARE_JETMATCHING_TABLE(_jet_type_##MCDetectorLevel, _jet_type_##_duplicatenumber_##MCDetectorLevel, _shortname_ "JETD2" STRINGIFY(_duplicatenumber_)) \ + DECLARE_JETMATCHING_TABLE(_jet_type_##_duplicatenumber_##MCDetectorLevel, _jet_type_##MCDetectorLevel, _shortname_ "JET" STRINGIFY(_duplicatenumber_) "2D") \ + DECLARE_JETMATCHING_TABLE(_jet_type_##MCParticleLevel, _jet_type_##_duplicatenumber_##MCParticleLevel, _shortname_ "JETP2" STRINGIFY(_duplicatenumber_)) \ + DECLARE_JETMATCHING_TABLE(_jet_type_##_duplicatenumber_##MCParticleLevel, _jet_type_##MCParticleLevel, _shortname_ "JET" STRINGIFY(_duplicatenumber_) "2P") \ + DECLARE_JETMATCHING_TABLE(_jet_type_##EventWiseSubtracted, _jet_type_##_duplicatenumber_##EventWiseSubtracted, _shortname_ "JETEWS2" STRINGIFY(_duplicatenumber_)) \ + DECLARE_JETMATCHING_TABLE(_jet_type__duplicatenumber_##EventWiseSubtracted, _jet_type_##EventWiseSubtracted, _shortname_ "JET" STRINGIFY(_duplicatenumber_) "2EWS") + namespace o2::aod { DECLARE_JET_TABLES_LEVELS(Charged, JTrackSub, HfD0Bases, HfD0PBases, "C"); @@ -170,6 +185,9 @@ DECLARE_JET_TABLES_LEVELS(LcCharged, JTrackLcSub, Hf3PBases, Hf3PPBases, "Lc"); DECLARE_JET_TABLES_LEVELS(BplusCharged, JTrackBplusSub, HfCandBplus, HfD0PBases, "BPl"); DECLARE_JET_TABLES_LEVELS(V0Charged, JTrackSub, V0Cores, V0Cores, "V0"); +// duplicate jet tables (added as needed for analyses) +DECLARE_JET_DUPLICATE_TABLES_LEVELS(Charged, JTrackSub, HfD0Bases, HfD0PBases, "C", 1); + } // namespace o2::aod using JetCollisions = o2::aod::JCollisions; diff --git a/PWGJE/JetFinders/CMakeLists.txt b/PWGJE/JetFinders/CMakeLists.txt index cba1ff66662..da0224ac7d1 100644 --- a/PWGJE/JetFinders/CMakeLists.txt +++ b/PWGJE/JetFinders/CMakeLists.txt @@ -103,5 +103,20 @@ o2physics_add_dpl_workflow(jet-finder-v0-mcp-charged PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-finder-data-charged-1 + SOURCES Duplicates/jetfinderdatacharged1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-mcd-charged-1 + SOURCES Duplicates/jetfindermcdcharged1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-mcp-charged-1 + SOURCES Duplicates/jetfindermcpcharged1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + endif() diff --git a/PWGJE/JetFinders/Duplicates/jetfinderdatacharged1.cxx b/PWGJE/JetFinders/Duplicates/jetfinderdatacharged1.cxx new file mode 100644 index 00000000000..d102d57c675 --- /dev/null +++ b/PWGJE/JetFinders/Duplicates/jetfinderdatacharged1.cxx @@ -0,0 +1,29 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// jet finder data charged 1 task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetfinder.cxx" + +using JetFinderDataCharged1 = JetFinderTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJets", true}}}, TaskName{"jet-finder-data-charged-1"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/Duplicates/jetfindermcdcharged1.cxx b/PWGJE/JetFinders/Duplicates/jetfindermcdcharged1.cxx new file mode 100644 index 00000000000..36f9412aad2 --- /dev/null +++ b/PWGJE/JetFinders/Duplicates/jetfindermcdcharged1.cxx @@ -0,0 +1,29 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// jet finder mcd charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetfinder.cxx" + +using JetFinderMCDetectorLevelCharged1 = JetFinderTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJets", true}}}, TaskName{"jet-finder-mcd-charged-1"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/Duplicates/jetfindermcpcharged1.cxx b/PWGJE/JetFinders/Duplicates/jetfindermcpcharged1.cxx new file mode 100644 index 00000000000..ff1d2a10e2b --- /dev/null +++ b/PWGJE/JetFinders/Duplicates/jetfindermcpcharged1.cxx @@ -0,0 +1,29 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// jet finder mcp charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetfinder.cxx" + +using JetFinderMCParticleLevelCharged1 = JetFinderTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processParticleLevelChargedJets", true}}}, TaskName{"jet-finder-mcp-charged-1"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/CMakeLists.txt b/PWGJE/TableProducer/CMakeLists.txt index 378ea7b1a01..b4a576fade7 100644 --- a/PWGJE/TableProducer/CMakeLists.txt +++ b/PWGJE/TableProducer/CMakeLists.txt @@ -57,6 +57,11 @@ o2physics_add_dpl_workflow(jet-matching-mc-sub PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-duplicates + SOURCES jetmatchingduplicates.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-eventweight-mcd SOURCES jeteventweightmcd.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore diff --git a/PWGJE/TableProducer/jetmatchingduplicates.cxx b/PWGJE/TableProducer/jetmatchingduplicates.cxx new file mode 100644 index 00000000000..f7f48d0694c --- /dev/null +++ b/PWGJE/TableProducer/jetmatchingduplicates.cxx @@ -0,0 +1,125 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file jetmatching.cxx +/// \brief matching duplicate jets +/// \author Nima Zardoshti + +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "Framework/runDataProcessing.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +template +struct JetMatchingDuplicates { + + Configurable doMatchingGeo{"doMatchingGeo", true, "Enable geometric matching"}; + Configurable doMatchingPt{"doMatchingPt", true, "Enable pt matching"}; + Configurable doMatchingHf{"doMatchingHf", false, "Enable HF matching"}; + Configurable maxMatchingDistance{"maxMatchingDistance", 0.24f, "Max matching distance"}; + Configurable minPtFraction{"minPtFraction", 0.5f, "Minimum pt fraction for pt matching"}; + + Produces jetsBasetoTagMatchingTable; + Produces jetsTagtoBaseMatchingTable; + + // preslicing jet collections, only for Mc-based collection + static constexpr bool jetsBaseIsMc = o2::soa::relatedByIndex(); + static constexpr bool jetsTagIsMc = o2::soa::relatedByIndex(); + + Preslice baseJetsPerCollision = jetsBaseIsMc ? aod::jet::mcCollisionId : aod::jet::collisionId; + Preslice tagJetsPerCollision = jetsTagIsMc ? aod::jet::mcCollisionId : aod::jet::collisionId; + + void init(InitContext const&) + { + } + + void processDummy(JetCollisions const&) + { + } + PROCESS_SWITCH(JetMatchingDuplicates, processDummy, "Dummy process", true); + + void processJets(JetCollisions const& collisions, + JetsBase const& jetsBase, JetsTag const& jetsTag, + Tracks const& tracks, Candidates const& candidates) + { + + // initialise objects used to store the matching index arrays (array in case a mcCollision is split) before filling the matching tables + std::vector> jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF; + std::vector> jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF; + // waiting for framework fix to make sliced collection of same type as original collection: + jetsBasetoTagMatchingGeo.assign(jetsBase.size(), {}); + jetsBasetoTagMatchingPt.assign(jetsBase.size(), {}); + jetsBasetoTagMatchingHF.assign(jetsBase.size(), {}); + jetsTagtoBaseMatchingGeo.assign(jetsTag.size(), {}); + jetsTagtoBaseMatchingPt.assign(jetsTag.size(), {}); + jetsTagtoBaseMatchingHF.assign(jetsTag.size(), {}); + + for (const auto& collision : collisions) { + + const auto jetsBasePerColl = jetsBase.sliceBy(baseJetsPerCollision, collision.globalIndex()); + const auto jetsTagPerColl = jetsTag.sliceBy(tagJetsPerCollision, collision.globalIndex()); + // initialise template parameters as false since even if they are Mc we are not matching between detector and particle level + jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, candidates, tracks, tracks, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + } + + for (auto i = 0; i < jetsBase.size(); ++i) { + jetsBasetoTagMatchingTable(jetsBasetoTagMatchingGeo[i], jetsBasetoTagMatchingPt[i], jetsBasetoTagMatchingHF[i]); // is (and needs to) be filled in order + } + for (auto i = 0; i < jetsTag.size(); i++) { + jetsTagtoBaseMatchingTable(jetsTagtoBaseMatchingGeo[i], jetsTagtoBaseMatchingPt[i], jetsTagtoBaseMatchingHF[i]); // is (and needs to) be filled in order + } + } + PROCESS_SWITCH(JetMatchingDuplicates, processJets, "Perform jet matching", false); +}; + +using Charged1JetDataMatching = JetMatchingDuplicates, + soa::Join, + aod::ChargedJetsMatchedToCharged1Jets, + aod::Charged1JetsMatchedToChargedJets, + aod::JTracks, + aod::JDummys>; + +using Charged1JetMCDMatching = JetMatchingDuplicates, + soa::Join, + aod::ChargedMCDetectorLevelJetsMatchedToCharged1MCDetectorLevelJets, + aod::Charged1MCDetectorLevelJetsMatchedToChargedMCDetectorLevelJets, + aod::JTracks, + aod::JDummys>; + +using Charged1JetMCPMatching = JetMatchingDuplicates, + soa::Join, + aod::ChargedMCParticleLevelJetsMatchedToCharged1MCParticleLevelJets, + aod::Charged1MCParticleLevelJetsMatchedToChargedMCParticleLevelJets, + aod::JMcParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-matching-data-ch-1"})); + tasks.emplace_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-matching-mcd-ch-1"})); + tasks.emplace_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-matching-mcp-ch-1"})); + + return WorkflowSpec{tasks}; +}