Skip to content
Merged
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
37 changes: 35 additions & 2 deletions PWGHF/TableProducer/mcPidTof.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
///
/// \file mcPidTof.cxx
/// \author Fabrizio Grosa fabrizio.grosa@cern.ch
/// \brief Task to produce PID tables for TOF split for pi, K, p, copied from https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/PID/pidTofMerge.cxx
/// \brief Task to produce PID tables for TOF split for pi, K, p, de, copied from https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/PID/pidTofMerge.cxx
/// It works only for MC and adds the possibility to apply postcalibrations for MC.
///

Expand Down Expand Up @@ -465,10 +465,10 @@
Produces<o2::aod::TOFEvTime> tableEvTime;
Produces<o2::aod::EvTimeTOFOnly> tableEvTimeTOFOnly;
Produces<o2::aod::pidEvTimeFlags> tableFlags;
static constexpr bool removeTOFEvTimeBias = true; // Flag to subtract the Ev. Time bias for low multiplicity events with TOF

Check failure on line 468 in PWGHF/TableProducer/mcPidTof.cxx

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 diamond = 6.0; // Collision diamond used in the estimation of the TOF event time

Check failure on line 469 in PWGHF/TableProducer/mcPidTof.cxx

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 errDiamond = diamond * 33.356409f;

Check failure on line 470 in PWGHF/TableProducer/mcPidTof.cxx

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 weightDiamond = 1.f / (errDiamond * errDiamond);

Check failure on line 471 in PWGHF/TableProducer/mcPidTof.cxx

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".

bool enableTableTOFEvTime = false;
bool enableTableEvTimeTOFOnly = false;
Expand Down Expand Up @@ -719,21 +719,24 @@

// Part 3 Nsigma computation

static constexpr int idxPi = 2;

Check failure on line 722 in PWGHF/TableProducer/mcPidTof.cxx

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 int idxKa = 3;

Check failure on line 723 in PWGHF/TableProducer/mcPidTof.cxx

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 int idxPr = 4;

Check failure on line 724 in PWGHF/TableProducer/mcPidTof.cxx

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 int idxDe = 5;

Check failure on line 725 in PWGHF/TableProducer/mcPidTof.cxx

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".

/// Task to produce the response table
struct mcPidTof {
// Tables to produce
Produces<o2::aod::pidTOFPi> tablePIDPi;
Produces<o2::aod::pidTOFKa> tablePIDKa;
Produces<o2::aod::pidTOFPr> tablePIDPr;
Produces<o2::aod::pidTOFDe> tablePIDDe;

// Tables to produce (full)
Produces<o2::aod::pidTOFFullPi> tablePIDFullPi;
Produces<o2::aod::pidTOFFullKa> tablePIDFullKa;
Produces<o2::aod::pidTOFFullPr> tablePIDFullPr;
Produces<o2::aod::pidTOFFullDe> tablePIDFullDe;

// Detector response parameters
o2::pid::tof::TOFResoParamsV3 mRespParamsV3;
Expand Down Expand Up @@ -768,7 +771,7 @@
{
mTOFCalibConfig.inheritFromBaseTask(initContext);
// Checking the tables are requested in the workflow and enabling them (only pi, K, p)
std::array<int, 3> supportedSpecies = {idxPi, idxKa, idxPr};
std::array<int, 4> supportedSpecies = {idxPi, idxKa, idxPr, idxDe};
for (auto iSpecie{0u}; iSpecie < supportedSpecies.size(); ++iSpecie) {
// First checking tiny
int flag = -1;
Expand Down Expand Up @@ -881,6 +884,14 @@
tablePIDPr);
}
break;
case idxDe:
if (fullTable) {
tablePIDFullDe(-999.f, -999.f);
} else {
aod::pidutils::packInTable<aod::pidtof_tiny::binning>(-999.f,
tablePIDDe);
}
break;
default:
LOG(fatal) << "Wrong particle ID in makeTableEmpty() for " << (fullTable ? "full" : "tiny") << " tables";
break;
Expand Down Expand Up @@ -924,7 +935,7 @@
template <typename T>
T applyMcRecalib(int pidId, T trackPt, T nSigma)
{
if (nSigma < -998) {

Check failure on line 938 in PWGHF/TableProducer/mcPidTof.cxx

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 nSigma;
}

Expand Down Expand Up @@ -957,9 +968,10 @@
aod::BCsWithTimestamps const& bcs,
aod::McParticles const&)
{
constexpr auto responsePi = ResponseImplementation<PID::Pion>();

Check failure on line 971 in PWGHF/TableProducer/mcPidTof.cxx

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".
constexpr auto responseKa = ResponseImplementation<PID::Kaon>();
constexpr auto responsePr = ResponseImplementation<PID::Proton>();
constexpr auto responseDe = ResponseImplementation<PID::Deuteron>();

mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bcs.iteratorAt(0)); // Update the calibration parameters

Expand Down Expand Up @@ -1026,6 +1038,16 @@
aod::pidutils::packInTable<aod::pidtof_tiny::binning>(nSigma, tablePIDPr);
break;
}
case idxDe: {
nSigma = responseDe.GetSeparation(mRespParamsV3, trk);
if (enableMcRecalib && trk.has_mcParticle()) {
if (std::abs(trk.mcParticle().pdgCode()) == o2::constants::physics::kDeuteron) { // we rescale only true signal
nSigma = applyMcRecalib(idxPr, trk.pt(), nSigma); // FIXME: currently postcalibrations for protons applied to deuterons, to be checked
}
}
aod::pidutils::packInTable<aod::pidtof_tiny::binning>(nSigma, tablePIDDe);
break;
}
default:
LOG(fatal) << "Wrong particle ID for standard tables";
break;
Expand Down Expand Up @@ -1070,6 +1092,17 @@
tablePIDFullPr(resolution, nSigma);
break;
}
case idxDe: {
resolution = responseDe.GetExpectedSigma(mRespParamsV3, trk);
nSigma = responseDe.GetSeparation(mRespParamsV3, trk, resolution);
if (enableMcRecalib && trk.has_mcParticle()) {
if (std::abs(trk.mcParticle().pdgCode()) == o2::constants::physics::kDeuteron) { // we rescale only true signal
nSigma = applyMcRecalib(idxPr, trk.pt(), nSigma); // FIXME: currently postcalibrations for protons applied to deuterons, to be checked
}
}
tablePIDFullDe(resolution, nSigma);
break;
}
default:
LOG(fatal) << "Wrong particle ID for full tables";
break;
Expand Down
Loading