Skip to content

Conversation

@lubynets
Copy link
Contributor

@lubynets lubynets commented Oct 6, 2025

Reduced code repetition:

  • merged process functions "with" and "without" dEdx correction;
  • merged process functions "WithdEdxTrQA" and "WithTrQA";
  • iteration by V0s (tracks) in V0 (TOF) tree creator replaced with a for-loop over a dedicated struct for mentioned objects;
  • removed a redundant if-esle construction with identical consequent and alternative in struct TreeWriterTPCTOF.

Readability and code cosmetics:

  • added const and const& where possible and necessary, removed const from function arguments passed by value;
  • introduced constexpr shortcuts for particles' masses and ids;
  • removed sqrtsNN from member functions' arguments since sqrtsNN is a struct's configurable;
  • renamed TreeWriterTPCTOF::processStandard2() function into TreeWriterTPCTOF::processStandardWithCorrecteddEdx() for keeping the same naming style in the entire source file.

Minor bugfixes:

  • use downsamplingTsalisTritons and downsamplingTsalisDeuterons variables for tritons and deuterons respectively (instead of downsamplingTsalisProtons);
  • use Preclise perCollisionTracksWithCorrecteddEdx instead of perCollisionTracks in TreeWriterTPCTOF::processWithTrQAWithCorrecteddEdx().

Addressed linter error messages:

  • introduced enums instead of hardcoded constants for track- and event-selection;
  • removed underscore _ symbol from configurable names, configurable string names are made consistent with their variable names;
    full commit of linter error fixes.

FYI @amaringarcia

@github-actions github-actions bot added the dpg label Oct 6, 2025
@github-actions github-actions bot changed the title Refactor tpcSkimsTableCreator [DPG] Refactor tpcSkimsTableCreator Oct 6, 2025
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

O2 linter results: ❌ 1 errors, ⚠️ 0 warnings, 🔕 0 disabled

@lubynets lubynets marked this pull request as draft October 6, 2025 09:09
@lubynets lubynets marked this pull request as ready for review October 6, 2025 09:50
@vkucera
Copy link
Collaborator

vkucera commented Oct 6, 2025

@lubynets Nice work!
Did you use clang-tidy?
Why did you remove const from function arguments passed by value? Having const prevents them from being modified inside the function which is a valuable protection and indication of intent.

constexpr static o2::track::PID::ID PidKaon{o2::track::PID::Kaon};
constexpr static o2::track::PID::ID PidProton{o2::track::PID::Proton};

constexpr static double MassElectorn{o2::track::pid_constants::sMasses[PidElectron]};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr static double MassElectorn{o2::track::pid_constants::sMasses[PidElectron]};
constexpr static double MassElectron{o2::track::pid_constants::sMasses[PidElectron]};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 154 to 155
template <bool doUseCorrecteddEdx = false, typename T, typename C, typename V0Casc>
void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, C const& collision, float nSigmaTPC, float nSigmaTOF, float dEdxExp, o2::track::PID::ID id, int runnumber, double dwnSmplFactor, float hadronicRate)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <bool doUseCorrecteddEdx = false, typename T, typename C, typename V0Casc>
void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, C const& collision, float nSigmaTPC, float nSigmaTOF, float dEdxExp, o2::track::PID::ID id, int runnumber, double dwnSmplFactor, float hadronicRate)
template <bool DoUseCorrectedDeDx = false, typename T, typename C, typename V0Casc>
void fillSkimmedV0Table(V0Casc const& v0casc, T const& track, C const& collision, float nSigmaTPC, float nSigmaTOF, float dEdxExp, o2::track::PID::ID id, int runnumber, double dwnSmplFactor, float hadronicRate)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 485 to 486
template <bool IsCorrecteddEdx, bool IsWithdEdx, typename TrksType, typename BCType>
void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::TracksQAVersion const& tracksQA, Preslice<TrksType> const& perCollisionTracksType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <bool IsCorrecteddEdx, bool IsWithdEdx, typename TrksType, typename BCType>
void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::TracksQAVersion const& tracksQA, Preslice<TrksType> const& perCollisionTracksType)
template <bool IsCorrectedDeDx, bool IsWithDeDx, typename TrksType, typename BCType>
void runWithTrQAGeneric(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, aod::TracksQAVersion const& tracksQA, Preslice<TrksType> const& perCollisionTracksType)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 663 to 667
constexpr static double MassPion{o2::track::pid_constants::sMasses[PidPion]};
constexpr static double MassKaon{o2::track::pid_constants::sMasses[PidKaon]};
constexpr static double MassProton{o2::track::pid_constants::sMasses[PidProton]};
constexpr static double MassDeuteron{o2::track::pid_constants::sMasses[PidDeuteron]};
constexpr static double MassTriton{o2::track::pid_constants::sMasses[PidTriton]};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these needed? The PDG masses are in the common constant header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (used common constant header).

