-
Notifications
You must be signed in to change notification settings - Fork 680
Expand file tree
/
Copy pathtracksCombinations.cxx
More file actions
190 lines (167 loc) · 6.68 KB
/
Copy pathtracksCombinations.cxx
File metadata and controls
190 lines (167 loc) · 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \brief Iterate over pair of tracks with combinations interface, without and with binning.
// Iterate over pairs of collisions with configurable binning.
// Iterate over pairs of tracks with binning predefined by a hash task.
/// \author
/// \since
#include "Common/DataModel/Multiplicity.h"
#include <Framework/ASoA.h>
#include <Framework/ASoAHelpers.h>
#include <Framework/AnalysisDataModel.h>
#include <Framework/AnalysisHelpers.h>
#include <Framework/AnalysisTask.h>
#include <Framework/BinningPolicy.h>
#include <Framework/Configurable.h>
#include <Framework/HistogramSpec.h>
#include <Framework/runDataProcessing.h>
#include <vector>
using namespace o2;
using namespace o2::framework;
using namespace o2::soa;
namespace o2::aod
{
namespace hash
{
DECLARE_SOA_COLUMN(Bin, bin, int);
} // namespace hash
DECLARE_SOA_TABLE(MixingHashes, "AOD", "HASH", hash::Bin);
} // namespace o2::aod
struct TrackCombinations {
void process(aod::Tracks const& tracks)
{
int count = 0;
// Strictly upper tracks
for (auto& [t0, t1] : combinations(tracks, tracks)) {
LOGF(info, "Tracks pair: %d %d", t0.index(), t1.index());
count++;
if (count > 100)
break;
}
}
};
struct BinnedTrackCombinations {
std::vector<double> xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072};
std::vector<double> yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360};
ColumnBinningPolicy<aod::track::X, aod::track::Y> trackBinning{{xBins, yBins}, true};
void process(aod::Tracks const& tracks)
{
int count = 0;
// Strictly upper tracks binned by x and y position
for (auto& [t0, t1] : selfCombinations(trackBinning, 5, -1, tracks, tracks)) {
int bin = trackBinning.getBin({t0.x(), t0.y()});
LOGF(info, "Tracks bin: %d pair: %d (%f, %f, %f), %d (%f, %f, %f)", bin, t0.index(), t0.x(), t0.y(), t0.z(), t1.index(), t1.x(), t1.y(), t1.z());
count++;
if (count > 100)
break;
}
}
};
struct ConfigurableBinnedCollisionCombinations {
ConfigurableAxis axisVertex{"axisVertex", {7, -7, 7}, "vertex axis for histograms"};
ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1}, "multiplicity / centrality axis for histograms"};
void process(soa::Join<aod::Collisions, aod::Mults> const& collisions)
{
using BinningType = ColumnBinningPolicy<aod::collision::PosZ, aod::mult::MultFV0M<aod::mult::MultFV0A, aod::mult::MultFV0C>>;
BinningType colBinning{{axisVertex, axisMultiplicity}, true};
int count = 0;
// Strictly upper tracks binned by x and y position
for (auto& [c0, c1] : selfCombinations(colBinning, 5, -1, collisions, collisions)) {
int bin = colBinning.getBin({c0.posZ(), c0.multFV0M()});
LOGF(info, "Collision bin: %d pair: %d (%f, %f), %d (%f, %f)", bin, c0.index(), c0.posZ(), c0.multFV0M(), c1.index(), c1.posZ(), c1.multFV0A());
count++;
if (count > 100)
break;
}
}
};
struct BinnedTrackPartitionsCombinations {
std::vector<double> xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072};
std::vector<double> yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360};
ColumnBinningPolicy<aod::track::X, aod::track::Y> trackBinning{{xBins, yBins}, true};
Configurable<float> philow{"phiLow", 1.0f, "lowest phi"};
void process(aod::Tracks const& tracks)
{
Partition<aod::Tracks> leftPhi = aod::track::phi < philow;
Partition<aod::Tracks> rightPhi = aod::track::phi >= philow;
leftPhi.bindTable(tracks);
rightPhi.bindTable(tracks);
int count = 0;
// Strictly upper tracks binned by x and y position
for (auto& [t0, t1] : selfCombinations(trackBinning, 5, -1, leftPhi, rightPhi)) {
int bin = trackBinning.getBin({t0.x(), t0.y()});
LOGF(info, "Tracks bin: %d pair: %d (%f, %f, %f) phi %f, %d (%f, %f, %f) phi %f", bin, t0.index(), t0.x(), t0.y(), t0.z(), t0.phi(), t1.index(), t1.x(), t1.y(), t1.z(), t1.phi());
count++;
if (count > 100)
break;
}
}
};
struct HashTask {
std::vector<float> xBins{-0.064f, -0.062f, -0.060f, 0.066f, 0.068f, 0.070f, 0.072};
std::vector<float> yBins{-0.320f, -0.301f, -0.300f, 0.330f, 0.340f, 0.350f, 0.360};
Produces<aod::MixingHashes> hashes;
// Calculate hash for an element based on 2 properties and their bins.
int getHash(const std::vector<float>& xBins, const std::vector<float>& yBins, float colX, float colY)
{
// underflow
if (colX < xBins[0] || colY < yBins[0])
return -1;
for (unsigned int i = 1; i < xBins.size(); i++) {
if (colX < xBins[i]) {
for (unsigned int j = 1; j < yBins.size(); j++) {
if (colY < yBins[j]) {
return i + j * (xBins.size() + 1);
}
}
// overflow for yBins only
return -1;
}
}
// overflow
return -1;
}
void process(aod::Tracks const& tracks)
{
for (auto& track : tracks) {
int hash = getHash(xBins, yBins, track.x(), track.y());
LOGF(info, "Track: %d (%f, %f, %f) hash: %d", track.index(), track.x(), track.y(), track.z(), hash);
hashes(hash);
}
}
};
struct BinnedTrackCombinationsWithHashTable {
NoBinningPolicy<aod::hash::Bin> hashBin;
void process(soa::Join<aod::MixingHashes, aod::Tracks> const& hashedTracks)
{
int count = 0;
// Strictly upper categorised tracks
for (auto& [t0, t1] : selfCombinations(hashBin, 5, -1, hashedTracks, hashedTracks)) {
int bin = hashBin.getBin({t0.bin()});
LOGF(info, "Tracks bin: %d from policy: %d pair: %d (%f, %f, %f), %d (%f, %f, %f)", t0.bin(), bin, t0.index(), t0.x(), t0.y(), t0.z(), t1.index(), t1.x(), t1.y(), t1.z());
count++;
if (count > 100)
break;
}
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<TrackCombinations>(cfgc),
adaptAnalysisTask<BinnedTrackCombinations>(cfgc),
adaptAnalysisTask<ConfigurableBinnedCollisionCombinations>(cfgc),
adaptAnalysisTask<BinnedTrackPartitionsCombinations>(cfgc),
adaptAnalysisTask<HashTask>(cfgc),
adaptAnalysisTask<BinnedTrackCombinationsWithHashTable>(cfgc),
};
}