Skip to content

Commit 0c78590

Browse files
committed
linter and clang tidy
1 parent 8924407 commit 0c78590

2 files changed

Lines changed: 41 additions & 45 deletions

File tree

PWGHF/Tasks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ o2physics_add_dpl_workflow(task-pid-studies
5151

5252
o2physics_add_dpl_workflow(task-mc-injection
5353
SOURCES taskMcInjection.cxx
54-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils
54+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
5555
COMPONENT_NAME Analysis)
5656

5757
# o2physics_add_dpl_workflow(task-sel-optimisation

PWGHF/Tasks/taskMcInjection.cxx

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,21 @@
1515
/// \author Fabrizio Chinu <fabrizio.chinu@cern.ch>, Università and INFN Torino
1616

1717
#include "Common/DataModel/Centrality.h"
18-
#include "Common/DataModel/EventSelection.h"
19-
#include "Common/DataModel/Multiplicity.h"
2018

2119
#include <Framework/ASoA.h>
2220
#include <Framework/AnalysisDataModel.h>
21+
#include <Framework/AnalysisHelpers.h>
2322
#include <Framework/AnalysisTask.h>
24-
#include <Framework/Configurable.h>
2523
#include <Framework/HistogramRegistry.h>
2624
#include <Framework/HistogramSpec.h>
2725
#include <Framework/InitContext.h>
28-
#include <Framework/StaticFor.h>
2926
#include <Framework/runDataProcessing.h>
3027

31-
#include <TH2.h>
32-
#include <TPDGCode.h>
28+
#include <TH1.h>
3329

34-
#include <array>
35-
#include <cstdint>
30+
#include <algorithm>
3631
#include <cstdlib>
3732
#include <memory>
38-
#include <string>
39-
#include <string_view>
4033
#include <vector>
4134

4235
using namespace o2;
@@ -62,11 +55,11 @@ DECLARE_SOA_COLUMN(Centrality, centrality, int); //! Centrality FT0C
6255
DECLARE_SOA_COLUMN(XCollRec, xCollRec, float); //! Reconstructed x coordinate of the collision
6356
DECLARE_SOA_COLUMN(YCollRec, yCollRec, float); //! Reconstructed y coordinate of the collision
6457
DECLARE_SOA_COLUMN(ZCollRec, zCollRec, float); //! Reconstructed z coordinate of the collision
65-
DECLARE_SOA_COLUMN(BC, Bc, int); //! Bunch crossing
58+
DECLARE_SOA_COLUMN(Bc, bc, int); //! Bunch crossing
6659
// Tracks
67-
DECLARE_SOA_COLUMN(VX, vx, float); // x coordinate of the track production vertex
68-
DECLARE_SOA_COLUMN(VY, vy, float); // y coordinate of the track production vertex
69-
DECLARE_SOA_COLUMN(VZ, vz, float); // z coordinate of the track production vertex
60+
DECLARE_SOA_COLUMN(Vx, vx, float); // x coordinate of the track production vertex
61+
DECLARE_SOA_COLUMN(Vy, vy, float); // y coordinate of the track production vertex
62+
DECLARE_SOA_COLUMN(Vz, vz, float); // z coordinate of the track production vertex
7063
DECLARE_SOA_COLUMN(IsFromSignal, isFromSignal, bool); // Whether the track is from the signal event
7164
} // namespace check_mc_pv_contr
7265

@@ -85,52 +78,37 @@ DECLARE_SOA_TABLE(CheckInj, "AOD", "CHECKINJ", //! Table with PID information
8578
check_mc_pv_contr::NCharmFromInj,
8679
check_mc_pv_contr::NPVContributors,
8780
check_mc_pv_contr::Centrality,
88-
check_mc_pv_contr::BC);
81+
check_mc_pv_contr::Bc);
8982

9083
DECLARE_SOA_TABLE(TracksInjection, "AOD", "TRKINJ", //! Table with MC labels for tracks
9184
check_mc_pv_contr::IdCollGen,
92-
check_mc_pv_contr::VX,
93-
check_mc_pv_contr::VY,
94-
check_mc_pv_contr::VZ,
85+
check_mc_pv_contr::Vx,
86+
check_mc_pv_contr::Vy,
87+
check_mc_pv_contr::Vz,
9588
check_mc_pv_contr::IsFromSignal);
9689
} // namespace o2::aod
9790

