Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PWGLF] strangeness derived data QA added #7955

Merged
merged 14 commits into from
Oct 11, 2024
9 changes: 9 additions & 0 deletions PWGLF/DataModel/LFStrangenessTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
namespace o2::aod
{

// for DF name follow-up and debug
namespace straorigin
{
DECLARE_SOA_COLUMN(DataframeID, dataframeID, uint64_t); //! Data frame ID (what is usually found in directory name in the AO2D.root, i.e.
} // namespace straorigin

DECLARE_SOA_TABLE(StraOrigins, "AOD", "STRAORIGIN", //! Table which contains the IDs of all dataframes merged into this dataframe
o2::soa::Index<>, straorigin::DataframeID);

namespace stracollision
{
DECLARE_SOA_DYNAMIC_COLUMN(IsUPC, isUPC, //! check whether this is a UPC or hadronic collision
Expand Down
67 changes: 41 additions & 26 deletions PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ struct strangederivedbuilder {
Produces<aod::V0FoundTags> v0FoundTags;
Produces<aod::CascFoundTags> cascFoundTags;

//__________________________________________________
// Debug
Produces<aod::StraOrigins> straOrigin;

// histogram registry for bookkeeping
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};

Expand Down Expand Up @@ -164,15 +168,17 @@ struct strangederivedbuilder {
Configurable<bool> roundNSigmaVariables{"roundNSigmaVariables", false, "round NSigma variables"};
Configurable<float> precisionNSigmas{"precisionNSigmas", 0.1f, "precision to keep NSigmas"};

Configurable<bool> fillRawFT0A{"fillRawFT0A", false, "Fill raw FT0A information for debug"};
Configurable<bool> fillRawFT0C{"fillRawFT0C", true, "Fill raw FT0C information for debug"};
Configurable<bool> fillRawFV0A{"fillRawFV0A", false, "Fill raw FV0A information for debug"};
Configurable<bool> fillRawFDDA{"fillRawFDDA", false, "Fill raw FDDA information for debug"};
Configurable<bool> fillRawFDDC{"fillRawFDDC", false, "Fill raw FDDC information for debug"};
Configurable<bool> fillRawZDC{"fillRawZDC", false, "Fill raw ZDC information for debug"};
Configurable<bool> fillRawNTracksEta1{"fillRawNTracksEta1", true, "Fill raw NTracks |eta|<1 information for debug"};
Configurable<bool> fillRawNTracksForCorrelation{"fillRawNTracksForCorrelation", true, "Fill raw NTracks for correlation cuts"};
Configurable<bool> fillTOFInformation{"fillTOFInformation", true, "Fill Daughter Track TOF information"};
struct : ConfigurableGroup {
Configurable<bool> fillRawFT0A{"fillRawFT0A", false, "Fill raw FT0A information for debug"};
Configurable<bool> fillRawFT0C{"fillRawFT0C", true, "Fill raw FT0C information for debug"};
Configurable<bool> fillRawFV0A{"fillRawFV0A", false, "Fill raw FV0A information for debug"};
Configurable<bool> fillRawFDDA{"fillRawFDDA", false, "Fill raw FDDA information for debug"};
Configurable<bool> fillRawFDDC{"fillRawFDDC", false, "Fill raw FDDC information for debug"};
Configurable<bool> fillRawZDC{"fillRawZDC", false, "Fill raw ZDC information for debug"};
Configurable<bool> fillRawNTracksEta1{"fillRawNTracksEta1", true, "Fill raw NTracks |eta|<1 information for debug"};
Configurable<bool> fillRawNTracksForCorrelation{"fillRawNTracksForCorrelation", true, "Fill raw NTracks for correlation cuts"};
Configurable<bool> fillTOFInformation{"fillTOFInformation", true, "Fill Daughter Track TOF information"};
} fillTruncationOptions;

Configurable<bool> qaCentrality{"qaCentrality", false, "qa centrality flag: check base raw values"};
struct : ConfigurableGroup {
Expand Down Expand Up @@ -347,23 +353,23 @@ struct strangederivedbuilder {
strangeCents(collision.centFT0M(), collision.centFT0A(),
centrality, collision.centFV0A());
strangeEvSels(collision.sel8(), collision.selection_raw(),
collision.multFT0A() * static_cast<float>(fillRawFT0A),
collision.multFT0C() * static_cast<float>(fillRawFT0C),
collision.multFV0A() * static_cast<float>(fillRawFV0A),
collision.multFDDA() * static_cast<float>(fillRawFDDA),
collision.multFDDC() * static_cast<float>(fillRawFDDC),
collision.multNTracksPVeta1() * static_cast<int>(fillRawNTracksEta1),
collision.multPVTotalContributors() * static_cast<int>(fillRawNTracksForCorrelation),
collision.multNTracksGlobal() * static_cast<int>(fillRawNTracksForCorrelation),
collision.multNTracksITSTPC() * static_cast<int>(fillRawNTracksForCorrelation),
collision.multAllTracksTPCOnly() * static_cast<int>(fillRawNTracksForCorrelation),
collision.multAllTracksITSTPC() * static_cast<int>(fillRawNTracksForCorrelation),
collision.multZNA() * static_cast<float>(fillRawZDC),
collision.multZNC() * static_cast<float>(fillRawZDC),
collision.multZEM1() * static_cast<float>(fillRawZDC),
collision.multZEM2() * static_cast<float>(fillRawZDC),
collision.multZPA() * static_cast<float>(fillRawZDC),
collision.multZPC() * static_cast<float>(fillRawZDC),
collision.multFT0A() * static_cast<float>(fillTruncationOptions.fillRawFT0A),
collision.multFT0C() * static_cast<float>(fillTruncationOptions.fillRawFT0C),
collision.multFV0A() * static_cast<float>(fillTruncationOptions.fillRawFV0A),
collision.multFDDA() * static_cast<float>(fillTruncationOptions.fillRawFDDA),
collision.multFDDC() * static_cast<float>(fillTruncationOptions.fillRawFDDC),
collision.multNTracksPVeta1() * static_cast<int>(fillTruncationOptions.fillRawNTracksEta1),
collision.multPVTotalContributors() * static_cast<int>(fillTruncationOptions.fillRawNTracksForCorrelation),
collision.multNTracksGlobal() * static_cast<int>(fillTruncationOptions.fillRawNTracksForCorrelation),
collision.multNTracksITSTPC() * static_cast<int>(fillTruncationOptions.fillRawNTracksForCorrelation),
collision.multAllTracksTPCOnly() * static_cast<int>(fillTruncationOptions.fillRawNTracksForCorrelation),
collision.multAllTracksITSTPC() * static_cast<int>(fillTruncationOptions.fillRawNTracksForCorrelation),
collision.multZNA() * static_cast<float>(fillTruncationOptions.fillRawZDC),
collision.multZNC() * static_cast<float>(fillTruncationOptions.fillRawZDC),
collision.multZEM1() * static_cast<float>(fillTruncationOptions.fillRawZDC),
collision.multZEM2() * static_cast<float>(fillTruncationOptions.fillRawZDC),
collision.multZPA() * static_cast<float>(fillTruncationOptions.fillRawZDC),
collision.multZPC() * static_cast<float>(fillTruncationOptions.fillRawZDC),
collision.trackOccupancyInTimeRange(),
// UPC info
gapSide,
Expand Down Expand Up @@ -864,6 +870,15 @@ struct strangederivedbuilder {
}
}

void processDataframeIDs(aod::Origins const& origins)
{
auto origin = origins.begin();
straOrigin(origin.dataframeID());
}

// debug processing
PROCESS_SWITCH(strangederivedbuilder, processDataframeIDs, "Produce data frame ID tags", false);

// collision processing
PROCESS_SWITCH(strangederivedbuilder, processCollisions, "Produce collisions", true);
PROCESS_SWITCH(strangederivedbuilder, processCollisionsWithUD, "Produce collisions with UD info", true);
Expand Down
5 changes: 5 additions & 0 deletions PWGLF/Tasks/QC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ o2physics_add_dpl_workflow(mc-particle-predictions
SOURCES mcParticlePrediction.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(strange-derived-qa
SOURCES strangederivedqa.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
158 changes: 158 additions & 0 deletions PWGLF/Tasks/QC/strangederivedqa.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// 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.
//
// V0 analysis task
// ================
//
// This code does basic QA of strangeness derived data

#include <Math/Vector4D.h>
#include <cmath>
#include <array>
#include <cstdlib>

#include <TFile.h>
#include <TH2F.h>
#include <TProfile.h>
#include <TLorentzVector.h>
#include <TPDGCode.h>
#include <TDatabasePDG.h>

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/ASoAHelpers.h"
#include "ReconstructionDataFormats/Track.h"
#include "CommonConstants/PhysicsConstants.h"
#include "Common/Core/trackUtilities.h"
#include "PWGLF/DataModel/LFStrangenessTables.h"

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace std;
using std::array;

struct strangederivedqa {
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};

ConfigurableAxis axisNCollisions{"axisNCollisions", {50000, -0.5f, 49999.5f}, "collisions"};
ConfigurableAxis axisNV0s{"axisNV0s", {50000, -0.5f, 49999.5f}, "V0s"};

Configurable<bool> verbose{"verbose", false, "do more printouts"};

void init(InitContext const&)
{
auto h = histos.add<TH1>("hDFCounter", "hDFCounter", kTH1D, {{6, -0.5f, 5.5f}});
h->GetXaxis()->SetBinLabel(1, "All");
h->GetXaxis()->SetBinLabel(2, "Ordered");
h->GetXaxis()->SetBinLabel(3, "Unordered");

auto h2 = histos.add<TH2>("hEventCounter", "hEventCounter", kTH2D, {{1, -0.5f, 0.5f}, {3, -0.5f, 2.5f}});
auto h3 = histos.add<TH2>("hEventsPerDF", "hEventsPerDF", kTH2D, {axisNCollisions, {3, -0.5f, 2.5f}});
auto h4 = histos.add<TH2>("hV0sPerDF", "hV0sPerDF", kTH2D, {axisNV0s, {3, -0.5f, 2.5f}});

h2->GetYaxis()->SetBinLabel(1, "All");
h2->GetYaxis()->SetBinLabel(2, "Ordered");
h2->GetYaxis()->SetBinLabel(3, "Unordered");
h3->GetYaxis()->SetBinLabel(1, "All");
h3->GetYaxis()->SetBinLabel(2, "Ordered");
h3->GetYaxis()->SetBinLabel(3, "Unordered");
h4->GetYaxis()->SetBinLabel(1, "All");
h4->GetYaxis()->SetBinLabel(2, "Ordered");
h4->GetYaxis()->SetBinLabel(3, "Unordered");
}

// Real data processing
void processOriginal(aod::Collisions const& collisions, aod::Origins const& origins, soa::Join<aod::V0Indices, aod::V0Cores> const& fullV0s)
{
histos.fill(HIST("hDFCounter"), 0.0f);
histos.fill(HIST("hEventCounter"), 0.0f, 0.0f, collisions.size());
histos.fill(HIST("hEventsPerDF"), collisions.size(), 0.0f);
histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 0.0f);
bool ordered = true;
int previousIndex = -100;
for (auto const& v0 : fullV0s) {
if (v0.collisionId() < previousIndex) {
ordered = false;
}
previousIndex = v0.collisionId();
}
if (ordered) {
histos.fill(HIST("hEventCounter"), 0.0f, 1.0f, collisions.size());
histos.fill(HIST("hEventsPerDF"), collisions.size(), 1.0f);
histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 1.0f);

if (verbose) {
auto origin = origins.begin();
LOGF(info, "Sorted DF ID: %lld collisions: %i V0s: %i", origin.dataframeID(), collisions.size(), fullV0s.size());
}
} else {
histos.fill(HIST("hEventCounter"), 0.0f, 2.0f, collisions.size());
histos.fill(HIST("hEventsPerDF"), collisions.size(), 2.0f);
histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 2.0f);

if (verbose) {
auto origin = origins.begin();
LOGF(info, "Unsorted DF ID: %lld collisions: %i V0s: %i", origin.dataframeID(), collisions.size(), fullV0s.size());
}
}
}

// Real data processing
void processDerived(aod::StraCollisions const& collisions, aod::StraOrigins const& origins, soa::Join<aod::V0CollRefs, aod::V0Cores> const& fullV0s)
{
histos.fill(HIST("hDFCounter"), 0.0f);
histos.fill(HIST("hEventCounter"), 0.0f, 0.0f, collisions.size());
histos.fill(HIST("hEventsPerDF"), collisions.size(), 0.0f);
histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 0.0f);
bool ordered = true;
int previousIndex = -100;
for (auto const& v0 : fullV0s) {
if (v0.straCollisionId() < previousIndex) {
ordered = false;
}
previousIndex = v0.straCollisionId();
}
if (ordered) {
histos.fill(HIST("hEventCounter"), 0.0f, 1.0f, collisions.size());
histos.fill(HIST("hEventsPerDF"), collisions.size(), 1.0f);
histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 1.0f);

if (verbose) {
auto origin = origins.begin();
LOGF(info, "Sorted DF ID: %lld collisions: %i V0s: %i Origins size: %i", origin.dataframeID(), collisions.size(), fullV0s.size(), origins.size());
}
} else {
histos.fill(HIST("hEventCounter"), 0.0f, 2.0f, collisions.size());
histos.fill(HIST("hEventsPerDF"), collisions.size(), 2.0f);
histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 2.0f);

if (verbose) {
auto origin = origins.begin();
LOGF(info, "Unsorted DF ID: %lld collisions: %i V0s: %i Origins size: %i", origin.dataframeID(), collisions.size(), fullV0s.size(), origins.size());
uint64_t directoryName = origin.dataframeID();
for (auto const& orig : origins) {
LOGF(info, "Unsorted DF ID: %lld separate origin: %lld", directoryName, orig.dataframeID());
}
}
}
}

PROCESS_SWITCH(strangederivedqa, processOriginal, "Process original data", false);
PROCESS_SWITCH(strangederivedqa, processDerived, "Process derived data", true);
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<strangederivedqa>(cfgc)};
}
Loading