Skip to content

Commit aed3bcd

Browse files
authored
[PWGHF,Tutorial] Update tutorial (#13716)
1 parent 4262144 commit aed3bcd

File tree

10 files changed

+1189
-538
lines changed

10 files changed

+1189
-538
lines changed

Tutorials/PWGHF/DataModelMini.h

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, Tracks, "_1"); //! prong 1
4444
} // namespace hf_track_index
4545

4646
// Track index skim table
47-
DECLARE_SOA_TABLE(HfT2Prongs, "AOD", "HFT2PRONG", //! table with prongs indices
47+
DECLARE_SOA_TABLE(HfT2Prongs, "AOD", "HFT2PRONG", //! table with prong indices
48+
o2::soa::Index<>,
4849
hf_track_index::Prong0Id,
4950
hf_track_index::Prong1Id);
5051

@@ -53,43 +54,44 @@ namespace hf_cand_prong2
5354
{
5455
// Candidate columns
5556
// collision properties
56-
DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! collisions
57+
DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! collision
5758
// secondary vertex
58-
DECLARE_SOA_COLUMN(XSecondaryVertex, xSecondaryVertex, float); //! x coordinate of the secondary vertex
59-
DECLARE_SOA_COLUMN(YSecondaryVertex, ySecondaryVertex, float); //! y coordinate of the secondary vertex
60-
DECLARE_SOA_COLUMN(ZSecondaryVertex, zSecondaryVertex, float); //! z coordinate of the secondary vertex
61-
DECLARE_SOA_DYNAMIC_COLUMN(RSecondaryVertex, rSecondaryVertex, //! radius of the secondary vertex
59+
DECLARE_SOA_COLUMN(XSecondaryVertex, xSecondaryVertex, float); //! x coordinate of the secondary vertex [cm]
60+
DECLARE_SOA_COLUMN(YSecondaryVertex, ySecondaryVertex, float); //! y coordinate of the secondary vertex [cm]
61+
DECLARE_SOA_COLUMN(ZSecondaryVertex, zSecondaryVertex, float); //! z coordinate of the secondary vertex [cm]
62+
DECLARE_SOA_DYNAMIC_COLUMN(RSecondaryVertex, rSecondaryVertex, //! radius of the secondary vertex [cm]
6263
[](float xVtxS, float yVtxS) -> float { return RecoDecay::sqrtSumOfSquares(xVtxS, yVtxS); });
6364
// prong properties
64-
DECLARE_SOA_COLUMN(PxProng0, pxProng0, float); //! px of prong 0
65-
DECLARE_SOA_COLUMN(PyProng0, pyProng0, float); //! py of prong 0
66-
DECLARE_SOA_COLUMN(PzProng0, pzProng0, float); //! pz of prong 0
67-
DECLARE_SOA_DYNAMIC_COLUMN(PtProng0, ptProng0, //! pt of prong 0
65+
DECLARE_SOA_COLUMN(PxProng0, pxProng0, float); //! px of prong 0 [GeV/c]
66+
DECLARE_SOA_COLUMN(PyProng0, pyProng0, float); //! py of prong 0 [GeV/c]
67+
DECLARE_SOA_COLUMN(PzProng0, pzProng0, float); //! pz of prong 0 [GeV/c]
68+
DECLARE_SOA_DYNAMIC_COLUMN(PtProng0, ptProng0, //! pt of prong 0 [GeV/c]
6869
[](float px, float py) -> float { return RecoDecay::pt(px, py); });
69-
DECLARE_SOA_COLUMN(PxProng1, pxProng1, float); //! px of prong 1
70-
DECLARE_SOA_COLUMN(PyProng1, pyProng1, float); //! py of prong 1
71-
DECLARE_SOA_COLUMN(PzProng1, pzProng1, float); //! pz of prong 1
72-
DECLARE_SOA_DYNAMIC_COLUMN(PtProng1, ptProng1, //! pt of prong 1
70+
DECLARE_SOA_COLUMN(PxProng1, pxProng1, float); //! px of prong 1 [GeV/c]
71+
DECLARE_SOA_COLUMN(PyProng1, pyProng1, float); //! py of prong 1 [GeV/c]
72+
DECLARE_SOA_COLUMN(PzProng1, pzProng1, float); //! pz of prong 1 [GeV/c]
73+
DECLARE_SOA_DYNAMIC_COLUMN(PtProng1, ptProng1, //! pt of prong 1 [GeV/c]
7374
[](float px, float py) -> float { return RecoDecay::pt(px, py); });
7475
// candidate properties
75-
DECLARE_SOA_DYNAMIC_COLUMN(DecayLength, decayLength, //! decay length of candidate
76+
DECLARE_SOA_DYNAMIC_COLUMN(DecayLength, decayLength, //! decay length of candidate [cm]
7677
[](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS) -> float { return RecoDecay::distance(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}); });
77-
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! pt of candidate
78+
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! pt of candidate [GeV/c]
7879
[](float px, float py) -> float { return RecoDecay::pt(px, py); });
79-
DECLARE_SOA_EXPRESSION_COLUMN(Px, px, //! px of candidate
80+
DECLARE_SOA_EXPRESSION_COLUMN(Px, px, //! px of candidate [GeV/c]
8081
float, 1.f * pxProng0 + 1.f * pxProng1);
81-
DECLARE_SOA_EXPRESSION_COLUMN(Py, py, //! py of candidate
82+
DECLARE_SOA_EXPRESSION_COLUMN(Py, py, //! py of candidate [GeV/c]
8283
float, 1.f * pyProng0 + 1.f * pyProng1);
83-
DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! pz of candidate
84+
DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! pz of candidate [GeV/c]
8485
float, 1.f * pzProng0 + 1.f * pzProng1);
85-
DECLARE_SOA_DYNAMIC_COLUMN(M, m, //! invariant mass of candidate
86+
DECLARE_SOA_DYNAMIC_COLUMN(M, m, //! invariant mass of candidate [GeV/c^2]
8687
[](float px0, float py0, float pz0, float px1, float py1, float pz1, const std::array<double, 2>& m) -> float { return RecoDecay::m(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, m); });
8788
DECLARE_SOA_DYNAMIC_COLUMN(Cpa, cpa, //! cosine of pointing angle of candidate
8889
[](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); });
8990
} // namespace hf_cand_prong2
9091

9192
// Candidate table
9293
DECLARE_SOA_TABLE(HfTCand2ProngBase, "AOD", "HFTCAND2PBASE", //! 2-prong candidate table
94+
o2::soa::Index<>,
9395
hf_cand_prong2::CollisionId,
9496
collision::PosX, collision::PosY, collision::PosZ,
9597
hf_cand_prong2::XSecondaryVertex, hf_cand_prong2::YSecondaryVertex, hf_cand_prong2::ZSecondaryVertex,
@@ -116,7 +118,7 @@ namespace hf_selcandidate_d0
116118
{
117119
// Candidate selection columns
118120
DECLARE_SOA_COLUMN(IsSelD0, isSelD0, int); //! selection flag for D0
119-
DECLARE_SOA_COLUMN(IsSelD0bar, isSelD0bar, int); //! selection flag for D0 bar
121+
DECLARE_SOA_COLUMN(IsSelD0bar, isSelD0bar, int); //! selection flag for D0bar
120122
} // namespace hf_selcandidate_d0
121123

122124
// Candidate selection table

Tutorials/PWGHF/README.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,72 @@
44

55
Welcome to the heavy-flavour analysis tutorial!
66

7-
This directory contains the code and configuration for running a minimalistic version of the D<sup>0</sup> analysis on Run 3 real data.
7+
This directory contains the code and configuration for running a minimalistic version of the D<sup>0</sup> analysis on Run 3 data.
88

9-
See the [official PWG-HF O<sup>2</sup> documentation](https://aliceo2group.github.io/analysis-framework/docs/advanced-specifics/pwghf.html) for the overview of the full heavy-flavour analysis framework.
9+
See the [PWG-HF O<sup>2</sup> documentation](https://aliceo2group.github.io/analysis-framework/docs/advanced-specifics/pwghf.html) for the overview of the full heavy-flavour analysis framework.
1010

1111
## Setup
1212

13-
1. Create a dedicated working directory on your device.
14-
This is the directory, where you will put your input files, run the code and produce the output files, so it is a good idea to have it outside the O2Physics repository.
15-
2. Put the input file(s) `AO2D.root` (and `AnalysisResults_trees.root`) in the working directory.
16-
3. Load the O2Physics environment.
13+
1. Create and enter a dedicated working directory on your device.
14+
This is the directory, where you will put your input files, run the code, and produce the output files, so it is a good idea to have it outside the O2Physics repository.
15+
1. Put the input file(s) `AO2D.root` (and `AnalysisResults_trees.root`) in the working directory (or in a dedicated directory for input data).
16+
1. Copy the [`input_skim.txt`](input_skim.txt) and [`input_task.txt`](input_task.txt) files into the working directory and adjust the paths inside if needed.
17+
1. Load the O2Physics environment.
1718

1819
## Skim production
1920

20-
The file `AnalysisResults_trees.root` contains a derived table with track index skims of 2-prong decay candidates.
21-
This table contains paired track indices which point to the track table in the parent `AO2D.root` file.
22-
It is produced from the `AO2D.root` file by a dedicated workflow `o2-analysistutorial-hf-skim-creator-mini` (implemented in [`skimCreatorMini.cxx`](skimCreatorMini.cxx)).
21+
The mini skim creator workflow `o2-analysistutorial-hf-skim-creator-mini` (implemented in [`skimCreatorMini.cxx`](skimCreatorMini.cxx)) is a simplified version of the `o2-analysis-hf-track-index-skim-creator` workflow (implemented in [`trackIndexSkimCreator.cxx`](https://github.com/AliceO2Group/O2Physics/blob/master/PWGHF/TableProducer/trackIndexSkimCreator.cxx)) which is used for the central production of linked derived data for all HF analyses and which performs:
2322

24-
If you need to produce these derived skims, you can do that by executing the [`run_skim.sh`](run_skim.sh) bash script in the working directory:
23+
- the HF event selection,
24+
- the HF secondary-track selection,
25+
- the HF secondary-vertex reconstruction and loose selection of found HF decay candidates.
26+
27+
The mini skim creator processes the `AO2D.root` file(s) and produces a derived table [`HfT2Prongs`](DataModelMini.h) with track index skims of 2-prong decay candidates.
28+
This table contains paired track indices which point to tracks in the track table in the parent `AO2D.root` file.
29+
30+
These derived skims are produced by executing the [`run_skim.sh`](run_skim.sh) bash script in the working directory:
2531

2632
```bash
27-
bash ~/alice/O2Physics/Tutorials/PWGHF/run_skim.sh
33+
~/alice/O2Physics/Tutorials/PWGHF/run_skim.sh
2834
```
2935

30-
It will use the configuration from [`dpl-config_skim.json`](dpl-config_skim.json).
36+
It processes files specified in `./input_skim.txt`, uses the configuration from [`dpl-config_skim.json`](dpl-config_skim.json), and produces the `./AnalysisResults_trees.root` file with the derived table and the `./AnalysisResults.root` file with control histograms.
3137

3238
## Mini task
3339

3440
The mini task workflow `o2-analysistutorial-hf-task-mini` (implemented in [`taskMini.cxx`](taskMini.cxx)) is a simplified version of the D<sup>0</sup> analysis chain part which includes:
3541

36-
- the 2-prong candidate creator,
37-
- the D<sup>0</sup> candidate selector,
38-
- the D<sup>0</sup> analysis task.
42+
- the 2-prong candidate creator (for the full candidate reconstruction),
43+
- the D<sup>0</sup> candidate selector (for the candidate selection),
44+
- the D<sup>0</sup> analysis task (for the analysis of selected candidates and filling of output histograms).
3945

4046
The first step (candidate creator) consumes the track index skim table and therefore needs the derived `AnalysisResults_trees.root` file as input.
4147

4248
Processing the derived file requires access to the parent `AO2D.root` file.
43-
The absolute path to the parent file is stored in the derived file but it can be overridden with the parameter `aod-parent-base-path-replacement` in the JSON configuration,
44-
where one has to provide a replacement mask in the format `"old-path-to-parent;new-path-to-parent"`.
49+
The absolute path to the parent file is stored in the derived file but it can be overridden with the command line parameter `--aod-parent-base-path-replacement "old-path-to-parent;new-path-to-parent"`.
4550
(If the parent and the derived files are both in the same directory, `new-path-to-parent` can be empty.)
4651

4752
Run the mini task by executing the [`run_task.sh`](run_task.sh) bash script in the working directory:
4853

4954
```bash
50-
bash ~/alice/O2Physics/Tutorials/PWGHF/run_task.sh
55+
~/alice/O2Physics/Tutorials/PWGHF/run_task.sh
5156
```
5257

53-
It will use the configuration from [`dpl-config_task.json`](dpl-config_task.json) and produce the output file `AnalysisResults.root` with histograms in the working directory.
58+
It processes files specified in `./input_task.txt`, uses the configuration from [`dpl-config_task.json`](dpl-config_task.json), and produces the `./AnalysisResults.root` file with histograms.
5459

55-
### Exercise tips
60+
## Exercise tips
5661

5762
Organise your working environment so that you can easily switch between running the code in the working directory and modifying the code in the O2Physics repository.
5863

59-
When you execute the bash script, the terminal output is saved in the `stdout.log` log file in the working directory.
64+
When you execute the bash script, the terminal output is saved in the `./stdout.log` log file.
6065
If an error occurs, the script will report the non-zero exit code and ask you to check the log file to find the problem.
66+
If you get errors that have to be tolerated, you need to remove the `--min-failure-level error` option from the command.
67+
68+
The full O<sup>2</sup> configuration is dumped at the end of processing into the `./dpl-config.json` file.
69+
It is useful to compare it with the input configuration file to spot mismatches.
6170

62-
The full O<sup>2</sup> configuration is dumped at the end of processing into the `dpl-config.json` file in the working directory.
71+
See the [rebuilding instructions](https://aliceo2group.github.io/analysis-framework/docs/gettingstarted/installing.html#building-partially-for-development-using-ninja) in the analysis framework documentation for advice on compiling your code changes.
6372

64-
See the [rebuilding instructions](https://aliceo2group.github.io/analysis-framework/docs/gettingstarted/installing.html#building-partially-for-development-using-ninja) in the official O<sup>2</sup> analysis framework documentation for advice on compiling your code changes.
73+
See the [Troubleshooting](https://aliceo2group.github.io/analysis-framework/docs/troubleshooting/) section of the analysis framework documentation for debugging advice.
6574

66-
See the [Troubleshooting](https://aliceo2group.github.io/analysis-framework/docs/troubleshooting/) section of the official O<sup>2</sup> analysis framework documentation for debugging advice.
75+
Consider using the [Shell rc utilities](https://aliceo2group.github.io/analysis-framework/docs/tools/#shell-rc-utilities) for easier recompilation and debugging.

0 commit comments

Comments
 (0)