diff --git a/Common/TableProducer/CMakeLists.txt b/Common/TableProducer/CMakeLists.txt index b1805257bb9..17735237459 100644 --- a/Common/TableProducer/CMakeLists.txt +++ b/Common/TableProducer/CMakeLists.txt @@ -34,6 +34,12 @@ o2physics_add_dpl_workflow(event-selection-service O2::DataFormatsITSMFT COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(event-selection-service-run2 + SOURCES eventSelectionServiceRun2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCCDB + O2::DataFormatsITSMFT + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(multiplicity-table SOURCES multiplicityTable.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/Common/TableProducer/PID/CMakeLists.txt b/Common/TableProducer/PID/CMakeLists.txt index ab502d138b0..975898966fe 100644 --- a/Common/TableProducer/PID/CMakeLists.txt +++ b/Common/TableProducer/PID/CMakeLists.txt @@ -53,11 +53,6 @@ o2physics_add_dpl_workflow(pid-tpc-service-run2 PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(pid-tpc-service-run3 - SOURCES pidTPCServiceRun3.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(pid-tpc-base SOURCES pidTPCBase.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB diff --git a/Common/TableProducer/PID/pidTPCService.cxx b/Common/TableProducer/PID/pidTPCService.cxx index 02f8cfa255b..6ad86916c1f 100644 --- a/Common/TableProducer/PID/pidTPCService.cxx +++ b/Common/TableProducer/PID/pidTPCService.cxx @@ -67,33 +67,23 @@ struct pidTpcService { pidTPC.init(ccdb, ccdbApi, initContext, pidTPCopts, metadataInfo); } - void processTracks(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs) - { - pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); - } - void processTracksWithTracksQA(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::TracksQA const& tracksQA) - { - pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, tracksQA, products); - } - - void processTracksMC(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) + void processTracksIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs) { pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); } - void processTracksIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs) + void processTracksMCIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) { pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); } - void processTracksMCIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) + void processTracksIUWithTracksQA(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::TracksQAVersion const& tracksQA) { - pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); + pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, tracksQA, products); } - PROCESS_SWITCH(pidTpcService, processTracks, "Process Tracks", false); - PROCESS_SWITCH(pidTpcService, processTracksMC, "Process Tracks in MC (enables tune-on-data)", false); PROCESS_SWITCH(pidTpcService, processTracksIU, "Process TracksIU (Run 3)", true); + PROCESS_SWITCH(pidTpcService, processTracksIUWithTracksQA, "Process TracksIU (Run 3)", false); PROCESS_SWITCH(pidTpcService, processTracksMCIU, "Process TracksIUMC (Run 3)", false); }; diff --git a/Common/TableProducer/PID/pidTPCServiceRun2.cxx b/Common/TableProducer/PID/pidTPCServiceRun2.cxx index 4ab83e917a2..184fb4eb6e0 100644 --- a/Common/TableProducer/PID/pidTPCServiceRun2.cxx +++ b/Common/TableProducer/PID/pidTPCServiceRun2.cxx @@ -71,10 +71,6 @@ struct pidTpcServiceRun2 { { pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); } - void processTracksWithTracksQA(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::TracksQA const& tracksQA) - { - pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, tracksQA, products); - } void processTracksMC(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) { diff --git a/Common/TableProducer/PID/pidTPCServiceRun3.cxx b/Common/TableProducer/PID/pidTPCServiceRun3.cxx deleted file mode 100644 index 5902ed9c6c9..00000000000 --- a/Common/TableProducer/PID/pidTPCServiceRun3.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// 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 trackPropagationTester.cxx -/// \brief testing ground for track propagation -/// \author ALICE - -//=============================================================== -// -// Modularized version of TPC PID task -// -//=============================================================== - -#include "Common/Core/MetadataHelper.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Tools/PID/pidTPCModule.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -using namespace o2; -using namespace o2::framework; - -o2::common::core::MetadataHelper metadataInfo; // Metadata helper - -struct pidTpcServiceRun3 { - - // CCDB boilerplate declarations - o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Service ccdb; - o2::ccdb::CcdbApi ccdbApi; - - o2::aod::pid::pidTPCProducts products; - o2::aod::pid::pidTPCConfigurables pidTPCopts; - o2::aod::pid::pidTPCModule pidTPC; - - void init(o2::framework::InitContext& initContext) - { - // CCDB boilerplate init - ccdb->setURL(ccdburl.value); - ccdb->setFatalWhenNull(false); // manual fallback in case ccdb entry empty - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - ccdbApi.init(ccdburl.value); - - // task-specific - pidTPC.init(ccdb, ccdbApi, initContext, pidTPCopts, metadataInfo); - } - - void processTracksIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs) - { - pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); - } - - void processTracksMCIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) - { - pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); - } - - PROCESS_SWITCH(pidTpcServiceRun3, processTracksIU, "Process TracksIU (Run 3)", true); - PROCESS_SWITCH(pidTpcServiceRun3, processTracksMCIU, "Process TracksIUMC (Run 3)", false); -}; - -//**************************************************************************************** -/** - * Workflow definition. - */ -//**************************************************************************************** -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - // Parse the metadata for later too - metadataInfo.initMetadata(cfgc); - - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} diff --git a/Common/TableProducer/eventSelectionService.cxx b/Common/TableProducer/eventSelectionService.cxx index 834b1c28321..55068b32fe7 100644 --- a/Common/TableProducer/eventSelectionService.cxx +++ b/Common/TableProducer/eventSelectionService.cxx @@ -197,6 +197,11 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) if (isRun3) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } else { + LOGF(info, "******************************************************************"); + LOGF(info, " Event selection service self-configuring for Run 2."); + LOGF(info, " WARNING: THIS HAS NOT BEEN VALIDATED YET, USE WITH CAUTION"); + LOGF(info, " If this fails, please use event-selection-service-run2 instead."); + LOGF(info, "******************************************************************"); return WorkflowSpec{adaptAnalysisTask(cfgc)}; } } diff --git a/Common/TableProducer/eventSelectionServiceRun2.cxx b/Common/TableProducer/eventSelectionServiceRun2.cxx new file mode 100644 index 00000000000..554ec1ff480 --- /dev/null +++ b/Common/TableProducer/eventSelectionServiceRun2.cxx @@ -0,0 +1,186 @@ +// 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 eventSelectionTester.cxx +/// \brief unified, self-configuring event selection task +/// \author ALICE + +//=============================================================== +// +// Unified, self-configuring event selection task +// +//=============================================================== + +#include "Common/Core/MetadataHelper.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/Tools/EventSelectionModule.h" +#include "Common/Tools/timestampModule.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; + +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + +using BCsWithRun2InfosAndMatches = soa::Join; +using BCsWithRun3Matchings = soa::Join; +using FullTracks = soa::Join; +using FullTracksIU = soa::Join; + +struct eventselectionRun2 { + o2::common::timestamp::timestampConfigurables timestampConfigurables; + o2::common::timestamp::TimestampModule timestampMod; + + o2::common::eventselection::bcselConfigurables bcselOpts; + o2::common::eventselection::BcSelectionModule bcselmodule; + + o2::common::eventselection::evselConfigurables evselOpts; + o2::common::eventselection::EventSelectionModule evselmodule; + + Produces timestampTable; /// Table with SOR timestamps produced by the task + Produces bcsel; + Produces evsel; + + // for slicing + SliceCache cache; + + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // buffering intermediate results for passing + std::vector timestamps; + std::vector bcselsbuffer; + + // auxiliary + Partition tracklets = (aod::track::trackType == static_cast(o2::aod::track::TrackTypeEnum::Run2Tracklet)); + Preslice perCollision = aod::track::collisionId; + + void init(o2::framework::InitContext& context) + { + // CCDB boilerplate init + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); + + // task-specific + timestampMod.init(timestampConfigurables, metadataInfo); + bcselmodule.init(context, bcselOpts, histos, metadataInfo); + evselmodule.init(context, evselOpts, histos, metadataInfo); + } + + void process(BCsWithRun2InfosAndMatches const& bcs, + aod::Collisions const& collisions, + aod::Zdcs const&, + aod::FV0As const&, + aod::FV0Cs const&, + aod::FT0s const&, + aod::FDDs const&, + FullTracks const&) + { + timestampMod.process(bcs, ccdb, timestamps, timestampTable); + bcselmodule.processRun2(ccdb, bcs, timestamps, bcselsbuffer, bcsel); + evselmodule.processRun2(ccdb, histos, collisions, tracklets, cache, timestamps, bcselsbuffer, evsel); + } +}; + +struct eventselectionRun3 { + o2::common::timestamp::timestampConfigurables timestampConfigurables; + o2::common::timestamp::TimestampModule timestampMod; + + o2::common::eventselection::bcselConfigurables bcselOpts; + o2::common::eventselection::BcSelectionModule bcselmodule; + + o2::common::eventselection::evselConfigurables evselOpts; + o2::common::eventselection::EventSelectionModule evselmodule; + + o2::common::eventselection::lumiConfigurables lumiOpts; + o2::common::eventselection::LumiModule lumimodule; + + Produces timestampTable; /// Table with SOR timestamps produced by the task + Produces bcsel; + Produces evsel; + + // for slicing + SliceCache cache; + + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // the best: have readable cursors + // this: a stopgap solution to avoid spawning yet another device + std::vector timestamps; + std::vector bcselsbuffer; + + // auxiliary + Partition pvTracks = ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + Preslice perCollisionIU = aod::track::collisionId; + + void init(o2::framework::InitContext& context) + { + // CCDB boilerplate init + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); + + // task-specific + timestampMod.init(timestampConfigurables, metadataInfo); + bcselmodule.init(context, bcselOpts, histos, metadataInfo); + evselmodule.init(context, evselOpts, histos, metadataInfo); + lumimodule.init(context, lumiOpts, histos); + } + + void process(aod::Collisions const& collisions, + BCsWithRun3Matchings const& bcs, + aod::Zdcs const&, + aod::FV0As const&, + aod::FT0s const& ft0s, // to resolve iterator + aod::FDDs const&, + FullTracksIU const&) + { + timestampMod.process(bcs, ccdb, timestamps, timestampTable); + bcselmodule.processRun3(ccdb, histos, bcs, timestamps, bcselsbuffer, bcsel); + evselmodule.processRun3(ccdb, histos, bcs, collisions, pvTracks, ft0s, cache, timestamps, bcselsbuffer, evsel); + lumimodule.process(ccdb, histos, bcs, timestamps, bcselsbuffer); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata for later too + metadataInfo.initMetadata(cfgc); + + LOGF(info, "Event selection with forced Run 2 mode engaging in unchecked mode."); + LOGF(info, "To be improved once metadata enabling in defineDataProcessing is worked out."); + + // force Run 2 mode + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +}