forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpidDiHadron.cxx
More file actions
718 lines (625 loc) · 34.7 KB
/
pidDiHadron.cxx
File metadata and controls
718 lines (625 loc) · 34.7 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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
// 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 pidDiHadron.cxx
/// \brief di-hadron correlation of PID for O-O, Pb-Pb collisions
/// \author Preet Bhanjan Pati (preet.bhanjan.pati@cern.ch), Zhiyong Lu (zhiyong.lu@cern.ch)
/// \since July/29/2025
#include "PWGCF/Core/CorrelationContainer.h"
#include "PWGCF/Core/PairCuts.h"
#include "PWGCF/DataModel/CorrelationsDerived.h"
#include "Common/Core/RecoDecay.h"
#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/CollisionAssociationTables.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/PIDResponseITS.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "CommonConstants/MathConstants.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "DataFormatsParameters/GRPObject.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Framework/StepTHn.h"
#include "Framework/runDataProcessing.h"
#include "ReconstructionDataFormats/PID.h"
#include "ReconstructionDataFormats/Track.h"
#include <CCDB/BasicCCDBManager.h>
#include "TF1.h"
#include "TRandom3.h"
#include <TPDGCode.h>
#include <string>
#include <vector>
using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
// define the filtered collisions and tracks
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
struct PidDiHadron {
Service<ccdb::BasicCCDBManager> ccdb;
O2_DEFINE_CONFIGURABLE(cfgCutVtxZ, float, 10.0f, "Accepted z-vertex range")
O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "minimum accepted track pT")
O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "maximum accepted track pT")
O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta cut")
O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters")
O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 50.0f, "minimum TPC clusters")
O2_DEFINE_CONFIGURABLE(cfgCutTPCCrossedRows, float, 70.0f, "minimum TPC crossed rows")
O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters")
O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z")
O2_DEFINE_CONFIGURABLE(cfgCutMerging, float, 0.0, "Merging cut on track merge")
O2_DEFINE_CONFIGURABLE(cfgSelCollByNch, bool, true, "Select collisions by Nch or centrality")
O2_DEFINE_CONFIGURABLE(cfgCutMultMin, int, 0, "Minimum multiplicity for collision")
O2_DEFINE_CONFIGURABLE(cfgCutMultMax, int, 10, "Maximum multiplicity for collision")
O2_DEFINE_CONFIGURABLE(cfgCutCentMin, float, 60.0f, "Minimum centrality for collision")
O2_DEFINE_CONFIGURABLE(cfgCutCentMax, float, 80.0f, "Maximum centrality for collision")
O2_DEFINE_CONFIGURABLE(cfgMixEventNumMin, int, 5, "Minimum number of events to mix")
O2_DEFINE_CONFIGURABLE(cfgRadiusLow, float, 0.8, "Low radius for merging cut")
O2_DEFINE_CONFIGURABLE(cfgRadiusHigh, float, 2.5, "High radius for merging cut")
O2_DEFINE_CONFIGURABLE(cfgSampleSize, double, 10, "Sample size for mixed event")
O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A")
O2_DEFINE_CONFIGURABLE(cfgCentTableUnavailable, bool, false, "if a dataset does not provide centrality information")
O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations")
O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing")
O2_DEFINE_CONFIGURABLE(cfgEvSelkNoITSROFrameBorder, bool, false, "reject events at ITS ROF border")
O2_DEFINE_CONFIGURABLE(cfgEvSelkNoTimeFrameBorder, bool, false, "reject events at TF border")
O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution")
O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range")
O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves")
O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold")
O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold")
O2_DEFINE_CONFIGURABLE(cfgEvSelMultCorrelation, bool, true, "Multiplicity correlation cut")
O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, true, "V0A T0A 5 sigma cut")
O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut")
O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 2000, "High cut on TPC occupancy")
O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy")
O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object")
O2_DEFINE_CONFIGURABLE(cfgLocalEfficiency, bool, false, "Use local efficiency object")
O2_DEFINE_CONFIGURABLE(cfgVerbosity, bool, false, "Verbose output")
O2_DEFINE_CONFIGURABLE(cfgUseEventWeights, bool, false, "Use event weights for mixed event")
O2_DEFINE_CONFIGURABLE(cfgUsePtOrder, bool, false, "enable trigger pT < associated pT cut")
O2_DEFINE_CONFIGURABLE(cfgUsePtOrderInMixEvent, bool, false, "enable trigger pT < associated pT cut in mixed event")
O2_DEFINE_CONFIGURABLE(cfgPIDUseITSPID, bool, true, "Use ITS PID for particle identification")
O2_DEFINE_CONFIGURABLE(cfgPIDTofPtCut, float, 0.5f, "Minimum pt to use TOF N-sigma")
O2_DEFINE_CONFIGURABLE(cfgPIDParticle, int, 0, "1 = pion, 2 = kaon, 3 = proton, 0 for no PID")
SliceCache cache;
ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"};
ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260}, "multiplicity axis for histograms"};
ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, "centrality axis for histograms"};
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt axis for histograms"};
ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"};
ConfigurableAxis axisDeltaEta{"axisDeltaEta", {48, -2.4, 2.4}, "delta eta axis for histograms"};
ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt trigger axis for histograms"};
ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt associated axis for histograms"};
ConfigurableAxis axisVtxMix{"axisVtxMix", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "vertex axis for mixed event histograms"};
ConfigurableAxis axisMultMix{"axisMultMix", {VARIABLE_WIDTH, 0, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260}, "multiplicity / centrality axis for mixed event histograms"};
ConfigurableAxis axisSample{"axisSample", {cfgSampleSize, 0, cfgSampleSize}, "sample axis for histograms"};
Configurable<std::vector<double>> pidTofNsigmaCut{"pidTofNsigmaCut", std::vector<double>{1.5, 1.5, 1.5, -1.5, -1.5, -1.5}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"};
Configurable<std::vector<double>> pidItsNsigmaCut{"pidItsNsigmaCut", std::vector<double>{3, 3, 3, -3, -3, -3}, "ITS n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"};
Configurable<std::vector<double>> pidTpcNsigmaCut{"pidTpcNsigmaCut", std::vector<double>{10, 10, 10, -10, -10, -10}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"};
ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"};
ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"};
ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt axis for efficiency histograms"};
// make the filters and cuts.
Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVtxZ);
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz);
using FilteredCollisions = soa::Filtered<soa::Join<aod::Collisions, aod::EvSel, aod::CentFT0Cs, aod::CentFT0CVariant1s, aod::CentFT0Ms, aod::CentFV0As, aod::Mults>>;
using FilteredTracks = soa::Filtered<soa::Join<aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTOFbeta, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>>;
Preslice<aod::Tracks> perCollision = aod::track::collisionId;
// Corrections
TH3D* mEfficiency = nullptr;
bool correctionsLoaded = false;
// Define the outputs
OutputObj<CorrelationContainer> same{"sameEvent"};
OutputObj<CorrelationContainer> mixed{"mixedEvent"};
HistogramRegistry registry{"registry"};
// define global variables
TRandom3* gRandom = new TRandom3();
enum CentEstimators {
kCentFT0C = 0,
kCentFT0CVariant1,
kCentFT0M,
kCentFV0A,
// Count the total number of enum
kCount_CentEstimators
};
enum EventType {
SameEvent = 1,
MixedEvent = 3
};
std::vector<double> tofNsigmaCut;
std::vector<double> itsNsigmaCut;
std::vector<double> tpcNsigmaCut;
o2::aod::ITSResponse itsResponse;
enum Particles {
PIONS,
KAONS,
PROTONS
};
// persistent caches
std::vector<float> efficiencyAssociatedCache;
TF1* fMultPVCutLow = nullptr;
TF1* fMultPVCutHigh = nullptr;
TF1* fMultCutLow = nullptr;
TF1* fMultCutHigh = nullptr;
TF1* fMultMultPVCut = nullptr;
TF1* fT0AV0AMean = nullptr;
TF1* fT0AV0ASigma = nullptr;
void init(InitContext&)
{
if (cfgCentTableUnavailable && !cfgSelCollByNch) {
LOGF(fatal, "Centrality table is unavailable, cannot select collisions by centrality");
}
const AxisSpec axisPhi{72, 0.0, constants::math::TwoPI, "#varphi"};
const AxisSpec axisEta{40, -1., 1., "#eta"};
ccdb->setURL("http://alice-ccdb.cern.ch");
ccdb->setCaching(true);
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
ccdb->setCreatedNotAfter(now);
LOGF(info, "Starting init");
// Event Counter
if (doprocessSame && cfgUseAdditionalEventCut) {
registry.add("hEventCount", "Number of Event;; Count", {HistType::kTH1D, {{12, 0, 12}}});
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(1, "after sel8");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "kNoITSROFrameBorder");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "kNoTimeFrameBorder");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(5, "kIsGoodZvtxFT0vsPV");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(6, "kNoCollInTimeRangeStandard");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(7, "kIsGoodITSLayersAll");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(8, "kNoCollInRofStandard");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(9, "kNoHighMultCollInPrevRof");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(10, "occupancy");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(11, "MultCorrelation");
registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(12, "cfgEvSelV0AT0ACut");
}
if (cfgUseAdditionalEventCut) {
fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100);
fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06);
fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100);
fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06);
fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100);
fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06);
fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100);
fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06);
fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000);
fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01);
fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000);
fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17);
}
std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator);
// Make histograms to check the distributions after cuts
if (doprocessSame) {
registry.add("deltaEta_deltaPhi_same", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); // check to see the delta eta and delta phi distribution
registry.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}});
registry.add("Phi", "Phi", {HistType::kTH1D, {axisPhi}});
registry.add("Eta", "Eta", {HistType::kTH1D, {axisEta}});
registry.add("EtaCorrected", "EtaCorrected", {HistType::kTH1D, {axisEta}});
registry.add("pT", "pT", {HistType::kTH1D, {axisPtTrigger}});
registry.add("pTCorrected", "pTCorrected", {HistType::kTH1D, {axisPtTrigger}});
registry.add("Nch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}});
registry.add("Nch_used", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); // histogram to see how many events are in the same and mixed event
registry.add("Centrality", hCentTitle.c_str(), {HistType::kTH1D, {axisCentrality}});
registry.add("Centrality_used", hCentTitle.c_str(), {HistType::kTH1D, {axisCentrality}}); // histogram to see how many events are in the same and mixed event
registry.add("zVtx", "zVtx", {HistType::kTH1D, {axisVertex}});
registry.add("zVtx_used", "zVtx_used", {HistType::kTH1D, {axisVertex}});
registry.add("Trig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}});
}
registry.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event
LOGF(info, "Initializing correlation container");
std::vector<AxisSpec> corrAxis = {{axisSample, "Sample"},
{axisVertex, "z-vtx (cm)"},
{axisPtTrigger, "p_{T} (GeV/c)"},
{axisPtAssoc, "p_{T} (GeV/c)"},
{axisDeltaPhi, "#Delta#varphi (rad)"},
{axisDeltaEta, "#Delta#eta"}};
std::vector<AxisSpec> effAxis = {
{axisEtaEfficiency, "#eta"},
{axisPtEfficiency, "p_{T} (GeV/c)"},
{axisVertexEfficiency, "z-vtx (cm)"},
};
std::vector<AxisSpec> userAxis;
same.setObject(new CorrelationContainer("sameEvent", "sameEvent", corrAxis, effAxis, userAxis));
mixed.setObject(new CorrelationContainer("mixedEvent", "mixedEvent", corrAxis, effAxis, userAxis));
tofNsigmaCut = pidTofNsigmaCut;
itsNsigmaCut = pidItsNsigmaCut;
tpcNsigmaCut = pidTpcNsigmaCut;
LOGF(info, "End of init");
}
int getMagneticField(uint64_t timestamp)
{
// Get the magnetic field
static o2::parameters::GRPMagField* grpo = nullptr;
if (grpo == nullptr) {
grpo = ccdb->getForTimeStamp<o2::parameters::GRPMagField>("/GLO/Config/GRPMagField", timestamp);
if (grpo == nullptr) {
LOGF(fatal, "GRP object not found for timestamp %llu", timestamp);
return 0;
}
LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field());
}
return grpo->getNominalL3Field();
}
template <typename TCollision>
float getCentrality(TCollision const& collision)
{
float cent;
switch (cfgCentEstimator) {
case kCentFT0C:
cent = collision.centFT0C();
break;
case kCentFT0CVariant1:
cent = collision.centFT0CVariant1();
break;
case kCentFT0M:
cent = collision.centFT0M();
break;
case kCentFV0A:
cent = collision.centFV0A();
break;
default:
cent = collision.centFT0C();
}
return cent;
}
template <typename TTrack>
bool trackSelected(TTrack track)
{
return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.tpcNClsCrossedRows() >= cfgCutTPCCrossedRows) && (track.itsNCls() >= cfgCutITSclu));
}
void loadEfficiency(uint64_t timestamp)
{
if (correctionsLoaded) {
return;
}
if (cfgEfficiency.value.empty() == false) {
if (cfgLocalEfficiency > 0) {
TFile* fEfficiencyTrigger = TFile::Open(cfgEfficiency.value.c_str(), "READ");
mEfficiency = reinterpret_cast<TH3D*>(fEfficiencyTrigger->Get("ccdb_object"));
} else {
mEfficiency = ccdb->getForTimeStamp<TH3D>(cfgEfficiency, timestamp);
}
if (mEfficiency == nullptr) {
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str());
}
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency);
}
correctionsLoaded = true;
}
bool getEfficiencyCorrection(float& weight_nue, float eta, float pt, float posZ)
{
float eff = 1.;
if (mEfficiency) {
int etaBin = mEfficiency->GetXaxis()->FindBin(eta);
int ptBin = mEfficiency->GetYaxis()->FindBin(pt);
int zBin = mEfficiency->GetZaxis()->FindBin(posZ);
eff = mEfficiency->GetBinContent(etaBin, ptBin, zBin);
} else {
eff = 1.0;
}
if (eff == 0)
return false;
weight_nue = 1. / eff;
return true;
}
// fill multiple histograms
template <typename TCollision, typename TTracks>
void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms.
{
float weff1 = 1;
float vtxz = collision.posZ();
for (auto const& track1 : tracks) {
if (!trackSelected(track1))
continue;
if (cfgPIDParticle && getNsigmaPID(track1) != cfgPIDParticle)
continue; // if PID is selected, check if the track has the right PID
if (!getEfficiencyCorrection(weff1, track1.eta(), track1.pt(), vtxz))
continue;
registry.fill(HIST("Phi"), RecoDecay::constrainAngle(track1.phi(), 0.0));
registry.fill(HIST("Eta"), track1.eta());
registry.fill(HIST("EtaCorrected"), track1.eta(), weff1);
registry.fill(HIST("pT"), track1.pt());
registry.fill(HIST("pTCorrected"), track1.pt(), weff1);
}
}
template <typename TTrack, typename TTrackAssoc>
float getDPhiStar(TTrack const& track1, TTrackAssoc const& track2, float radius, int magField)
{
float charge1 = track1.sign();
float charge2 = track2.sign();
float phi1 = track1.phi();
float phi2 = track2.phi();
float pt1 = track1.pt();
float pt2 = track2.pt();
int fbSign = (magField > 0) ? 1 : -1;
float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2);
if (dPhiStar > constants::math::PI)
dPhiStar = constants::math::TwoPI - dPhiStar;
if (dPhiStar < -constants::math::PI)
dPhiStar = -constants::math::TwoPI - dPhiStar;
return dPhiStar;
}
template <CorrelationContainer::CFStep step, typename TTracks, typename TTracksAssoc>
void fillCorrelations(TTracks tracks1, TTracksAssoc tracks2, float posZ, int system, int magneticField, float cent, float eventWeight) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
{
// Cache efficiency for particles (too many FindBin lookups)
if (mEfficiency) {
efficiencyAssociatedCache.clear();
efficiencyAssociatedCache.reserve(tracks2.size());
for (const auto& track2 : tracks2) {
float weff = 1.;
getEfficiencyCorrection(weff, track2.eta(), track2.pt(), posZ);
efficiencyAssociatedCache.push_back(weff);
}
}
if (system == SameEvent) {
if (!cfgCentTableUnavailable)
registry.fill(HIST("Centrality_used"), cent);
registry.fill(HIST("Nch_used"), tracks1.size());
}
int fSampleIndex = gRandom->Uniform(0, cfgSampleSize);
float triggerWeight = 1.0f;
float associatedWeight = 1.0f;
// loop over all tracks
for (auto const& track1 : tracks1) {
if (!trackSelected(track1))
continue;
if (cfgPIDParticle && getNsigmaPID(track1) != cfgPIDParticle)
continue; // if PID is selected, check if the track has the right PID
if (!getEfficiencyCorrection(triggerWeight, track1.eta(), track1.pt(), posZ))
continue;
if (system == SameEvent) {
registry.fill(HIST("Trig_hist"), fSampleIndex, posZ, track1.pt(), eventWeight * triggerWeight);
}
for (auto const& track2 : tracks2) {
if (!trackSelected(track2))
continue;
if (mEfficiency) {
associatedWeight = efficiencyAssociatedCache[track2.filteredIndex()];
}
if (!cfgUsePtOrder && track1.globalIndex() == track2.globalIndex())
continue; // For pt-differential correlations, skip if the trigger and associate are the same track
if (cfgUsePtOrder && system == SameEvent && track1.pt() <= track2.pt())
continue; // Without pt-differential correlations, skip if the trigger pt is less than the associate pt
if (cfgUsePtOrder && system == MixedEvent && cfgUsePtOrderInMixEvent && track1.pt() <= track2.pt())
continue; // For pt-differential correlations in mixed events, skip if the trigger pt is less than the associate pt
float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi(), -PIHalf);
float deltaEta = track1.eta() - track2.eta();
if (std::abs(deltaEta) < cfgCutMerging) {
double dPhiStarHigh = getDPhiStar(track1, track2, cfgRadiusHigh, magneticField);
double dPhiStarLow = getDPhiStar(track1, track2, cfgRadiusLow, magneticField);
const double kLimit = 3.0 * cfgCutMerging;
bool bIsBelow = false;
if (std::abs(dPhiStarLow) < kLimit || std::abs(dPhiStarHigh) < kLimit || dPhiStarLow * dPhiStarHigh < 0) {
for (double rad(cfgRadiusLow); rad < cfgRadiusHigh; rad += 0.01) {
double dPhiStar = getDPhiStar(track1, track2, rad, magneticField);
if (std::abs(dPhiStar) < kLimit) {
bIsBelow = true;
break;
}
}
if (bIsBelow)
continue;
}
}
// fill the right sparse and histograms
if (system == SameEvent) {
same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight);
registry.fill(HIST("deltaEta_deltaPhi_same"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight);
} else if (system == MixedEvent) {
mixed->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight);
registry.fill(HIST("deltaEta_deltaPhi_mixed"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight);
}
}
}
}
template <typename TCollision>
bool eventSelected(TCollision collision, const int multTrk, const float centrality, const bool fillCounter)
{
registry.fill(HIST("hEventCount"), 0.5);
if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) {
// rejects collisions which are associated with the same "found-by-T0" bunch crossing
// https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof
return 0;
}
if (fillCounter && cfgEvSelkNoSameBunchPileup)
registry.fill(HIST("hEventCount"), 1.5);
if (cfgEvSelkNoITSROFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) {
return 0;
}
if (fillCounter && cfgEvSelkNoITSROFrameBorder)
registry.fill(HIST("hEventCount"), 2.5);
if (cfgEvSelkNoTimeFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
return 0;
}
if (fillCounter && cfgEvSelkNoTimeFrameBorder)
registry.fill(HIST("hEventCount"), 3.5);
if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) {
// removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference
// use this cut at low multiplicities with caution
return 0;
}
if (fillCounter && cfgEvSelkIsGoodZvtxFT0vsPV)
registry.fill(HIST("hEventCount"), 4.5);
if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) {
// no collisions in specified time range
return 0;
}
if (fillCounter && cfgEvSelkNoCollInTimeRangeStandard)
registry.fill(HIST("hEventCount"), 5.5);
if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) {
// from Jan 9 2025 AOT meeting
// cut time intervals with dead ITS staves
return 0;
}
if (fillCounter && cfgEvSelkIsGoodITSLayersAll)
registry.fill(HIST("hEventCount"), 6.5);
if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) {
// no other collisions in this Readout Frame with per-collision multiplicity above threshold
return 0;
}
if (fillCounter && cfgEvSelkNoCollInRofStandard)
registry.fill(HIST("hEventCount"), 7.5);
if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) {
// veto an event if FT0C amplitude in previous ITS ROF is above threshold
return 0;
}
if (fillCounter && cfgEvSelkNoHighMultCollInPrevRof)
registry.fill(HIST("hEventCount"), 8.5);
auto occupancy = collision.trackOccupancyInTimeRange();
if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh))
return 0;
if (fillCounter && cfgEvSelOccupancy)
registry.fill(HIST("hEventCount"), 9.5);
auto multNTracksPV = collision.multNTracksPV();
if (cfgEvSelMultCorrelation) {
if (multNTracksPV < fMultPVCutLow->Eval(centrality))
return 0;
if (multNTracksPV > fMultPVCutHigh->Eval(centrality))
return 0;
if (multTrk < fMultCutLow->Eval(centrality))
return 0;
if (multTrk > fMultCutHigh->Eval(centrality))
return 0;
}
if (fillCounter && cfgEvSelMultCorrelation)
registry.fill(HIST("hEventCount"), 10.5);
// V0A T0A 5 sigma cut
float sigma = 5.0;
if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > sigma * fT0AV0ASigma->Eval(collision.multFT0A())))
return 0;
if (fillCounter && cfgEvSelV0AT0ACut)
registry.fill(HIST("hEventCount"), 11.5);
return 1;
}
void processSame(FilteredCollisions::iterator const& collision, FilteredTracks const& tracks, aod::BCsWithTimestamps const&)
{
if (!collision.sel8())
return;
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
float cent = -1.;
if (!cfgCentTableUnavailable)
cent = getCentrality(collision);
if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent, true))
return;
if (!cfgCentTableUnavailable)
registry.fill(HIST("Centrality"), cent);
registry.fill(HIST("Nch"), tracks.size());
registry.fill(HIST("zVtx"), collision.posZ());
if (cfgSelCollByNch && (tracks.size() < cfgCutMultMin || tracks.size() >= cfgCutMultMax)) {
return;
}
if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) {
return;
}
loadEfficiency(bc.timestamp());
registry.fill(HIST("eventcount"), SameEvent); // because its same event i put it in the 1 bin
fillYield(collision, tracks);
same->fillEvent(tracks.size(), CorrelationContainer::kCFStepReconstructed);
fillCorrelations<CorrelationContainer::kCFStepReconstructed>(tracks, tracks, collision.posZ(), SameEvent, getMagneticField(bc.timestamp()), cent, 1.0f);
}
PROCESS_SWITCH(PidDiHadron, processSame, "Process same event", true);
// the process for filling the mixed events
void processMixed(FilteredCollisions const& collisions, FilteredTracks const& tracks, aod::BCsWithTimestamps const&)
{
auto getTracksSize = [&tracks, this](FilteredCollisions::iterator const& collision) {
auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache);
auto mult = associatedTracks.size();
return mult;
};
using MixedBinning = FlexibleBinningPolicy<std::tuple<decltype(getTracksSize)>, aod::collision::PosZ, decltype(getTracksSize)>;
MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxMix, axisMultMix}, true};
auto tracksTuple = std::make_tuple(tracks, tracks);
Pair<FilteredCollisions, FilteredTracks, FilteredTracks, MixedBinning> pairs{binningOnVtxAndMult, cfgMixEventNumMin, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip
for (auto it = pairs.begin(); it != pairs.end(); it++) {
auto& [collision1, tracks1, collision2, tracks2] = *it;
if (!collision1.sel8() || !collision2.sel8())
continue;
if (cfgSelCollByNch && (tracks1.size() < cfgCutMultMin || tracks1.size() >= cfgCutMultMax))
continue;
if (cfgSelCollByNch && (tracks2.size() < cfgCutMultMin || tracks2.size() >= cfgCutMultMax))
continue;
float cent1 = -1;
float cent2 = -1;
if (!cfgCentTableUnavailable) {
cent1 = getCentrality(collision1);
cent2 = getCentrality(collision2);
}
if (cfgUseAdditionalEventCut && !eventSelected(collision1, tracks1.size(), cent1, false))
continue;
if (cfgUseAdditionalEventCut && !eventSelected(collision2, tracks2.size(), cent2, false))
continue;
if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent1 < cfgCutCentMin || cent1 >= cfgCutCentMax))
continue;
if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent2 < cfgCutCentMin || cent2 >= cfgCutCentMax))
continue;
registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin
auto bc = collision1.bc_as<aod::BCsWithTimestamps>();
loadEfficiency(bc.timestamp());
float eventWeight = 1.0f;
if (cfgUseEventWeights) {
eventWeight = 1.0f / it.currentWindowNeighbours();
}
fillCorrelations<CorrelationContainer::kCFStepReconstructed>(tracks1, tracks2, collision1.posZ(), MixedEvent, getMagneticField(bc.timestamp()), cent1, eventWeight);
}
}
PROCESS_SWITCH(PidDiHadron, processMixed, "Process mixed events", true);
template <typename TTrack>
int getNsigmaPID(TTrack track)
{
// Computing Nsigma arrays for pion, kaon, and protons
std::array<float, 3> nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()};
std::array<float, 3> nSigmaTOF = {track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()};
std::array<float, 3> nSigmaITS = {itsResponse.nSigmaITS<o2::track::PID::Pion>(track), itsResponse.nSigmaITS<o2::track::PID::Kaon>(track), itsResponse.nSigmaITS<o2::track::PID::Proton>(track)};
int pid = -1;
std::array<float, 3> nSigmaToUse = cfgPIDUseITSPID ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS
std::vector<double> detectorNsigmaCut = cfgPIDUseITSPID ? itsNsigmaCut : tpcNsigmaCut; // Choose which nSigma to use: TPC or ITS
bool isPion, isKaon, isProton;
bool isDetectedPion = nSigmaToUse[0] < detectorNsigmaCut[0] && nSigmaToUse[0] > detectorNsigmaCut[0 + 3];
bool isDetectedKaon = nSigmaToUse[1] < detectorNsigmaCut[1] && nSigmaToUse[1] > detectorNsigmaCut[1 + 3];
bool isDetectedProton = nSigmaToUse[2] < detectorNsigmaCut[2] && nSigmaToUse[2] > detectorNsigmaCut[2 + 3];
bool isTofPion = nSigmaTOF[0] < tofNsigmaCut[0] && nSigmaTOF[0] > tofNsigmaCut[0 + 3];
bool isTofKaon = nSigmaTOF[1] < tofNsigmaCut[1] && nSigmaTOF[1] > tofNsigmaCut[1 + 3];
bool isTofProton = nSigmaTOF[2] < tofNsigmaCut[2] && nSigmaTOF[2] > tofNsigmaCut[2 + 3];
if (track.pt() > cfgPIDTofPtCut && !track.hasTOF()) {
return 0;
} else if (track.pt() > cfgPIDTofPtCut && track.hasTOF()) {
isPion = isTofPion && isDetectedPion;
isKaon = isTofKaon && isDetectedKaon;
isProton = isTofProton && isDetectedProton;
} else {
isPion = isDetectedPion;
isKaon = isDetectedKaon;
isProton = isDetectedProton;
}
if ((isPion && isKaon) || (isPion && isProton) || (isKaon && isProton)) {
return 0; // more than one particle satisfy the criteria
}
if (isPion) {
pid = PIONS;
} else if (isKaon) {
pid = KAONS;
} else if (isProton) {
pid = PROTONS;
} else {
return 0; // no particle satisfies the criteria
}
return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<PidDiHadron>(cfgc),
};
}