Skip to content

Commit

Permalink
Common: extra centrality study histos (AliceO2Group#5956)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ddobrigk and alibuild authored May 2, 2024
1 parent 13610f9 commit e2aa3f4
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Common/DataModel/Multiplicity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 33 additions & 1 deletion Common/TableProducer/multiplicityExtraTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches;

struct MultiplicityExtraTable {
Produces<aod::MultsBC> multBC;
Produces<aod::MultNeighs> multNeigh;

o2::ccdb::CcdbApi ccdbApi;
Service<o2::ccdb::BasicCCDBManager> ccdb;
Expand All @@ -50,7 +51,7 @@ struct MultiplicityExtraTable {

using BCsWithRun3Matchings = soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse>;

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;
Expand Down Expand Up @@ -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<float> 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)
Expand Down
58 changes: 56 additions & 2 deletions Common/Tasks/centralityStudy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -45,6 +46,7 @@ struct centralityStudy {
Configurable<bool> requireIsVertexTOFmatched{"requireIsVertexTOFmatched", true, "require events with at least one of vertex contributors matched to TOF"};
Configurable<bool> requireIsVertexTRDmatched{"requireIsVertexTRDmatched", true, "require events with at least one of vertex contributors matched to TRD"};
Configurable<bool> rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"};
Configurable<float> 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"};
Expand All @@ -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<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(1, "All collisions");
histos.get<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut");
histos.get<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut");
Expand All @@ -72,6 +79,7 @@ struct centralityStudy {
histos.get<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(8, "kIsVertexTOFmatched");
histos.get<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched");
histos.get<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup");
histos.get<TH1>(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(11, "Neighbour rejection");

histos.add("hFT0C_Collisions", "hFT0C_Collisions", kTH1D, {axisMultUltraFineFT0C});
histos.add("hNPVContributors", "hNPVContributors", kTH1D, {axisMultUltraFinePVContributors});
Expand All @@ -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<aod::Mults, aod::MultsExtra, aod::MultSelections>::iterator const& collision)
template <typename TCollision>
void genericProcessCollision(TCollision collision)
// process this collisions
{

histos.fill(HIST("hCollisionSelection"), 0); // all collisions
if (applySel8 && !collision.multSel8())
return;
Expand Down Expand Up @@ -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());
Expand All @@ -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<aod::Mults, aod::MultsExtra, aod::MultSelections>::iterator const& collision)
{
genericProcessCollision(collision);
}

void processCollisionsWithCentrality(soa::Join<aod::Mults, aod::MultsExtra, aod::MultSelections, aod::CentFT0Cs, aod::MultsGlobal, aod::MultNeighs>::iterator const& collision)
{
genericProcessCollision(collision);
}

void processBCs(aod::MultsBC::iterator const& multbc)
Expand All @@ -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);
};

Expand Down

0 comments on commit e2aa3f4

Please sign in to comment.