forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrelatorHfeHadrons.cxx
More file actions
574 lines (485 loc) · 25.2 KB
/
correlatorHfeHadrons.cxx
File metadata and controls
574 lines (485 loc) · 25.2 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
// 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.
/// \file correlatorHfeHadrons.cxx
/// \brief Heavy Flavour electron-Hadron correaltor task - data-like, MC-reco and MC-Kine analyses.
/// \author Rashi Gupta <rashi.gupta@cern.ch>, IIT Indore
/// \author Ravindra Singh <ravindra.singh@cern.ch>, IIT Indore
#include "PWGHF/HFC/DataModel/CorrelationTables.h"
#include "PWGHF/HFL/DataModel/ElectronSelectionTable.h"
#include "Common/CCDB/TriggerAliases.h"
#include "Common/Core/RecoDecay.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include <CommonConstants/MathConstants.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/GroupedCombinations.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/HistogramSpec.h>
#include <Framework/InitContext.h>
#include <Framework/runDataProcessing.h>
#include <TRandom3.h>
#include <cstdint>
#include <vector>
using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::soa;
using namespace o2::aod::hf_sel_electron;
const std::vector<double> zBins{VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0};
const std::vector<double> multBins{VARIABLE_WIDTH, 0., 200., 500.0, 5000.};
const std::vector<double> multBinsMcGen{VARIABLE_WIDTH, 0., 20., 50.0, 500.}; // In MCGen multiplicity is defined by counting primaries
using BinningType = ColumnBinningPolicy<aod::collision::PosZ, aod::mult::MultFT0M<aod::mult::MultFT0A, aod::mult::MultFT0C>>;
const BinningType corrBinning{{zBins, multBins}, true};
using BinningTypeMcGen = ColumnBinningPolicy<aod::mccollision::PosZ, o2::aod::mult::MultMCFT0A>;
struct HfCorrelatorHfeHadrons {
Produces<aod::HfEHadronPair> entryElectronHadronPair;
Produces<aod::HfEHadronMcPair> entryElectronHadronPairmcGen;
Produces<aod::HfElectron> entryElectron;
Produces<aod::Hadron> entryHadron;
// Configurables
// Event Selection
Configurable<float> zPvPosMax{"zPvPosMax", 10., "Maximum z of the primary vertex (cm)"};
Configurable<bool> isRun3{"isRun3", true, "Data is from Run3 or Run2"};
Configurable<int> numberEventsMixed{"numberEventsMixed", 5, "number of events mixed in ME process"};
Configurable<float> invMassEEMax{"invMassEEMax", 0.14f, "max Invariant Mass for Photonic electron"};
// Associated Hadron selection
Configurable<float> ptTrackMin{"ptTrackMin", 0.1f, "Transverse momentum range for associated hadron tracks"};
Configurable<float> etaTrackMax{"etaTrackMax", 0.8f, "Eta range for associated hadron tracks"};
Configurable<float> etaTrackMin{"etaTrackMin", -0.8f, "Eta range for associated hadron tracks"};
Configurable<float> dcaXYTrackMax{"dcaXYTrackMax", 0.5f, "DCA XY cut"};
Configurable<float> dcaZTrackMax{"dcaZTrackMax", 1.0f, "DCA Z cut"};
Configurable<bool> requireEmcal{"requireEmcal", true, "Require electron to be in EMCal"};
// Sigma cut for non-EMCal electrons
Configurable<float> tofNSigmaEl{"tofNSigmaEl", 3.0, "Sigma cut for electrons not in EMCal"};
Configurable<float> tpcNsigmaElectronMin{"tpcNsigmaElectronMin", -0.5f, "min Electron TPCnsigma"};
Configurable<float> tpcNsigmaElectronMax{"tpcNsigmaElectronMax", 3.0f, "max Electron TPCnsigma"};
// Electron hadron correlation condition
Configurable<bool> ptCondition{"ptCondition", true, "Electron pT should be greater than associate particle pT"};
Configurable<float> eventFractionToAnalyze{"eventFractionToAnalyze", -1, "Fraction of events to analyze (use only for ME offline on very large samples)"};
TRandom3 rnd{0};
SliceCache cache;
using TableCollisions = o2::soa::Filtered<o2::soa::Join<aod::Collisions, aod::Mults, aod::EvSels>>;
using TableCollision = TableCollisions::iterator;
using TableTracks = o2::soa::Join<o2::aod::Tracks, o2::aod::TracksCov, o2::aod::TracksExtra, o2::aod::TracksDCA, o2::aod::TrackSelection, o2::aod::TrackSelectionExtension>;
using McGenTableCollisions = soa::Join<aod::McCollisions, aod::MultsExtraMC>;
using McGenTableCollision = McGenTableCollisions::iterator;
using McTableCollisions = o2::soa::Filtered<o2::soa::Join<TableCollisions, aod::McCollisionLabels>>;
using McTableCollision = McTableCollisions::iterator;
using McTableTracks = soa::Join<TableTracks, aod::McTrackLabels>;
Filter collisionFilter = nabs(aod::collision::posZ) < zPvPosMax && aod::collision::numContrib > static_cast<uint16_t>(1);
Preslice<aod::Tracks> perCol = aod::track::collisionId;
Preslice<aod::HfSelEl> perCollision = aod::hf_sel_electron::collisionId;
ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"};
ConfigurableAxis binsDeltaEta{"binsDeltaEta", {30, -1.8, 1.8}, "#it{#Delta#eta}"};
ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {32, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "#it{#Delta#varphi}"};
ConfigurableAxis binsPt{"binsPt", {50, 0.0, 50}, "#it{p_{T}}(GeV/#it{c})"};
ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"};
ConfigurableAxis binsNSigma{"binsNSigma", {30, -15., 15.}, "#it{#sigma_{TPC}}"};
ConfigurableAxis binsMass{"binsMass", {100, 0.0, 2.0}, "Mass (GeV/#it{c}^{2}); entries"};
HistogramRegistry registry{
"registry",
{}};
void init(InitContext&)
{
AxisSpec const axisPosZ = {binsPosZ, "Pos Z"};
AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta #eta = #eta_{Electron}- #eta_{Hadron}"};
AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta #varphi = #varphi_{Electron}- #varphi_{Hadron}"};
AxisSpec axisPt = {binsPt, "#it{p_{T}}(GeV/#it{c})"};
AxisSpec axisMass = {binsMass, "Mass (GeV/#it{c}^{2}); entries"};
AxisSpec const axisPoolBin = {binsPoolBin, "PoolBin"};
AxisSpec axisNSigma = {binsNSigma, "it{#sigma_{TPC}}"};
registry.add("hZvertex", "z vertex", {HistType::kTH1D, {axisPosZ}});
registry.add("hNevents", "No of events", {HistType::kTH1D, {{3, 1, 4}}});
registry.add("hLikeMass", "Like mass", {HistType::kTH1D, {{axisMass}}});
registry.add("hUnLikeMass", "unLike mass", {HistType::kTH1D, {{axisMass}}});
registry.add("hLikeSignPt", "Like sign Momentum ", {HistType::kTH1D, {{axisPt}}});
registry.add("hUnLikeSignPt", "UnLike sign Momentum", {HistType::kTH1D, {{axisPt}}});
registry.add("hInclusiveEHCorrel", "Sparse for Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hLSEHCorrel", "Sparse for Delta phi and Delta eta Like sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hULSEHCorrel", "Sparse for Delta phi and Delta eta UnLike sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hTofnSigmaVsP", " Tof nSigma info vs P; n#sigma;#it{p} (GeV#it{/c});passEMcal;", {HistType::kTH2F, {{axisNSigma}, {axisPt}}});
registry.add("hTpcnSigmaVsP", " TPC nSigma info vs P; n#sigma;#it{p} (GeV#it{/c});passEMcal;", {HistType::kTH2F, {{axisNSigma}, {axisPt}}});
registry.add("hMCgenNonHfEHCorrel", "Sparse for Delta phi and Delta eta for McGen Non Hf Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hMCgenInclusiveEHCorrl", "Sparse for Delta phi and Delta eta for McGen Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hptElectron", "hptElectron", {HistType::kTH1D, {axisPt}});
registry.add("hptHadron", "hptHadron", {HistType::kTH1D, {axisPt}});
registry.add("hMCgenptHadron", "hMCgenptHadron", {HistType::kTH1D, {axisPt}});
registry.add("hMCgenptHadronprimary", "hMCgenptHadronprimary", {HistType::kTH1D, {axisPt}});
registry.add("hMixEventInclusiveEHCorrl", "Sparse for mix event Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hMixEventLSEHCorrel", "Sparse for mix event Delta phi and Delta eta Like sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hMixEventULSEHCorrel", "Sparse for mix event Delta phi and Delta eta Unlike sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hMixEventMcGenInclusiveEHCorrl", "Sparse for mix event Delta phi and Delta eta Mc gen Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hMixEventMcGenNonHfEHCorrl", "Sparse for mix event Delta phi and Delta eta Mc gen Non Hf Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}});
registry.add("hElectronBin", "Electron bin", {HistType::kTH1D, {axisPoolBin}});
registry.add("hLSElectronBin", "Electron bin", {HistType::kTH1D, {axisPoolBin}});
registry.add("hULSElectronBin", "Electron bin", {HistType::kTH1D, {axisPoolBin}});
registry.add("hTracksBin", "Particles associated pool bin", {HistType::kTH1D, {axisPoolBin}});
}
// Associated Hadron Selection Cut
template <typename T>
bool selAssoHadron(T const& track)
{
if (!track.isGlobalTrackWoDCA()) {
return false;
}
if (std::abs(track.dcaXY()) > dcaXYTrackMax || std::abs(track.dcaZ()) > dcaZTrackMax) {
return false;
}
if (track.eta() < etaTrackMin || track.eta() > etaTrackMax) {
return false;
}
if (track.pt() < ptTrackMin) {
return false;
}
return true;
}
// Electron-hadron Correlation
template <typename TracksType, typename ElectronType, typename CollisionType, typename BcType>
void fillCorrelation(CollisionType const& collision, ElectronType const& electrons, TracksType const& tracks, BcType const&)
{
if (!(isRun3 ? collision.sel8() : (collision.sel7() && collision.alias_bit(kINT7)))) {
return;
}
int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M()));
auto bc = collision.template bc_as<BcType>();
int gCollisionId = collision.globalIndex();
int64_t timeStamp = bc.timestamp();
bool skipEventTableFilling = false;
if (eventFractionToAnalyze > 0) {
if (rnd.Uniform(0, 1) > eventFractionToAnalyze) {
skipEventTableFilling = true;
}
}
registry.fill(HIST("hNevents"), 1);
// Add hadron Table For Mix Event Electron Hadron correlation
if (!skipEventTableFilling) {
registry.fill(HIST("hZvertex"), collision.posZ());
for (const auto& hTrack : tracks) {
if (!selAssoHadron(hTrack)) {
continue;
}
registry.fill(HIST("hTracksBin"), poolBin);
registry.fill(HIST("hptHadron"), hTrack.pt());
entryHadron(hTrack.phi(), hTrack.eta(), hTrack.pt(), poolBin, gCollisionId, timeStamp);
}
}
// Construct Deta Phi between electrons and hadrons
double ptElectron = -999;
double phiElectron = -999;
double etaElectron = -999;
for (const auto& eTrack : electrons) {
ptElectron = eTrack.ptTrack();
phiElectron = eTrack.phiTrack();
etaElectron = eTrack.etaTrack();
bool acceptElectron = false;
double deltaPhi = -999;
double deltaEta = -999;
double ptHadron = -999;
double etaHadron = -999;
double phiHadron = -999;
// EMCal electron
if (eTrack.isEmcal() && requireEmcal) {
acceptElectron = true;
} else if (!eTrack.isEmcal() && !requireEmcal) {
// Apply sigma cut
if (std::abs(eTrack.tofNSigmaElTrack()) < tofNSigmaEl && eTrack.tpcNSigmaElTrack() > tpcNsigmaElectronMin &&
eTrack.tpcNSigmaElTrack() < tpcNsigmaElectronMax) {
registry.fill(HIST("hTofnSigmaVsP"), eTrack.tofNSigmaElTrack(), eTrack.ptTrack());
registry.fill(HIST("hTpcnSigmaVsP"), eTrack.tpcNSigmaElTrack(), eTrack.ptTrack());
acceptElectron = true;
}
}
if (!acceptElectron) {
continue; // skip electron if not passing criteria
}
registry.fill(HIST("hptElectron"), ptElectron);
int nElectronLS = 0;
int nElectronUS = 0;
float massLike = 0;
float massUnLike = 0;
if (eTrack.nElPairLS() > 0) {
for (int i = 0; i < eTrack.nElPairLS(); ++i) {
massLike = eTrack.invariantMassEE();
registry.fill(HIST("hLSElectronBin"), poolBin);
registry.fill(HIST("hLikeMass"), massLike);
if (massLike <= invMassEEMax) {
++nElectronLS;
registry.fill(HIST("hLikeSignPt"), eTrack.ptTrack());
}
}
}
if (eTrack.nElPairUS() > 0) {
for (int i = 0; i < eTrack.nElPairUS(); ++i) {
massUnLike = eTrack.invariantMassEE();
registry.fill(HIST("hULSElectronBin"), poolBin);
registry.fill(HIST("hUnLikeMass"), massUnLike);
if (massUnLike <= invMassEEMax) {
++nElectronUS;
registry.fill(HIST("hLikeSignPt"), eTrack.ptTrack());
}
}
}
if (!skipEventTableFilling) {
registry.fill(HIST("hElectronBin"), poolBin);
entryElectron(phiElectron, etaElectron, ptElectron, nElectronLS, nElectronUS, poolBin, gCollisionId, timeStamp);
}
for (const auto& hTrack : tracks) {
// Apply Hadron cut
if (!selAssoHadron(hTrack)) {
continue;
}
ptHadron = hTrack.pt();
phiHadron = hTrack.phi();
etaHadron = hTrack.eta();
if (hTrack.globalIndex() == eTrack.trackId()) {
continue;
}
if (ptCondition && (ptElectron < ptHadron)) {
continue;
}
deltaPhi = RecoDecay::constrainAngle(phiElectron - phiHadron, -o2::constants::math::PIHalf);
deltaEta = etaElectron - etaHadron;
registry.fill(HIST("hInclusiveEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta);
int nElHadLSCorr = 0;
int nElHadUSCorr = 0;
if (eTrack.nElPairLS() > 0) {
for (int i = 0; i < eTrack.nElPairLS(); ++i) {
if (eTrack.invariantMassEE() <= invMassEEMax) {
++nElHadLSCorr;
registry.fill(HIST("hLSEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta);
}
}
}
if (eTrack.nElPairUS() > 0) {
for (int i = 0; i < eTrack.nElPairUS(); ++i) {
if (eTrack.invariantMassEE() <= invMassEEMax) {
registry.fill(HIST("hULSEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta);
++nElHadUSCorr;
}
}
}
entryElectronHadronPair(deltaPhi, deltaEta, ptElectron, ptHadron, poolBin, nElHadLSCorr, nElHadUSCorr);
} // end Hadron Track loop
} // end Electron loop
}
// mix event electron-hadron correlation
template <typename TracksType, typename ElectronType, typename CollisionType1, typename CollisionType2>
void fillMixCorrelation(CollisionType1 const&, CollisionType2 const& c2, ElectronType const& tracks1, TracksType const& tracks2)
{
if (!(isRun3 ? c2.sel8() : (c2.sel7() && c2.alias_bit(kINT7)))) {
return;
}
double ptElectronMix = -999;
double phiElectronMix = -999;
double etaElectronMix = -999;
double deltaPhiMix = -999;
double deltaEtaMix = -999;
double ptHadronMix = -999;
double etaHadronMix = -999;
double phiHadronMix = -999;
int poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFT0M()));
for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) {
if (!t1.isEmcal()) {
continue;
}
ptHadronMix = t2.pt();
ptElectronMix = t1.ptTrack();
phiElectronMix = t1.phiTrack();
phiHadronMix = t2.phi();
etaElectronMix = t1.etaTrack();
etaHadronMix = t2.eta();
if (!selAssoHadron(t2)) {
continue;
}
if (ptCondition && (ptElectronMix < ptHadronMix)) {
continue;
}
deltaPhiMix = RecoDecay::constrainAngle(phiElectronMix - phiHadronMix, -o2::constants::math::PIHalf);
deltaEtaMix = etaElectronMix - etaHadronMix;
registry.fill(HIST("hMixEventInclusiveEHCorrl"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix);
int nElHadLSCorr = 0;
int nElHadUSCorr = 0;
if (t1.nElPairLS() > 0) {
for (int i = 0; i < t1.nElPairLS(); ++i) {
registry.fill(HIST("hMixEventLSEHCorrel"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix);
++nElHadLSCorr;
}
}
if (t1.nElPairUS() > 0) {
for (int i = 0; i < t1.nElPairUS(); ++i) {
registry.fill(HIST("hMixEventULSEHCorrel"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix);
++nElHadUSCorr;
}
}
entryElectronHadronPair(deltaPhiMix, deltaEtaMix, ptElectronMix, ptHadronMix, poolBin, nElHadLSCorr, nElHadUSCorr);
}
}
// ======= Process starts for Data, Same event ============
void processData(TableCollision const& collision,
aod::HfCorrSelEl const& electrons,
TableTracks const& tracks,
aod::BCsWithTimestamps const& bcs)
{
fillCorrelation(collision, electrons, tracks, bcs);
}
PROCESS_SWITCH(HfCorrelatorHfeHadrons, processData, "Process for Data", true);
// ======= Process starts for McRec, Same event ============
void processMcRec(McTableCollision const& mcCollision,
aod::HfCorrSelEl const& mcElectrons,
McTableTracks const& mcTracks,
aod::BCsWithTimestamps const& bcs)
{
fillCorrelation(mcCollision, mcElectrons, mcTracks, bcs);
}
PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcRec, "Process MC Reco mode", false);
void processMcGen(McGenTableCollision const& mcCollision, aod::McParticles const& mcParticles, aod::HfMcGenSelEl const& electrons)
{
BinningTypeMcGen const corrBinningMcGen{{zBins, multBinsMcGen}, true};
int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A()));
for (const auto& particleMc : mcParticles) {
if (particleMc.eta() < etaTrackMin || particleMc.eta() > etaTrackMax) {
continue;
}
if (particleMc.pt() < ptTrackMin) {
continue;
}
registry.fill(HIST("hMCgenptHadron"), particleMc.pt());
if (particleMc.isPhysicalPrimary()) {
registry.fill(HIST("hMCgenptHadronprimary"), particleMc.pt());
}
}
double ptElectron = 0;
double phiElectron = 0;
double etaElectron = 0;
for (const auto& electronMc : electrons) {
double ptHadron = 0;
double phiHadron = 0;
double etaHadron = 0;
double deltaPhi = 0;
double deltaEta = 0;
ptElectron = electronMc.ptTrackMc();
phiElectron = electronMc.phiTrackMc();
etaElectron = electronMc.etaTrackMc();
for (const auto& particleMc : mcParticles) {
if (particleMc.globalIndex() == electronMc.trackId()) {
continue;
}
// Associated hadron Selection //////
if (!particleMc.isPhysicalPrimary()) {
continue;
}
if (particleMc.eta() < etaTrackMin || particleMc.eta() > etaTrackMax) {
continue;
}
if (particleMc.pt() < ptTrackMin) {
continue;
}
ptHadron = particleMc.pt();
phiHadron = particleMc.phi();
etaHadron = particleMc.eta();
if (ptCondition && (ptElectron < ptHadron)) {
return; // Apply pT condition
}
deltaPhi = RecoDecay::constrainAngle(phiElectron - phiHadron, -o2::constants::math::PIHalf);
deltaEta = etaElectron - etaHadron;
bool isNonHfeCorr = false;
if (electronMc.isNonHfeMc()) {
registry.fill(HIST("hMCgenNonHfEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta);
isNonHfeCorr = true;
} else {
registry.fill(HIST("hMCgenInclusiveEHCorrl"), ptElectron, ptHadron, deltaPhi, deltaEta);
}
entryElectronHadronPairmcGen(deltaPhi, deltaEta, ptElectron, ptHadron, poolBin, isNonHfeCorr);
}
}
}
PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcGen, "Process MC Gen mode", false);
// ====================== Implement Event mixing on Data ===============================
// ====================== Implement Event mixing on Data ===================================
void processDataMixedEvent(TableCollisions const& collision, aod::HfCorrSelEl const& electron, TableTracks const& tracks)
{
auto tracksTuple = std::make_tuple(electron, tracks);
Pair<TableCollisions, aod::HfCorrSelEl, TableTracks, BinningType> const pair{corrBinning, numberEventsMixed, -1, collision, tracksTuple, &cache};
// loop over the rows of the new table
for (const auto& [c1, tracks1, c2, tracks2] : pair) {
fillMixCorrelation(c1, c2, tracks1, tracks2);
}
}
PROCESS_SWITCH(HfCorrelatorHfeHadrons, processDataMixedEvent, "Process Mixed Event Data", false);
// ====================== Implement Event mixing on McRec ===================================
void processMcRecMixedEvent(McTableCollisions const& mccollision, aod::HfCorrSelEl const& electron, McTableTracks const& mcTracks)
{
auto tracksTuple = std::make_tuple(electron, mcTracks);
Pair<McTableCollisions, aod::HfCorrSelEl, McTableTracks, BinningType> const pairMcRec{corrBinning, numberEventsMixed, -1, mccollision, tracksTuple, &cache};
// loop over the rows of the new table
for (const auto& [c1, tracks1, c2, tracks2] : pairMcRec) {
fillMixCorrelation(c1, c2, tracks1, tracks2);
}
}
PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcRecMixedEvent, "Process Mixed Event MC Reco mode", false);
void processMcGenMixedEvent(McGenTableCollisions const& mcCollision, aod::HfMcGenSelEl const& electrons, aod::McParticles const& mcParticles)
{
BinningTypeMcGen const corrBinningMcGen{{zBins, multBinsMcGen}, true};
auto tracksTuple = std::make_tuple(electrons, mcParticles);
Pair<McGenTableCollisions, aod::HfMcGenSelEl, aod::McParticles, BinningTypeMcGen> const pairMcGen{corrBinningMcGen, 5, -1, mcCollision, tracksTuple, &cache};
// loop over the rows of the new table
double ptElectronMix = -999;
double phiElectronMix = -999;
double etaElectronMix = -999;
double deltaPhiMix = -999;
double deltaEtaMix = -999;
double ptHadronMix = -999;
double etaHadronMix = -999;
double phiHadronMix = -999;
for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) {
int poolBin = corrBinningMcGen.getBin(std::make_tuple(c1.posZ(), c1.multMCFT0A()));
for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) {
ptHadronMix = t2.pt();
ptElectronMix = t1.ptTrackMc();
phiElectronMix = t1.phiTrackMc();
phiHadronMix = t2.phi();
etaElectronMix = t1.etaTrackMc();
etaHadronMix = t2.eta();
if (t2.eta() < etaTrackMin || t2.eta() > etaTrackMax) {
continue;
}
if (t2.pt() < ptTrackMin) {
continue;
}
if (ptCondition && (ptElectronMix < ptHadronMix)) {
continue;
}
deltaPhiMix = RecoDecay::constrainAngle(phiElectronMix - phiHadronMix, -o2::constants::math::PIHalf);
deltaEtaMix = etaElectronMix - etaHadronMix;
bool isNonHfeCorr = false;
if (t1.isNonHfeMc()) {
isNonHfeCorr = true;
registry.fill(HIST("hMixEventMcGenNonHfEHCorrl"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix);
} else {
registry.fill(HIST("hMixEventMcGenInclusiveEHCorrl"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix);
}
entryElectronHadronPairmcGen(deltaPhiMix, deltaEtaMix, ptElectronMix, ptHadronMix, poolBin, isNonHfeCorr);
}
}
}
PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcGenMixedEvent, "Process Mixed Event MC Gen mode", false);
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<HfCorrelatorHfeHadrons>(cfgc)};
}