Skip to content

Commit 00c114a

Browse files
Merge branch 'AliceO2Group:master' into master
2 parents 66f069c + c4f3bed commit 00c114a

61 files changed

Lines changed: 2009 additions & 2021 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.checkov.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
# You can see all available properties here: https://github.com/bridgecrewio/checkov#configuration-using-a-config-file
3+
quiet: true
4+
skip-check:
5+
- CKV_DOCKER_2
6+
- CKV_GHA_7

.github/workflows/labeler.yml

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
name: "Pull Request Labeler"
3-
on:
4-
- pull_request_target
3+
'on':
4+
pull_request_target:
5+
types: [opened, synchronize, reopened, edited]
56
permissions: read-all
67

78
jobs:
@@ -10,8 +11,112 @@ jobs:
1011
permissions:
1112
contents: read
1213
pull-requests: write
14+
outputs:
15+
labels: ${{ steps.labeler.outputs.all-labels }}
1316
steps:
14-
- uses: actions/labeler@v5
17+
- name: Label the PR
18+
id: labeler
19+
uses: actions/labeler@v5
1520
with:
1621
repo-token: ${{ secrets.GITHUB_TOKEN }}
1722
sync-labels: true
23+
title-prefix-checker:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
pull-requests: write
28+
needs: labeler
29+
steps:
30+
- name: Check the PR title prefix
31+
id: check-prefix
32+
env:
33+
title: ${{ github.event.pull_request.title }}
34+
labels: ${{ needs.labeler.outputs.labels }}
35+
shell: python
36+
run: |
37+
import os
38+
import re
39+
import sys
40+
title = os.environ['title']
41+
labels = os.environ['labels']
42+
tags = {
43+
"infrastructure": "Infrastructure",
44+
"common": "Common",
45+
"alice3": "ALICE3",
46+
"pwgcf": "PWGCF",
47+
"pwgdq": "PWGDQ",
48+
"pwgem": "PWGEM",
49+
"pwghf": "PWGHF",
50+
"pwgje": "PWGJE",
51+
"pwglf": "PWGLF",
52+
"pwgud": "PWGUD",
53+
"dpg": "DPG",
54+
"trigger": "Trigger",
55+
"tutorial": "Tutorial",
56+
}
57+
print(f'PR title: "{title}"')
58+
print(f'PR labels: "{labels}"')
59+
tags_relevant = [tags[label] for label in tags if label in labels.split(",")]
60+
print("Relevant title tags:", ",".join(tags_relevant))
61+
passed = True
62+
prefix_good = ",".join(tags_relevant)
63+
prefix_good = f"[{prefix_good}] "
64+
print(f"Generated prefix: {prefix_good}")
65+
replace_title = 0
66+
title_new = title
67+
# If there is a prefix which contains a known tag, check it for correct tags, and reformat it if needed.
68+
# If there is a prefix which does not contain any known tag, add the tag prefix.
69+
# If there is no prefix, add the tag prefix.
70+
if match := re.match(r"\[?(\w[\w, /\+-]+)[\]:]+ ", title):
71+
prefix_title = match.group(1)
72+
words_prefix_title = prefix_title.replace(",", " ").replace("/", " ").split()
73+
title_stripped = title[len(match.group()) :]
74+
print(f'PR title prefix: "{prefix_title}" -> tags: {words_prefix_title}')
75+
print(f'Stripped PR title: "{title_stripped}"')
76+
if any(tag in words_prefix_title for tag in tags.values()):
77+
for tag in tags.values():
78+
if tag in tags_relevant and tag not in words_prefix_title:
79+
print(f'::error::Relevant tag "{tag}" not found in the prefix of the PR title.')
80+
passed = False
81+
if tag not in tags_relevant and tag in words_prefix_title:
82+
print(f'::error::Irrelevant tag "{tag}" found in the prefix of the PR title.')
83+
passed = False
84+
# Format a valid prefix.
85+
if passed:
86+
prefix_good = ",".join(w for w in prefix_title.replace(",", " ").split() if w)
87+
prefix_good = f"[{prefix_good}] "
88+
print(f"::notice::Reformatted prefix: {prefix_good}")
89+
if match.group() != prefix_good:
90+
replace_title = 1
91+
title_new = prefix_good + title_stripped
92+
else:
93+
print("::warning::No known tags found in the prefix.")
94+
if tags_relevant:
95+
replace_title = 1
96+
title_new = prefix_good + title
97+
else:
98+
print("::warning::No valid prefix found in the PR title.")
99+
if tags_relevant:
100+
replace_title = 1
101+
title_new = prefix_good + title
102+
if not passed:
103+
print("::error::Problems were found in the PR title prefix.")
104+
print('::notice::Use the form "tags: title" or "[tags] title".')
105+
sys.exit(1)
106+
if replace_title:
107+
print("::warning::The PR title prefix with tags needs to be added or adjusted.")
108+
print(f'::warning::New title: "{title_new}".')
109+
else:
110+
print("::notice::The PR title prefix is fine.")
111+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
112+
print(f"replace={replace_title}", file=fh)
113+
print(f"title={title_new}", file=fh)
114+
- name: Fix the PR title prefix
115+
if: ${{ steps.check-prefix.outputs.replace == 1 }}
116+
uses: the-wright-jamie/Update-PR-Info-Action@v1.1.0
117+
with:
118+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
119+
base-branch-regex: master
120+
error-on-fail: false
121+
title-template: "${{ steps.check-prefix.outputs.title }}"
122+
title-update-action: replace

