Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Archita-Dash committed Jan 6, 2025
2 parents 565be19 + a477ab1 commit ec36dfa
Show file tree
Hide file tree
Showing 69 changed files with 5,406 additions and 1,971 deletions.
5 changes: 5 additions & 0 deletions Common/LegacyDataQA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ o2physics_add_dpl_workflow(otfv0qa
o2physics_add_dpl_workflow(centqa
SOURCES centqa.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(tpcpidqa
SOURCES tpcpidqa.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
36 changes: 18 additions & 18 deletions Common/LegacyDataQA/otfv0qa.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
// 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 code calculates output histograms for centrality calibration
// as well as vertex-Z dependencies of raw variables (either for calibration
// of vtx-Z dependencies or for the calibration of those).
//
// This task is not strictly necessary in a typical analysis workflow,
// except for centrality calibration! The necessary task is the multiplicity
// tables.
//
// Comments, suggestions, questions? Please write to:
// - [email protected]
// - [email protected]
//

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
Expand All @@ -39,20 +26,33 @@ struct OTFV0Qa {
// Raw multiplicities
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};

Configurable<float> maxGammaMassForXYplot{"maxGammaMassForXYplot", 0.1f, "Max photon mass for XY plot"};

ConfigurableAxis axisNCandidates{"axisNCandidates", {500, 0, 500}, "Number of OTF v0s"};
ConfigurableAxis axisPosition{"axisPosition", {1000, -100, 100}, "position (cm)"};
ConfigurableAxis axisMass{"axisMass", {100, 0.0f, 1.0f}, "Mass (GeV/c2)"};

void init(InitContext&)
{
const AxisSpec axisEvent{10, 0, 10, "Event counter"};
const AxisSpec axisNCandidates{500, 0, 500, "Number of OTF v0s"};
const AxisSpec axisPVz{30, -15, 15, "Primary vertex Z (cm)"};

// Base histograms
histos.add("hEventCounter", "Event counter", kTH1F, {axisEvent});
histos.add("hPrimaryVertexZ", "Event counter", kTH1F, {axisPVz});
histos.add("hCandidates", "Number of OTF V0s", kTH1F, {axisNCandidates});
histos.add("hGammaMass", "mass distribution", kTH1F, {axisMass});
histos.add("h2dPosition", "xy positions", kTH2F, {axisPosition, axisPosition});
}

void process(aod::Collision const&, aod::Run2OTFV0s const& v0s)
void process(aod::Collision const& collision, aod::Run2OTFV0s const& v0s)
{
histos.fill(HIST("hEventCounter"), 0.5);
histos.fill(HIST("hPrimaryVertexZ"), collision.posZ());
histos.fill(HIST("hCandidates"), v0s.size());
for (auto const& v0 : v0s) {
histos.fill(HIST("hGammaMass"), v0.mass());
if (v0.mass() < maxGammaMassForXYplot) {
histos.fill(HIST("h2dPosition"), v0.x(), v0.y());
}
}
}
};

Expand Down
119 changes: 119 additions & 0 deletions Common/LegacyDataQA/tpcpidqa.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// 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 converts tiny PID tables into full PID tables.
// It is meant to be used with Run 2 converted data to maintain
// full compatibility with any task that may subscribe to the Full
// tables (at the cost of some memory consumption).
// It is also able to produce very simple QA plots on the stored
// quantities (optionally disabled for simplicity)
//
// Warning: expected resolution is NOT provided.

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include "Common/DataModel/PIDResponse.h"
#include "TableHelper.h"

using namespace o2;
using namespace o2::framework;

using tinyPidTracks = soa::Join<aod::Tracks, aod::pidTPCFullEl, aod::pidTPCFullMu, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullTr, aod::pidTPCFullHe, aod::pidTPCFullAl>;

static constexpr int nParameters = 1;
static const std::vector<std::string> tableNames{"Electron", // 0
"Muon", // 1
"Pion", // 2
"Kaon", // 3
"Proton", // 4
"Deuteron", // 5
"Triton", // 6
"Helium", // 7
"Alpha"}; // 8
static const std::vector<std::string> parameterNames{"enable"};
static const int defaultParameters[9][nParameters]{{0}, {0}, {1}, {1}, {1}, {0}, {0}, {0}, {0}};

static constexpr int kPidEl = 0;
static constexpr int kPidMu = 1;
static constexpr int kPidPi = 2;
static constexpr int kPidKa = 3;
static constexpr int kPidPr = 4;
static constexpr int kPidDe = 5;
static constexpr int kPidTr = 6;
static constexpr int kPidHe = 7;
static constexpr int kPidAl = 8;
static constexpr int nTables = 9;

struct TpcPidQa {
Configurable<LabeledArray<int>> enabledTables{"enabledTables",
{defaultParameters[0], nTables, nParameters, tableNames, parameterNames},
"Produce QA for this species: 0 - no, 1 - yes"};
std::vector<int> mEnabledTables; // Vector of enabled tables

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

ConfigurableAxis axisMomentum{"axisMomentum", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "momentum"};

ConfigurableAxis axisNSigma{"axisNSigma", {48, -6.0f, 6.0f}, "axisNSigma"};

void init(InitContext&)
{
mEnabledTables.resize(9, 0);

for (int i = 0; i < nTables; i++) {
int f = enabledTables->get(tableNames[i].c_str(), "enable");
if (f == 1) {
mEnabledTables[i] = 1;
histos.add(fmt::format("hNSigmaVsPTot{}", tableNames[i]).c_str(), "", kTH2F, {axisMomentum, axisNSigma});
}
}
}

void process(tinyPidTracks const& tracks)
{
for (const auto& track : tracks) {
if (mEnabledTables[kPidEl]) {
histos.fill(HIST("hNSigmaVsPTotElectron"), track.p(), track.tpcNSigmaEl());
}
if (mEnabledTables[kPidMu]) {
histos.fill(HIST("hNSigmaVsPTotMuon"), track.p(), track.tpcNSigmaMu());
}
if (mEnabledTables[kPidPi]) {
histos.fill(HIST("hNSigmaVsPTotPion"), track.p(), track.tpcNSigmaPi());
}
if (mEnabledTables[kPidKa]) {
histos.fill(HIST("hNSigmaVsPTotKaon"), track.p(), track.tpcNSigmaKa());
}
if (mEnabledTables[kPidPr]) {
histos.fill(HIST("hNSigmaVsPTotProton"), track.p(), track.tpcNSigmaPr());
}
if (mEnabledTables[kPidDe]) {
histos.fill(HIST("hNSigmaVsPTotDeuteron"), track.p(), track.tpcNSigmaDe());
}
if (mEnabledTables[kPidTr]) {
histos.fill(HIST("hNSigmaVsPTotTriton"), track.p(), track.tpcNSigmaTr());
}
if (mEnabledTables[kPidHe]) {
histos.fill(HIST("hNSigmaVsPTotHelium"), track.p(), track.tpcNSigmaHe());
}
if (mEnabledTables[kPidAl]) {
histos.fill(HIST("hNSigmaVsPTotAlpha"), track.p(), track.tpcNSigmaAl());
}
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<TpcPidQa>(cfgc)};
}
4 changes: 4 additions & 0 deletions Common/TableProducer/Converters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ o2physics_add_dpl_workflow(run2-tracks-extra-converter
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(run2-tiny-to-full-pid
SOURCES run2TinyToFullPID.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
166 changes: 166 additions & 0 deletions Common/TableProducer/Converters/run2TinyToFullPID.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// 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 converts tiny PID tables into full PID tables.
// It is meant to be used with Run 2 converted data to maintain
// full compatibility with any task that may subscribe to the Full
// tables (at the cost of some memory consumption).
// It is also able to produce very simple QA plots on the stored
// quantities (optionally disabled for simplicity)
//
// Warning: expected resolution is NOT provided.

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include "Common/DataModel/PIDResponse.h"
#include "TableHelper.h"

using namespace o2;
using namespace o2::framework;

using tinyPidTracks = soa::Join<aod::Tracks, aod::pidTPCEl, aod::pidTPCMu, aod::pidTPCPi, aod::pidTPCKa, aod::pidTPCPr, aod::pidTPCDe, aod::pidTPCTr, aod::pidTPCHe, aod::pidTPCAl>;

static constexpr int kPidEl = 0;
static constexpr int kPidMu = 1;
static constexpr int kPidPi = 2;
static constexpr int kPidKa = 3;
static constexpr int kPidPr = 4;
static constexpr int kPidDe = 5;
static constexpr int kPidTr = 6;
static constexpr int kPidHe = 7;
static constexpr int kPidAl = 8;
static constexpr int nTables = 9;

static constexpr int nParameters = 1;
static const std::vector<std::string> tableNames{"pidTPCFullEl", // 0
"pidTPCFullMu", // 1
"pidTPCFullPi", // 2
"pidTPCFullKa", // 3
"pidTPCFullPr", // 4
"pidTPCFullDe", // 5
"pidTPCFullTr", // 6
"pidTPCFullHe", // 7
"pidTPCFullAl"}; // 8
static const std::vector<std::string> parameterNames{"enable"};
static const int defaultParameters[nTables][nParameters]{{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}};

struct Run2TinyToFullPID {
Produces<aod::pidTPCFullEl> pidTPCFullEl;
Produces<aod::pidTPCFullMu> pidTPCFullMu;
Produces<aod::pidTPCFullPi> pidTPCFullPi;
Produces<aod::pidTPCFullKa> pidTPCFullKa;
Produces<aod::pidTPCFullPr> pidTPCFullPr;
Produces<aod::pidTPCFullDe> pidTPCFullDe;
Produces<aod::pidTPCFullTr> pidTPCFullTr;
Produces<aod::pidTPCFullHe> pidTPCFullHe;
Produces<aod::pidTPCFullAl> pidTPCFullAl;

Configurable<LabeledArray<int>> enabledTables{"enabledTables",
{defaultParameters[0], nTables, nParameters, tableNames, parameterNames},
"Produce full PID tables depending on needs. Autodetect is -1, Force no is 0 and force yes is 1."};

std::vector<int> mEnabledTables; // Vector of enabled tables

void init(InitContext& context)
{
for (int i = 0; i < nTables; i++) {
LOGF(info, "test %i", i);
int f = enabledTables->get(tableNames[i].c_str(), "enable");
enableFlagIfTableRequired(context, tableNames[i], f);
if (f == 1) {
mEnabledTables.push_back(i);
}
}
}

void process(tinyPidTracks const& tracks)
{
// reserve memory
for (auto i : mEnabledTables) {
switch (i) {
case kPidEl:
pidTPCFullEl.reserve(tracks.size());
break;
case kPidMu:
pidTPCFullMu.reserve(tracks.size());
break;
case kPidPi:
pidTPCFullPi.reserve(tracks.size());
break;
case kPidKa:
pidTPCFullKa.reserve(tracks.size());
break;
case kPidPr:
pidTPCFullPr.reserve(tracks.size());
break;
case kPidDe:
pidTPCFullDe.reserve(tracks.size());
break;
case kPidTr:
pidTPCFullTr.reserve(tracks.size());
break;
case kPidHe:
pidTPCFullHe.reserve(tracks.size());
break;
case kPidAl:
pidTPCFullAl.reserve(tracks.size());
break;
default:
LOG(fatal) << "Unknown table requested: " << i;
break;
}
}

for (const auto& track : tracks) {
for (auto i : mEnabledTables) {
switch (i) {
case kPidEl:
pidTPCFullEl(0.0f, track.tpcNSigmaEl());
break;
case kPidMu:
pidTPCFullMu(0.0f, track.tpcNSigmaMu());
break;
case kPidPi:
pidTPCFullPi(0.0f, track.tpcNSigmaPi());
break;
case kPidKa:
pidTPCFullKa(0.0f, track.tpcNSigmaKa());
break;
case kPidPr:
pidTPCFullPr(0.0f, track.tpcNSigmaPr());
break;
case kPidDe:
pidTPCFullDe(0.0f, track.tpcNSigmaDe());
break;
case kPidTr:
pidTPCFullTr(0.0f, track.tpcNSigmaTr());
break;
case kPidHe:
pidTPCFullHe(0.0f, track.tpcNSigmaHe());
break;
case kPidAl:
pidTPCFullAl(0.0f, track.tpcNSigmaAl());
break;
default:
LOG(fatal) << "Unknown table requested: " << i;
break;
}
}
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<Run2TinyToFullPID>(cfgc)};
}
14 changes: 14 additions & 0 deletions Common/TableProducer/multiplicityTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ struct MultiplicityTable {
TProfile* hVtxZFT0A;
TProfile* hVtxZFT0C;
TProfile* hVtxZFDDA;

TProfile* hVtxZFDDC;
TProfile* hVtxZNTracks;
std::vector<int> mEnabledTables; // Vector of enabled tables
Expand All @@ -160,6 +161,19 @@ struct MultiplicityTable {
if (doprocessRun2 == true && doprocessRun3 == true) {
LOGF(fatal, "Cannot enable processRun2 and processRun3 at the same time. Please choose one.");
}

// exploratory
auto& workflows = context.services().get<o2::framework::RunningWorkflowInfo const>();
for (auto const& device : workflows.devices) {
for (auto const& input : device.inputs) {
// input.print();
TString devNam = device.name.c_str();
TString inBin = input.matcher.binding.c_str();
// TString subSpec = input.matcher.subspec.c_str();
LOGF(info, Form("device %s input binding %s subspec", devNam.Data(), inBin.Data()));
}
}

bool tEnabled[nTables] = {false};
for (int i = 0; i < nTables; i++) {
int f = enabledTables->get(tableNames[i].c_str(), "Enable");
Expand Down
Loading

0 comments on commit ec36dfa

Please sign in to comment.