98-
struct taskMcInjection {
91+
struct HfTaskMcInjection {
9992

10093
Produces<o2::aod::CheckInj> checkInj;
10194
Produces<o2::aod::TracksInjection> tracksInj;
10295

96+
Configurable<double> centMaxForCollDelta{"centMaxForCollDelta", 20., "max. cent. for gen-rec collision position histograms"};
97+
98+
std::shared_ptr<TH1> hCharmPerCollImpPar, hCollisions;
99+
103100
using TrackWLabels = soa::Join<aod::Tracks, aod::McTrackLabels>;
104101
using CollisionWLabels = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::CentFT0Cs, aod::CentNTPVs>;
105102

106-
PresliceUnsorted<CollisionWLabels> colPerMcCollision = aod::mccollisionlabel::mcCollisionId;
107103
Preslice<TrackWLabels> tracksPerCollision = aod::track::collisionId;
108104
Preslice<aod::McParticles> perMcCollision = aod::mcparticle::mcCollisionId;
109-
110-
HistogramRegistry registry{"registry", {}};
111-
std::shared_ptr<TH1> hCharmPerCollImpPar, hCollisions;
105+
PresliceUnsorted<CollisionWLabels> colPerMcCollision = aod::mccollisionlabel::mcCollisionId;
112106

113107
AxisSpec impParBins = {200, 0, 20};
114108
AxisSpec deltaXYbins = {200, -0.05, 0.05};
115109
AxisSpec deltaZbins = {200, -10, 10};
116110

117-
bool isCharm(int pdg)
118-
{
119-
if (std::abs(pdg) / 1000 == 4)
120-
return true;
121-
if (std::abs(pdg) / 100 == 4)
122-
return true;
123-
return false;
124-
}
125-
126-
bool isBeauty(int pdg) // if needed in the future
127-
{
128-
if (std::abs(pdg) / 1000 == 5)
129-
return true;
130-
if (std::abs(pdg) / 100 == 5)
131-
return true;
132-
return false;
133-
}
111+
HistogramRegistry registry{"registry", {}};
134112

135113
void init(InitContext&)
136114
{
@@ -159,12 +137,29 @@ struct taskMcInjection {
159137
hCollisions->GetXaxis()->SetBinLabel(2, "Reconstructed");
160138
}
161139

140+
bool isCharm(int pdg)
141+
{
142+
if (std::abs(pdg) / 1000 == 4) // o2-linter: disable=pdg/explicit-code magic-number
143+
return true;
144+
if (std::abs(pdg) / 100 == 4) // o2-linter: disable=pdg/explicit-code magic-number
145+
return true;
146+
return false;
147+
}
148+
149+
bool isBeauty(int pdg) // if needed in the future
150+
{
151+
if (std::abs(pdg) / 1000 == 5) // o2-linter: disable=pdg/explicit-code magic-number
152+
return true;
153+
if (std::abs(pdg) / 100 == 5) // o2-linter: disable=pdg/explicit-code magic-number
154+
return true;
155+
return false;
156+
}
157+
162158
void process(CollisionWLabels const& collisions,
163159
TrackWLabels const& tracks,
164160
aod::McParticles const& mcParticles,
165161
aod::McCollisions const& mcCollisions)
166162
{
167-
int splitColls{0};
168163
for (const auto& mcColl : mcCollisions) {
169164
registry.fill(HIST("hCollImpPar"), mcColl.impactParameter());
170165
const auto mcPartColl = mcParticles.sliceBy(perMcCollision, mcColl.globalIndex());
@@ -200,12 +195,13 @@ struct taskMcInjection {
200195
const auto collTracks = tracks.sliceBy(tracksPerCollision, collision.globalIndex());
201196
std::vector<int> charmIds{};
202197
int fromSignalEv{0};
203-
if (collision.centFT0C() < 20.f) {
198+
if (collision.centFT0C() < centMaxForCollDelta) {
204199
registry.fill(HIST("hDeltaX"), collision.posX() - collision.mcCollision().posX());
205200
registry.fill(HIST("hDeltaY"), collision.posY() - collision.mcCollision().posY());
206201
registry.fill(HIST("hDeltaZ"), collision.posZ() - collision.mcCollision().posZ());
207202

208-
if (collision.numContrib() > 2000) {
203+
constexpr unsigned maxNcontrib{2000};
204+
if (collision.numContrib() > maxNcontrib) {
209205
registry.fill(HIST("hDeltaX_NPV_gt2000"), collision.posX() - collision.mcCollision().posX());
210206
registry.fill(HIST("hDeltaY_NPV_gt2000"), collision.posY() - collision.mcCollision().posY());
211207
registry.fill(HIST("hDeltaZ_NPV_gt2000"), collision.posZ() - collision.mcCollision().posZ());
@@ -245,5 +241,5 @@ struct taskMcInjection {
245241

246242
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
247243
{
248-
return WorkflowSpec{adaptAnalysisTask<taskMcInjection>(cfgc)};
244+
return WorkflowSpec{adaptAnalysisTask<HfTaskMcInjection>(cfgc)};
249245
}

0 commit comments

Comments
 (0)