Skip to content

Commit

Permalink
Merge branch 'AliceO2Group:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gbencedi authored Dec 11, 2024
2 parents 98d8071 + d0ea950 commit 43f4ee2
Show file tree
Hide file tree
Showing 220 changed files with 18,966 additions and 7,695 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/o2-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Find issues in O2 code
name: O2 linter

'on': [pull_request, push]
permissions: {}
env:
MAIN_BRANCH: master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
o2-linter:
name: O2 linter
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed to get the full history
- name: Run tests
run: |
# Diff against the common ancestor of the source branch and the main branch.
readarray -t files < <(git diff --diff-filter d --name-only origin/${{ env.MAIN_BRANCH }}...)
if [ ${#files[@]} -eq 0 ]; then
echo "::notice::No files to lint."
exit 0
fi
[ ${{ github.event_name }} == 'pull_request' ] && options="-g"
# shellcheck disable=SC2086 # Ignore unquoted options.
python3 Scripts/o2_linter.py $options "${files[@]}"
echo "Tip: If you allow actions in your fork repository, O2 linter will run when you push commits."
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
/PWGLF/TableProducer/GlobalEventProperties @alibuild @njacazio @skundu692 @gbencedi @omvazque
/PWGLF/Tasks/Nuspex @alibuild @njacazio @skundu692 @fmazzasc @chiarapinto @maciacco
/PWGLF/TableProducer/Nuspex @alibuild @njacazio @skundu692 @fmazzasc @chiarapinto @maciacco
/PWGLF/Tasks/Resonances @alibuild @njacazio @skundu692 @BongHwi @smaff92
/PWGLF/TableProducer/Resonances @alibuild @njacazio @skundu692 @BongHwi @smaff92
/PWGLF/Tasks/Resonances @alibuild @njacazio @skundu692 @dmallick2 @smaff92
/PWGLF/TableProducer/Resonances @alibuild @njacazio @skundu692 @dmallick2 @smaff92
/PWGLF/Tasks/Strangeness @alibuild @njacazio @skundu692 @ercolessi @ChiaraDeMartin95
/PWGLF/TableProducer/Strangeness @alibuild @njacazio @skundu692 @ercolessi @ChiaraDeMartin95

Expand Down
77 changes: 66 additions & 11 deletions Common/Core/PID/PIDTOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static constexpr float kCSPEDDInv = 1.f / kCSPEED; /// Inverse of
static constexpr float defaultReturnValue = -999.f; /// Default return value in case TOF measurement is not available

/// \brief Class to handle the the TOF detector response for the TOF beta measurement
template <typename TrackType>
class Beta
{
public:
Expand All @@ -62,11 +61,19 @@ class Beta
/// Gets the beta for the track of interest
/// \param track Track of interest
/// \param collisionTime Collision time
static float GetBeta(const TrackType& track, const float collisionTime) { return track.hasTOF() ? GetBeta(track.length(), track.tofSignal(), collisionTime) : defaultReturnValue; }
template <typename TrackType>
static float GetBeta(const TrackType& track, const float collisionTime)
{
return track.hasTOF() ? GetBeta(track.length(), track.tofSignal(), collisionTime) : defaultReturnValue;
}

/// Gets the beta for the track of interest
/// \param track Track of interest
static float GetBeta(const TrackType& track) { return GetBeta(track, track.tofEvTime()); }
template <typename TrackType>
static float GetBeta(const TrackType& track)
{
return GetBeta(track, track.tofEvTime());
}

/// Computes the expected uncertainty on the beta measurement
/// \param length Length in cm of the track
Expand All @@ -77,7 +84,11 @@ class Beta

/// Gets the expected uncertainty on the beta measurement of the track of interest
/// \param track Track of interest
float GetExpectedSigma(const TrackType& track) const { return GetExpectedSigma(track.length(), track.tofSignal(), track.tofEvTime(), mExpectedResolution); }
template <typename TrackType>
float GetExpectedSigma(const TrackType& track) const
{
return GetExpectedSigma(track.length(), track.tofSignal(), track.tofEvTime(), mExpectedResolution);
}

/// Gets the expected beta for a given mass hypothesis (no energy loss taken into account)
/// \param momentum momentum in GeV/c of the track
Expand All @@ -86,15 +97,15 @@ class Beta

/// Gets the expected beta given the particle index (no energy loss taken into account) of the track of interest
/// \param track Track of interest
template <o2::track::PID::ID id>
template <o2::track::PID::ID id, typename TrackType>
float GetExpectedBeta(const TrackType& track) const
{
return GetExpectedBeta(track.p(), o2::track::PID::getMass2Z(id));
}

/// Gets the number of sigmas with respect the approximate beta (no energy loss taken into account) of the track of interest
/// \param track Track of interest
template <o2::track::PID::ID id>
template <o2::track::PID::ID id, typename TrackType>
float GetSeparation(const TrackType& track) const
{
return (GetBeta(track) - GetExpectedBeta<id>(track)) / GetExpectedSigma(track);
Expand All @@ -104,7 +115,6 @@ class Beta
};

/// \brief Class to handle the the TOF detector response for the TOF mass measurement
template <typename TrackType>
class TOFMass
{
public:
Expand All @@ -118,11 +128,19 @@ class TOFMass

/// Gets the TOF mass for the track of interest
/// \param track Track of interest
static float GetTOFMass(const TrackType& track, const float beta) { return track.hasTOF() ? GetTOFMass(track.p(), beta) : defaultReturnValue; }
template <typename TrackType>
static float GetTOFMass(const TrackType& track, const float beta)
{
return track.hasTOF() ? GetTOFMass(track.p(), beta) : defaultReturnValue;
}

/// Gets the TOF mass for the track of interest
/// \param track Track of interest
static float GetTOFMass(const TrackType& track) { return track.hasTOF() ? GetTOFMass(track.p(), Beta<TrackType>::GetBeta(track)) : defaultReturnValue; }
template <typename TrackType>
static float GetTOFMass(const TrackType& track)
{
return track.hasTOF() ? GetTOFMass(track.p(), Beta::GetBeta<TrackType>(track)) : defaultReturnValue;
}
};

/// \brief Next implementation class to store TOF response parameters for exp. times
Expand Down Expand Up @@ -219,7 +237,7 @@ class TOFResoParamsV2 : public o2::tof::Parameters<13>
}
f.Close();
}
LOG(info) << "Set the Time Shift parameters from file " << filename << " and object " << objname << " for " << (positive ? "positive" : "negative");
LOG(info) << "Set the Time Shift parameters from file " << filename << " and object " << objname << " for " << (positive ? "positive" : "negative") << " example of shift at eta 0: " << getTimeShift(0, positive);
}
void setTimeShiftParameters(TGraph* g, bool positive)
{
Expand Down Expand Up @@ -266,7 +284,7 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
"time_resolution", "time_resolution", "time_resolution", "time_resolution"},
"TOFResoParamsV3")
{
setParameters(std::array<float, 13>{60.0});
setParameters(std::array<float, 13>{60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0});
} // Default constructor with default parameters

