Skip to content

Commit 120b784

Browse files
njacazioalibuild
andauthored
[ALICE3] Update TrackUtilities.h (#12058)
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
1 parent cba0a9b commit 120b784

File tree

3 files changed

+54
-29
lines changed

3 files changed

+54
-29
lines changed

ALICE3/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
o2physics_add_library(ALICE3Core
1313
SOURCES TOFResoALICE3.cxx
14+
TrackUtilities.cxx
1415
DelphesO2TrackSmearer.cxx
1516
PUBLIC_LINK_LIBRARIES O2::Framework
1617
O2Physics::AnalysisCore)

ALICE3/Core/TrackUtilities.cxx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
/// \file TrackUtilities.cxx
13+
/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT)
14+
/// \brief Set of utilities for the ALICE3 track handling
15+
/// \since May 21, 2025
16+
///
17+
18+
#include "TrackUtilities.h"
19+
20+
#include <vector>
21+
22+
void o2::upgrade::convertTLorentzVectorToO2Track(const int charge,
23+
const TLorentzVector particle,
24+
const std::vector<double> productionVertex,
25+
o2::track::TrackParCov& o2track)
26+
{
27+
std::array<float, 5> params;
28+
std::array<float, 15> covm = {0.};
29+
float s, c, x;
30+
o2::math_utils::sincos(static_cast<float>(particle.Phi()), s, c);
31+
o2::math_utils::rotateZInv(static_cast<float>(productionVertex[0]), static_cast<float>(productionVertex[1]), x, params[0], s, c);
32+
params[1] = static_cast<float>(productionVertex[2]);
33+
params[2] = 0.; // since alpha = phi
34+
const auto theta = 2. * std::atan(std::exp(-particle.PseudoRapidity()));
35+
params[3] = 1. / std::tan(theta);
36+
params[4] = charge / particle.Pt();
37+
38+
// Initialize TrackParCov in-place
39+
new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm);
40+
}

ALICE3/Core/TrackUtilities.h

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111
///
12-
/// \file TrackUtilities.h
13-
///
14-
/// \brief Set of utilities for the ALICE3 track handling
15-
///
12+
/// \file TrackUtilities.h
13+
/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT)
14+
/// \brief Set of utilities for the ALICE3 track handling
1615
/// \since May 21, 2025
1716
///
1817

1918
#ifndef ALICE3_CORE_TRACKUTILITIES_H_
2019
#define ALICE3_CORE_TRACKUTILITIES_H_
2120

22-
#include <vector>
23-
2421
#include "ReconstructionDataFormats/Track.h"
25-
#include "Framework/O2DatabasePDGPlugin.h"
26-
#include "Framework/AnalysisHelpers.h"
22+
2723
#include "TLorentzVector.h"
2824

25+
#include <vector>
26+
2927
namespace o2::upgrade
3028
{
3129

@@ -37,34 +35,20 @@ namespace o2::upgrade
3735
void convertTLorentzVectorToO2Track(const int charge,
3836
const TLorentzVector particle,
3937
const std::vector<double> productionVertex,
40-
o2::track::TrackParCov& o2track)
41-
{
42-
std::array<float, 5> params;
43-
std::array<float, 15> covm = {0.};
44-
float s, c, x;
45-
o2::math_utils::sincos(static_cast<float>(particle.Phi()), s, c);
46-
o2::math_utils::rotateZInv(static_cast<float>(productionVertex[0]), static_cast<float>(productionVertex[1]), x, params[0], s, c);
47-
params[1] = static_cast<float>(productionVertex[2]);
48-
params[2] = 0.; // since alpha = phi
49-
const auto theta = 2. * std::atan(std::exp(-particle.PseudoRapidity()));
50-
params[3] = 1. / std::tan(theta);
51-
params[4] = charge / particle.Pt();
52-
53-
// Initialize TrackParCov in-place
54-
new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm);
55-
}
38+
o2::track::TrackParCov& o2track);
5639

5740
/// Function to convert a TLorentzVector into a perfect Track
5841
/// \param pdgCode particle pdg
5942
/// \param particle the particle to convert (TLorentzVector)
6043
/// \param productionVertex where the particle was produced
6144
/// \param o2track the address of the resulting TrackParCov
6245
/// \param pdg the pdg service
46+
template <typename PdgService>
6347
void convertTLorentzVectorToO2Track(int pdgCode,
6448
TLorentzVector particle,
6549
std::vector<double> productionVertex,
6650
o2::track::TrackParCov& o2track,
67-
const o2::framework::Service<o2::framework::O2DatabasePDG>& pdg)
51+
const PdgService& pdg)
6852
{
6953
const auto pdgInfo = pdg->GetParticle(pdgCode);
7054
int charge = 0;
@@ -78,10 +62,10 @@ void convertTLorentzVectorToO2Track(int pdgCode,
7862
/// \param particle the particle to convert (mcParticle)
7963
/// \param o2track the address of the resulting TrackParCov
8064
/// \param pdg the pdg service
81-
template <typename McParticleType>
65+
template <typename McParticleType, typename PdgService>
8266
void convertMCParticleToO2Track(McParticleType& particle,
8367
o2::track::TrackParCov& o2track,
84-
const o2::framework::Service<o2::framework::O2DatabasePDG>& pdg)
68+
const PdgService& pdg)
8569
{
8670
static TLorentzVector tlv;
8771
tlv.SetPxPyPzE(particle.px(), particle.py(), particle.pz(), particle.e());
@@ -92,9 +76,9 @@ void convertMCParticleToO2Track(McParticleType& particle,
9276
/// \param particle the particle to convert (mcParticle)
9377
/// \param o2track the address of the resulting TrackParCov
9478
/// \param pdg the pdg service
95-
template <typename McParticleType>
79+
template <typename McParticleType, typename PdgService>
9680
o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
97-
const o2::framework::Service<o2::framework::O2DatabasePDG>& pdg)
81+
const PdgService& pdg)
9882
{
9983
o2::track::TrackParCov o2track;
10084
convertMCParticleToO2Track(particle, o2track, pdg);

0 commit comments

Comments
 (0)