Comment on lines 831 to 832
template <bool doCorrectdEdx, bool isWithdEdx, typename T, typename TQA, typename C>
void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, float nSigmaTPC, float nSigmaTOF, float nSigmaITS, float dEdxExp, o2::track::PID::ID id, int runnumber, double dwnSmplFactor, double hadronicRate, int bcGlobalIndex, int bcTimeFrameId, int bcBcInTimeFrame)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <bool doCorrectdEdx, bool isWithdEdx, typename T, typename TQA, typename C>
void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, float nSigmaTPC, float nSigmaTOF, float nSigmaITS, float dEdxExp, o2::track::PID::ID id, int runnumber, double dwnSmplFactor, double hadronicRate, int bcGlobalIndex, int bcTimeFrameId, int bcBcInTimeFrame)
template <bool DoCorrectDeDx, bool IsWithDeDx, typename T, typename TQA, typename C>
void fillSkimmedTPCTOFTableWithTrkQAGeneric(T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, float nSigmaTPC, float nSigmaTOF, float nSigmaITS, float dEdxExp, o2::track::PID::ID id, int runnumber, double dwnSmplFactor, double hadronicRate, int bcGlobalIndex, int bcTimeFrameId, int bcBcInTimeFrame)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 840 to 841
const auto trackocc = collision.trackOccupancyInTimeRange();
const auto ft0occ = collision.ft0cOccupancyInTimeRange();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const auto trackocc = collision.trackOccupancyInTimeRange();
const auto ft0occ = collision.ft0cOccupancyInTimeRange();
const auto trackOcc = collision.trackOccupancyInTimeRange();
const auto ft0Occ = collision.ft0cOccupancyInTimeRange();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +753 to +754
double nSigmaTofTpctof;
double nSigmaTpcTpctof;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
double nSigmaTofTpctof;
double nSigmaTpcTpctof;
double nSigmaTofTpcTof;
double nSigmaTpcTpcTof;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since initially it was nSigmaTPC_TPCTOF, I think the first part TPC must be separated from the second part TPCTOF. That's why I merged Tpctof in a single substring.

@lubynets
Copy link
Contributor Author

lubynets commented Oct 6, 2025

@lubynets Nice work! Did you use clang-tidy? Why did you remove const from function arguments passed by value? Having const prevents them from being modified inside the function which is a valuable protection and indication of intent.

@vkucera, thanks!
No, I did not use clang-tidy.
About const arguments by value, honestly I had a feeling that the const should not be remove exactly because of the reasons which you mentioned. But I have read that it's a common practice not to pass arguments by value with const - isn't it the case for O2Physics? Or maybe I am missing something, and there is no such a "rule" in general?

@vkucera
Copy link
Collaborator

vkucera commented Oct 6, 2025

@lubynets Nice work! Did you use clang-tidy? Why did you remove const from function arguments passed by value? Having const prevents them from being modified inside the function which is a valuable protection and indication of intent.

@vkucera, thanks! No, I did not use clang-tidy. About const arguments by value, honestly I had a feeling that the const should not be remove exactly because of the reasons which you mentioned. But I have read that it's a common practice not to pass arguments by value with const - isn't it the case for O2Physics? Or maybe I am missing something, and there is no such a "rule" in general?

I don't think there is a rule for it in O2Physics. The C++ Core Guideline Con.1 considers it to be "pedantic" though. :-)

Btw, the misc-const-correctness check in clang-tidy can fix the missing const automatically.

@lubynets
Copy link
Contributor Author

lubynets commented Oct 6, 2025

@lubynets Nice work! Did you use clang-tidy? Why did you remove const from function arguments passed by value? Having const prevents them from being modified inside the function which is a valuable protection and indication of intent.

@vkucera, thanks! No, I did not use clang-tidy. About const arguments by value, honestly I had a feeling that the const should not be remove exactly because of the reasons which you mentioned. But I have read that it's a common practice not to pass arguments by value with const - isn't it the case for O2Physics? Or maybe I am missing something, and there is no such a "rule" in general?

I don't think there is a rule for it in O2Physics. The C++ Core Guideline Con.1 considers it to be "pedantic" though. :-)

Btw, the misc-const-correctness check in clang-tidy can fix the missing const automatically.

Ok, I mixed it with another practice - avoiding const in function declaration when it is separated from the definition (link).

@alcaliva alcaliva enabled auto-merge (squash) October 6, 2025 21:30
@lubynets
Copy link
Contributor Author

lubynets commented Oct 7, 2025

Dear @alcaliva, thanks for enabling auto-merge! Could you please merge the PR?

@alcaliva alcaliva merged commit 01cd68c into AliceO2Group:master Oct 7, 2025
20 of 21 checks passed
@lubynets lubynets deleted the tpcSkimsRefactor branch October 7, 2025 20:29
ArkaprabhaSaha001 pushed a commit to ArkaprabhaSaha001/O2Physics that referenced this pull request Oct 21, 2025
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
ThePhDane pushed a commit to ThePhDane/O2Physics that referenced this pull request Nov 3, 2025
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
jloemker pushed a commit to jloemker/O2Physics that referenced this pull request Nov 11, 2025
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
lmattei01 pushed a commit to lmattei01/O2Physics that referenced this pull request Dec 5, 2025
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants