Skip to content

Commit f70c29f

Browse files
committed
Add first version of derived data creator for D0 calibration studies
1 parent f8b9552 commit f70c29f

File tree

3 files changed

+761
-0
lines changed

3 files changed

+761
-0
lines changed

DPG/Tasks/AOTTrack/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,8 @@ o2physics_add_dpl_workflow(tag-and-probe-dmesons
8585
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing O2Physics::MLCore
8686
COMPONENT_NAME Analysis)
8787

88+
o2physics_add_dpl_workflow(derived-data-creator-d0-calibration
89+
SOURCES derivedDataCreatorD0Calibration.cxx
90+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCore O2::DCAFitter
91+
COMPONENT_NAME Analysis)
92+

DPG/Tasks/AOTTrack/D0CalibTables.h

Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
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 D0CalibTables.h
13+
/// \brief Definitions of derived tables produced by data creator for D0 calibration studies
14+
/// \author Fabrizio Grosa <fabrizio.grosa@cern.ch>, CERN
15+
16+
#ifndef D0CALIBTABLES_H_
17+
#define D0CALIBTABLES_H_
18+
19+
#include <sys/types.h>
20+
#include <cstdint>
21+
#include <limits>
22+
23+
#include <Framework/AnalysisDataModel.h>
24+
#include <Framework/ASoA.h>
25+
26+
#include "Common/DataModel/EventSelection.h"
27+
#include "Common/DataModel/TrackSelectionTables.h"
28+
29+
namespace o2
30+
{
31+
namespace hf_calib
32+
{
33+
enum D0MassHypo : uint8_t {
34+
D0 = 1,
35+
D0Bar,
36+
D0AndD0Bar,
37+
ND0MassHypos
38+
};
39+
40+
const float toMicrometers = 10000.; // from cm to µm
41+
42+
/// It compresses a value to a int8_t with a given precision
43+
///\param origValue is the original values
44+
///\param precision is the desired precision
45+
///\return The value compressed to a int8_t
46+
template<typename T>
47+
int8_t getCompressedInt8(T origValue, double precision)
48+
{
49+
int roundValue = static_cast<int>(std::round(origValue / precision));
50+
return static_cast<int8_t>(std::clamp(roundValue, -128, 128));
51+
}
52+
53+
/// It compresses a value to a uint8_t with a given precision
54+
///\param origValue is the original values
55+
///\param precision is the desired precision
56+
///\return The value compressed to a uint8_t
57+
template<typename T>
58+
uint8_t getCompressedUint8(T origValue, double precision)
59+
{
60+
int roundValue = static_cast<int>(std::round(origValue / precision));
61+
return static_cast<uint8_t>(std::clamp(roundValue, 0, 255));
62+
}
63+
64+
/// It uses a sinh-based scaling function, which provides a compromise between fixed-step and relative quantization.
65+
// This approach reflects typical resolution formulas and is well-suited for detector calibration data.
66+
///\param origValue is the original value
67+
///\param sigma0 is a asinh parameter
68+
///\param sigma1 is a asinh parameter
69+
///\param clampMin is the maximum value
70+
///\param clampMax is the minimum value
71+
///\return The value compressed
72+
int codeSqrtScaling(float origValue, float sigma0, float sigma1, int clampMin, int clampMax)
73+
{
74+
float codeF = std::asinh((sigma1 * origValue) / sigma0) / sigma0;
75+
return std::clamp(static_cast<int>(std::round(codeF)), clampMin, clampMax);
76+
}
77+
78+
/// It compresses the decay length (10 micron precision)
79+
///\param decLen is the decay length in cm
80+
///\return The decay length compressed to a uint8_t with 10 micron precision
81+
template<typename T>
82+
uint8_t getCompressedDecayLength(T decLen)
83+
{
84+
return getCompressedUint8(decLen * hf_calib::toMicrometers, 0.1);
85+
}
86+
87+
/// It compresses the normalised decay length (0.5 precision)
88+
///\param normDecLen is the normalised decay length
89+
///\return The normalised decay length compressed to a uint8_t with 0.5 precision
90+
template<typename T>
91+
uint8_t getCompressedNormDecayLength(T normDecLen)
92+
{
93+
return getCompressedUint8(normDecLen, 0.5);
94+
}
95+
96+
/// It compresses the pointing angle (0.005 precision)
97+
///\param pointAngle is the pointing angle
98+
///\return The pointing angle compressed to a uint8_t with 0.005 precision
99+
template<typename T>
100+
uint8_t getCompressedPointingAngle(T pointAngle)
101+
{
102+
return getCompressedUint8(pointAngle, 0.005);
103+
}
104+
105+
/// It compresses the cosine of pointing angle (0.001 precision)
106+
///\param cosPa is the cosine of pointing angle
107+
///\return The cosine of pointing angle compressed to a uint8_t with 0.001 precision
108+
template<typename T>
109+
int8_t getCompressedCosPa(T cosPa)
110+
{
111+
return getCompressedUint8(cosPa - 0.25, 0.001); // in the range from 0.75 to 1
112+
}
113+
114+
/// It compresses the chi2 (0.1 precision)
115+
///\param chi2 is the chi2
116+
///\return The chi2 compressed to a uint8_t with 0.1 precision
117+
template<typename T>
118+
int8_t getCompressedChi2(T chi2)
119+
{
120+
return getCompressedUint8(chi2, 0.1);
121+
}
122+
123+
/// It compresses the number of sigma
124+
///\param numSigma is the number of sigma
125+
///\return The number of sigma compressed to a int8_t
126+
template<typename T>
127+
int8_t getCompressedNumSigmaPid(T numSigma)
128+
{
129+
int8_t compressedNumSigma = static_cast<int8_t>(codeSqrtScaling(numSigma, 0.05, 0.05, -128, 128));
130+
return compressedNumSigma;
131+
}
132+
133+
/// It compresses the number of sigma (0.1 sigma precision)
134+
///\param occupancy is the occupancy value
135+
///\return The number of sigma compressed to a int8_t with 0.1 precision
136+
template<typename T>
137+
uint8_t getCompressedOccupancy(T occupancy)
138+
{
139+
uint8_t compressedOcc = static_cast<uint8_t>(codeSqrtScaling(occupancy, 0.04, 0.04, 0, 256));
140+
return compressedOcc;
141+
}
142+
143+
static constexpr int NBinsPtTrack = 6;
144+
static constexpr int NCutVarsTrack = 4;
145+
constexpr float BinsPtTrack[NBinsPtTrack + 1] = {
146+
0,
147+
0.5,
148+
1.0,
149+
1.5,
150+
2.0,
151+
3.0,
152+
1000.0};
153+
auto vecBinsPtTrack = std::vector<float>{BinsPtTrack, BinsPtTrack + NBinsPtTrack + 1};
154+
155+
// default values for the dca_xy and dca_z cuts of displaced tracks
156+
constexpr float CutsTrack[NBinsPtTrack][NCutVarsTrack] = {{0.0015, 2., 0.0000, 2.}, /* 0 < pt < 0.5 */
157+
{0.0015, 2., 0.0000, 2.}, /* 0.5 < pt < 1 */
158+
{0.0015, 2., 0.0000, 2.}, /* 1 < pt < 1.5 */
159+
{0.0015, 2., 0.0000, 2.}, /* 1.5 < pt < 2 */
160+
{0.0000, 2., 0.0000, 2.}, /* 2 < pt < 3 */
161+
{0.0000, 2., 0.0000, 2.}}; /* 3 < pt < 1000 */
162+
// row labels
163+
static const std::vector<std::string> labelsPtTrack{};
164+
165+
// column labels
166+
static const std::vector<std::string> labelsCutVarTrack = {"min_dcaxytoprimary", "max_dcaxytoprimary", "min_dcaztoprimary", "max_dcaztoprimary"};
167+
168+
static constexpr int NBinsPtCand = 10;
169+
static constexpr int NCutVarsCand = 10;
170+
// default values for the pT bin edges (can be used to configure histogram axis)
171+
// offset by 1 from the bin numbers in cuts array
172+
constexpr float BinsPtCand[NBinsPtCand + 1] = {
173+
0,
174+
1.0,
175+
2.0,
176+
4.0,
177+
6.0,
178+
8.0,
179+
12.0,
180+
16.0,
181+
24.0,
182+
50.0,
183+
1000.0};
184+
auto vecBinsPtCand = std::vector<float>{BinsPtCand, BinsPtCand + NBinsPtCand + 1};
185+
186+
// default values for the cuts
187+
constexpr float CutsCand[NBinsPtCand][NCutVarsCand] = {{0.400, 0., 10., 10., 0.97, 0.97, 0, 2, 0.01, 0.01}, /* 0 < pT < 1 */
188+
{0.400, 0., 10., 10., 0.97, 0.97, 0, 2, 0.01, 0.01}, /* 1 < pT < 2 */
189+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 2 < pT < 4 */
190+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 4 < pT < 6 */
191+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 6 < pT < 8 */
192+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 8 < pT < 12 */
193+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 12 < pT < 16 */
194+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 16 < pT < 24 */
195+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 24 < pT < 50 */
196+
{0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}}; /* 50 < pT < 1000 */
197+
198+
// row labels
199+
static const std::vector<std::string> labelsPtCand = {
200+
"pT bin 0",
201+
"pT bin 1",
202+
"pT bin 2",
203+
"pT bin 3",
204+
"pT bin 4",
205+
"pT bin 5",
206+
"pT bin 6",
207+
"pT bin 7",
208+
"pT bin 8",
209+
"pT bin 9"};
210+
211+
// column labels
212+
static const std::vector<std::string> labelsCutVarCand = {"delta inv. mass", "max d0d0", "max pointing angle", "max pointing angle XY", "min cos pointing angle", "min cos pointing angle xy", "min norm decay length", "min norm decay length XY", "min decay length", "min decay length XY"};
213+
} // namespace hf_calib
214+
215+
namespace aod
216+
{
217+
namespace hf_calib
218+
{
219+
DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! Run number
220+
DECLARE_SOA_COLUMN(Orbit, orbit, uint32_t); //! orbit ID
221+
DECLARE_SOA_COLUMN(CentFT0C, centFT0C, uint8_t); //! FTOC centrality
222+
DECLARE_SOA_COLUMN(OccupancyTracks, occupancyTracks, uint8_t); //! FT0 occupancy
223+
DECLARE_SOA_COLUMN(OccupancyFT0C, occupancyFT0C, uint8_t); //! FT0 occupancy
224+
} // namespace hf_calib
225+
226+
DECLARE_SOA_TABLE(D0CalibColl, "AOD", "D0CALIBCOLLS",
227+
o2::soa::Index<>,
228+
collision::PosX,
229+
collision::PosY,
230+
collision::PosZ,
231+
collision::CovXX,
232+
collision::CovXY,
233+
collision::CovXZ,
234+
collision::CovYY,
235+
collision::CovYZ,
236+
collision::CovZZ,
237+
collision::NumContrib,
238+
hf_calib::CentFT0C,
239+
hf_calib::OccupancyTracks,
240+
hf_calib::OccupancyFT0C,
241+
hf_calib::Orbit,
242+
hf_calib::RunNumber);
243+
244+
namespace hf_calib
245+
{
246+
DECLARE_SOA_INDEX_COLUMN_FULL(Collision, collision, int, D0CalibColl, ""); //! Index of collision
247+
DECLARE_SOA_COLUMN(TpcNumSigmaPi, tpcNumSigmaPi, int8_t); //! compressed NsigmaTPC for pions
248+
DECLARE_SOA_COLUMN(TpcNumSigmaKa, tpcNumSigmaKa, int8_t); //! compressed NsigmaTPC for kaons
249+
DECLARE_SOA_COLUMN(TofNumSigmaPi, tofNumSigmaPi, int8_t); //! compressed NsigmaTOF for pions
250+
DECLARE_SOA_COLUMN(TofNumSigmaKa, tofNumSigmaKa, int8_t); //! compressed NsigmaTOF for kaons
251+
} // namespace hf_calib
252+
253+
DECLARE_SOA_TABLE(D0CalibTrack, "AOD", "D0CALIBTRACKS",
254+
o2::soa::Index<>,
255+
/// *** collision index
256+
hf_calib::CollisionId,
257+
/// *** track pars
258+
track::X,
259+
track::Alpha,
260+
track::Y,
261+
track::Z,
262+
track::Snp,
263+
track::Tgl,
264+
track::Signed1Pt,
265+
/// *** track covs
266+
track::CYY,
267+
track::CZY,
268+
track::CZZ,
269+
track::CSnpY,
270+
track::CSnpZ,
271+
track::CSnpSnp,
272+
track::CTglY,
273+
track::CTglZ,
274+
track::CTglSnp,
275+
track::CTglTgl,
276+
track::C1PtY,
277+
track::C1PtZ,
278+
track::C1PtSnp,
279+
track::C1PtTgl,
280+
track::C1Pt21Pt2,
281+
/// *** track extra (static) TODO: check if also dynamic columns are needed
282+
track::TPCInnerParam,
283+
track::Flags,
284+
track::ITSClusterSizes,
285+
track::TPCNClsFindable,
286+
track::TPCNClsFindableMinusFound,
287+
track::TPCNClsFindableMinusCrossedRows,
288+
track::TPCNClsShared,
289+
track::TRDPattern,
290+
track::ITSChi2NCl,
291+
track::TPCChi2NCl,
292+
track::TRDChi2,
293+
track::TOFChi2,
294+
track::TPCSignal,
295+
track::TRDSignal,
296+
track::Length,
297+
track::TOFExpMom,
298+
track::TrackTime,
299+
track::TrackTimeRes,
300+
/// *** track QA --> FIXME: info not present for each track in normal AO2Ds, check how to do
301+
/// *** DCA, Nsigma
302+
track::DcaXY,
303+
track::DcaZ,
304+
hf_calib::TpcNumSigmaPi,
305+
hf_calib::TpcNumSigmaKa,
306+
hf_calib::TofNumSigmaPi,
307+
hf_calib::TofNumSigmaKa);
308+
309+
namespace hf_calib
310+
{
311+
DECLARE_SOA_INDEX_COLUMN_FULL(TrackPos, trackPos, int, D0CalibTrack, ""); //! Index of positive track
312+
DECLARE_SOA_INDEX_COLUMN_FULL(TrackNeg, trackNeg, int, D0CalibTrack, ""); //! Index of negative track
313+
DECLARE_SOA_COLUMN(MassHypo, massHypo, uint8_t); //! mass hypothesis for D0 (D0, D0bar, or both)
314+
DECLARE_SOA_COLUMN(Pt, pt, float); //! D0-candidate pT
315+
DECLARE_SOA_COLUMN(Eta, eta, float); //! D0-candidate eta
316+
DECLARE_SOA_COLUMN(Phi, phi, float); //! D0-candidate phi
317+
DECLARE_SOA_COLUMN(InvMassD0, invMassD0, float); //! invariant mass (D0 hypothesis)
318+
DECLARE_SOA_COLUMN(InvMassD0bar, invMassD0bar, float); //! invariant mass (D0bar hypothesis)
319+
DECLARE_SOA_COLUMN(DecLength, decLength, uint8_t); //! compressed decay length
320+
DECLARE_SOA_COLUMN(DecLengthXY, decLengthXY, uint8_t); //! compressed decay length XY
321+
DECLARE_SOA_COLUMN(NormDecLength, normDecLength, uint8_t); //! compressed normalised decay length
322+
DECLARE_SOA_COLUMN(NormDecLengthXY, normDecLengthXY, uint8_t); //! compressed normalised decay length XY
323+
DECLARE_SOA_COLUMN(CosPa, cosPa, uint8_t); //! compressed cosine of pointing angle
324+
DECLARE_SOA_COLUMN(CosPaXY, cosPaXY, uint8_t); //! compressed cosine of pointing angle XY
325+
DECLARE_SOA_COLUMN(PointingAngle, pointingAngle, uint8_t); //! compressed pointing angle
326+
DECLARE_SOA_COLUMN(PointingAngleXY, pointingAngleXY, uint8_t); //! compressed pointing angle XY
327+
DECLARE_SOA_COLUMN(DecVtxChi2, decVtxChi2, uint8_t); //! compressed decay vertex chi2
328+
} // namespace hf_calib
329+
330+
DECLARE_SOA_TABLE(D0CalibCand, "AOD", "D0CALIBCANDS",
331+
o2::soa::Index<>,
332+
hf_calib::CollisionId,
333+
hf_calib::TrackPosId,
334+
hf_calib::TrackNegId,
335+
hf_calib::MassHypo,
336+
hf_calib::Pt,
337+
hf_calib::Eta,
338+
hf_calib::Phi,
339+
hf_calib::InvMassD0,
340+
hf_calib::InvMassD0bar,
341+
hf_calib::DecLength,
342+
hf_calib::DecLengthXY,
343+
hf_calib::NormDecLength,
344+
hf_calib::NormDecLengthXY,
345+
hf_calib::CosPa,
346+
hf_calib::CosPaXY,
347+
hf_calib::PointingAngle,
348+
hf_calib::PointingAngleXY,
349+
hf_calib::DecVtxChi2);
350+
} // namespace aod
351+
} // namespace o2
352+
#endif // D0CALIBTABLES_H_

0 commit comments

Comments
 (0)