.github/workflows/mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
id: ml
3939
# You can override MegaLinter flavor used to have faster performances
4040
# More info at https://megalinter.io/flavors/
41-
uses: oxsecurity/megalinter@v8
41+
uses: oxsecurity/megalinter@v8.1.0
4242
env:
4343
# All available variables are described in documentation:
4444
# https://megalinter.io/configuration/

CPPLINT.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
filter=-build/c++11,-build/namespaces,-readability/fn_size,-readability/todo,-runtime/references,-whitespace/blank_line,-whitespace/braces,-whitespace/comments,-whitespace/line_length,-whitespace/semicolon,-whitespace/todo
1+
filter=-build/c++11,-build/namespaces,-readability/fn_size,-readability/todo,-runtime/references,-whitespace/blank_line,-whitespace/braces,-whitespace/comments,-whitespace/indent_namespace,-whitespace/line_length,-whitespace/semicolon,-whitespace/todo

Common/TableProducer/ft0CorrectedTable.cxx

Lines changed: 157 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,89 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include <bitset>
13-
#include "Common/DataModel/FT0Corrected.h"
1413
#include "Framework/ConfigParamSpec.h"
1514
#include "Framework/runDataProcessing.h"
1615
#include "Framework/AnalysisTask.h"
17-
#include "Common/DataModel/EventSelection.h"
1816
#include "Framework/AnalysisDataModel.h"
17+
#include "Framework/HistogramRegistry.h"
18+
#include "Common/DataModel/FT0Corrected.h"
19+
#include "Common/DataModel/EventSelection.h"
1920
#include "CommonConstants/LHCConstants.h"
2021
#include "CommonConstants/PhysicsConstants.h"
2122
#include "DataFormatsFT0/Digit.h"
23+
#include "CCDB/BasicCCDBManager.h"
24+
#include "CollisionTypeHelper.h"
25+
#include "TRandom3.h"
2226

