Skip to content

Commit f40f7f0

Browse files
committed
[PWGLF] WIP strangeness builder
1 parent 20a2474 commit f40f7f0

File tree

6 files changed

+779
-0
lines changed

6 files changed

+779
-0
lines changed

PWGLF/TableProducer/Strangeness/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ o2physics_add_dpl_workflow(strangederivedbuilder
107107
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase
108108
COMPONENT_NAME Analysis)
109109

110+
o2physics_add_dpl_workflow(strangenessbuilder
111+
SOURCES strangenessbuilder.cxx
112+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase O2Physics::strangenessBuilderHelper
113+
COMPONENT_NAME Analysis)
114+
110115
o2physics_add_dpl_workflow(v0-selector
111116
SOURCES v0selector.cxx
112117
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore

PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx

Lines changed: 464 additions & 0 deletions
Large diffs are not rendered by default.

PWGLF/Utils/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ o2physics_add_library(v0SelectionGroup
1616
o2physics_target_root_dictionary(v0SelectionGroup
1717
HEADERS v0SelectionGroup.h
1818
LINKDEF v0SelectionGroupLinkDef.h)
19+
20+
o2physics_add_library(strangenessBuilderHelper
21+
SOURCES strangenessBuilderHelper.cxx
22+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore)
23+
24+
o2physics_target_root_dictionary(strangenessBuilderHelper
25+
HEADERS strangenessBuilderHelper.h
26+
LINKDEF strangenessBuilderHelperLinkDef.h)
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
///
13+
/// \file strangenessBuilderHelper.cxx
14+
/// \since 07/01/2025
15+
/// \brief Utilities to build strange decays in a modular way. Used by strangeness builder task
16+
///
17+
18+
#include "strangenessBuilderHelper.h"
19+
#include "ReconstructionDataFormats/Track.h"
20+
#include "DetectorsBase/GeometryManager.h"
21+
#include "CommonConstants/PhysicsConstants.h"
22+
#include "Framework/AnalysisDataModel.h"
23+
#include "Common/Core/trackUtilities.h"
24+
25+
namespace o2
26+
{
27+
namespace pwglf
28+
{
29+
//_______________________________________________________________
30+
strangenessBuilderHelper::strangenessBuilderHelper() {
31+
// standards hardcoded in builder ...
32+
// ...but can be changed easily since fitter is public
33+
fitter.setPropagateToPCA(true);
34+
fitter.setMaxR(200.);
35+
fitter.setMinParamChange(1e-3);
36+
fitter.setMinRelChi2Change(0.9);
37+
fitter.setMaxDZIni(1e9);
38+
fitter.setMaxDXYIni(4.0f);
39+
fitter.setMaxChi2(1e9);
40+
fitter.setUseAbsDCA(true);
41+
fitter.setWeightedFinalPCA(false);
42+
43+
// LUT has to be loaded later
44+
lut = nullptr;
45+
fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrLUT);
46+
47+
// mag field has to be set later
48+
fitter.setBz(-999.9f); // will NOT make sense if not changed
49+
}
50+
51+
//_______________________________________________________________
52+
// builds V0 from two tracks. Does not check any conditionals
53+
// except for DCA fitter convergence (should be minimal overhead)
54+
// Resulting properties can be checked with strangenessBuilderHelper::v0
55+
bool strangenessBuilderHelper::buildV0Candidate(
56+
o2::aod::Collision const& collision,
57+
soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& positiveTrack,
58+
soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& negativeTrack,
59+
bool useCollinearFit){
60+
// Calculate DCA with respect to the collision associated to the V0, not individual tracks
61+
gpu::gpustd::array<float, 2> dcaInfo;
62+
63+
auto posTrackPar = getTrackPar(positiveTrack);
64+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo);
65+
v0.positiveDCAxy = dcaInfo[0];
66+
67+
auto negTrackPar = getTrackPar(negativeTrack);
68+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo);
69+
v0.negativeDCAxy = dcaInfo[0];
70+
71+
o2::track::TrackParCov positiveTrackParam = getTrackParCov(positiveTrack);
72+
o2::track::TrackParCov negativeTrackParam = getTrackParCov(negativeTrack);
73+
74+
// Perform DCA fit
75+
int nCand = 0;
76+
fitter.setCollinear(useCollinearFit);
77+
try {
78+
nCand = fitter.process(positiveTrackParam, negativeTrackParam);
79+
} catch (...) {
80+
return false;
81+
}
82+
if (nCand == 0) {
83+
return false;
84+
}
85+
86+
v0.positiveTrackX = fitter.getTrack(0).getX();
87+
v0.negativeTrackX = fitter.getTrack(1).getX();
88+
positiveTrackParam = fitter.getTrack(0);
89+
negativeTrackParam = fitter.getTrack(1);
90+
positiveTrackParam.getPxPyPzGlo(v0.positiveMomentum);
91+
negativeTrackParam.getPxPyPzGlo(v0.negativeMomentum);
92+
positiveTrackParam.getXYZGlo(v0.positivePosition);
93+
negativeTrackParam.getXYZGlo(v0.negativePosition);
94+
95+
// get decay vertex coordinates
96+
const auto& vtx = fitter.getPCACandidate();
97+
for (int i = 0; i < 3; i++) {
98+
v0.position[i] = vtx[i];
99+
}
100+
101+
v0.daughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate());
102+
v0.pointingAngle = TMath::ACos(RecoDecay::cpa(
103+
std::array{collision.posX(), collision.posY(), collision.posZ()},
104+
std::array{v0.position[0], v0.position[1], v0.position[2]},
105+
std::array{v0.positiveMomentum[0] + v0.negativeMomentum[0], v0.positiveMomentum[1] + v0.negativeMomentum[1], v0.positiveMomentum[2] + v0.negativeMomentum[2]}
106+
));
107+
108+
v0.dcaXY = CalculateDCAStraightToPV(
109+
v0.position[0], v0.position[1], v0.position[2],
110+
v0.positiveMomentum[0] + v0.negativeMomentum[0],
111+
v0.positiveMomentum[1] + v0.negativeMomentum[1],
112+
v0.positiveMomentum[2] + v0.negativeMomentum[2],
113+
collision.posX(), collision.posY(), collision.posZ());
114+
115+
// Calculate masses
116+
v0.massGamma = RecoDecay::m(std::array{
117+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
118+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
119+
std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron});
120+
v0.massK0Short = RecoDecay::m(std::array{
121+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
122+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
123+
std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged});
124+
v0.massLambda = RecoDecay::m(std::array{
125+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
126+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
127+
std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged});
128+
v0.massAntiLambda = RecoDecay::m(std::array{
129+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
130+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
131+
std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton});
132+
133+
// information validated, V0 built successfully. Signal OK
134+
return true;
135+
}
136+
137+
//_______________________________________________________________
138+
// internal helper to calculate DCAxy of a straight line to a given PV analytically
139+
float strangenessBuilderHelper::CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ)
140+
{
141+
return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz));
142+
}
143+
144+
//_______________________________________________________________
145+
} // namespace pwglf
146+
} // namespace o2
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
#ifndef PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_
13+
#define PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_
14+
15+
#include <cstdlib>
16+
#include <cmath>
17+
#include <array>
18+
#include "DCAFitter/DCAFitterN.h"
19+
#include "Framework/runDataProcessing.h"
20+
#include "Framework/AnalysisTask.h"
21+
#include "Framework/AnalysisDataModel.h"
22+
23+
namespace o2
24+
{
25+
namespace pwglf
26+
{
27+
//__________________________________________
28+
// V0 information storage
29+
struct v0candidate{
30+
// indexing
31+
int collisionId = -1;
32+
int negativeTrack = -1;
33+
int positiveTrack = -1;
34+
35+
// daughter properties
36+
std::array<float, 3> positiveMomentum = {0.0f, 0.0f, 0.0f};
37+
std::array<float, 3> negativeMomentum = {0.0f, 0.0f, 0.0f};
38+
std::array<float, 3> positivePosition = {0.0f, 0.0f, 0.0f};
39+
std::array<float, 3> negativePosition = {0.0f, 0.0f, 0.0f};
40+
float positiveTrackX = 0.0f;
41+
float negativeTrackX = 0.0f;
42+
float positiveDCAxy = 0.0f;
43+
float negativeDCAxy = 0.0f;
44+
45+
// V0 properties
46+
std::array<float, 3> position = {0.0f, 0.0f, 0.0f};
47+
float daughterDCA = 1000.0f;
48+
float pointingAngle = 0.0f;
49+
float dcaXY = 0.0f;
50+
51+
// calculated masses for convenience
52+
float massGamma;
53+
float massK0Short;
54+
float massLambda;
55+
float massAntiLambda;
56+
57+
// stored for decay chains
58+
std::array<float, 21> covariance;
59+
};
60+
61+
//__________________________________________
62+
// Cascade information storage
63+
struct cascadeCandidate {
64+
// indexing
65+
int collisionId = -1;
66+
int v0Id = -1;
67+
int negativeTrack = -1;
68+
int positiveTrack = -1;
69+
int bachelorTrack = -1;
70+
71+
// daughter properties
72+
std::array<float, 3> positiveMomentum = {0.0f, 0.0f, 0.0f};
73+
std::array<float, 3> negativeMomentum = {0.0f, 0.0f, 0.0f};
74+
std::array<float, 3> bachelorMomentum = {0.0f, 0.0f, 0.0f};
75+
std::array<float, 3> positivePosition = {0.0f, 0.0f, 0.0f};
76+
std::array<float, 3> negativePosition = {0.0f, 0.0f, 0.0f};
77+
std::array<float, 3> bachelorPosition = {0.0f, 0.0f, 0.0f};
78+
float positiveDCAxy = 0.0f;
79+
float negativeDCAxy = 0.0f;
80+
float bachelorDCAxy = 0.0f;
81+
float positiveTrackX = 0.0f;
82+
float negativeTrackX = 0.0f;
83+
float bacheloTrackX = 0.0f;
84+
85+
// cascade properties
86+
std::array<float, 3> position = {0.0f, 0.0f, 0.0f};
87+
int charge = -1; // default: []Minus
88+
float cascadeDaughterDCA = 1000.0f;
89+
float v0DaughterDCA = 1000.0f;
90+
91+
float pointingAngle = 0.0f;
92+
float cascadeDCAxy = 0.0f;
93+
float cascadeDCAz = 0.0f;
94+
std::array<float, 3> v0Position = {0.0f, 0.0f, 0.0f};
95+
std::array<float, 3> v0Momentum = {0.0f, 0.0f, 0.0f};
96+
std::array<float, 3> cascadePosition = {0.0f, 0.0f, 0.0f};
97+
std::array<float, 3> cascadeMomentum = {0.0f, 0.0f, 0.0f};
98+
99+
float bachBaryonPointingAngle = 0.0f;
100+
float bachBaryonDCAxyToPV = 0.0f;
101+
float massXi = 0.0f;
102+
float massOmega = 0.0f;
103+
104+
// stored for decay chains
105+
std::array<float, 21> covariance;
106+
};
107+
108+
//__________________________________________
109+
// builder helper class
110+
class strangenessBuilderHelper
111+
{
112+
public:
113+
strangenessBuilderHelper();
114+
115+
bool buildV0Candidate(o2::aod::Collision const& collision,
116+
soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& positiveTrack,
117+
soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& negativeTrack,
118+
bool useCollinearFit = false);
119+
120+
o2::base::MatLayerCylSet* lut; // material LUT for DCA fitter
121+
o2::vertexing::DCAFitterN<2> fitter; // 2-prong o2 dca fitter
122+
123+
v0candidate v0; // storage for V0 candidate properties
124+
cascadeCandidate cascade; // storage for cascade candidate properties
125+
126+
private:
127+
// internal helper to calculate DCAxy of a straight line to a given PV analytically
128+
float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ);
129+
};
130+
131+
} // namespace pwglf
132+
} // namespace o2
133+
134+
#endif // PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#ifndef PWGLF_UTILS_STRANGENESSBUILDERHELPERLINKDEF_H_
13+
#define PWGLF_UTILS_STRANGENESSBUILDERHELPERLINKDEF_H_
14+
15+
#pragma link off all globals;
16+
#pragma link off all classes;
17+
#pragma link off all functions;
18+
#pragma link C++ nestedclasses;
19+
#pragma link C++ class o2::pwglf::strangenessBuilderHelper + ;
20+
#pragma link C++ class std::vector < int> + ;
21+
22+
#endif // PWGLF_UTILS_STRANGENESSBUILDERHELPERLINKDEF_H_

0 commit comments

Comments
 (0)