Skip to content

Commit 812cdbd

Browse files
committed
PWGHF: Add more coding guidelines
1 parent 9ee1a91 commit 812cdbd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/advanced-specifics/pwghf.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,18 @@ Workflow | File | Type
160160
- Respect the alphabetic order and groups in `CMakeLists.txt` when adding a new workflow.
161161
- Link only necessary libraries in `CMakeLists.txt`.
162162
- Avoid code duplication and reuse existing code (e.g. `RecoDecay`, table columns, constants).
163+
- Define variables for repeatedly used objects (histogram types, axes, strings, calculated values).
163164
- Explicitly state when using the `std` namespace (e.g. `std::abs`, `std::array`, `std::vector`).
164-
- Do not use ROOT features unnecessarily (e.g. `TMath::Abs``std::abs`).
165+
- Do not use ROOT features unnecessarily (e.g. `TMath::Abs``std::abs`, `Double_t``double`).
165166
- Use of macros for [bit manipulations](https://root.cern/doc/master/Rtypes_8h_source.html#l00083) (`BIT`, `SETBIT`, `TESTBIT`, `CLRBIT`) is encouraged.
167+
- Do not use `M_PI`. Instead, use `PI`, `TwoPI`, `PIHalf`, `PIThird`, `PIQuarter` from the `o2::constants::math` namespace.
168+
- Use `LOG`, `LOGF`, `LOGP` macros for logging (instead of `Printf`, `printf`, `std::cout`).
169+
- Use the right logging level:
170+
- `debug` for technical information useful for debugging and development,
171+
- `info` for information about what the code is doing that is useful to report at every execution,
172+
- `warn` for conditions that are likely to affect the expected behaviour of the code,
173+
- `error` for problems that lead to an unwanted behaviour of the code,
174+
- `fatal` for critical problems that make further running of the code impossible or useless.
166175
- Include only needed headers but do not rely on implicitly included headers.
167176
- Organise `#include`s into groups (separated by a blank line) in the following order:
168177
- C++
@@ -176,8 +185,10 @@ Workflow | File | Type
176185
- Sort `#include`s alphabetically within a group.
177186
- Avoid using hard-coded PDG codes. Use their `enum` names instead
178187
(from [`PDG_t`](https://root.cern/doc/master/TPDGCode_8h.html) or
179-
[`o2::analysis::pdg::Code`](https://github.com/AliceO2Group/O2Physics/blob/master/PWGHF/Core/SelectorCuts.h)).
188+
[`o2::analysis::pdg::Code`](https://github.com/AliceO2Group/O2Physics/blob/master/PWGHF/Core/PDG.h)).
180189
See also [Magic numbers](https://rawgit.com/AliceO2Group/CodingGuidelines/master/coding_guidelines.html?showone=Magic_numbers#Magic_numbers).
190+
- Use `Type const&` for table subscriptions in function arguments.
191+
- Declare iterators in range-based `for` loops over tables with `const auto&`.
181192
- Test your code before making a pull request.
182193
- Check that your branch compiles without warnings.
183194
- Propagate your changes into the [Run3Analysisvalidation](https://github.com/AliceO2Group/Run3Analysisvalidation/tree/master/codeHF#add-a-new-workflow) configuration.
@@ -210,6 +221,7 @@ Organising the code in a well defined structure makes it easier to navigate thro
210221
- `init` function
211222
- helper functions
212223
- `process` function(s)
224+
- Put one process function argument per line.
213225
- `PROCESS_SWITCH` follows immediately after the function definition.
214226

215227
### Naming conventions

0 commit comments

Comments
 (0)