2327
using namespace o2;
2428
using namespace o2::framework;
25-
2629
using namespace o2::aod;
27-
struct FT0CorrectedTable {
30+
31+
struct ft0CorrectedTable {
32+
// Configurables
33+
Configurable<float> resoFT0A{"resoFT0A", 20.f, "FT0A resolution"};
34+
Configurable<float> resoFT0C{"resoFT0C", 20.f, "FT0C resolution"};
35+
Configurable<bool> addHistograms{"addHistograms", false, "Add QA histograms"};
36+
Configurable<int> cfgCollisionSystem{"collisionSystem", -2, "Collision system: -2 (use cfg values), -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"};
37+
Configurable<std::string> cfgUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
38+
Configurable<std::string> cfgPathGrpLhcIf{"ccdb-path-grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"};
39+
Configurable<int64_t> cfgTimestamp{"ccdb-timestamp", -1, "timestamp of the object"};
40+
Service<o2::ccdb::BasicCCDBManager> ccdb;
41+
42+
// Producer
2843
Produces<o2::aod::FT0sCorrected> table;
2944
using BCsWithMatchings = soa::Join<aod::BCs, aod::Run3MatchedToBCSparse>;
3045
using CollisionEvSel = soa::Join<aod::Collisions, aod::EvSels>::iterator;
46+
static constexpr float invLightSpeedCm2NS = 1.f / o2::constants::physics::LightSpeedCm2NS;
3147

32-
void process(BCsWithMatchings const&, soa::Join<aod::Collisions, aod::EvSels> const& collisions, aod::FT0s const&)
48+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
49+
void init(o2::framework::InitContext&)
3350
{
51+
if (doprocessStandard && doprocessWithBypassFT0timeInMC) {
52+
LOG(fatal) << "Both processStandard and processWithBypassFT0timeInMC are enabled. Pick one of the two";
53+
}
54+
if (!doprocessStandard && !doprocessWithBypassFT0timeInMC) {
55+
LOG(fatal) << "No process is enabled. Pick one";
56+
}
57+
ccdb->setURL(cfgUrl);
58+
ccdb->setTimestamp(cfgTimestamp);
59+
ccdb->setCaching(true);
60+
ccdb->setLocalObjectValidityChecking();
61+
// Not later than now objects
62+
ccdb->setCreatedNotAfter(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
63+
64+
if (!addHistograms) {
65+
return;
66+
}
67+
histos.add("t0A", "t0A", kTH1D, {{1000, -1, 1, "t0A (ns)"}});
68+
histos.add("t0C", "t0C", kTH1D, {{1000, -1, 1, "t0C (ns)"}});
69+
histos.add("t0AC", "t0AC", kTH1D, {{1000, -1000, 1000, "t0AC (ns)"}});
70+
histos.add("deltat0AC", "deltat0AC", kTH1D, {{1000, -10, 10, "#Deltat0AC (ns)"}});
71+
if (doprocessWithBypassFT0timeInMC) {
72+
histos.add("MC/deltat0A", "t0A", kTH1D, {{1000, -50, 50, "t0A (ps)"}});
73+
histos.add("MC/deltat0C", "t0C", kTH1D, {{1000, -50, 50, "t0C (ps)"}});
74+
histos.add("MC/deltat0AC", "t0AC", kTH1D, {{1000, -50, 50, "t0AC (ps)"}});
75+
}
76+
}
77+
78+
void processStandard(soa::Join<aod::Collisions, aod::EvSels> const& collisions,
79+
BCsWithMatchings const&,
80+
aod::FT0s const&)
81+
{
82+
table.reserve(collisions.size());
83+
float t0A = 1e10f;
84+
float t0C = 1e10f;
3485
for (auto& collision : collisions) {
35-
float vertexPV = collision.posZ();
36-
float vertex_corr = vertexPV / o2::constants::physics::LightSpeedCm2NS;
37-
float t0A = 1e10;
38-
float t0C = 1e10;
86+
t0A = 1e10f;
87+
t0C = 1e10f;
88+
const float vertexPV = collision.posZ();
89+
const float vertex_corr = vertexPV * invLightSpeedCm2NS;
3990
constexpr float dummyTime = 30.; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns
4091
if (collision.has_foundFT0()) {
41-
auto ft0 = collision.foundFT0();
42-
std::bitset<8> triggers = ft0.triggerMask();
43-
bool ora = triggers[o2::ft0::Triggers::bitA];
44-
bool orc = triggers[o2::ft0::Triggers::bitC];
92+
const auto& ft0 = collision.foundFT0();
93+
const std::bitset<8>& triggers = ft0.triggerMask();
94+
const bool ora = triggers[o2::ft0::Triggers::bitA];
95+
const bool orc = triggers[o2::ft0::Triggers::bitC];
4596
LOGF(debug, "triggers OrA %i OrC %i ", ora, orc);
4697
LOGF(debug, " T0A = %f, T0C %f, vertex_corr %f", ft0.timeA(), ft0.timeC(), vertex_corr);
4798
if (ora && ft0.timeA() < dummyTime) {
@@ -52,11 +103,100 @@ struct FT0CorrectedTable {
52103
}
53104
}
54105
LOGF(debug, " T0 collision time T0A = %f, T0C = %f", t0A, t0C);
106+
if (addHistograms) {
107+
histos.fill(HIST("t0A"), t0A);
108+
histos.fill(HIST("t0C"), t0C);
109+
histos.fill(HIST("t0AC"), (t0A + t0C) * 0.5f);
110+
histos.fill(HIST("deltat0AC"), t0A - t0C);
111+
}
112+
table(t0A, t0C);
113+
}
114+
}
115+
PROCESS_SWITCH(ft0CorrectedTable, processStandard, "Process standard table (default)", true);
116+
117+
void processWithBypassFT0timeInMC(soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels> const& collisions,
118+
soa::Join<BCsWithMatchings, aod::Timestamps> const& bcs,
119+
aod::FT0s const&,
120+
aod::McCollisions const&)
121+
{
122+
if (cfgCollisionSystem.value == -1) {
123+
o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp<o2::parameters::GRPLHCIFData>(cfgPathGrpLhcIf,
124+
bcs.iteratorAt(0).timestamp());
125+
cfgCollisionSystem.value = CollisionSystemType::getCollisionTypeFromGrp(grpo);
126+
switch (cfgCollisionSystem.value) {
127+
case CollisionSystemType::kCollSyspp:
128+
resoFT0A.value = 24.f;
129+
resoFT0C.value = 24.f;
130+
break;
131+
case CollisionSystemType::kCollSysPbPb:
132+
resoFT0A.value = 5.65f;
133+
resoFT0C.value = 5.65f;
134+
break;
135+
default:
136+
break;
137+
}
138+
}
139+
table.reserve(collisions.size());
140+
float t0A = 1e10f;
141+
float t0C = 1e10f;
142+
float eventtimeMC = 1e10f;
143+
float posZMC = 0;
144+
bool hasMCcoll = false;
145+
146+
for (auto& collision : collisions) {
147+
hasMCcoll = false;
148+
eventtimeMC = 1e10f;
149+
t0A = 1e10f;
150+
t0C = 1e10f;
151+
posZMC = 0;
152+
const float vertexPV = collision.posZ();
153+
const float vertex_corr = vertexPV * invLightSpeedCm2NS;
154+
constexpr float dummyTime = 30.; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns
155+
if (collision.has_mcCollision()) {
156+
hasMCcoll = true;
157+
const auto& collisionMC = collision.mcCollision();
158+
eventtimeMC = collisionMC.t();
159+
posZMC = collisionMC.posZ();
160+
}
161+
if (collision.has_foundFT0()) {
162+
const auto& ft0 = collision.foundFT0();
163+
const std::bitset<8>& triggers = ft0.triggerMask();
164+
const bool ora = triggers[o2::ft0::Triggers::bitA];
165+
const bool orc = triggers[o2::ft0::Triggers::bitC];
166+
167+
if (ora && ft0.timeA() < dummyTime) {
168+
t0A = ft0.timeA();
169+
if (hasMCcoll) {
170+
const float diff = eventtimeMC - posZMC * invLightSpeedCm2NS + gRandom->Gaus(0.f, resoFT0A);
171+
t0A = diff;
172+
}
173+
t0A += vertex_corr;
174+
}
175+
if (orc && ft0.timeC() < dummyTime) {
176+
t0C = ft0.timeC();
177+
if (hasMCcoll) {
178+
const float diff = eventtimeMC + posZMC * invLightSpeedCm2NS + gRandom->Gaus(0.f, resoFT0C);
179+
t0C = diff;
180+
}
181+
t0C -= vertex_corr;
182+
}
183+
}
184+
LOGF(debug, " T0 collision time T0A = %f, T0C = %f", t0A, t0C);
185+
if (addHistograms) {
186+
histos.fill(HIST("t0A"), t0A);
187+
histos.fill(HIST("t0C"), t0C);
188+
histos.fill(HIST("t0AC"), (t0A + t0C) * 0.5f);
189+
histos.fill(HIST("deltat0AC"), t0A - t0C);
190+
if (hasMCcoll) {
191+
histos.fill(HIST("MC/deltat0A"), (t0A - eventtimeMC) * 1000.f);
192+
histos.fill(HIST("MC/deltat0C"), (t0C - eventtimeMC) * 1000.f);
193+
histos.fill(HIST("MC/deltat0AC"), ((t0A + t0C) * 0.5f - eventtimeMC) * 1000.f);
194+
}
195+
}
55196
table(t0A, t0C);
56197
}
57198
}
199+
PROCESS_SWITCH(ft0CorrectedTable, processWithBypassFT0timeInMC, "Process MC with bypass of the AO2D information. Use with care!", false);
58200
};
59-
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
60-
{
61-
return WorkflowSpec{adaptAnalysisTask<FT0CorrectedTable>(cfgc, TaskName{"ft0-corrected-table"})};
62-
}
201+
202+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<ft0CorrectedTable>(cfgc)}; }

0 commit comments

Comments
 (0)