From 0460fcc4265808f33e0e90f697938eca55ff6f03 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Thu, 25 Apr 2024 02:34:13 +0200 Subject: [PATCH] Common: add run 3 centrality study task (#5834) * Common: add run 3 centrality study task * forgot git add... * Please consider the following formatting changes (#280) * Add basic 2d qa * Please consider the following formatting changes (#281) --------- Co-authored-by: ALICE Builder --- Common/Tasks/CMakeLists.txt | 5 + Common/Tasks/centralityStudy.cxx | 168 +++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 Common/Tasks/centralityStudy.cxx diff --git a/Common/Tasks/CMakeLists.txt b/Common/Tasks/CMakeLists.txt index 6c15bf176fa..2884d3b8b31 100644 --- a/Common/Tasks/CMakeLists.txt +++ b/Common/Tasks/CMakeLists.txt @@ -78,3 +78,8 @@ o2physics_add_dpl_workflow(qvectors-correction SOURCES qVectorsCorrection.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(centrality-study + SOURCES centralityStudy.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/Common/Tasks/centralityStudy.cxx b/Common/Tasks/centralityStudy.cxx new file mode 100644 index 00000000000..9a87e1c5b7d --- /dev/null +++ b/Common/Tasks/centralityStudy.cxx @@ -0,0 +1,168 @@ +// 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. +// +// This task does dedicated centrality studies for understanding the +// Run 3 Pb-Pb centrality selections in 2023 data. It is compatible with +// derived data. + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/EventSelection.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "TH1F.h" +#include "TH2F.h" + +using namespace o2; +using namespace o2::framework; + +using BCsWithRun3Matchings = soa::Join; + +struct centralityStudy { + // Raw multiplicities + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Configurables + Configurable do2DPlots{"do2DPlots", true, "0 - no, 1 - yes"}; + Configurable applySel8{"applySel8", true, "0 - no, 1 - yes"}; + Configurable applyVtxZ{"applyVtxZ", true, "0 - no, 1 - yes"}; + + // Apply extra event selections + Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; + Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", true, "require events with at least one ITS-TPC track"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", true, "require events with at least one of vertex contributors matched to TOF"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", true, "require events with at least one of vertex contributors matched to TRD"}; + Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; + + // Configurable Axes + ConfigurableAxis axisMultFT0C{"axisMultFT0C", {2000, 0, 100000}, "FT0C amplitude"}; + ConfigurableAxis axisMultPVContributors{"axisMultPVContributors", {200, 0, 6000}, "Number of PV Contributors"}; + ConfigurableAxis axisMultITSOnly{"axisMultITSOnly", {200, 0, 6000}, "Number of ITS only tracks"}; + ConfigurableAxis axisMultITSTPC{"axisMultITSTPC", {200, 0, 6000}, "Number of ITSTPC matched tracks"}; + + void init(InitContext&) + { + if (doprocessCollisions) { + const AxisSpec axisCollisions{100, -0.5f, 99.5f, "Number of collisions"}; + histos.add("hCollisionSelection", "hCollisionSelection", kTH1D, {{10, -0.5f, +9.5f}}); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(6, "kIsVertexITSTPC"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(7, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(8, "kIsVertexTOFmatched"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup"); + + histos.add("hFT0C_Collisions", "hFT0C_Collisions", kTH1D, {axisMultFT0C}); + } + + if (doprocessBCs) { + histos.add("hBCSelection", "hBCSelection", kTH1D, {{10, -0.5, 9.5f}}); + histos.add("hFT0C_BCs", "hFT0C_BCs", kTH1D, {axisMultFT0C}); + } + + if (do2DPlots) { + histos.add("hFT0CvsNContribs", "hFT0CvsNContribs", kTH2F, {axisMultPVContributors, axisMultFT0C}); + histos.add("hMatchedVsITSOnly", "hMatchedVsITSOnly", kTH2F, {axisMultITSOnly, axisMultITSTPC}); + } + } + + void processCollisions(soa::Join::iterator const& collision) + { + histos.fill(HIST("hCollisionSelection"), 0); // all collisions + if (applySel8 && !collision.multSel8()) + return; + histos.fill(HIST("hCollisionSelection"), 1); + if (applyVtxZ && TMath::Abs(collision.multPVz()) > 10) + return; + histos.fill(HIST("hCollisionSelection"), 2); + + // _______________________________________________________ + // Extra event selections start here + if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 3 /* Not at ITS ROF border */); + + if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 4 /* Not at TF border */); + + if (requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 5 /* Contains at least one ITS-TPC track */); + + if (requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 6 /* PV position consistency check */); + + if (requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 7 /* PV with at least one contributor matched with TOF */); + + if (requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 8 /* PV with at least one contributor matched with TRD */); + + if (rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 9 /* Not at same bunch pile-up */); + + // if we got here, we also finally fill the FT0C histogram, please + histos.fill(HIST("hFT0C_Collisions"), collision.multFT0C() /* Not at same bunch pile-up */); + + if (do2DPlots) { + histos.fill(HIST("hFT0CvsNContribs"), collision.multNTracksPV(), collision.multFT0C()); + histos.fill(HIST("hMatchedVsITSOnly"), collision.multNTracksITSOnly(), collision.multNTracksITSTPC()); + } + } + + void processBCs(aod::MultsBC::iterator const& multbc) + { + // process BCs, calculate FT0C distribution + // conditionals suggested by FIT team (Jacek O. et al) + histos.fill(HIST("hBCSelection"), 0); // all BCs + if (!multbc.multBCColliding()) + return; + histos.fill(HIST("hBCSelection"), 1); // colliding + if (!multbc.multBCTVX()) + return; + histos.fill(HIST("hBCSelection"), 2); // TVX + if (!multbc.multBCFV0OrA()) + return; + histos.fill(HIST("hBCSelection"), 3); // FV0OrA + + // if we got here, we also finally fill the FT0C histogram, please + histos.fill(HIST("hFT0C_BCs"), multbc.multBCFT0C()); + } + + PROCESS_SWITCH(centralityStudy, processCollisions, "per-collision analysis", true); + PROCESS_SWITCH(centralityStudy, processBCs, "per-BC analysis", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +}