Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Common/Core/TableHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#ifndef COMMON_CORE_TABLEHELPER_H_
#define COMMON_CORE_TABLEHELPER_H_

#include <string>

#include "Framework/Configurable.h"
#include "Framework/InitContext.h"
#include "Framework/RunningWorkflowInfo.h"

#include <string>

/// Function to print the table required in the full workflow
/// @param initContext initContext of the init function
void printTablesInWorkflow(o2::framework::InitContext& initContext);
Expand Down Expand Up @@ -76,14 +76,16 @@
}
if (device.name == taskName) { // Found the mother task
int optionCounter = 0;
for (auto const& option : device.options) {
for (const o2::framework::ConfigParamSpec& option : device.options) {

Check failure on line 79 in Common/Core/TableHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (verbose) {
LOG(info) << " Option " << optionCounter++ << " " << option.name << " = '" << option.defaultValue.asString() << "'";
LOG(info) << " Option " << optionCounter++ << " " << option.name << " of type " << static_cast<int>(option.type) << " = '" << option.defaultValue.asString() << "'";
}
if (option.name == optName) {
value = option.defaultValue.get<ValueType>();
if (verbose) {
LOG(info) << " Found option '" << optName << "' with value '" << value << "'";
if constexpr (!std::is_same_v<ValueType, o2::framework::LabeledArray<float>>) {
LOG(info) << " Found option '" << optName << "' with value '" << value << "'";
}
found = true;
} else {
return true;
Expand Down
38 changes: 37 additions & 1 deletion Common/DataModel/PIDResponseITS.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
#define COMMON_DATAMODEL_PIDRESPONSEITS_H_

// O2 includes
#include "TableHelper.h"

#include "Framework/ASoA.h"
#include "Framework/AnalysisDataModel.h"
#include "ReconstructionDataFormats/PID.h"
#include "Framework/Logger.h"
#include "ReconstructionDataFormats/PID.h"

namespace o2::aod
{
Expand All @@ -37,7 +39,7 @@
float sum = 0;
int nclusters = 0;
int max = 0;
for (int layer = 0; layer < 7; layer++) {

Check failure on line 42 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
int clsize = (itsClusterSizes >> (layer * 4)) & 0xf;
if (clsize > 0) {
nclusters++;
Expand All @@ -57,7 +59,7 @@
template <o2::track::PID::ID id>
static float expSignal(const float momentum)
{
static constexpr float inverseMass = 1. / o2::track::pid_constants::sMasses[id];

Check failure on line 62 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".
// static constexpr float charge = static_cast<float>(o2::track::pid_constants::sCharges[id]);
const float bg = momentum * inverseMass;
if (id == o2::track::PID::Helium3 || id == o2::track::PID::Alpha) {
Expand All @@ -69,13 +71,13 @@
template <o2::track::PID::ID id>
static float expResolution(const float momentum)
{
static constexpr float inverseMass = 1. / o2::track::pid_constants::sMasses[id];

Check failure on line 74 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".
// static constexpr float charge = static_cast<float>(o2::track::pid_constants::sCharges[id]);
const float bg = momentum * inverseMass;
if (id == o2::track::PID::Helium3 || id == o2::track::PID::Alpha) {
return mResolutionParamsZ2[1] > -999.0 ? mResolutionParamsZ2[0] * std::erf((bg - mResolutionParamsZ2[1]) / mResolutionParamsZ2[2]) : mResolutionParamsZ2[0];

Check failure on line 78 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
}
return mResolutionParams[1] > -999.0 ? mResolutionParams[0] * std::erf((bg - mResolutionParams[1]) / mResolutionParams[2]) : mResolutionParams[0];

Check failure on line 80 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
}

template <o2::track::PID::ID id>
Expand Down Expand Up @@ -125,6 +127,40 @@
0.09, -999., -999.);
}

/// Initialize the TOF response parameters in the init function of each task
/// \param initContext Initialization context. Gets the configuration parameters from the pidITS task
static void setParameters(o2::framework::InitContext& initContext, bool isMC = false)
{
float p0 = 0, p1 = 0, p2 = 0;
float p0_Z2 = 0, p1_Z2 = 0, p2_Z2 = 0;

Check failure on line 135 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
float p0_res = 0, p1_res = 0, p2_res = 0;

Check failure on line 136 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
float p0_res_Z2 = 0, p1_res_Z2 = 0, p2_res_Z2 = 0;

Check failure on line 137 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
o2::framework::LabeledArray<float> itsParams;
getTaskOptionValue(initContext, "its-pid", "itsParams", itsParams, true);
auto data = itsParams.getData();
const int col = isMC ? 1 : 0; // 0 for Data, 1 for MC
if (data.rows != 2 || data.cols != 12) {

Check failure on line 142 in Common/DataModel/PIDResponseITS.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOG(fatal) << "ITSResponse parameters not initialized, check the itsParams configuration";
}
p0 = data(col, 0);
p1 = data(col, 1);
p2 = data(col, 2);
p0_Z2 = data(col, 3);
p1_Z2 = data(col, 4);
p2_Z2 = data(col, 5);
p0_res = data(col, 6);
p1_res = data(col, 7);
p2_res = data(col, 8);
p0_res_Z2 = data(col, 9);
p1_res_Z2 = data(col, 10);
p2_res_Z2 = data(col, 11);

setParameters(p0, p1, p2,
p0_Z2, p1_Z2, p2_Z2,
p0_res, p1_res, p2_res,
p0_res_Z2, p1_res_Z2, p2_res_Z2);
}

private:
static std::array<float, 3> mITSRespParams;
static std::array<float, 3> mITSRespParamsZ2;
Expand Down
18 changes: 10 additions & 8 deletions DPG/Tasks/AOTTrack/PID/ITS/qaPIDITS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
/// \brief Implementation for QA tasks of the ITS PID quantities
///

#include <string>
#include <vector>
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/PIDResponseITS.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "Framework/AnalysisTask.h"
#include "Framework/runDataProcessing.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/StaticFor.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/PIDResponseITS.h"
#include "Framework/runDataProcessing.h"

#include <string>
#include <vector>

using namespace o2;
using namespace o2::framework;
Expand Down Expand Up @@ -183,8 +184,9 @@ struct itsPidQa {
return averageClusterSizePerCoslInv(track.itsClusterSizes(), track.eta());
}

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
o2::aod::ITSResponse::setParameters(context);
const AxisSpec vtxZAxis{100, -20, 20, "Vtx_{z} (cm)"};
const AxisSpec etaAxis{etaBins, "#it{#eta}"};
const AxisSpec phiAxis{phiBins, "#it{#phi}"};
Expand Down
Loading