diff --git a/Common/TableProducer/propagationService.cxx b/Common/TableProducer/propagationService.cxx index 25c951ef396..0c144bb43f9 100644 --- a/Common/TableProducer/propagationService.cxx +++ b/Common/TableProducer/propagationService.cxx @@ -77,6 +77,7 @@ struct propagationService { o2::pwglf::strangenessbuilder::v0Configurables v0BuilderOpts; o2::pwglf::strangenessbuilder::cascadeConfigurables cascadeBuilderOpts; o2::pwglf::strangenessbuilder::preSelectOpts preSelectOpts; + o2::pwglf::strangenessbuilder::eventSelectOpts eventSelectOpts; o2::pwglf::strangenessbuilder::BuilderModule strangenessBuilderModule; // the track tuner object -> needs to be here as it inherits from ConfigurableGroup (+ has its own copy of ccdbApi) @@ -99,7 +100,7 @@ struct propagationService { // task-specific trackPropagation.init(trackPropagationConfigurables, trackTunerObj, histos, initContext); - strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, histos, initContext); + strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, eventSelectOpts, histos, initContext); } void processRealData(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIU const& tracks, aod::BCsWithTimestamps const& bcs) diff --git a/Common/TableProducer/propagationServiceRun2.cxx b/Common/TableProducer/propagationServiceRun2.cxx index 85dd2d0942b..4266acaaa0d 100644 --- a/Common/TableProducer/propagationServiceRun2.cxx +++ b/Common/TableProducer/propagationServiceRun2.cxx @@ -75,6 +75,7 @@ struct propagationServiceRun2 { o2::pwglf::strangenessbuilder::v0Configurables v0BuilderOpts; o2::pwglf::strangenessbuilder::cascadeConfigurables cascadeBuilderOpts; o2::pwglf::strangenessbuilder::preSelectOpts preSelectOpts; + o2::pwglf::strangenessbuilder::eventSelectOpts eventSelectOpts; o2::pwglf::strangenessbuilder::BuilderModule strangenessBuilderModule; // registry @@ -89,7 +90,7 @@ struct propagationServiceRun2 { ccdb->setFatalWhenNull(false); // task-specific - strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, histos, initContext); + strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, eventSelectOpts, histos, initContext); } void processRealData(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExt const& tracks, aod::BCsWithTimestamps const& bcs) diff --git a/Common/TableProducer/propagationServiceV2.cxx b/Common/TableProducer/propagationServiceV2.cxx index 364d27101e6..14f47a4c96d 100644 --- a/Common/TableProducer/propagationServiceV2.cxx +++ b/Common/TableProducer/propagationServiceV2.cxx @@ -82,6 +82,7 @@ struct propagationServiceV2 { o2::pwglf::strangenessbuilder::v0Configurables v0BuilderOpts; o2::pwglf::strangenessbuilder::cascadeConfigurables cascadeBuilderOpts; o2::pwglf::strangenessbuilder::preSelectOpts preSelectOpts; + o2::pwglf::strangenessbuilder::eventSelectOpts eventSelectOpts; o2::pwglf::strangenessbuilder::BuilderModule strangenessBuilderModule; // the track tuner object -> needs to be here as it inherits from ConfigurableGroup (+ has its own copy of ccdbApi) @@ -106,7 +107,7 @@ struct propagationServiceV2 { // task-specific trackPropagation.init(trackPropagationConfigurables, trackTunerObj, histos, initContext); - strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, histos, initContext); + strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, eventSelectOpts, histos, initContext); } // Load MatLUT once (needs rectifyPtrFromFile, kept manual), set B-field and mean vertex diff --git a/PWGLF/DataModel/LFStrangenessPIDTables.h b/PWGLF/DataModel/LFStrangenessPIDTables.h index 852be92347d..067966859ed 100644 --- a/PWGLF/DataModel/LFStrangenessPIDTables.h +++ b/PWGLF/DataModel/LFStrangenessPIDTables.h @@ -182,7 +182,17 @@ DECLARE_SOA_TABLE_VERSIONED(DauTrackTOFPIDs_002, "AOD", "DAUTRACKTOFPID", 2, // dautrack::TOFExpTimeKa, dautrack::TOFExpTimePr); -using DauTrackTOFPIDs = DauTrackTOFPIDs_002; // second gen: with collision Id, with TOFExpMom +DECLARE_SOA_TABLE_VERSIONED(DauTrackTOFPIDs_003, "AOD", "DAUTRACKTOFPID", 3, // raw table (for posterior TOF calculation) + o2::soa::Index<>, + bc::GlobalBC, dautrack::DauTrackExtraId, + dautrack::TOFSignal, dautrack::TOFEvTime, dautrack::TOFEvTimeErr, + dautrack::Length, dautrack::TOFExpMom, + dautrack::TOFExpTimeEl, + dautrack::TOFExpTimePi, + dautrack::TOFExpTimeKa, + dautrack::TOFExpTimePr); + +using DauTrackTOFPIDs = DauTrackTOFPIDs_003; // second gen: with collision Id, with TOFExpMom namespace v0data { diff --git a/PWGLF/DataModel/LFStrangenessTables.h b/PWGLF/DataModel/LFStrangenessTables.h index 4eb92b3d43a..37fa6facf54 100644 --- a/PWGLF/DataModel/LFStrangenessTables.h +++ b/PWGLF/DataModel/LFStrangenessTables.h @@ -44,6 +44,16 @@ DECLARE_SOA_COLUMN(DataframeID, dataframeID, uint64_t); //! Data frame ID (what DECLARE_SOA_TABLE(StraOrigins, "AOD", "STRAORIGIN", //! Table which contains the IDs of all dataframes merged into this dataframe o2::soa::Index<>, straorigin::DataframeID); +// for keeping track of the number of selected collisions +namespace straselections +{ +DECLARE_SOA_COLUMN(TotalNbrOfCollisions, totalNbrOfCollisions, int); //! total number of analysed collisions +DECLARE_SOA_COLUMN(TotalNbrOfSelCollisions, totalNbrOfSelCollisions, int); //! total number of selected collisions +} // namespace straselections + +DECLARE_SOA_TABLE(StraSelections, "AOD", "STRASELECTIONS", //! keep track of the number of analysed collisions in this DF + o2::soa::Index<>, straselections::TotalNbrOfCollisions, straselections::TotalNbrOfSelCollisions); + namespace stracollision { DECLARE_SOA_DYNAMIC_COLUMN(IsUPC, isUPC, //! check whether this is a UPC or hadronic collision diff --git a/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt b/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt index 2cd12ee97b1..484d98f1126 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt +++ b/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt @@ -34,6 +34,11 @@ o2physics_add_dpl_workflow(stradautrackstofpidconverter3 PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(stradautrackstofpidconverter4 + SOURCES stradautrackstofpidconverter4.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(stradautracksextraconverter SOURCES stradautracksextraconverter.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/PWGLF/TableProducer/Strangeness/Converters/stradautrackstofpidconverter4.cxx b/PWGLF/TableProducer/Strangeness/Converters/stradautrackstofpidconverter4.cxx new file mode 100644 index 00000000000..b94dd91714d --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/stradautrackstofpidconverter4.cxx @@ -0,0 +1,58 @@ +// 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 stradautrackstofpidconverter4.cxx +/// \brief Converts DauTrackTOFPID_002 into DauTrackTOFPID_003 +/// +/// \author David Dobrigkeit Chinellato , Austrian Academy of Sciences & MBI +/// \author Romain Schotter , Austrian Academy of Sciences & MBI + +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; + +// converts DauTrackTOFPIDs_002 to _003 +struct stradautrackstofpidconverter4 { + Produces dautracktofpids; + + void process(aod::DauTrackTOFPIDs_002 const& dauTracks, soa::Join const& collisions) + { + // create new TOFPIDs + dautracktofpids.reserve(dauTracks.size()); + for (const auto& dauTrack : dauTracks) { + uint64_t bc = 0; + if (dauTrack.straCollisionId() >= 0) { + auto collision = collisions.rawIteratorAt(dauTrack.straCollisionId()); + bc = collision.globalBC(); + } + dautracktofpids( + bc, + dauTrack.dauTrackExtraId(), + dauTrack.tofSignal(), + dauTrack.tofEvTime(), + dauTrack.tofEvTimeErr(), + dauTrack.length(), + dauTrack.tofExpMom()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx index 45992de95e8..4c90b25caaf 100644 --- a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx @@ -25,6 +25,8 @@ #include "PWGLF/DataModel/SPCalibrationTables.h" #include "PWGUD/DataModel/UDTables.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/RCTSelectionFlags.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/McCollisionExtra.h" @@ -153,6 +155,10 @@ struct strangederivedbuilder { //__________________________________________________ // Debug Produces straOrigin; + + //__________________________________________________ + // Keep track of analysed collisions + Produces straSelection; } products; // histogram registry for bookkeeping @@ -184,6 +190,24 @@ struct strangederivedbuilder { Configurable fillEmptyCollisions{"fillEmptyCollisions", false, "fill collision entries without candidates"}; + // Configurable options for event selections + // --> configuration inherited from the strangenessBuilderModule in the propagationService + Configurable inheritEvtSelFromTask{"inheritEvtSelFromTask", "propagation-service", "Inherit event selection parameters from which task?"}; + Configurable inheritEvtSelFromTaskCfgGroup{"inheritEvtSelFromTaskCfgGroup", "eventSelectOpts", "What is the configurable group prefix? If none, put nothing"}; + Configurable inheritEvtSelFromTaskVerbose{"inheritEvtSelFromTaskVerbose", false, "Enable verbose mode on the getTaskOption utility"}; + bool fillOnlySelectedCollisions = false; // Fill only tables for selected collisions? + bool requireTriggerTVX = false; // require FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level (Run 3 only) + bool rejectITSROFBorder = false; // reject events at ITS ROF border (Run 3 only) + bool rejectTFBorder = false; // reject events at TF border (Run 3 only) + bool rejectSameBunchPileup = false; // reject collisions in case of pileup with another collision in the same foundBC (Run 3 only) + float maxZVtxPosition = 10.; // max Z vtx position (cm) + bool cfgApplyRCTrequirement = false; // Apply RCT requirement? + std::string cfgRCTLabel = ""; // Which detector condition requirements? (CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo) + bool cfgCheckZDC = false; // Include ZDC flags in the bit selection (for Pb-Pb only) + bool cfgTreatLimitedAcceptanceAsBad = false; // reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance + + o2::aod::rctsel::RCTFlagsChecker rctFlagsChecker; + // round Nsigma variables up to a certain level of precision if requested // useful to keep derived data sizes under control // variables that are rounded include the DCAs but not the CosPA (precision needed) @@ -220,6 +244,7 @@ struct strangederivedbuilder { } axisDetectors; // For manual sliceBy + Preslice TrackperCollision = o2::aod::track::collisionId; Preslice V0perCollision = o2::aod::v0data::collisionId; Preslice CascperCollision = o2::aod::cascdata::collisionId; Preslice KFCascperCollision = o2::aod::cascdata::collisionId; @@ -237,6 +262,13 @@ struct strangederivedbuilder { std::vector genOmegaMinus; std::vector genOmegaPlus; + // create collision indices beforehand + std::vector TrackCollIndices; // index -1: no collision + std::vector V0CollIndices; // index -1: no collision + std::vector CascadeCollIndices; // index -1: no collision + std::vector KFCascadeCollIndices; // index -1: no collision + std::vector TraCascadeCollIndices; // index -1: no collision + float roundToPrecision(float number, float step = 0.01) { // this function rounds a certain number in an axis that is quantized by @@ -246,7 +278,46 @@ struct strangederivedbuilder { return step * static_cast(static_cast((number) / step)) + TMath::Sign(1.0f, number) * (0.5f) * step; } - void init(InitContext&) + template + void getCfg(o2::framework::InitContext& initContext, const std::string& name, VType& v, const std::string& task) + { + if (!o2::common::core::getTaskOptionValue(initContext, task, name, v, inheritEvtSelFromTaskVerbose)) { + LOG(fatal) << "Could not get " << name << " from " << task << " task"; + } + } + + template + bool isCollisionAccepted(TCollision collision) + // check whether the collision passes our collision selections + { + if (requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + + if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + + if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + if (std::abs(collision.posZ()) > maxZVtxPosition) { + return false; + } + + if (rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + + if (!cfgApplyRCTrequirement && !rctFlagsChecker(collision)) { + return false; + } + + return true; + } + + void init(InitContext& initContext) { LOGF(info, "Initializing now: cross-checking correctness..."); if (doprocessCollisionsRun3 + @@ -384,7 +455,34 @@ struct strangederivedbuilder { } else { LOGF(info, "Process strange mothers...........: no"); } - LOGF(info, "=================================================================="); + LOGF(info, "====] Event selection information processing [===================="); + std::string eventSelectOptsPrefix = inheritEvtSelFromTaskCfgGroup.value; + if (!inheritEvtSelFromTaskCfgGroup.value.empty()) { + eventSelectOptsPrefix += "."; + } + + getCfg(initContext, eventSelectOptsPrefix + "fillOnlySelectedCollisions", fillOnlySelectedCollisions, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "requireTriggerTVX", requireTriggerTVX, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "rejectITSROFBorder", rejectITSROFBorder, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "rejectTFBorder", rejectTFBorder, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "rejectSameBunchPileup", rejectSameBunchPileup, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "maxZVtxPosition", maxZVtxPosition, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "cfgApplyRCTrequirement", cfgApplyRCTrequirement, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "cfgRCTLabel", cfgRCTLabel, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "cfgCheckZDC", cfgCheckZDC, inheritEvtSelFromTask); + getCfg(initContext, eventSelectOptsPrefix + "cfgTreatLimitedAcceptanceAsBad", cfgTreatLimitedAcceptanceAsBad, inheritEvtSelFromTask); + + LOG(info) << "Inherit event selections from : " << inheritEvtSelFromTask; + LOG(info) << "Fill only selected position........: " << (fillOnlySelectedCollisions ? "yes" : "no"); + LOG(info) << "Require TriggerTVX.................: " << (requireTriggerTVX ? "yes" : "no"); + LOG(info) << "Reject ITS ROF border..............: " << (rejectITSROFBorder ? "yes" : "no"); + LOG(info) << "Reject TF border...................: " << (rejectTFBorder ? "yes" : "no"); + LOG(info) << "Reject same bunch pile-up..........: " << (rejectSameBunchPileup ? "yes" : "no"); + LOG(info) << "Apply RCT requirement..............: " << (cfgApplyRCTrequirement ? "yes" : "no"); + LOG(info) << "RCT requirement....................: " << cfgRCTLabel; + LOG(info) << "Check ZDC in RCT requirement.......: " << (cfgCheckZDC ? "yes" : "no"); + LOG(info) << "Treat limited acceptance as bad....: " << (cfgCheckZDC ? "yes" : "no"); + LOG(info) << "================================================================="; // setup map for fast checking if enabled static_for<0, nSpecies - 1>([&](auto i) { @@ -417,6 +515,11 @@ struct strangederivedbuilder { auto hZNATimeVsZNAUD = histos.add("hZNATimeVsZNAUD", "hZNAMultVsZNAUD; ZNA time; ZNA UD", kTH2F, {axisDetectors.axisZNAtime, axisDetectors.axisZNAtime}); auto hZNCTimeVsZNCUD = histos.add("hZNCTimeVsZNCUD", "hZNCMultVsZNCUD; ZNC time; ZNC UD", kTH2F, {axisDetectors.axisZNCtime, axisDetectors.axisZNCtime}); + // Initialise the RCTFlagsChecker + if (cfgApplyRCTrequirement) { + rctFlagsChecker.init(cfgRCTLabel, cfgCheckZDC, cfgTreatLimitedAcceptanceAsBad); + } + for (int ii = 1; ii < 101; ii++) { float value = 100.5f - static_cast(ii); hRawCentrality->SetBinContent(ii, value); @@ -438,19 +541,30 @@ struct strangederivedbuilder { } // master function to process a collision - template - void populateCollisionTables(coll const& collisions, udcoll const& udCollisions, v0d const& V0s, cad const& Cascades, kfcad const& KFCascades, tracad const& TraCascades, bcType const& /*bcs*/) + template + void populateCollisionTables(coll const& collisions, udcoll const& udCollisions, tracks const& Tracks, v0d const& V0s, cad const& Cascades, kfcad const& KFCascades, tracad const& TraCascades, bcType const& /*bcs*/) { // create collision indices beforehand - std::vector V0CollIndices(V0s.size(), -1); // index -1: no collision - std::vector CascadeCollIndices(Cascades.size(), -1); // index -1: no collision - std::vector KFCascadeCollIndices(KFCascades.size(), -1); // index -1: no collision - std::vector TraCascadeCollIndices(TraCascades.size(), -1); // index -1: no collision + TrackCollIndices.clear(); + V0CollIndices.clear(); + CascadeCollIndices.clear(); + KFCascadeCollIndices.clear(); + TraCascadeCollIndices.clear(); + + TrackCollIndices.resize(Tracks.size(), 0); // index -1: no collision + V0CollIndices.resize(V0s.size(), -1); // index -1: no collision + CascadeCollIndices.resize(Cascades.size(), -1); // index -1: no collision + KFCascadeCollIndices.resize(KFCascades.size(), -1); // index -1: no collision + TraCascadeCollIndices.resize(TraCascades.size(), -1); // index -1: no collision + + int totalNbrCollisions = collisions.size(); + int totalNbrSelectedCollisions = 0; // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ for (const auto& collision : collisions) { const uint64_t collIdx = collision.globalIndex(); + auto TrackTable_thisColl = Tracks.sliceBy(TrackperCollision, collIdx); auto V0Table_thisColl = V0s.sliceBy(V0perCollision, collIdx); auto CascTable_thisColl = Cascades.sliceBy(CascperCollision, collIdx); auto KFCascTable_thisColl = KFCascades.sliceBy(KFCascperCollision, collIdx); @@ -522,6 +636,13 @@ struct strangederivedbuilder { } } + for (const auto& track : TrackTable_thisColl) + TrackCollIndices[track.globalIndex()] = bc.globalBC(); + + if (fillOnlySelectedCollisions && !isCollisionAccepted(collision)) { + continue; + } + // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ // fill collision tables if (strange || fillEmptyCollisions) { @@ -624,6 +745,7 @@ struct strangederivedbuilder { collision.multZPC() * static_cast(fillTruncationOptions.fillRawZDC), collision.alias_raw()); } + totalNbrSelectedCollisions++; } for (const auto& v0 : V0Table_thisColl) V0CollIndices[v0.globalIndex()] = products.strangeColl.lastIndex(); @@ -649,6 +771,7 @@ struct strangederivedbuilder { for (const auto& casc : TraCascades) { products.tracasccollref(TraCascadeCollIndices[casc.globalIndex()]); } + products.straSelection(totalNbrCollisions, totalNbrSelectedCollisions); } // helper function to estimate collision time @@ -674,6 +797,9 @@ struct strangederivedbuilder { collisionEventTime[collision.globalIndex()] = -1e+6; // undefined collisionEventTimeErr[collision.globalIndex()] = -1e-6; // undefined } + if (fillOnlySelectedCollisions && !isCollisionAccepted(collision)) { + continue; + } histos.fill(HIST("h2dCollisionTimesVsNTracks"), collisionNtracks[collision.globalIndex()], collisionEventTime[collision.globalIndex()]); products.straEvTimes(collisionEventTime[collision.globalIndex()], collisionEventTimeErr[collision.globalIndex()]); } @@ -719,37 +845,37 @@ struct strangederivedbuilder { } } - void processCollisionsRun3(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&) + void processCollisionsRun3(soa::Join const& collisions, aod::Tracks const& tracks, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&) { - populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); + populateCollisionTables(collisions, collisions, tracks, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsRun3WithUD(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&, UDCollisionsFull const& udCollisions) + void processCollisionsRun3WithUD(soa::Join const& collisions, aod::Tracks const& tracks, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&, UDCollisionsFull const& udCollisions) { - populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades, bcs); + populateCollisionTables(collisions, udCollisions, tracks, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsRun3WithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) + void processCollisionsRun3WithMC(soa::Join const& collisions, aod::Tracks const& tracks, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) { populateMCCollisionTable(mcCollisions, mcParticles); - populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); + populateCollisionTables(collisions, collisions, tracks, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsRun3WithUDWithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&, UDCollisionsFull const& udCollisions, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) + void processCollisionsRun3WithUDWithMC(soa::Join const& collisions, aod::Tracks const& tracks, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& bcs, aod::FT0s const&, aod::FV0As const&, aod::FDDs const&, aod::Zdcs const&, UDCollisionsFull const& udCollisions, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) { populateMCCollisionTable(mcCollisions, mcParticles); - populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades, bcs); + populateCollisionTables(collisions, udCollisions, tracks, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsRun2(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, BCsWithTimestampsAndRun2Infos const& bcs) + void processCollisionsRun2(soa::Join const& collisions, aod::Tracks const& tracks, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, BCsWithTimestampsAndRun2Infos const& bcs) { - populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); + populateCollisionTables(collisions, collisions, tracks, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsRun2WithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, BCsWithTimestampsAndRun2Infos const& bcs, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) + void processCollisionsRun2WithMC(soa::Join const& collisions, aod::Tracks const& tracks, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, BCsWithTimestampsAndRun2Infos const& bcs, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) { populateMCCollisionTable(mcCollisions, mcParticles); - populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); + populateCollisionTables(collisions, collisions, tracks, V0s, Cascades, KFCascades, TraCascades, bcs); } void processTrackExtrasV0sOnly(aod::V0Datas const& V0s, TracksWithExtra const& tracksExtra) @@ -905,7 +1031,7 @@ struct strangederivedbuilder { aod::dautrack::packing::packInInt8(tr.tpcNSigmaPr())); // populate daughter-level TOF information if (tr.hasTOF()) { - products.dauTrackTOFPIDs(tr.collisionId(), products.dauTrackExtras.lastIndex(), tr.tofSignal(), tr.tofEvTime(), tr.tofEvTimeErr(), tr.length(), tr.tofExpMom()); + products.dauTrackTOFPIDs(TrackCollIndices[tr.globalIndex()], products.dauTrackExtras.lastIndex(), tr.tofSignal(), tr.tofEvTime(), tr.tofEvTimeErr(), tr.length(), tr.tofExpMom()); } } else { // populate with empty fully-compatible Nsigmas if no corresponding table available @@ -916,7 +1042,7 @@ struct strangederivedbuilder { // done! } - void processPopulateEventTimes(aod::Collisions const& collisions, soa::Join const& tracks) + void processPopulateEventTimes(soa::Join const& collisions, soa::Join const& tracks) { populateEventTimes(collisions, tracks); } diff --git a/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx b/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx index e34227a8b70..b635c0fc1db 100644 --- a/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx +++ b/PWGLF/TableProducer/Strangeness/strangenesstofpid.cxx @@ -1996,24 +1996,19 @@ struct strangenesstofpid { pTof.tpcNSigmaPr = pTra.tpcNSigmaPr(); if (tofIndices[V0.posTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) { auto pTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[V0.posTrackExtraId()]); - - if (pTofExt.straCollisionId() >= 0) { - // extract BC for BC time shift - auto collisionTrack = collisions.rawIteratorAt(pTofExt.straCollisionId()); - const int64_t deltaBc = collisionTrack.globalBC() - collision.globalBC(); - const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; - histos.fill(HIST("hV0PositiveBCShift"), deltaTimeBc); - deltaTimeBcPos = deltaTimeBc; - - // assign variables - pTof.collisionId = pTofExt.straCollisionId(); - pTof.tofExpMom = pTofExt.tofExpMom(); - pTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : pTofExt.tofEvTime(); - pTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : pTofExt.tofEvTimeErr(); - // pTof.tofEvTimeErr = pTofExt.tofEvTimeErr(); - pTof.tofSignal = pTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); - pTof.length = pTofExt.length(); - } + // extract BC for BC time shift + const int64_t deltaBc = pTofExt.globalBC() - collision.globalBC(); + const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; + histos.fill(HIST("hV0PositiveBCShift"), deltaTimeBc); + deltaTimeBcPos = deltaTimeBc; + + // assign variables + pTof.tofExpMom = pTofExt.tofExpMom(); + pTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : pTofExt.tofEvTime(); + pTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : pTofExt.tofEvTimeErr(); + // pTof.tofEvTimeErr = pTofExt.tofEvTimeErr(); + pTof.tofSignal = pTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); + pTof.length = pTofExt.length(); } nTof.hasITS = nTra.hasITS(); @@ -2023,24 +2018,19 @@ struct strangenesstofpid { nTof.tpcNSigmaPr = nTra.tpcNSigmaPr(); if (tofIndices[V0.negTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) { auto nTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[V0.negTrackExtraId()]); - - if (nTofExt.straCollisionId() >= 0) { - // extract BC for BC time shift - auto collisionTrack = collisions.rawIteratorAt(nTofExt.straCollisionId()); - const int64_t deltaBc = collisionTrack.globalBC() - collision.globalBC(); - const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; - histos.fill(HIST("hV0NegativeBCShift"), deltaTimeBc); - deltaTimeBcNeg = deltaTimeBc; - - // assign variables - nTof.collisionId = nTofExt.straCollisionId(); - nTof.tofExpMom = nTofExt.tofExpMom(); - nTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : nTofExt.tofEvTime(); - nTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : nTofExt.tofEvTimeErr(); - // nTof.tofEvTimeErr = nTofExt.tofEvTimeErr(); - nTof.tofSignal = nTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); - nTof.length = nTofExt.length(); - } + // extract BC for BC time shift + const int64_t deltaBc = nTofExt.globalBC() - collision.globalBC(); + const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; + histos.fill(HIST("hV0NegativeBCShift"), deltaTimeBc); + deltaTimeBcNeg = deltaTimeBc; + + // assign variables + nTof.tofExpMom = nTofExt.tofExpMom(); + nTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : nTofExt.tofEvTime(); + nTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : nTofExt.tofEvTimeErr(); + // nTof.tofEvTimeErr = nTofExt.tofEvTimeErr(); + nTof.tofSignal = nTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); + nTof.length = nTofExt.length(); } if (pTof.hasTOF) { histos.fill(HIST("hTOFSignalPositive"), pTof.tofSignal); @@ -2093,23 +2083,18 @@ struct strangenesstofpid { pTof.tpcNSigmaPr = pTra.tpcNSigmaPr(); if (tofIndices[cascade.posTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) { auto pTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[cascade.posTrackExtraId()]); - - if (pTofExt.straCollisionId() >= 0) { - // extract BC for BC time shift - auto collisionTrack = collisions.rawIteratorAt(pTofExt.straCollisionId()); - const int64_t deltaBc = collisionTrack.globalBC() - collision.globalBC(); - const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; - histos.fill(HIST("hCascadePositiveBCShift"), deltaTimeBc); - histos.fill(HIST("h2dTOFSignalCascadePositive"), pTof.tofSignal, deltaTimeBc); - - pTof.collisionId = pTofExt.straCollisionId(); - pTof.tofExpMom = pTofExt.tofExpMom(); - pTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : pTofExt.tofEvTime(); - pTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : pTofExt.tofEvTimeErr(); - // pTof.tofEvTimeErr = pTofExt.tofEvTimeErr(); - pTof.tofSignal = pTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); - pTof.length = pTofExt.length(); - } + // extract BC for BC time shift + const int64_t deltaBc = pTofExt.globalBC() - collision.globalBC(); + const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; + histos.fill(HIST("hCascadePositiveBCShift"), deltaTimeBc); + histos.fill(HIST("h2dTOFSignalCascadePositive"), pTof.tofSignal, deltaTimeBc); + + pTof.tofExpMom = pTofExt.tofExpMom(); + pTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : pTofExt.tofEvTime(); + pTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : pTofExt.tofEvTimeErr(); + // pTof.tofEvTimeErr = pTofExt.tofEvTimeErr(); + pTof.tofSignal = pTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); + pTof.length = pTofExt.length(); } nTof.hasITS = nTra.hasITS(); @@ -2119,23 +2104,18 @@ struct strangenesstofpid { nTof.tpcNSigmaPr = nTra.tpcNSigmaPr(); if (tofIndices[cascade.negTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) { auto nTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[cascade.negTrackExtraId()]); - - if (nTofExt.straCollisionId() >= 0) { - // extract BC for BC time shift - auto collisionTrack = collisions.rawIteratorAt(nTofExt.straCollisionId()); - const int64_t deltaBc = collisionTrack.globalBC() - collision.globalBC(); - const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; - histos.fill(HIST("hCascadeNegativeBCShift"), deltaTimeBc); - histos.fill(HIST("h2dTOFSignalCascadeNegative"), nTof.tofSignal, deltaTimeBc); - - nTof.collisionId = nTofExt.straCollisionId(); - nTof.tofExpMom = nTofExt.tofExpMom(); - nTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : nTofExt.tofEvTime(); - nTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTime() : nTofExt.tofEvTimeErr(); - // nTof.tofEvTimeErr = nTofExt.tofEvTimeErr(); - nTof.tofSignal = nTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); - nTof.length = nTofExt.length(); - } + // extract BC for BC time shift + const int64_t deltaBc = nTofExt.globalBC() - collision.globalBC(); + const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; + histos.fill(HIST("hCascadeNegativeBCShift"), deltaTimeBc); + histos.fill(HIST("h2dTOFSignalCascadeNegative"), nTof.tofSignal, deltaTimeBc); + + nTof.tofExpMom = nTofExt.tofExpMom(); + nTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : nTofExt.tofEvTime(); + nTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTime() : nTofExt.tofEvTimeErr(); + // nTof.tofEvTimeErr = nTofExt.tofEvTimeErr(); + nTof.tofSignal = nTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); + nTof.length = nTofExt.length(); } bTof.hasITS = bTra.hasITS(); @@ -2145,23 +2125,18 @@ struct strangenesstofpid { bTof.tpcNSigmaKa = bTra.tpcNSigmaKa(); if (tofIndices[cascade.bachTrackExtraId()] >= 0 && collision.eventTime() > -1e+5) { auto bTofExt = dauTrackTOFPIDs.rawIteratorAt(tofIndices[cascade.bachTrackExtraId()]); - - if (bTofExt.straCollisionId() >= 0) { - // extract BC for BC time shift - auto collisionTrack = collisions.rawIteratorAt(bTofExt.straCollisionId()); - const int64_t deltaBc = collisionTrack.globalBC() - collision.globalBC(); - const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; - histos.fill(HIST("hCascadeBachelorBCShift"), deltaTimeBc); - histos.fill(HIST("h2dTOFSignalCascadeBachelor"), bTof.tofSignal, deltaTimeBc); - - bTof.collisionId = bTofExt.straCollisionId(); - bTof.tofExpMom = bTofExt.tofExpMom(); - bTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : bTofExt.tofEvTime(); - bTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : bTofExt.tofEvTimeErr(); - // bTof.tofEvTimeErr = bTofExt.tofEvTimeErr(); - bTof.tofSignal = bTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); - bTof.length = bTofExt.length(); - } + // extract BC for BC time shift + const int64_t deltaBc = bTofExt.globalBC() - collision.globalBC(); + const double deltaTimeBc = o2::constants::lhc::LHCBunchSpacingNS * deltaBc * 1000.0f; + histos.fill(HIST("hCascadeBachelorBCShift"), deltaTimeBc); + histos.fill(HIST("h2dTOFSignalCascadeBachelor"), bTof.tofSignal, deltaTimeBc); + + bTof.tofExpMom = bTofExt.tofExpMom(); + bTof.tofEvTime = reassociateTracks.value ? collision.eventTime() : bTofExt.tofEvTime(); + bTof.tofEvTimeErr = reassociateTracks.value ? collision.eventTimeErr() : bTofExt.tofEvTimeErr(); + // bTof.tofEvTimeErr = bTofExt.tofEvTimeErr(); + bTof.tofSignal = bTofExt.tofSignal() + (doBCshift.value ? deltaTimeBc : 0.0f); + bTof.length = bTofExt.length(); } cascTofInfo casctof = calculateTofInfoCascade(collisions, cascade.straCollisionId(), cascade, pTof, nTof, bTof); diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index 1d293c9c620..5f0b744fd3b 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -324,6 +324,7 @@ struct derivedlambdakzeroanalysis { ConfigurableAxis axisK0Mass{"axisK0Mass", {200, 0.4f, 0.6f}, ""}; ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.101f, 1.131f}, ""}; ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f}, "Centrality"}; + ConfigurableAxis axisCentralityFine{"axisCentralityFine", {101, 0.0f, 101.0f}, "Centrality"}; ConfigurableAxis axisNch{"axisNch", {500, 0.0f, +5000.0f}, "Number of charged particles"}; ConfigurableAxis axisIRBinning{"axisIRBinning", {500, 0, 50}, "Binning for the interaction rate (kHz)"}; ConfigurableAxis axisMultFT0M{"axisMultFT0M", {500, 0.0f, +100000.0f}, "Multiplicity FT0M"}; @@ -670,6 +671,13 @@ struct derivedlambdakzeroanalysis { // Initialise the RCTFlagsChecker rctFlagsChecker.init(rctConfigurations.cfgRCTLabel.value, rctConfigurations.cfgCheckZDC, rctConfigurations.cfgTreatLimitedAcceptanceAsBad); + // + if (doprocessAnalysedCollisions) { + histos.add("hEventPreSelection", "hEventPreSelection", kTH1D, {{2, -0.5f, +1.5f}}); + histos.get(HIST("hEventPreSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("hEventPreSelection"))->GetXaxis()->SetBinLabel(2, "Preselected collisions"); + } + // Event Counters histos.add("hEventSelection", "hEventSelection", kTH1D, {{21, -0.5f, +20.5f}}); if (isRun3) { @@ -722,11 +730,11 @@ struct derivedlambdakzeroanalysis { } } - histos.add("hEventCentrality", "hEventCentrality", kTH1D, {{101, 0.0f, 101.0f}}); - histos.add("hCentralityVsNch", "hCentralityVsNch", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisNch}); + histos.add("hEventCentrality", "hEventCentrality", kTH1D, {axisConfigurations.axisCentralityFine}); + histos.add("hCentralityVsNch", "hCentralityVsNch", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisNch}); if (doEventQA) { if (isRun3) { - histos.add("hEventSelectionVsCentrality", "hEventSelectionVsCentrality", kTH2D, {{21, -0.5f, +20.5f}, {101, 0.0f, 101.0f}}); + histos.add("hEventSelectionVsCentrality", "hEventSelectionVsCentrality", kTH2D, {{21, -0.5f, +20.5f}, axisConfigurations.axisCentralityFine}); histos.get(HIST("hEventSelectionVsCentrality"))->GetXaxis()->SetBinLabel(1, "All collisions"); histos.get(HIST("hEventSelectionVsCentrality"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); histos.get(HIST("hEventSelectionVsCentrality"))->GetXaxis()->SetBinLabel(3, "kIsTriggerTVX"); @@ -754,11 +762,11 @@ struct derivedlambdakzeroanalysis { histos.get(HIST("hEventSelectionVsCentrality"))->GetXaxis()->SetBinLabel(20, "Above max IR"); histos.get(HIST("hEventSelectionVsCentrality"))->GetXaxis()->SetBinLabel(21, "RCT flags"); - histos.add("hCentralityVsNGlobal", "hCentralityVsNGlobal", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisNch}); - histos.add("hEventCentVsMultFT0M", "hEventCentVsMultFT0M", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisMultFT0M}); - histos.add("hEventCentVsMultFT0C", "hEventCentVsMultFT0C", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisMultFT0C}); - histos.add("hEventCentVsMultNGlobal", "hEventCentVsMultNGlobal", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisNch}); - histos.add("hEventCentVsMultFV0A", "hEventCentVsMultFV0A", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisMultFV0A}); + histos.add("hCentralityVsNGlobal", "hCentralityVsNGlobal", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisNch}); + histos.add("hEventCentVsMultFT0M", "hEventCentVsMultFT0M", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisMultFT0M}); + histos.add("hEventCentVsMultFT0C", "hEventCentVsMultFT0C", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisMultFT0C}); + histos.add("hEventCentVsMultNGlobal", "hEventCentVsMultNGlobal", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisNch}); + histos.add("hEventCentVsMultFV0A", "hEventCentVsMultFV0A", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisMultFV0A}); histos.add("hEventMultFT0MvsMultNGlobal", "hEventMultFT0MvsMultNGlobal", kTH2D, {axisConfigurations.axisMultFT0M, axisConfigurations.axisNch}); histos.add("hEventMultFT0CvsMultNGlobal", "hEventMultFT0CvsMultNGlobal", kTH2D, {axisConfigurations.axisMultFT0C, axisConfigurations.axisNch}); histos.add("hEventMultFV0AvsMultNGlobal", "hEventMultFV0AvsMultNGlobal", kTH2D, {axisConfigurations.axisMultFV0A, axisConfigurations.axisNch}); @@ -768,23 +776,23 @@ struct derivedlambdakzeroanalysis { } histos.add("hEventPVz", "hEventPVz", kTH1D, {{100, -20.0f, +20.0f}}); - histos.add("hCentralityVsPVz", "hCentralityVsPVz", kTH2D, {{101, 0.0f, 101.0f}, {100, -20.0f, +20.0f}}); + histos.add("hCentralityVsPVz", "hCentralityVsPVz", kTH2D, {axisConfigurations.axisCentralityFine, {100, -20.0f, +20.0f}}); if (doprocessGeneratedRun3 || doprocessGeneratedRun2) { histos.add("hEventPVzMC", "hEventPVzMC", kTH1D, {{100, -20.0f, +20.0f}}); - histos.add("hCentralityVsPVzMC", "hCentralityVsPVzMC", kTH2D, {{101, 0.0f, 101.0f}, {100, -20.0f, +20.0f}}); + histos.add("hCentralityVsPVzMC", "hCentralityVsPVzMC", kTH2D, {axisConfigurations.axisCentralityFine, {100, -20.0f, +20.0f}}); } histos.add("hEventOccupancy", "hEventOccupancy", kTH1D, {axisConfigurations.axisOccupancy}); - histos.add("hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisOccupancy}); + histos.add("hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisOccupancy}); if (doUPCanalysis) { histos.add("hGapSide", "Gap side; Entries", kTH1D, {{5, -0.5, 4.5}}); histos.add("hSelGapSide", "Selected gap side; Entries", kTH1D, {axisConfigurations.axisSelGap}); - histos.add("hEventCentralityVsSelGapSide", ";Centrality (%); Selected gap side", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisSelGap}); + histos.add("hEventCentralityVsSelGapSide", ";Centrality (%); Selected gap side", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisSelGap}); } histos.add("hInteractionRate", "hInteractionRate", kTH1D, {axisConfigurations.axisIRBinning}); - histos.add("hCentralityVsInteractionRate", "hCentralityVsInteractionRate", kTH2D, {{101, 0.0f, 101.0f}, axisConfigurations.axisIRBinning}); + histos.add("hCentralityVsInteractionRate", "hCentralityVsInteractionRate", kTH2D, {axisConfigurations.axisCentralityFine, axisConfigurations.axisIRBinning}); histos.add("hInteractionRateVsOccupancy", "hInteractionRateVsOccupancy", kTH2D, {axisConfigurations.axisIRBinning, axisConfigurations.axisOccupancy}); @@ -847,6 +855,11 @@ struct derivedlambdakzeroanalysis { hSelectionV0s->GetXaxis()->SetBinLabel(selPhysPrimAntiLambda + 2, "Phys. prim. #bar{#Lambda}"); hSelectionV0s->GetXaxis()->SetBinLabel(selPhysPrimAntiLambda + 3, "Cand. selected"); + if (doTOFQA) { + histos.add("hCollisionTimes", "hCollisionTimes", kTH1F, {{2000, -1000.0f, 1000.0f}}); + histos.add("hCollisionTimesError", "hCollisionTimesError", kTH1F, {{2000, -1000.0f, 1000.0f}}); + } + // histograms versus mass if (analyseK0Short) { histos.add("h2dNbrOfK0ShortVsCentrality", "h2dNbrOfK0ShortVsCentrality", kTH2D, {axisConfigurations.axisCentrality, {10, -0.5f, 9.5f}}); @@ -874,6 +887,8 @@ struct derivedlambdakzeroanalysis { histos.add("K0Short/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3D, {axisConfigurations.axisCentrality, axisConfigurations.axisPtCoarse, axisConfigurations.axisTPCsignal}); } if (doTOFQA) { + histos.add("K0Short/h1dPosNsigmaTOF", "h1dPosNsigmaTOF", kTH1D, {axisConfigurations.axisNsigmaTOF}); + histos.add("K0Short/h1dNegNsigmaTOF", "h1dNegNsigmaTOF", kTH1D, {axisConfigurations.axisNsigmaTOF}); histos.add("K0Short/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3D, {axisConfigurations.axisCentrality, axisConfigurations.axisPtCoarse, axisConfigurations.axisNsigmaTOF}); histos.add("K0Short/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3D, {axisConfigurations.axisCentrality, axisConfigurations.axisPtCoarse, axisConfigurations.axisNsigmaTOF}); histos.add("K0Short/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3D, {axisConfigurations.axisCentrality, axisConfigurations.axisPtCoarse, axisConfigurations.axisTOFdeltaT}); @@ -1245,7 +1260,9 @@ struct derivedlambdakzeroanalysis { } // ______________________________________________________ - // Return slicing output + // Return centrality estimate for a given collision. + // If takeMcCentrality is enabled, the centrality is taken from the MC collision; otherwise it is taken + // from the reconstructed collision. Returns -1 if no corresponding centrality estimator is found or if no MC collision is associated to the recoed collision. template auto getCentralityRun3(TCollision const& collision) { @@ -1946,6 +1963,8 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/h3dNegTPCsignalVsTrackPt"), centrality, v0.negativept(), negTrackExtra.tpcSignal()); } if (doTOFQA) { + histos.fill(HIST("K0Short/h1dPosNsigmaTOF"), v0.tofNSigmaK0PiPlus()); + histos.fill(HIST("K0Short/h1dNegNsigmaTOF"), v0.tofNSigmaK0PiMinus()); histos.fill(HIST("K0Short/h3dPosNsigmaTOF"), centrality, pt, v0.tofNSigmaK0PiPlus()); histos.fill(HIST("K0Short/h3dNegNsigmaTOF"), centrality, pt, v0.tofNSigmaK0PiMinus()); histos.fill(HIST("K0Short/h3dPosTOFdeltaT"), centrality, pt, v0.posTOFDeltaTK0Pi()); @@ -2672,6 +2691,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("hSelGapSide"), selGapSide); histos.fill(HIST("hEventCentralityVsSelGapSide"), centrality, selGapSide <= 2 ? selGapSide : -1); } + if (doTOFQA) { + histos.fill(HIST("hCollisionTimes"), collision.eventTime()); + histos.fill(HIST("hCollisionTimesError"), collision.eventTimeErr()); + } } else { // no, we are in Run 2 centrality = eventSelections.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); } @@ -3138,44 +3161,54 @@ struct derivedlambdakzeroanalysis { } } + // ______________________________________________________ + // Simulated processing in Run 2 (subscribes to MC information too) + void processAnalysedCollisions(aod::StraSelections const& straSelections) + { + for (auto const& straSelection : straSelections) { + histos.get(HIST("hEventPreSelection"))->AddBinContent(1, straSelection.totalNbrOfCollisions() /* all collisions */); + histos.get(HIST("hEventPreSelection"))->AddBinContent(2, straSelection.totalNbrOfSelCollisions() /* preselected collisions */); + } + } + // ______________________________________________________ // Real data processing in Run 3 - no MC subscription - void processRealDataRun3(soa::Join::iterator const& collision, V0Candidates const& fullV0s, DauTracks const&) + void processRealDataRun3(soa::Join::iterator const& collision, V0Candidates const& fullV0s, DauTracks const&) { analyzeRecoedV0sInRealData(collision, fullV0s); } // ______________________________________________________ // Real data processing in Run 2 - no MC subscription - void processRealDataRun2(soa::Join::iterator const& collision, V0Candidates const& fullV0s, DauTracks const&) + void processRealDataRun2(soa::Join::iterator const& collision, V0Candidates const& fullV0s, DauTracks const&) { analyzeRecoedV0sInRealData(collision, fullV0s); } // ______________________________________________________ // Simulated processing in Run 3 (subscribes to MC information too) - void processMonteCarloRun3(soa::Join::iterator const& collision, V0McCandidates const& fullV0s, DauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) + void processMonteCarloRun3(soa::Join::iterator const& collision, V0McCandidates const& fullV0s, DauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) { analyzeRecoedV0sInMonteCarlo(collision, fullV0s); } // ______________________________________________________ // Simulated processing in Run 2 (subscribes to MC information too) - void processMonteCarloRun2(soa::Join::iterator const& collision, V0McCandidates const& fullV0s, DauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) + void processMonteCarloRun2(soa::Join::iterator const& collision, V0McCandidates const& fullV0s, DauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) { analyzeRecoedV0sInMonteCarlo(collision, fullV0s); } // ______________________________________________________ // Simulated processing in Run 3 (subscribes to MC information too) - void processGeneratedRun3(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) + void processGeneratedRun3(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) { analyzeGeneratedV0s(mcCollisions, V0MCCores, CascMCCores, collisions); } // ______________________________________________________ // Simulated processing in Run 2 (subscribes to MC information too) - void processGeneratedRun2(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) + void processGeneratedRun2(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) { analyzeGeneratedV0s(mcCollisions, V0MCCores, CascMCCores, collisions); } @@ -3245,6 +3278,7 @@ struct derivedlambdakzeroanalysis { } } + PROCESS_SWITCH(derivedlambdakzeroanalysis, processAnalysedCollisions, "process filtered events for bookkeeping", false); PROCESS_SWITCH(derivedlambdakzeroanalysis, processRealDataRun3, "process as if real data in Run 3", true); PROCESS_SWITCH(derivedlambdakzeroanalysis, processRealDataRun2, "process as if real data in Run 2", false); PROCESS_SWITCH(derivedlambdakzeroanalysis, processMonteCarloRun3, "process as if MC in Run 3", false); diff --git a/PWGLF/Utils/strangenessBuilderModule.h b/PWGLF/Utils/strangenessBuilderModule.h index 980e13e4da8..63ee3198b6d 100644 --- a/PWGLF/Utils/strangenessBuilderModule.h +++ b/PWGLF/Utils/strangenessBuilderModule.h @@ -19,6 +19,8 @@ #include "PWGLF/DataModel/LFStrangenessTables.h" // IWYU pragma: keep #include "PWGLF/Utils/strangenessBuilderHelper.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/RCTSelectionFlags.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/TPCVDriftManager.h" @@ -427,6 +429,22 @@ struct preSelectOpts : o2::framework::ConfigurableGroup { o2::framework::Configurable maxTPCpidNsigma{"maxTPCpidNsigma", 5.0, "Maximum TPC PID N sigma (in abs value)"}; }; +// collision preselection options +struct eventSelectOpts : o2::framework::ConfigurableGroup { + std::string prefix = "eventSelectOpts"; // JSON group name + o2::framework::Configurable fillOnlySelectedCollisions{"fillOnlySelectedCollisions", false, "Fill only tables for selected collisions"}; + o2::framework::Configurable requireTriggerTVX{"requireTriggerTVX", false, "require FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level (Run 3 only)"}; + o2::framework::Configurable rejectITSROFBorder{"rejectITSROFBorder", false, "reject events at ITS ROF border (Run 3 only)"}; + o2::framework::Configurable rejectTFBorder{"rejectTFBorder", false, "reject events at TF border (Run 3 only)"}; + o2::framework::Configurable rejectSameBunchPileup{"rejectSameBunchPileup", false, "reject collisions in case of pileup with another collision in the same foundBC (Run 3 only)"}; + o2::framework::Configurable maxZVtxPosition{"maxZVtxPosition", 10., "max Z vtx position"}; + + o2::framework::Configurable cfgApplyRCTrequirement{"cfgApplyRCTrequirement", false, "Apply RCT requirement?"}; + o2::framework::Configurable cfgRCTLabel{"cfgRCTLabel", "", "Which detector condition requirements? (CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo)"}; + o2::framework::Configurable cfgCheckZDC{"cfgCheckZDC", false, "Include ZDC flags in the bit selection (for Pb-Pb only)"}; + o2::framework::Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; +}; + class BuilderModule { public: @@ -435,6 +453,37 @@ class BuilderModule // constructor } + template + bool isCollisionAccepted(TCollision collision) + // check whether the collision passes our collision selections + { + if (eventSelectOpts.requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + + if (eventSelectOpts.rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + + if (eventSelectOpts.rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + if (std::abs(collision.posZ()) > eventSelectOpts.maxZVtxPosition) { + return false; + } + + if (eventSelectOpts.rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + + if (!eventSelectOpts.cfgApplyRCTrequirement && !rctFlagsChecker(collision)) { + return false; + } + + return true; + } + // mass windows float getMassSigmaK0Short(float pt) { @@ -566,9 +615,12 @@ class BuilderModule o2::pwglf::strangenessbuilder::v0Configurables v0BuilderOpts; o2::pwglf::strangenessbuilder::cascadeConfigurables cascadeBuilderOpts; o2::pwglf::strangenessbuilder::preSelectOpts preSelectOpts; + o2::pwglf::strangenessbuilder::eventSelectOpts eventSelectOpts; - template - void init(TBaseConfigurables const& inputBaseOpts, TV0Configurables const& inputV0BuilderOpts, TCascadeConfigurables const& inputCascadeBuilderOpts, TPreSelOpts const& inputPreSelectOpts, THistoRegistry& histos, TInitContext& context) + o2::aod::rctsel::RCTFlagsChecker rctFlagsChecker; + + template + void init(TBaseConfigurables const& inputBaseOpts, TV0Configurables const& inputV0BuilderOpts, TCascadeConfigurables const& inputCascadeBuilderOpts, TPreSelOpts const& inputPreSelectOpts, TPreEventSelOpts const& inputEventSelectOpts, THistoRegistry& histos, TInitContext& context) { // read in configurations from the task where it's used // could be grouped even further, but should work @@ -576,6 +628,7 @@ class BuilderModule v0BuilderOpts = inputV0BuilderOpts; cascadeBuilderOpts = inputCascadeBuilderOpts; preSelectOpts = inputPreSelectOpts; + eventSelectOpts = inputEventSelectOpts; baseOpts.mEnabledTables.resize(nTables, 0); @@ -769,6 +822,11 @@ class BuilderModule // Set option to refit with material corrections straHelper.fitter.setRefitWithMatCorr(baseOpts.refitWithMaterialCorrection.value); + + // Initialise the RCTFlagsChecker + if (eventSelectOpts.cfgApplyRCTrequirement) { + rctFlagsChecker.init(eventSelectOpts.cfgRCTLabel.value, eventSelectOpts.cfgCheckZDC, eventSelectOpts.cfgTreatLimitedAcceptanceAsBad); + } } // for sorting @@ -1435,6 +1493,9 @@ class BuilderModule pvX = collision.posX(); pvY = collision.posY(); pvZ = collision.posZ(); + if (eventSelectOpts.fillOnlySelectedCollisions && !isCollisionAccepted(collision)) { + continue; + } if (v0BuilderOpts.generatePhotonCandidates && v0BuilderOpts.moveTPCOnlyTracks && collision.has_bc()) { mVDriftMgr.update(collision.template bc_as().timestamp()); } @@ -2009,6 +2070,11 @@ class BuilderModule pvX = collision.posX(); pvY = collision.posY(); pvZ = collision.posZ(); + if (eventSelectOpts.fillOnlySelectedCollisions && !isCollisionAccepted(collision)) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; + } } auto const& posTrack = tracks.rawIteratorAt(cascade.posTrackId); auto const& negTrack = tracks.rawIteratorAt(cascade.negTrackId); @@ -2467,6 +2533,11 @@ class BuilderModule pvX = collision.posX(); pvY = collision.posY(); pvZ = collision.posZ(); + if (eventSelectOpts.fillOnlySelectedCollisions && !isCollisionAccepted(collision)) { + products.kfcascdataLink(-1); + interlinks.cascadeToKFCascCores.push_back(-1); + continue; + } } auto const& posTrack = tracks.rawIteratorAt(cascade.posTrackId); auto const& negTrack = tracks.rawIteratorAt(cascade.negTrackId); @@ -2566,6 +2637,9 @@ class BuilderModule pvX = collision.posX(); pvY = collision.posY(); pvZ = collision.posZ(); + if (eventSelectOpts.fillOnlySelectedCollisions && !isCollisionAccepted(collision)) { + continue; + } } auto const& cascade = cascadeTrack.cascade(); auto const& v0 = cascade.v0();