Skip to content

Commit 7758661

Browse files
committed
style: Apply clang-format formatting standards
1 parent 38b58de commit 7758661

File tree

1 file changed

+54
-44
lines changed

1 file changed

+54
-44
lines changed

Tools/PIDFeatureExtractor/PIDFeatureExtractor.cxx

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
/// \brief Task to extract particle identification features from ALICE AO2D data for machine learning workflows
1414
/// \author Robert Forynski
1515

16-
#include "Framework/runDataProcessing.h"
17-
#include "Framework/AnalysisTask.h"
16+
#include "Common/DataModel/EventSelection.h"
17+
#include "Common/DataModel/PIDResponse.h"
1818
#include "Common/DataModel/TrackSelectionTables.h"
19+
1920
#include "Framework/ASoAHelpers.h"
20-
#include "Common/DataModel/PIDResponse.h"
21-
#include "Common/DataModel/EventSelection.h"
21+
#include "Framework/AnalysisTask.h"
22+
#include "Framework/runDataProcessing.h"
23+
2224
#include "TFile.h"
2325
#include "TTree.h"
24-
#include <fstream>
26+
2527
#include <cmath>
26-
#include <string>
28+
#include <fstream>
2729
#include <memory>
30+
#include <string>
2831

2932
using namespace o2;
3033
using namespace o2::framework;
@@ -51,44 +54,44 @@ struct PIDFeatureExtractor {
5154
int trackId; /// Track index within the event
5255

5356
// Momentum components (in GeV/c)
54-
float px, py, pz; /// Cartesian momentum components
55-
float pt, p; /// Transverse momentum and total momentum
57+
float px, py, pz; /// Cartesian momentum components
58+
float pt, p; /// Transverse momentum and total momentum
5659

5760
// Angular variables
58-
float eta; /// Pseudorapidity
59-
float phi; /// Azimuthal angle
60-
float theta; /// Polar angle (calculated from eta)
61+
float eta; /// Pseudorapidity
62+
float phi; /// Azimuthal angle
63+
float theta; /// Polar angle (calculated from eta)
6164

6265
// Track properties
63-
int charge; /// Track charge (+1 or -1)
64-
int trackType; /// Type of track (e.g., 0=global, 1=TPC-only, etc.)
66+
int charge; /// Track charge (+1 or -1)
67+
int trackType; /// Type of track (e.g., 0=global, 1=TPC-only, etc.)
6568

6669
// ============================================================================
6770
// TPC VARIABLES - Time Projection Chamber PID information
6871
// ============================================================================
69-
float tpcSignal; /// dE/dx energy loss in TPC (specific ionization)
72+
float tpcSignal; /// dE/dx energy loss in TPC (specific ionization)
7073

7174
// n-sigma values: standard deviations from expected energy loss for each particle
72-
float tpcNsigmaPi; /// n-sigma for pion (π)
73-
float tpcNsigmaKa; /// n-sigma for kaon (K)
74-
float tpcNsigmaPr; /// n-sigma for proton (p)
75-
float tpcNsigmaEl; /// n-sigma for electron (e)
75+
float tpcNsigmaPi; /// n-sigma for pion (π)
76+
float tpcNsigmaKa; /// n-sigma for kaon (K)
77+
float tpcNsigmaPr; /// n-sigma for proton (p)
78+
float tpcNsigmaEl; /// n-sigma for electron (e)
7679

7780
// Track quality variables
78-
int tpcNclusters; /// Number of TPC clusters used in track fit
79-
float tpcChi2; /// Chi-square per degree of freedom of TPC fit
81+
int tpcNclusters; /// Number of TPC clusters used in track fit
82+
float tpcChi2; /// Chi-square per degree of freedom of TPC fit
8083

8184
// ============================================================================
8285
// TOF VARIABLES - Time-Of-Flight PID information
8386
// ============================================================================
84-
float tofBeta; /// β = v/c (velocity over speed of light)
85-
float tofMass; /// Reconstructed mass from TOF measurement
87+
float tofBeta; /// β = v/c (velocity over speed of light)
88+
float tofMass; /// Reconstructed mass from TOF measurement
8689

8790
// n-sigma values for TOF detection
88-
float tofNsigmaPi; /// n-sigma for pion in TOF
89-
float tofNsigmaKa; /// n-sigma for kaon in TOF
90-
float tofNsigmaPr; /// n-sigma for proton in TOF
91-
float tofNsigmaEl; /// n-sigma for electron in TOF
91+
float tofNsigmaPi; /// n-sigma for pion in TOF
92+
float tofNsigmaKa; /// n-sigma for kaon in TOF
93+
float tofNsigmaPr; /// n-sigma for proton in TOF
94+
float tofNsigmaEl; /// n-sigma for electron in TOF
9295

9396
// ============================================================================
9497
// BAYESIAN PID VARIABLES - Combined PID probabilities
@@ -105,20 +108,20 @@ struct PIDFeatureExtractor {
105108
// ============================================================================
106109
// MONTE CARLO TRUTH INFORMATION - For simulated data
107110
// ============================================================================
108-
int mcPdg; /// PDG code of true particle (0 if no MC match)
109-
float mcPx, mcPy, mcPz; /// True momentum components from simulation
111+
int mcPdg; /// PDG code of true particle (0 if no MC match)
112+
float mcPx, mcPy, mcPz; /// True momentum components from simulation
110113

111114
// ============================================================================
112115
// DETECTOR AVAILABILITY FLAGS
113116
// ============================================================================
114-
bool hasTpc; /// Flag: track has TPC information
115-
bool hasTof; /// Flag: track has TOF information
117+
bool hasTpc; /// Flag: track has TPC information
118+
bool hasTof; /// Flag: track has TOF information
116119

117120
// ============================================================================
118121
// TRACK IMPACT PARAMETERS - Quality and background rejection
119122
// ============================================================================
120-
float dcaXy; /// Distance of closest approach in xy-plane
121-
float dcaZ; /// Distance of closest approach in z-direction
123+
float dcaXy; /// Distance of closest approach in xy-plane
124+
float dcaZ; /// Distance of closest approach in z-direction
122125

123126
// ============================================================================
124127
// HISTOGRAM REGISTRY - Quality control histograms
@@ -164,7 +167,8 @@ struct PIDFeatureExtractor {
164167
// INITIALIZATION FUNCTION
165168
// ============================================================================
166169
/// Initialize output files and histograms
167-
void init(InitContext const&) {
170+
void init(InitContext const&)
171+
{
168172
std::string base = outputPath.value;
169173

170174
// ROOT OUTPUT SETUP
@@ -254,12 +258,13 @@ struct PIDFeatureExtractor {
254258
// BAYESIAN PID CALCULATION FUNCTION
255259
// ============================================================================
256260
/// Compute Bayesian probabilities combining TPC and TOF information
257-
void computeBayesianPID(const float nsTPC[KNumSpecies], const float nsTOF[KNumSpecies], const float pri[KNumSpecies], float out[KNumSpecies]) {
261+
void computeBayesianPID(const float nsTPC[KNumSpecies], const float nsTOF[KNumSpecies], const float pri[KNumSpecies], float out[KNumSpecies])
262+
{
258263
float sum = 0;
259264

260265
for (int i = 0; i < KNumSpecies; i++) {
261-
float l = std::exp(-0.5f * (nsTPC[i]*nsTPC[i] +
262-
(std::isfinite(nsTOF[i]) ? nsTOF[i]*nsTOF[i] : 0.0f)));
266+
float l = std::exp(-0.5f * (nsTPC[i] * nsTPC[i] +
267+
(std::isfinite(nsTOF[i]) ? nsTOF[i] * nsTOF[i] : 0.0f)));
263268

264269
out[i] = l * pri[i];
265270
sum += out[i];
@@ -285,17 +290,18 @@ struct PIDFeatureExtractor {
285290
aod::pidTOFPi, aod::pidTOFKa, aod::pidTOFPr,
286291
aod::pidTOFEl,
287292
aod::pidTOFmass, aod::pidTOFbeta,
288-
aod::McTrackLabels
289-
> const& tracks,
293+
aod::McTrackLabels> const& tracks,
290294
aod::McParticles const& mcParticles)
291295
{
292296
static int eventCounter = 0;
293297
eventId = eventCounter++;
294298
int idx = 0;
295299

296300
for (const auto& t : tracks) {
297-
if (t.pt() < ptMin || t.pt() > ptMax) continue;
298-
if (t.eta() < etaMin || t.eta() > etaMax) continue;
301+
if (t.pt() < ptMin || t.pt() > ptMax)
302+
continue;
303+
if (t.eta() < etaMin || t.eta() > etaMax)
304+
continue;
299305

300306
trackId = idx++;
301307

@@ -370,7 +376,8 @@ struct PIDFeatureExtractor {
370376
}
371377

372378
// Write outputs
373-
if (exportROOT) featureTree->Fill();
379+
if (exportROOT)
380+
featureTree->Fill();
374381
if (exportCSV) {
375382
csvFile << eventId << "," << trackId << ","
376383
<< px << "," << py << "," << pz << ","
@@ -390,7 +397,8 @@ struct PIDFeatureExtractor {
390397
histos.fill(HIST("QC/nTracks"), 1);
391398
histos.fill(HIST("QC/pt"), pt);
392399
histos.fill(HIST("QC/eta"), eta);
393-
if (hasTpc) histos.fill(HIST("QC/tpc_dEdx_vs_pt"), pt, tpcSignal);
400+
if (hasTpc)
401+
histos.fill(HIST("QC/tpc_dEdx_vs_pt"), pt, tpcSignal);
394402
if (hasTof) {
395403
histos.fill(HIST("QC/tof_beta_vs_p"), p, tofBeta);
396404
histos.fill(HIST("QC/mass_vs_p"), p, tofMass);
@@ -402,7 +410,8 @@ struct PIDFeatureExtractor {
402410
// FINALIZATION FUNCTION
403411
// ============================================================================
404412
/// Clean up and finalize output files
405-
void finalize() {
413+
void finalize()
414+
{
406415
if (exportROOT) {
407416
outputFile->cd();
408417
featureTree->Write();
@@ -418,6 +427,7 @@ struct PIDFeatureExtractor {
418427
// WORKFLOW DEFINITION
419428
// ============================================================================
420429
/// Define the O2Physics workflow
421-
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) {
430+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
431+
{
422432
return WorkflowSpec{adaptAnalysisTask<PIDFeatureExtractor>(cfgc)};
423433
}

0 commit comments

Comments
 (0)