From e2aa3f477270320d3b40b4c1deb7c838cc9577a1 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Thu, 2 May 2024 22:09:52 +0200 Subject: [PATCH] Common: extra centrality study histos (#5956) * Common: extra centrality study histos * Please consider the following formatting changes (#286) * Some extra debug functionality * Please consider the following formatting changes (#287) --------- Co-authored-by: ALICE Builder --- Common/DataModel/Multiplicity.h | 10 ++++ .../TableProducer/multiplicityExtraTable.cxx | 34 ++++++++++- Common/Tasks/centralityStudy.cxx | 58 ++++++++++++++++++- 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/Common/DataModel/Multiplicity.h b/Common/DataModel/Multiplicity.h index 23e8e043af3..44097a15f6b 100644 --- a/Common/DataModel/Multiplicity.h +++ b/Common/DataModel/Multiplicity.h @@ -75,6 +75,12 @@ DECLARE_SOA_COLUMN(MultNTracksGlobal, multNTracksGlobal, int); //! DECLARE_SOA_COLUMN(BCNumber, bcNumber, int); //! +// even further QA: timing information for neighboring events +DECLARE_SOA_COLUMN(TimeToPrePrevious, timeToPrePrevious, float); //! +DECLARE_SOA_COLUMN(TimeToPrevious, timeToPrevious, float); //! +DECLARE_SOA_COLUMN(TimeToNext, timeToNext, float); //! +DECLARE_SOA_COLUMN(TimeToNeNext, timeToNeNext, float); //! + } // namespace mult DECLARE_SOA_TABLE(FV0Mults, "AOD", "FV0MULT", //! Multiplicity with the FV0 detector mult::MultFV0A, mult::MultFV0C, @@ -109,6 +115,10 @@ DECLARE_SOA_TABLE(MultsExtra, "AOD", "MULTEXTRA", //! mult::MultAllTracksTPCOnly, mult::MultAllTracksITSTPC, mult::BCNumber); +DECLARE_SOA_TABLE(MultNeighs, "AOD", "MULTNEIGH", //! + mult::TimeToPrePrevious, mult::TimeToPrevious, + mult::TimeToNext, mult::TimeToNeNext); + // for QA purposes DECLARE_SOA_TABLE(MultsGlobal, "AOD", "MULTGLOBAL", //! counters that use Track Selection (optional) mult::MultNTracksGlobal); diff --git a/Common/TableProducer/multiplicityExtraTable.cxx b/Common/TableProducer/multiplicityExtraTable.cxx index 5948347779c..fcbacf7b80e 100644 --- a/Common/TableProducer/multiplicityExtraTable.cxx +++ b/Common/TableProducer/multiplicityExtraTable.cxx @@ -32,6 +32,7 @@ const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; struct MultiplicityExtraTable { Produces multBC; + Produces multNeigh; o2::ccdb::CcdbApi ccdbApi; Service ccdb; @@ -50,7 +51,7 @@ struct MultiplicityExtraTable { using BCsWithRun3Matchings = soa::Join; - void process(BCsWithRun3Matchings::iterator const& bc, aod::FV0As const&, aod::FT0s const&, aod::FDDs const&, aod::Zdcs const&) + void processBCs(BCsWithRun3Matchings::iterator const& bc, aod::FV0As const&, aod::FT0s const&, aod::FDDs const&, aod::Zdcs const&) { bool Tvx = false; bool isFV0OrA = false; @@ -153,6 +154,37 @@ struct MultiplicityExtraTable { multBC(multFT0A, multFT0C, multFV0A, multFDDA, multFDDC, multZNA, multZNC, multZEM1, multZEM2, multZPA, multZPC, Tvx, isFV0OrA, multFV0TriggerBits, multFT0TriggerBits, multFDDTriggerBits, multBCTriggerMask, collidingBC); } + + void processCollisionNeighbors(aod::Collisions const& collisions) + { + std::vector timeArray; + timeArray.resize(collisions.size(), 1e+3); + + for (const auto& collision : collisions) { + timeArray[collision.globalIndex()] = collision.collisionTime(); + } + + float deltaPrevious = 1e+6, deltaPrePrevious = 1e+6; + float deltaNext = 1e+6, deltaNeNext = 1e+6; + for (const auto& collision : collisions) { + int ii = collision.globalIndex(); + + if (ii - 1 >= 0) + deltaPrevious = timeArray[ii] - timeArray[ii - 1]; + if (ii - 2 >= 0) + deltaPrePrevious = timeArray[ii] - timeArray[ii - 2]; + if (ii + 1 < collisions.size()) + deltaNext = timeArray[ii + 1] - timeArray[ii]; + if (ii + 2 < collisions.size()) + deltaNeNext = timeArray[ii + 2] - timeArray[ii]; + + multNeigh(deltaPrePrevious, deltaPrevious, deltaNext, deltaNeNext); + } + } + + // Process switches + PROCESS_SWITCH(MultiplicityExtraTable, processBCs, "Produce BC tables", true); + PROCESS_SWITCH(MultiplicityExtraTable, processCollisionNeighbors, "Produce neighbor timing tables", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/Common/Tasks/centralityStudy.cxx b/Common/Tasks/centralityStudy.cxx index 9c47ee53562..b48d2a3c90f 100644 --- a/Common/Tasks/centralityStudy.cxx +++ b/Common/Tasks/centralityStudy.cxx @@ -18,6 +18,7 @@ #include "Framework/AnalysisDataModel.h" #include "Common/DataModel/McCollisionExtra.h" #include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Framework/O2DatabasePDGPlugin.h" #include "TH1F.h" @@ -45,6 +46,7 @@ struct centralityStudy { 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 minTimeDelta{"minTimeDelta", -1.0f, "reject collision if another collision is this close or less in time"}; // Configurable Axes ConfigurableAxis axisMultFT0C{"axisMultFT0C", {2000, 0, 100000}, "FT0C amplitude"}; @@ -57,11 +59,16 @@ struct centralityStudy { ConfigurableAxis axisMultITSOnly{"axisMultITSOnly", {200, 0, 6000}, "Number of ITS only tracks"}; ConfigurableAxis axisMultITSTPC{"axisMultITSTPC", {200, 0, 6000}, "Number of ITSTPC matched tracks"}; + // For centrality studies if requested + ConfigurableAxis axisCentrality{"axisCentrality", {100, 0, 100}, "FT0C percentile"}; + ConfigurableAxis axisPVChi2{"axisPVChi2", {300, 0, 30}, "FT0C percentile"}; + ConfigurableAxis axisDeltaTime{"axisDeltaTime", {300, 0, 300}, "#Delta time"}; + 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.add("hCollisionSelection", "hCollisionSelection", kTH1D, {{20, -0.5f, +19.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"); @@ -72,6 +79,7 @@ struct centralityStudy { 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.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(11, "Neighbour rejection"); histos.add("hFT0C_Collisions", "hFT0C_Collisions", kTH1D, {axisMultUltraFineFT0C}); histos.add("hNPVContributors", "hNPVContributors", kTH1D, {axisMultUltraFinePVContributors}); @@ -86,10 +94,23 @@ struct centralityStudy { histos.add("hFT0CvsNContribs", "hFT0CvsNContribs", kTH2F, {axisMultPVContributors, axisMultFT0C}); histos.add("hMatchedVsITSOnly", "hMatchedVsITSOnly", kTH2F, {axisMultITSOnly, axisMultITSTPC}); } + + if (doprocessCollisionsWithCentrality) { + // in case requested: do vs centrality debugging + histos.add("hNContribsVsCentrality", "hNContribsVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); + histos.add("hNITSTPCTracksVsCentrality", "hNITSTPCTracksVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); + histos.add("hNITSOnlyTracksVsCentrality", "hNITSOnlyTracksVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); + histos.add("hNGlobalTracksVsCentrality", "hNGlobalTracksVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); + histos.add("hPVChi2VsCentrality", "hPVChi2VsCentrality", kTH2F, {axisCentrality, axisPVChi2}); + histos.add("hDeltaTimeVsCentrality", "hDeltaTimeVsCentrality", kTH2F, {axisCentrality, axisDeltaTime}); + } } - void processCollisions(soa::Join::iterator const& collision) + template + void genericProcessCollision(TCollision collision) + // process this collisions { + histos.fill(HIST("hCollisionSelection"), 0); // all collisions if (applySel8 && !collision.multSel8()) return; @@ -135,6 +156,18 @@ struct centralityStudy { } histos.fill(HIST("hCollisionSelection"), 9 /* Not at same bunch pile-up */); + // do this only if information is available + if constexpr (requires { collision.timeToNext(); }) { + float timeToNeighbour = TMath::Min( + std::abs(collision.timeToNext()), + std::abs(collision.timeToPrevious())); + histos.fill(HIST("hDeltaTimeVsCentrality"), collision.centFT0C(), timeToNeighbour); + if (timeToNeighbour < minTimeDelta) { + return; + } + histos.fill(HIST("hCollisionSelection"), 10 /* has suspicious neighbour */); + } + // if we got here, we also finally fill the FT0C histogram, please histos.fill(HIST("hNPVContributors"), collision.multPVTotalContributors()); histos.fill(HIST("hFT0C_Collisions"), collision.multFT0C()); @@ -143,6 +176,26 @@ struct centralityStudy { histos.fill(HIST("hFT0CvsNContribs"), collision.multNTracksPV(), collision.multFT0C()); histos.fill(HIST("hMatchedVsITSOnly"), collision.multNTracksITSOnly(), collision.multNTracksITSTPC()); } + + // if the table has centrality information + if constexpr (requires { collision.centFT0C(); }) { + // process FT0C centrality plots + histos.fill(HIST("hNContribsVsCentrality"), collision.centFT0C(), collision.multPVTotalContributors()); + histos.fill(HIST("hNITSTPCTracksVsCentrality"), collision.centFT0C(), collision.multNTracksITSOnly()); + histos.fill(HIST("hNITSOnlyTracksVsCentrality"), collision.centFT0C(), collision.multNTracksITSOnly()); + histos.fill(HIST("hNGlobalTracksVsCentrality"), collision.centFT0C(), collision.multNTracksGlobal()); + histos.fill(HIST("hPVChi2VsCentrality"), collision.centFT0C(), collision.multPVChi2()); + } + } + + void processCollisions(soa::Join::iterator const& collision) + { + genericProcessCollision(collision); + } + + void processCollisionsWithCentrality(soa::Join::iterator const& collision) + { + genericProcessCollision(collision); } void processBCs(aod::MultsBC::iterator const& multbc) @@ -165,6 +218,7 @@ struct centralityStudy { } PROCESS_SWITCH(centralityStudy, processCollisions, "per-collision analysis", true); + PROCESS_SWITCH(centralityStudy, processCollisionsWithCentrality, "per-collision analysis", true); PROCESS_SWITCH(centralityStudy, processBCs, "per-BC analysis", true); };