Skip to content

Commit dff8985

Browse files
authored
PWG-UD: added tutorial examples (AliceO2Group#2350)
* . added tutorial examples . some updates DGPIDSelector . adaptions of DGCandAnalyzer, diffQA, diffMCQA * avoid compilation warning because of ... comparison of integer expressions of different signedness * avoid compilation warning * moved UDTutorials to O2Physics/Tutorials/PWGUD
1 parent 7a4bfd3 commit dff8985

12 files changed

Lines changed: 1205 additions & 666 deletions

PWGUD/Core/DGPIDSelector.cxx

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,29 @@ DGAnaparHolder::~DGAnaparHolder()
122122
void DGAnaparHolder::Print()
123123
{
124124
LOGF(info, " DGAnaparHolder");
125-
LOGF(info, " nCombine: %i", mNCombine);
126-
LOGF(info, " max dcaxy: %f", mMaxDCAxy);
127-
LOGF(info, " max dcaz: %f", mMaxDCAz);
125+
LOGF(info, " min number tracks: %d", mMinNTracks);
126+
LOGF(info, " max number tracks: %d", mMaxNTracks);
127+
LOGF(info, " min fraction of PV contr. with TOF: %f", mMinRgtrwTOF);
128+
LOGF(info, " max dcaxy: %f", mMaxDCAxy);
129+
LOGF(info, " max dcaz: %f", mMaxDCAz);
130+
LOGF(info, " min dBC: %d", mdBCMin);
131+
LOGF(info, " max dBC: %d", mdBCMax);
132+
LOGF(info, " min track pT: %f", mMinpt);
133+
LOGF(info, " max track pT: %f", mMaxpt);
134+
LOGF(info, " min eta: %f", mMineta);
135+
LOGF(info, " max eta: %f", mMaxeta);
136+
LOGF(info, " min alpha: %f", mMinAlpha);
137+
LOGF(info, " max alpha: %f", mMaxAlpha);
138+
LOGF(info, " min system pT: %f", mMinptsys);
139+
LOGF(info, " max system pT: %f", mMaxptsys);
140+
LOGF(info, " nCombine: %d", mNCombine);
128141
LOGF(info, " net charges");
129142
for (auto ch : mNetCharges) {
130143
LOGF(info, " %i", ch);
131144
}
132145
LOGF(info, " PIDs");
133146
for (auto pid : mDGPIDs) {
134-
LOGF(info, " %f", pid);
147+
LOGF(info, " %d", pid);
135148
}
136149
PIDCuts().Print();
137150
}
@@ -145,8 +158,11 @@ DGPIDCuts DGAnaparHolder::PIDCuts()
145158
// -----------------------------------------------------------------------------
146159
void DGAnaparHolder::makeUniquePermutations()
147160
{
161+
// reset
162+
muniquePerms.clear();
163+
148164
// all permutations of mNCombine elements
149-
std::vector<std::vector<uint>> perms;
165+
std::vector<std::vector<int>> perms;
150166
permutations(mNCombine, perms);
151167

152168
// compute unique permutations
@@ -160,7 +176,7 @@ void DGAnaparHolder::makeUniquePermutations()
160176
cnt = -1;
161177
for (auto ind : perm) {
162178
cnt++;
163-
perminfo[cnt] = static_cast<int>(mDGPIDs[ind]);
179+
perminfo[cnt] = mDGPIDs[ind];
164180
}
165181
hashstr = "";
166182
for (auto tok : perminfo) {
@@ -183,19 +199,17 @@ void DGAnaparHolder::makeUniquePermutations()
183199
std::vector<int> DGAnaparHolder::uniquePermutations()
184200
{
185201
// create unique permutations if not done already
186-
if (muniquePerms.size() == 0) {
202+
if (muniquePerms.size() < mNCombine) {
187203
makeUniquePermutations();
188-
LOGF(info, "Number of unique permutations: %i", muniquePerms.size() / mNCombine);
189204
}
190205

191206
return muniquePerms;
192207
}
193208

194209
// -----------------------------------------------------------------------------
195210
// find all permutations of n0 elements
196-
void DGAnaparHolder::permutations(std::vector<uint>& ref, int n0, int np, std::vector<std::vector<uint>>& perms)
211+
void DGAnaparHolder::permutations(std::vector<int>& ref, int n0, int np, std::vector<std::vector<int>>& perms)
197212
{
198-
199213
// create local reference
200214
auto ref2u = ref;
201215

@@ -205,7 +219,7 @@ void DGAnaparHolder::permutations(std::vector<uint>& ref, int n0, int np, std::v
205219
// create a new permutation
206220
// copy first n0-np elements from ref
207221
// then rotate last np elements of ref
208-
std::vector<uint> perm(n0, 0);
222+
std::vector<int> perm(n0, 0);
209223
for (auto ii = 0; ii < n0 - np; ii++) {
210224
perm[ii] = ref2u[ii];
211225
}
@@ -233,15 +247,15 @@ void DGAnaparHolder::permutations(std::vector<uint>& ref, int n0, int np, std::v
233247

234248
//-----------------------------------------------------------------------------
235249
// find all permutations of n0 elements
236-
int DGAnaparHolder::permutations(int n0, std::vector<std::vector<uint>>& perms)
250+
int DGAnaparHolder::permutations(int n0, std::vector<std::vector<int>>& perms)
237251
{
238252
// initialize with first trivial combination
239253
perms.clear();
240254
if (n0 == 0) {
241255
return 0;
242256
}
243257

244-
std::vector<uint> ref(n0, 0);
258+
std::vector<int> ref(n0, 0);
245259
for (auto ii = 0; ii < n0; ii++) {
246260
ref[ii] = ii;
247261
}
@@ -323,8 +337,8 @@ int DGPIDSelector::pid2ind(int pid)
323337

324338
// -----------------------------------------------------------------------------
325339
// find selections of np out of n0
326-
void DGPIDSelector::combinations(int n0, std::vector<uint>& pool, int np, std::vector<uint>& inds, int n,
327-
std::vector<std::vector<uint>>& combs)
340+
void DGPIDSelector::combinations(int n0, std::vector<int>& pool, int np, std::vector<int>& inds, int n,
341+
std::vector<std::vector<int>>& combs)
328342
{
329343
// loop over pool
330344
for (auto ii = 0; ii < n0 - n; ii++) {
@@ -335,7 +349,7 @@ void DGPIDSelector::combinations(int n0, std::vector<uint>& pool, int np, std::v
335349
// else get next inds
336350
if (np == 1) {
337351

338-
std::vector<uint> comb(n + 1, 0);
352+
std::vector<int> comb(n + 1, 0);
339353
for (uint ii = 0; ii < inds.size(); ii++) {
340354
comb[ii] = inds[ii];
341355
}
@@ -344,7 +358,7 @@ void DGPIDSelector::combinations(int n0, std::vector<uint>& pool, int np, std::v
344358
} else {
345359

346360
auto n0new = n0 - ii;
347-
std::vector<uint> newpool(n0new, 0);
361+
std::vector<int> newpool(n0new, 0);
348362
for (auto kk = 0; kk < n0new; kk++) {
349363
newpool[kk] = pool[kk + ii + 1];
350364
}
@@ -358,19 +372,19 @@ void DGPIDSelector::combinations(int n0, std::vector<uint>& pool, int np, std::v
358372

359373
// -----------------------------------------------------------------------------
360374
// find all possible selections of np out of n0
361-
int DGPIDSelector::combinations(int n0, int np, std::vector<std::vector<uint>>& combs)
375+
int DGPIDSelector::combinations(int n0, int np, std::vector<std::vector<int>>& combs)
362376
{
363377
// initialisations
364378
combs.clear();
365379
if (n0 < np) {
366380
return 0;
367381
}
368382

369-
std::vector<uint> pool(n0, 0);
383+
std::vector<int> pool(n0, 0);
370384
for (auto ii = 0; ii < n0; ii++) {
371385
pool[ii] = ii;
372386
}
373-
std::vector<uint> inds(np, 0);
387+
std::vector<int> inds(np, 0);
374388

375389
// iterate recursively
376390
combinations(n0, pool, np, inds, 0, combs);
@@ -379,21 +393,21 @@ int DGPIDSelector::combinations(int n0, int np, std::vector<std::vector<uint>>&
379393
}
380394

381395
// -----------------------------------------------------------------------------
382-
std::vector<std::vector<uint>> DGPIDSelector::combinations(int nPool)
396+
std::vector<std::vector<int>> DGPIDSelector::combinations(int nPool)
383397
{
384398
// get the unique permutations
385399
auto uniquePerms = mAnaPars.uniquePermutations();
386400
auto numUniquePerms = uniquePerms.size() / mAnaPars.nCombine();
387401

388402
// all selections of nCombine elements from nPool elements
389-
std::vector<std::vector<uint>> combs;
403+
std::vector<std::vector<int>> combs;
390404
combinations(nPool, mAnaPars.nCombine(), combs);
391405

392406
// permute the combinations
393-
std::vector<std::vector<uint>> copes;
407+
std::vector<std::vector<int>> copes;
394408
for (auto comb : combs) {
395409
for (auto ii = 0u; ii < numUniquePerms; ii++) {
396-
std::vector<uint> cope(mAnaPars.nCombine(), 0);
410+
std::vector<int> cope(mAnaPars.nCombine(), 0);
397411
for (auto jj = 0; jj < mAnaPars.nCombine(); jj++) {
398412
auto ind = ii * mAnaPars.nCombine() + jj;
399413
cope[uniquePerms[ind]] = comb[jj];
@@ -402,15 +416,6 @@ std::vector<std::vector<uint>> DGPIDSelector::combinations(int nPool)
402416
}
403417
}
404418

405-
// print copes
406-
LOGF(debug, "copes");
407-
for (auto cope : copes) {
408-
LOGF(debug, " cope");
409-
for (auto ind : cope) {
410-
LOGF(debug, " %i", ind);
411-
}
412-
}
413-
414419
return copes;
415420
}
416421

0 commit comments

Comments
 (0)