~TOFResoParamsV3() = default;
Expand Down Expand Up @@ -372,6 +390,20 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
return gNegEtaTimeCorr->Eval(eta);
}

void printTimeShiftParameters() const
{
if (gPosEtaTimeCorr) {
LOG(info) << "Using a time shift for Pos " << gPosEtaTimeCorr->GetName() << " " << gPosEtaTimeCorr->GetTitle() << " value at 0: " << gPosEtaTimeCorr->Eval(0) << " vs correction " << getTimeShift(0, 1);
} else {
LOG(info) << "Using no time shift for Pos vs correction " << getTimeShift(0, 1);
}
if (gNegEtaTimeCorr) {
LOG(info) << "Using a time shift for Neg " << gNegEtaTimeCorr->GetName() << " " << gNegEtaTimeCorr->GetTitle() << " value at 0: " << gNegEtaTimeCorr->Eval(0) << " vs correction " << getTimeShift(0, -1);
} else {
LOG(info) << "Using no time shift for Neg vs correction " << getTimeShift(0, -1);
}
}

void setResolutionParametrization(std::unordered_map<std::string, float> const& pars)
{
static constexpr std::array<const char*, 9> particleNames = {"El", "Mu", "Pi", "Ka", "Pr", "De", "Tr", "He", "Al"};
Expand All @@ -382,6 +414,9 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
if (key.find(baseOpt) == 0) {
// Remove from the key the baseOpt
const std::string fun = key.substr(baseOpt.size());
if (mResolution[i]) {
delete mResolution[i];
}
mResolution[i] = new TF2(baseOpt.c_str(), fun.c_str(), 0., 20, -1, 1.);
LOG(info) << "Set the resolution function for " << particleNames[i] << " with formula " << mResolution[i]->GetFormula()->GetExpFormula();
break;
Expand All @@ -404,6 +439,26 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
return mResolution[pid]->Eval(p, eta);
}

void printResolution() const
{
static constexpr std::array<const char*, 9> particleNames = {"El", "Mu", "Pi", "Ka", "Pr", "De", "Tr", "He", "Al"};
// Print a summary
for (int i = 0; i < 9; ++i) {
if (!mResolution[i]) {
LOG(info) << "Resolution function for " << particleNames[i] << " is not defined yet";
continue;
}
LOG(info) << "Resolution function for " << particleNames[i] << " is " << mResolution[i]->GetName() << " with formula " << mResolution[i]->GetFormula()->GetExpFormula();
}
}
void printFullConfig() const
{
print();
printMomentumChargeShiftParameters();
printTimeShiftParameters();
printResolution();
}

private:
// Charge calibration
int mEtaN = 0; // Number of eta bins, 0 means no correction
Expand Down
21 changes: 13 additions & 8 deletions Common/Core/RecoDecay.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,23 @@ struct RecoDecay {
/// Constrains angle to be within a range.
/// \note Inspired by TVector2::Phi_0_2pi in ROOT.
/// \param angle angle
/// \param min minimum of the range
/// \return value within [min, min + 2π).
/// \param minimum minimum of the range
/// \param harmonic harmonic number
/// \return value of angle within [minimum, minimum + 2π / harmonic).
template <typename T, typename U = float>
static T constrainAngle(T angle, U min = 0.)
static T constrainAngle(T angle, U minimum = 0.0F, unsigned int harmonic = 1U)
{
while (angle < min) {
angle += o2::constants::math::TwoPI;
auto period = o2::constants::math::TwoPI;
if (harmonic != 1U) {
period /= harmonic;
}
while (angle >= min + o2::constants::math::TwoPI) {
angle -= o2::constants::math::TwoPI;
while (angle < minimum) {
angle += period;
}
return (T)angle;
while (angle >= minimum + period) {
angle -= period;
}
return angle;
}

/// Calculates cosine of pointing angle.
Expand Down
85 changes: 40 additions & 45 deletions Common/DataModel/Multiplicity.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(IsInelGt0, isInelGt0, //! is INEL > 0
[](int multPveta1) -> bool { return multPveta1 > 0; });
DECLARE_SOA_DYNAMIC_COLUMN(IsInelGt1, isInelGt1, //! is INEL > 1
[](int multPveta1) -> bool { return multPveta1 > 1; });

// forward track counters
DECLARE_SOA_COLUMN(MFTNtracks, mftNtracks, int); //!

// MC
DECLARE_SOA_COLUMN(MultMCFT0A, multMCFT0A, int); //!
DECLARE_SOA_COLUMN(MultMCFT0C, multMCFT0C, int); //!
Expand Down Expand Up @@ -108,9 +112,12 @@ DECLARE_SOA_TABLE(PVMults, "AOD", "PVMULT", //! Multiplicity from the PV contrib
mult::MultNTracksPVetaHalf,
mult::IsInelGt0<mult::MultNTracksPVeta1>,
mult::IsInelGt1<mult::MultNTracksPVeta1>);
DECLARE_SOA_TABLE(MFTMults, "AOD", "MFTMULT", //! Multiplicity with MFT
mult::MFTNtracks);
using BarrelMults = soa::Join<TrackletMults, TPCMults, PVMults>;
using Mults = soa::Join<BarrelMults, FV0Mults, FT0Mults, FDDMults, ZDCMults>;
using FT0Mult = FT0Mults::iterator;
using MFTMult = MFTMults::iterator;
using Mult = Mults::iterator;

DECLARE_SOA_TABLE(MultsExtra_000, "AOD", "MULTEXTRA", //!
Expand Down Expand Up @@ -206,54 +213,42 @@ DECLARE_SOA_TABLE(PVMultZeqs, "AOD", "PVMULTZEQ", //! Multiplicity equalized for
using MultZeqs = soa::Join<FV0MultZeqs, FT0MultZeqs, FDDMultZeqs, PVMultZeqs>;
using MultZeq = MultZeqs::iterator;

namespace multBC
namespace mult
{
DECLARE_SOA_COLUMN(MultBCFT0A, multBCFT0A, float); //!
DECLARE_SOA_COLUMN(MultBCFT0C, multBCFT0C, float); //!
DECLARE_SOA_COLUMN(MultBCFV0A, multBCFV0A, float); //!
DECLARE_SOA_COLUMN(MultBCFDDA, multBCFDDA, float); //!
DECLARE_SOA_COLUMN(MultBCFDDC, multBCFDDC, float); //!
// extra BC information
DECLARE_SOA_COLUMN(MultTVX, multTVX, bool); //!
DECLARE_SOA_COLUMN(MultFV0OrA, multFV0OrA, bool); //!
DECLARE_SOA_COLUMN(MultV0triggerBits, multV0triggerBits, uint8_t); //!
DECLARE_SOA_COLUMN(MultT0triggerBits, multT0triggerBits, uint8_t); //!
DECLARE_SOA_COLUMN(MultFDDtriggerBits, multFDDtriggerBits, uint8_t); //!
DECLARE_SOA_COLUMN(MultTriggerMask, multTriggerMask, uint64_t); //! CTP trigger mask
DECLARE_SOA_COLUMN(MultCollidingBC, multCollidingBC, bool); //! CTP trigger mask

DECLARE_SOA_COLUMN(MultBCZNA, multBCZNA, float); //!
DECLARE_SOA_COLUMN(MultBCZNC, multBCZNC, float); //!
DECLARE_SOA_COLUMN(MultBCZEM1, multBCZEM1, float); //!
DECLARE_SOA_COLUMN(MultBCZEM2, multBCZEM2, float); //!
DECLARE_SOA_COLUMN(MultBCZPA, multBCZPA, float); //!
DECLARE_SOA_COLUMN(MultBCZPC, multBCZPC, float); //!

DECLARE_SOA_COLUMN(MultBCTVX, multBCTVX, bool); //!
DECLARE_SOA_COLUMN(MultBCFV0OrA, multBCFV0OrA, bool); //!
DECLARE_SOA_COLUMN(MultBCV0triggerBits, multBCV0triggerBits, uint8_t); //!
DECLARE_SOA_COLUMN(MultBCT0triggerBits, multBCT0triggerBits, uint8_t); //!
DECLARE_SOA_COLUMN(MultBCFDDtriggerBits, multBCFDDtriggerBits, uint8_t); //!
DECLARE_SOA_COLUMN(MultBCTriggerMask, multBCTriggerMask, uint64_t); //! CTP trigger mask
DECLARE_SOA_COLUMN(MultBCColliding, multBCColliding, bool); //! CTP trigger mask

DECLARE_SOA_COLUMN(MultBCFT0PosZ, multBCFT0PosZ, float); //! Position along Z computed with the FT0 information within the BC
DECLARE_SOA_COLUMN(MultBCFT0PosZValid, multBCFT0PosZValid, bool); //! Validity of the position along Z computed with the FT0 information within the BC

} // namespace multBC
DECLARE_SOA_COLUMN(MultFT0PosZ, multFT0PosZ, float); //! Position along Z computed with the FT0 information within the BC
DECLARE_SOA_COLUMN(MultFT0PosZValid, multFT0PosZValid, bool); //! Validity of the position along Z computed with the FT0 information
} // namespace mult
DECLARE_SOA_TABLE(MultBCs, "AOD", "MULTBC", //!
multBC::MultBCFT0A,
multBC::MultBCFT0C,
multBC::MultBCFT0PosZ,
multBC::MultBCFT0PosZValid,
multBC::MultBCFV0A,
multBC::MultBCFDDA,
multBC::MultBCFDDC,
multBC::MultBCZNA,
multBC::MultBCZNC,
multBC::MultBCZEM1,
multBC::MultBCZEM2,
multBC::MultBCZPA,
multBC::MultBCZPC,
multBC::MultBCTVX,
multBC::MultBCFV0OrA,
multBC::MultBCV0triggerBits,
multBC::MultBCT0triggerBits,
multBC::MultBCFDDtriggerBits,
multBC::MultBCTriggerMask,
multBC::MultBCColliding,
mult::MultFT0A,
mult::MultFT0C,
mult::MultFT0PosZ,
mult::MultFT0PosZValid,
mult::MultFV0A,
mult::MultFDDA,
mult::MultFDDC,
mult::MultZNA,
mult::MultZNC,
mult::MultZEM1,
mult::MultZEM2,
mult::MultZPA,
mult::MultZPC,
mult::MultTVX,
mult::MultFV0OrA,
mult::MultV0triggerBits,
mult::MultT0triggerBits,
mult::MultFDDtriggerBits,
mult::MultTriggerMask,
mult::MultCollidingBC,
timestamp::Timestamp,
bc::Flags);
using MultBC = MultBCs::iterator;

Expand Down
6 changes: 6 additions & 0 deletions Common/DataModel/PIDResponseITS.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ struct ITSResponse {
return (average * coslInv - exp) / resolution;
};

template <o2::track::PID::ID id, typename T>
static float nSigmaITS(const T& track)
{
return nSigmaITS<id>(track.itsClusterSizes(), track.p(), track.eta());
}

static void setParameters(float p0, float p1, float p2, float p0_Z2, float p1_Z2, float p2_Z2, float p0_res, float p1_res, float p2_res)
{
if (mIsInitialized) {
Expand Down
5 changes: 5 additions & 0 deletions Common/TableProducer/Converters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ o2physics_add_dpl_workflow(multmcextras-converter
SOURCES multMCExtrasConverter.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(trackqa-converter
SOURCES trackQAConverter.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Loading

0 comments on commit 43f4ee2

Please sign in to comment.