-
Notifications
You must be signed in to change notification settings - Fork 652
Expand file tree
/
Copy pathmultiplicityPt.cxx
More file actions
1215 lines (1013 loc) · 48.2 KB
/
multiplicityPt.cxx
File metadata and controls
1215 lines (1013 loc) · 48.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
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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.
/// \author Dushmanta Sahu (dushmanta.sahu@cern.ch)
/// \file multiplicityPt.cxx
/// \brief Analysis to do PID with MC
#include "PWGLF/DataModel/LFParticleIdentification.h"
#include "PWGLF/DataModel/mcCentrality.h" // For McCentFT0Ms
#include "PWGLF/DataModel/spectraTOF.h"
#include "PWGLF/Utils/inelGt.h"
#include "Common/Core/RecoDecay.h"
#include "Common/Core/TrackSelection.h"
#include "Common/Core/TrackSelectionDefaults.h"
#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/McCollisionExtra.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/PIDResponseTOF.h"
#include "Common/DataModel/PIDResponseTPC.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "CCDB/BasicCCDBManager.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/Logger.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Framework/StaticFor.h"
#include "Framework/runDataProcessing.h"
#include "ReconstructionDataFormats/Track.h"
#include "TPDGCode.h"
#include <TF1.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TRandom.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric> // For std::accumulate
#include <set>
#include <string>
#include <vector>
using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::constants::math;
using namespace constants::physics;
using BCsRun3 = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels,
aod::Run3MatchedToBCSparse>;
struct MultiplicityPt {
// Service
Service<o2::framework::O2DatabasePDG> pdg;
Service<ccdb::BasicCCDBManager> ccdb;
static constexpr int CentBinMax = 100;
static constexpr int MultBinMax = 200;
static constexpr int RecMultBinMax = 100;
static constexpr int DebugCountMax = 20;
static constexpr int CentMultClasses = 10;
enum INELCutSelection : int {
INEL = 0,
INELgt0 = 1,
INELgt1 = 2
};
Configurable<bool> isRun3{"isRun3", true, "is Run3 dataset"};
Configurable<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"};
Configurable<int> cfgINELCut{"cfgINELCut", 0, "INEL event selection: 0 no sel, 1 INEL>0, 2 INEL>1"};
Configurable<bool> askForCustomTVX{"askForCustomTVX", false, "Ask for custom TVX rather than sel8"};
Configurable<bool> removeITSROFrameBorder{"removeITSROFrameBorder", false, "Remove ITS Read-Out Frame border"};
Configurable<bool> removeNoSameBunchPileup{"removeNoSameBunchPileup", false, "Remove no same bunch pileup"};
Configurable<bool> requireIsGoodZvtxFT0vsPV{"requireIsGoodZvtxFT0vsPV", false, "Require good Z vertex FT0 vs PV"};
Configurable<bool> requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "Require vertex ITSTPC"};
Configurable<bool> removeNoTimeFrameBorder{"removeNoTimeFrameBorder", false, "Remove no time frame border"};
Configurable<float> cfgCutEtaMax{"cfgCutEtaMax", 0.8f, "Max eta range for tracks"};
Configurable<float> cfgCutEtaMin{"cfgCutEtaMin", -0.8f, "Min eta range for tracks"};
Configurable<float> cfgCutY{"cfgCutY", 0.5f, "Y range for tracks"};
Configurable<float> cfgCutNsigma{"cfgCutNsigma", 3.0f, "nsigma cut range for tracks"};
Configurable<int> lastRequiredTrdCluster{"lastRequiredTrdCluster", -1, "Last cluster to require in TRD"};
Configurable<bool> requireTrdOnly{"requireTrdOnly", false, "Require only tracks from TRD"};
Configurable<bool> requireNoTrd{"requireNoTrd", false, "Require tracks without TRD"};
// Analysis switches
Configurable<bool> enableDCAHistograms{"enableDCAHistograms", false, "Enable DCA histograms"};
Configurable<bool> enablePIDHistograms{"enablePIDHistograms", true, "Enable PID histograms"};
Configurable<bool> useCustomTrackCuts{"useCustomTrackCuts", true, "Flag to use custom track cuts"};
Configurable<int> itsPattern{"itsPattern", 0, "0 = Run3ITSibAny, 1 = Run3ITSallAny, 2 = Run3ITSall7Layers, 3 = Run3ITSibTwo"};
Configurable<bool> requireITS{"requireITS", true, "Additional cut on the ITS requirement"};
Configurable<bool> requireTPC{"requireTPC", true, "Additional cut on the TPC requirement"};
Configurable<bool> requireGoldenChi2{"requireGoldenChi2", true, "Additional cut on the GoldenChi2"};
Configurable<float> minNCrossedRowsTPC{"minNCrossedRowsTPC", 70.f, "Additional cut on the minimum number of crossed rows in the TPC"};
Configurable<float> minNCrossedRowsOverFindableClustersTPC{"minNCrossedRowsOverFindableClustersTPC", 0.8f, "Additional cut on the minimum value of the ratio between crossed rows and findable clusters in the TPC"};
Configurable<float> maxChi2PerClusterTPC{"maxChi2PerClusterTPC", 4.f, "Additional cut on the maximum value of the chi2 per cluster in the TPC"};
Configurable<float> minChi2PerClusterTPC{"minChi2PerClusterTPC", 0.5f, "Additional cut on the minimum value of the chi2 per cluster in the TPC"};
Configurable<float> maxChi2PerClusterITS{"maxChi2PerClusterITS", 36.f, "Additional cut on the maximum value of the chi2 per cluster in the ITS"};
Configurable<float> maxDcaXYFactor{"maxDcaXYFactor", 1.f, "Additional cut on the maximum value of the DCA xy (multiplicative factor)"};
Configurable<float> maxDcaZ{"maxDcaZ", 0.1f, "Additional cut on the maximum value of the DCA z"};
Configurable<float> minTPCNClsFound{"minTPCNClsFound", 70.0f, "min number of found TPC clusters"};
Configurable<float> minTPCNClsPID{"minTPCNClsPID", 130.0f, "min number of PID TPC clusters"};
Configurable<bool> nClTPCFoundCut{"nClTPCFoundCut", false, "Apply TPC found clusters cut"};
Configurable<bool> nClTPCPIDCut{"nClTPCPIDCut", true, "Apply TPC clusters for PID cut"};
// Phi cut parameters
Configurable<bool> applyPhiCut{"applyPhiCut", false, "Apply phi sector cut to remove problematic TPC regions"};
Configurable<float> pTthresholdPhiCut{"pTthresholdPhiCut", 2.0f, "pT threshold above which to apply phi cut"};
Configurable<double> phiCutLowParam1{"phiCutLowParam1", 0.119297, "First parameter for low phi cut"};
Configurable<double> phiCutLowParam2{"phiCutLowParam2", 0.000379693, "Second parameter for low phi cut"};
Configurable<double> phiCutHighParam1{"phiCutHighParam1", 0.16685, "First parameter for high phi cut"};
Configurable<double> phiCutHighParam2{"phiCutHighParam2", 0.00981942, "Second parameter for high phi cut"};
// Basic track cuts
Configurable<float> cfgTrkEtaCut{"cfgTrkEtaCut", 0.8f, "Eta range for tracks"};
Configurable<float> cfgTrkLowPtCut{"cfgTrkLowPtCut", 0.15f, "Minimum constituent pT"};
// PID selection - make them configurable per particle
Configurable<float> cfgCutNsigmaPi{"cfgCutNsigmaPi", 3.0f, "nsigma cut for pions"};
Configurable<float> cfgCutNsigmaKa{"cfgCutNsigmaKa", 2.5f, "nsigma cut for kaons"};
Configurable<float> cfgCutNsigmaPr{"cfgCutNsigmaPr", 2.5f, "nsigma cut for protons"};
// Custom track cuts matching spectraTOF
TrackSelection customTrackCuts;
// TF1 pointers for phi cuts
TF1* fphiCutLow = nullptr;
TF1* fphiCutHigh = nullptr;
// Histogram Registry
HistogramRegistry ue;
// Data collisions (not used but kept for completeness)
using CollisionTableData = soa::Join<aod::Collisions, aod::EvSels, aod::McCentFT0Ms>;
// Track tables
using TrackTableData = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection,
aod::pidTPCPi, aod::pidTPCKa, aod::pidTPCPr>;
using TrackTableMC = soa::Join<aod::Tracks, aod::McTrackLabels, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection,
aod::pidTPCPi, aod::pidTPCKa, aod::pidTPCPr>;
// MC particles table
using ParticlesMC = aod::McParticles;
// MC collisions table
using McCollisions = aod::McCollisions;
// Reconstructed collisions (without joins that cause size mismatch)
using RecoCollisions = aod::Collisions;
// Preslice for MC particles
Preslice<aod::McParticles> perMCCol = aod::mcparticle::mcCollisionId;
enum ParticleSpecies : int {
kPion = 0,
kKaon = 1,
kProton = 2,
kNSpecies = 3
};
static constexpr int PDGPion = kPiPlus;
static constexpr int PDGKaon = kKPlus;
static constexpr int PDGProton = kProton;
// Get magnetic field from CCDB
int getMagneticField(uint64_t timestamp)
{
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();
}
// Get transformed phi for phi cut (with magnetic field)
float getTransformedPhi(const float phi, const int charge, const float magField) const
{
float transformedPhi = phi;
if (magField < 0) {
transformedPhi = o2::constants::math::TwoPI - transformedPhi;
}
if (charge < 0) {
transformedPhi = o2::constants::math::TwoPI - transformedPhi;
}
transformedPhi += o2::constants::math::PI / 18.0f;
transformedPhi = std::fmod(transformedPhi, o2::constants::math::PI / 9.0f);
return transformedPhi;
}
// Phi cut function (with magnetic field)
template <typename TrackType>
bool passedPhiCut(const TrackType& track, float magField) const
{
if (!applyPhiCut.value) {
return true;
}
if (track.pt() < pTthresholdPhiCut.value) {
return true;
}
float pt = track.pt();
float phi = track.phi();
int charge = track.sign();
if (magField < 0) {
phi = o2::constants::math::TwoPI - phi;
}
if (charge < 0) {
phi = o2::constants::math::TwoPI - phi;
}
phi += o2::constants::math::PI / 18.0f;
phi = std::fmod(phi, o2::constants::math::PI / 9.0f);
if (phi < fphiCutHigh->Eval(pt) && phi > fphiCutLow->Eval(pt)) {
return false;
}
return true;
}
template <typename ParticleContainer>
int countGeneratedChargedPrimaries(const ParticleContainer& particles, float etaMax, float ptMin) const
{
int count = 0;
for (const auto& particle : particles) {
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
if (!pdgParticle || pdgParticle->Charge() == 0.)
continue;
if (!particle.isPhysicalPrimary())
continue;
if (std::abs(particle.eta()) > etaMax)
continue;
if (particle.pt() < ptMin)
continue;
count++;
}
return count;
}
template <typename T>
bool passedNClTPCFoundCut(const T& trk) const
{
if (!nClTPCFoundCut.value)
return true;
return trk.tpcNClsFound() >= minTPCNClsFound.value;
}
template <typename T>
bool passedNClTPCPIDCut(const T& trk) const
{
if (!nClTPCPIDCut.value)
return true;
return trk.tpcNClsPID() >= minTPCNClsPID.value;
}
template <typename TrackType>
bool passesCutWoDCA(TrackType const& track) const
{
if (useCustomTrackCuts.value) {
for (int i = 0; i < static_cast<int>(TrackSelection::TrackCuts::kNCuts); i++) {
if (i == static_cast<int>(TrackSelection::TrackCuts::kDCAxy) ||
i == static_cast<int>(TrackSelection::TrackCuts::kDCAz)) {
continue;
}
if (!customTrackCuts.IsSelected(track, static_cast<TrackSelection::TrackCuts>(i))) {
return false;
}
}
return true;
}
return track.isGlobalTrackWoDCA();
}
template <typename TrackType>
bool passesDCAxyCut(TrackType const& track) const
{
if (useCustomTrackCuts.value) {
if (!passesCutWoDCA(track)) {
return false;
}
constexpr float DcaXYConst = 0.0105f;
constexpr float DcaXYPtScale = 0.0350f;
constexpr float DcaXYPtPower = 1.1f;
const float maxDcaXY = maxDcaXYFactor.value * (DcaXYConst + DcaXYPtScale / std::pow(track.pt(), DcaXYPtPower));
return std::abs(track.dcaXY()) <= maxDcaXY;
}
return track.isGlobalTrack();
}
template <typename TrackType>
bool passesTrackSelection(TrackType const& track, float magField = 0) const
{
if (track.eta() < cfgCutEtaMin.value || track.eta() > cfgCutEtaMax.value)
return false;
if (track.tpcChi2NCl() < minChi2PerClusterTPC.value || track.tpcChi2NCl() > maxChi2PerClusterTPC.value)
return false;
if (!passesCutWoDCA(track))
return false;
if (!passesDCAxyCut(track))
return false;
if (!passedNClTPCFoundCut(track))
return false;
if (!passedNClTPCPIDCut(track))
return false;
// Add phi cut with magnetic field
if (!passedPhiCut(track, magField))
return false;
return true;
}
template <int species, typename TrackType>
bool passesPIDSelection(TrackType const& track) const
{
float nsigmaTPC = 0.f;
if constexpr (species == kPion) {
nsigmaTPC = track.tpcNSigmaPi();
} else if constexpr (species == kKaon) {
nsigmaTPC = track.tpcNSigmaKa();
} else if constexpr (species == kProton) {
nsigmaTPC = track.tpcNSigmaPr();
}
float cutValue = cfgCutNsigma.value;
if constexpr (species == kPion)
cutValue = cfgCutNsigmaPi.value;
if constexpr (species == kKaon)
cutValue = cfgCutNsigmaKa.value;
if constexpr (species == kProton)
cutValue = cfgCutNsigmaPr.value;
return (std::abs(nsigmaTPC) < cutValue);
}
template <typename TrackType>
int getBestPIDHypothesis(TrackType const& track) const
{
float nsigmaPi = std::abs(track.tpcNSigmaPi());
float nsigmaKa = std::abs(track.tpcNSigmaKa());
float nsigmaPr = std::abs(track.tpcNSigmaPr());
float minNSigma = 999.0f;
int bestSpecies = -1;
if (nsigmaPi < cfgCutNsigmaPi.value && nsigmaPi < minNSigma) {
minNSigma = nsigmaPi;
bestSpecies = kPion;
}
if (nsigmaKa < cfgCutNsigmaKa.value && nsigmaKa < minNSigma) {
minNSigma = nsigmaKa;
bestSpecies = kKaon;
}
if (nsigmaPr < cfgCutNsigmaPr.value && nsigmaPr < minNSigma) {
minNSigma = nsigmaPr;
bestSpecies = kProton;
}
return bestSpecies;
}
template <typename ParticleType>
bool isGoodPrimary(ParticleType const& particle) const
{
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
if (!pdgParticle || pdgParticle->Charge() == 0.)
return false;
if (!particle.isPhysicalPrimary())
return false;
if (std::abs(particle.eta()) >= cfgCutEtaMax.value)
return false;
if (particle.pt() < cfgTrkLowPtCut.value)
return false;
return true;
}
void processData(CollisionTableData::iterator const& collision,
TrackTableData const& tracks,
BCsRun3 const& bcs);
PROCESS_SWITCH(MultiplicityPt, processData, "process data", false);
void processMC(TrackTableMC const& tracks,
aod::McParticles const& particles,
aod::McCollisions const& mcCollisions,
RecoCollisions const& collisions,
aod::McCollisionLabels const& labels,
aod::McCentFT0Ms const& centTable,
BCsRun3 const& bcs);
PROCESS_SWITCH(MultiplicityPt, processMC, "process MC", true);
void init(InitContext const&);
void endOfStream(EndOfStreamContext& /*eos*/)
{
LOG(info) << "\n=== END OF STREAM: Writing histograms to output ===";
auto hGenMult = ue.get<TH2>(HIST("MC/EventLoss/GenMultVsCent"));
if (hGenMult) {
LOG(info) << "GenMultVsCent: Entries=" << hGenMult->GetEntries()
<< ", Integral=" << hGenMult->Integral();
}
LOG(info) << "=== END OF STREAM COMPLETE ===";
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{adaptAnalysisTask<MultiplicityPt>(cfgc)};
}
void MultiplicityPt::init(InitContext const&)
{
LOG(info) << "==================================================";
LOG(info) << "Initializing MultiplicityPt task with full centrality diagnostics";
LOG(info) << "==================================================";
// Initialize phi cut functions
if (applyPhiCut.value) {
fphiCutLow = new TF1("StandardPhiCutLow",
Form("%f/x/x+pi/18.0-%f",
phiCutLowParam1.value, phiCutLowParam2.value),
0, 50);
fphiCutHigh = new TF1("StandardPhiCutHigh",
Form("%f/x+pi/18.0+%f",
phiCutHighParam1.value, phiCutHighParam2.value),
0, 50);
LOGF(info, "=== Phi Cut Parameters ===");
LOGF(info, "Low cut: %.6f/x² + pi/18 - %.6f",
phiCutLowParam1.value, phiCutLowParam2.value);
LOGF(info, "High cut: %.6f/x + pi/18 + %.6f",
phiCutHighParam1.value, phiCutHighParam2.value);
LOGF(info, "Applied for pT > %.1f GeV/c", pTthresholdPhiCut.value);
}
if (useCustomTrackCuts.value) {
LOG(info) << "Using custom track cuts matching spectraTOF approach";
customTrackCuts = getGlobalTrackSelectionRun3ITSMatch(itsPattern.value);
customTrackCuts.SetRequireITSRefit(requireITS.value);
customTrackCuts.SetRequireTPCRefit(requireTPC.value);
customTrackCuts.SetRequireGoldenChi2(requireGoldenChi2.value);
customTrackCuts.SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC.value);
customTrackCuts.SetMaxChi2PerClusterITS(maxChi2PerClusterITS.value);
customTrackCuts.SetMinNCrossedRowsTPC(minNCrossedRowsTPC.value);
customTrackCuts.SetMinNClustersTPC(minTPCNClsFound.value);
customTrackCuts.SetMinNCrossedRowsOverFindableClustersTPC(minNCrossedRowsOverFindableClustersTPC.value);
customTrackCuts.SetMaxDcaXYPtDep([](float /*pt*/) { return 10000.f; });
customTrackCuts.SetMaxDcaZ(maxDcaZ.value);
customTrackCuts.print();
}
// Axis definitions
ConfigurableAxis ptBinning{"ptBinning", {VARIABLE_WIDTH, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0}, "pT bin limits"};
AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"};
std::vector<double> centBinningStd = {0., 1., 5., 10., 15., 20., 30., 40., 50., 60., 70., 80., 90., 100.};
// Fine centrality binning for diagnostics (100 bins, guaranteed increasing)
std::vector<double> centBinningFine;
for (int i = 0; i <= CentBinMax; i++) {
centBinningFine.push_back(static_cast<double>(i));
}
AxisSpec centAxis = {centBinningStd, "FT0M Centrality (%)"};
AxisSpec centFineAxis = {centBinningFine, "FT0M Centrality (%)"};
// Multiplicity axes - properly defined
std::vector<double> multBins;
for (int i = 0; i <= MultBinMax; i++) {
multBins.push_back(static_cast<double>(i));
}
AxisSpec multAxis = {multBins, "N_{ch}^{gen} (|#eta|<0.8)"};
// Reconstructed multiplicity axis - properly defined with explicit bin edges
std::vector<double> recoMultBins;
for (int i = 0; i <= RecMultBinMax; i++) {
recoMultBins.push_back(static_cast<double>(i));
}
AxisSpec recoMultAxis = {recoMultBins, "N_{ch}^{reco}"};
// Centrality diagnostic histograms - USE FINE BINNING
ue.add("Centrality/hCentRaw", "Raw FT0M Centrality (no cuts);Centrality (%);Counts",
HistType::kTH1D, {centFineAxis});
ue.add("Centrality/hCentAfterVtx", "Centrality after vertex cut;Centrality (%);Counts",
HistType::kTH1D, {centFineAxis});
ue.add("Centrality/hCentAfterINEL", "Centrality after INEL cut;Centrality (%);Counts",
HistType::kTH1D, {centFineAxis});
ue.add("Centrality/hCentAfterAll", "Centrality after all cuts;Centrality (%);Counts",
HistType::kTH1D, {centFineAxis});
// 2D correlations - USE FINE BINNING FOR DIAGNOSTICS
ue.add("Centrality/hCentVsMult", "Centrality vs Generated Multiplicity;Centrality (%);N_{ch}^{gen}",
HistType::kTH2D, {centFineAxis, multAxis});
ue.add("Centrality/hMultVsCent", "Generated Multiplicity vs Centrality;N_{ch}^{gen};Centrality (%)",
HistType::kTH2D, {multAxis, centFineAxis});
ue.add("Centrality/hCentVsVz", "Centrality vs Vertex Z;Centrality (%);V_{z} (cm)",
HistType::kTH2D, {centFineAxis, {40, -20, 20}});
ue.add("Centrality/hRecoMultVsCent", "Reconstructed Track Multiplicity vs Centrality;Centrality (%);N_{tracks}^{reco}",
HistType::kTH2D, {centFineAxis, recoMultAxis});
ue.add("Centrality/hGenMultPerCent", "Generated Multiplicity Distribution per Centrality Bin;Centrality (%);<N_{ch}^{gen}>",
HistType::kTH2D, {centFineAxis, multAxis});
// Vertex resolution vs centrality
ue.add("Centrality/hVertexResVsCent", "Vertex Resolution vs Centrality;Centrality (%);V_{z} resolution (cm)",
HistType::kTH2D, {centFineAxis, {100, -1, 1}});
// INEL class distributions
ue.add("INEL/hINELClass", "INEL Class for MC Collisions;INEL Class;Counts",
HistType::kTH1D, {{3, 0.5, 3.5}});
auto hINEL = ue.get<TH1>(HIST("INEL/hINELClass"));
hINEL->GetXaxis()->SetBinLabel(1, "INEL0");
hINEL->GetXaxis()->SetBinLabel(2, "INEL>0");
hINEL->GetXaxis()->SetBinLabel(3, "INEL>1");
ue.add("INEL/hINELVsCent", "INEL Class vs Centrality;Centrality (%);INEL Class",
HistType::kTH2D, {centFineAxis, {3, 0.5, 3.5}});
// Cut flow
ue.add("CutFlow/hCutStats", "Cut Statistics;Cut Stage;Counts",
HistType::kTH1D, {{6, 0.5, 6.5}});
auto hCut = ue.get<TH1>(HIST("CutFlow/hCutStats"));
hCut->GetXaxis()->SetBinLabel(1, "All reco events");
hCut->GetXaxis()->SetBinLabel(2, "Has MC match");
hCut->GetXaxis()->SetBinLabel(3, "Has centrality");
hCut->GetXaxis()->SetBinLabel(4, "Pass vertex");
hCut->GetXaxis()->SetBinLabel(5, "Pass INEL");
hCut->GetXaxis()->SetBinLabel(6, "Selected");
ue.add("CutFlow/hCentPerCut", "Centrality Distribution at Each Cut;Cut Stage;Centrality (%)",
HistType::kTH2D, {{6, 0.5, 6.5}, centFineAxis});
ue.add("MC/GenRecoCollisions", "Generated and Reconstructed MC Collisions",
HistType::kTH1D, {{10, 0.5, 10.5}});
auto hColl = ue.get<TH1>(HIST("MC/GenRecoCollisions"));
hColl->GetXaxis()->SetBinLabel(1, "Collisions generated");
hColl->GetXaxis()->SetBinLabel(2, "Collisions reconstructed");
hColl->GetXaxis()->SetBinLabel(3, "INEL>0");
hColl->GetXaxis()->SetBinLabel(4, "INEL>1");
ue.add("hEventLossBreakdown", "Event loss breakdown",
HistType::kTH1D, {{4, 0.5, 4.5}});
auto hLoss = ue.get<TH1>(HIST("hEventLossBreakdown"));
hLoss->GetXaxis()->SetBinLabel(1, "Physics selected");
hLoss->GetXaxis()->SetBinLabel(2, "Reconstructed");
hLoss->GetXaxis()->SetBinLabel(3, "Selected");
hLoss->GetXaxis()->SetBinLabel(4, "Final efficiency");
// Multiplicity histograms
ue.add("MC/EventLoss/NchGenerated", "Generated charged multiplicity;N_{ch}^{gen} (|#eta|<0.8);Counts",
HistType::kTH1D, {{200, 0, 200}});
ue.add("MC/EventLoss/NchGenerated_PhysicsSelected", "Generated charged multiplicity (physics selected);N_{ch}^{gen} (|#eta|<0.8);Counts",
HistType::kTH1D, {{200, 0, 200}});
ue.add("MC/EventLoss/NchGenerated_Reconstructed", "Generated charged multiplicity (reconstructed);N_{ch}^{gen} (|#eta|<0.8);Counts",
HistType::kTH1D, {{200, 0, 200}});
// pT vs Multiplicity
ue.add("MC/GenPtVsNch", "Generated pT vs Multiplicity;#it{p}_{T} (GeV/#it{c});N_{ch}^{gen}",
HistType::kTH2D, {ptAxis, {200, 0, 200}});
ue.add("MC/GenPtVsNch_PhysicsSelected", "Generated pT vs Multiplicity (physics selected);#it{p}_{T} (GeV/#it{c});N_{ch}^{gen}",
HistType::kTH2D, {ptAxis, {200, 0, 200}});
// Centrality vs Multiplicity correlations - USE STANDARD BINNING FOR THESE
ue.add("MC/EventLoss/GenMultVsCent", "Generated charged particles vs FT0M centrality;FT0M Centrality (%);N_{ch}^{gen} (|#eta|<0.8)",
HistType::kTH2D, {centAxis, multAxis});
ue.add("MC/EventLoss/GenMultVsCent_Selected", "Generated vs FT0M centrality (selected events);FT0M Centrality (%);N_{ch}^{gen}",
HistType::kTH2D, {centAxis, multAxis});
ue.add("MC/EventLoss/GenMultVsCent_Rejected", "Generated vs FT0M centrality (rejected events);FT0M Centrality (%);N_{ch}^{gen}",
HistType::kTH2D, {centAxis, multAxis});
// TPC cluster histograms
ue.add("hNclFoundTPC", "Number of TPC found clusters",
HistType::kTH1D, {{200, 0, 200, "N_{cl, found}"}});
ue.add("hNclPIDTPC", "Number of TPC PID clusters",
HistType::kTH1D, {{200, 0, 200, "N_{cl, PID}"}});
ue.add("hNclFoundTPCvsPt", "TPC found clusters vs pT;#it{p}_{T} (GeV/#it{c});N_{cl,found}",
HistType::kTH2D, {ptAxis, {200, 0., 200.}});
ue.add("hNclPIDTPCvsPt", "TPC PID clusters vs pT;#it{p}_{T} (GeV/#it{c});N_{cl,PID}",
HistType::kTH2D, {ptAxis, {200, 0., 200.}});
// Inclusive histograms
ue.add("Inclusive/hPtPrimGenAll", "All generated primaries (no cuts);#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtPrimBadVertex", "Generated primaries (bad vertex);#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtPrimGen", "Generated primaries (after physics selection);#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtPrimRecoEv", "Generated primaries (reco events);#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtPrimGoodEv", "Generated primaries (good events);#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtNumEff", "Tracking efficiency numerator;#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtDenEff", "Tracking efficiency denominator;#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtAllReco", "All reconstructed tracks;#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtPrimReco", "Reconstructed primaries;#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtSecReco", "Reconstructed secondaries;#it{p}_{T} (GeV/#it{c});Counts",
HistType::kTH1D, {ptAxis});
ue.add("Inclusive/hPtMeasuredVsCent", "All measured tracks (PID) vs centrality;#it{p}_{T} (GeV/#it{c});FT0M Centrality (%)",
HistType::kTH2D, {ptAxis, centAxis});
// Phi cut monitoring histograms
if (applyPhiCut.value) {
ue.add("PhiCut/hPtVsPhiPrimeBefore", "pT vs φ' before cut;p_{T} (GeV/c);φ'",
HistType::kTH2F, {{100, 0, 10}, {100, 0, 0.4}});
ue.add("PhiCut/hPtVsPhiPrimeAfter", "pT vs φ' after cut;p_{T} (GeV/c);φ'",
HistType::kTH2F, {{100, 0, 10}, {100, 0, 0.4}});
ue.add("PhiCut/hRejectionRate", "Track rejection rate by phi cut;p_{T} (GeV/c);Rejection Rate",
HistType::kTProfile, {{100, 0, 10}});
}
// Particle-specific histograms
const std::array<std::string, kNSpecies> particleNames = {"Pion", "Kaon", "Proton"};
const std::array<std::string, kNSpecies> particleSymbols = {"#pi^{#pm}", "K^{#pm}", "p+#bar{p}"};
for (int iSpecies = 0; iSpecies < kNSpecies; ++iSpecies) {
const auto& name = particleNames[iSpecies];
const auto& symbol = particleSymbols[iSpecies];
ue.add(Form("%s/hPtPrimGenAll", name.c_str()),
Form("All generated %s (no cuts);#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtPrimBadVertex", name.c_str()),
Form("Generated %s (bad vertex);#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtPrimGen", name.c_str()),
Form("Generated %s (after physics selection);#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtPrimRecoEv", name.c_str()),
Form("Generated %s (reco events);#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtPrimGoodEv", name.c_str()),
Form("Generated %s (good events);#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtNumEff", name.c_str()),
Form("%s tracking efficiency numerator;#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtDenEff", name.c_str()),
Form("%s tracking efficiency denominator;#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtAllReco", name.c_str()),
Form("All reconstructed %s;#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtPrimReco", name.c_str()),
Form("Reconstructed primary %s;#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtSecReco", name.c_str()),
Form("Reconstructed secondary %s;#it{p}_{T} (GeV/#it{c});Counts", symbol.c_str()),
HistType::kTH1D, {ptAxis});
ue.add(Form("%s/hPtMeasuredVsCent", name.c_str()),
Form("Measured %s (PID) vs centrality;#it{p}_{T} (GeV/#it{c});FT0M Centrality (%%)", symbol.c_str()),
HistType::kTH2D, {ptAxis, centAxis});
if (enablePIDHistograms) {
ue.add(Form("%s/hNsigmaTPC", name.c_str()),
Form("TPC n#sigma %s;#it{p}_{T} (GeV/#it{c});n#sigma_{TPC}", symbol.c_str()),
HistType::kTH2D, {ptAxis, {200, -10, 10}});
}
}
// Event selection histogram
constexpr int NEvSelBins = 20;
constexpr float EvSelMin = 0.5f;
constexpr float EvSelMax = 20.5f;
ue.add("evsel", "Event selection", HistType::kTH1D, {{NEvSelBins, EvSelMin, EvSelMax}});
auto h = ue.get<TH1>(HIST("evsel"));
h->GetXaxis()->SetBinLabel(1, "Events read");
h->GetXaxis()->SetBinLabel(4, "Trigger passed");
h->GetXaxis()->SetBinLabel(5, "NoITSROFrameBorder");
h->GetXaxis()->SetBinLabel(6, "NoSameBunchPileup");
h->GetXaxis()->SetBinLabel(7, "IsGoodZvtxFT0vsPV");
h->GetXaxis()->SetBinLabel(8, "IsVertexITSTPC");
h->GetXaxis()->SetBinLabel(9, "NoTimeFrameBorder");
h->GetXaxis()->SetBinLabel(13, "posZ passed");
// Basic tracking histograms
ue.add("hEta", "Track eta;#eta;Counts", HistType::kTH1D, {{20, -0.8, 0.8}});
ue.add("hPhi", "Track phi;#varphi (rad);Counts", HistType::kTH1D, {{64, 0, TwoPI}});
ue.add("hvtxZ", "Vertex Z (data);Vertex Z (cm);Events", HistType::kTH1F, {{40, -20.0, 20.0}});
ue.add("hvtxZmc", "MC vertex Z;Vertex Z (cm);Events", HistType::kTH1F, {{40, -20.0, 20.0}});
LOG(info) << "=== Initialized MultiplicityPt task with full centrality diagnostics ===";
LOG(info) << "Standard centrality binning: " << centBinningStd.size() - 1 << " bins (0-100%)";
LOG(info) << "Fine centrality binning: " << centBinningFine.size() - 1 << " bins (0-100%)";
if (applyPhiCut.value) {
LOG(info) << "Phi cut ENABLED for pT > " << pTthresholdPhiCut.value << " GeV/c";
}
}
void MultiplicityPt::processData(CollisionTableData::iterator const& /*collision*/,
TrackTableData const& /*tracks*/,
BCsRun3 const& /*bcs*/)
{
// Intentionally empty - data processing disabled
}
void MultiplicityPt::processMC(TrackTableMC const& tracks,
aod::McParticles const& particles,
aod::McCollisions const& mcCollisions,
RecoCollisions const& collisions,
aod::McCollisionLabels const& labels,
aod::McCentFT0Ms const& centTable,
BCsRun3 const& /*bcs*/)
{
LOG(info) << "\n=== processMC START ===";
LOG(info) << "Total MC collisions (generated): " << mcCollisions.size();
LOG(info) << "Total reconstructed collisions: " << collisions.size();
LOG(info) << "Total collision labels: " << labels.size();
LOG(info) << "Total centrality entries: " << centTable.size();
LOG(info) << "\n=== CENTRALITY DEBUG - RAW DATA ===";
LOG(info) << "First 20 centrality values from centTable:";
int debugCount = 0;
float minCent = 999.0f, maxCent = -999.0f;
std::map<int, int> centDistribution;
for (const auto& cent : centTable) {
float c = cent.centFT0M();
if (debugCount < DebugCountMax) {
LOG(info) << " Cent entry " << debugCount << ": " << c;
}
minCent = std::min(minCent, c);
maxCent = std::max(maxCent, c);
int bin10 = static_cast<int>(c / 10) * 10;
centDistribution[bin10]++;
debugCount++;
}
LOG(info) << "Centrality range: [" << minCent << ", " << maxCent << "]";
LOG(info) << "Distribution by 10% bins:";
for (int i = 0; i < CentBinMax; i += 10) {
LOG(info) << " " << i << "-" << i + 10 << "%: " << centDistribution[i];
}
// Check if centrality is inverted (0 = peripheral, 100 = central)
// If minCent is near 0 and maxCent near 100, check correlation with multiplicity
LOG(info) << "Checking if centrality might be inverted...";
LOG(info) << "Will check correlation with multiplicity in the next step.";
std::map<int64_t, int> mcCollisionToNch;
std::map<int64_t, float> mcCollisionVz;
std::set<int64_t> physicsSelectedMCCollisions;
std::map<int64_t, int> mcCollisionToINELClass; // 0=INEL0, 1=INEL>0, 2=INEL>1
ue.fill(HIST("MC/GenRecoCollisions"), 1.f, mcCollisions.size());
ue.fill(HIST("MC/GenRecoCollisions"), 2.f, collisions.size());
LOG(info) << "\n--- FIRST PASS: Building MC collision maps ---";
int mcWithParticles = 0;
int mcINELgt0 = 0, mcINELgt1 = 0;
for (const auto& mcCollision : mcCollisions) {
int64_t mcCollId = mcCollision.globalIndex();
auto particlesInCollision = particles.sliceBy(perMCCol, mcCollId);
int nGenCharged = countGeneratedChargedPrimaries(particlesInCollision, cfgCutEtaMax.value, cfgTrkLowPtCut.value);
mcCollisionToNch[mcCollId] = nGenCharged;
mcCollisionVz[mcCollId] = mcCollision.posZ();
// Determine INEL class
bool inel0 = o2::pwglf::isINELgt0mc(particlesInCollision, pdg);
bool inel1 = o2::pwglf::isINELgt1mc(particlesInCollision, pdg);
int inelClass = 0;
if (inel1)
inelClass = 2;
else if (inel0)
inelClass = 1;
mcCollisionToINELClass[mcCollId] = inelClass;
ue.fill(HIST("INEL/hINELClass"), inelClass);
if (inel0)
mcINELgt0++;
if (inel1)
mcINELgt1++;
if (nGenCharged > 0)
mcWithParticles++;
ue.fill(HIST("MC/EventLoss/NchGenerated"), nGenCharged);
// Physics selection based on vertex and INEL cuts
bool physicsSelected = true;
if (std::abs(mcCollision.posZ()) > cfgCutVertex.value) {
physicsSelected = false;
}
// Apply INEL cut based on configuration
if (cfgINELCut.value == INELgt0 && !inel0) {
physicsSelected = false;
}
if (cfgINELCut.value == INELgt1 && !inel1) {
physicsSelected = false;
}
if (physicsSelected) {
physicsSelectedMCCollisions.insert(mcCollId);
ue.fill(HIST("MC/EventLoss/NchGenerated_PhysicsSelected"), nGenCharged);
if (inel0) {
ue.fill(HIST("MC/GenRecoCollisions"), 3.f);
}
if (inel1) {
ue.fill(HIST("MC/GenRecoCollisions"), 4.f);
}
}
}
LOG(info) << "\n--- FIRST PASS SUMMARY ---";
LOG(info) << "Total MC collisions processed: " << mcCollisions.size();
LOG(info) << "MC collisions with particles: " << mcWithParticles;
LOG(info) << "INEL0: " << (mcCollisions.size() - mcINELgt0);
LOG(info) << "INEL>0: " << mcINELgt0;
LOG(info) << "INEL>1: " << mcINELgt1;
LOG(info) << "Physics-selected MC collisions: " << physicsSelectedMCCollisions.size();
std::map<int64_t, int64_t> recoToMcMap;
std::map<int64_t, float> recoToCentMap;
size_t nCollisions = collisions.size();
// Associate labels with collisions by index
size_t iLabel = 0;
for (const auto& label : labels) {
if (iLabel < nCollisions) {
const auto& collision = collisions.iteratorAt(iLabel);
int64_t recoCollId = collision.globalIndex();
int64_t mcCollId = label.mcCollisionId();
recoToMcMap[recoCollId] = mcCollId;
}
iLabel++;
}
// Associate centrality with collisions by index
size_t iCent = 0;
for (const auto& cent : centTable) {
if (iCent < nCollisions) {
const auto& collision = collisions.iteratorAt(iCent);
int64_t recoCollId = collision.globalIndex();
float centValue = cent.centFT0M();
// Fill raw centrality histogram
ue.fill(HIST("Centrality/hCentRaw"), centValue);
recoToCentMap[recoCollId] = centValue;
}
iCent++;
}
LOG(info) << "\n--- MAP SIZES ---";
LOG(info) << "recoToMcMap size: " << recoToMcMap.size();
LOG(info) << "recoToCentMap size: " << recoToCentMap.size();
LOG(info) << "\n=== CENTRALITY VS MULTIPLICITY DEBUG ===";
// Create temporary vectors to check correlation
std::vector<std::pair<float, int>> centMultPairs;
for (const auto& collision : collisions) {
int64_t collId = collision.globalIndex();
auto mcIt = recoToMcMap.find(collId);
if (mcIt == recoToMcMap.end())
continue;
auto centIt = recoToCentMap.find(collId);
if (centIt == recoToCentMap.end())
continue;
auto nchIt = mcCollisionToNch.find(mcIt->second);
if (nchIt == mcCollisionToNch.end())
continue;
centMultPairs.push_back({centIt->second, nchIt->second});
}
// Sort by centrality
std::sort(centMultPairs.begin(), centMultPairs.end());
LOG(info) << "Correlation between centrality and multiplicity:";
LOG(info) << " If centrality is normal (0=central, 100=peripheral), multiplicity should decrease with centrality";
LOG(info) << " If inverted (0=peripheral, 100=central), multiplicity should increase with centrality";
// Print a few samples across the range
if (centMultPairs.size() > CentMultClasses) {
for (size_t i = 0; i < centMultPairs.size(); i += centMultPairs.size() / 10) {
LOG(info) << " Cent: " << centMultPairs[i].first
<< "%, Mult: " << centMultPairs[i].second;
}
}
//===========================================================================
// SECOND PASS: Process reconstructed collisions with detailed cut accounting
//===========================================================================
LOG(info) << "\n--- SECOND PASS: Processing reconstructed collisions ---";
std::set<int64_t> reconstructedMCCollisions;
std::set<int64_t> selectedMCCollisions;
int nRecoCollisions = 0;
int nSelectedEvents = 0;
int nRejectedEvents = 0;
int nNoMCMatch = 0;
int nNoCent = 0;
int nInvalidCent = 0;
// Cut counters
int nPassVertex = 0;
int nPassINEL = 0;
int nPassAll = 0;
// For mean calculations
std::vector<float> centAll, centVertex, centINEL, centSelected;
for (const auto& collision : collisions) {
nRecoCollisions++;
int64_t collId = collision.globalIndex();
// Fill cut flow
ue.fill(HIST("CutFlow/hCutStats"), 1);
// Get MC collision ID from labels map
auto mcIt = recoToMcMap.find(collId);
if (mcIt == recoToMcMap.end()) {
nNoMCMatch++;
continue;
}
ue.fill(HIST("CutFlow/hCutStats"), 2);
int64_t mcCollId = mcIt->second;
// Get generated multiplicity for this MC collision
auto nchIt = mcCollisionToNch.find(mcCollId);
if (nchIt == mcCollisionToNch.end()) {
continue;
}
int nGenCharged = nchIt->second;
// Get INEL class
auto inelIt = mcCollisionToINELClass.find(mcCollId);
int inelClass = (inelIt != mcCollisionToINELClass.end()) ? inelIt->second : 0;
// Get centrality from cent map
auto centIt = recoToCentMap.find(collId);
if (centIt == recoToCentMap.end()) {
nNoCent++;
continue;
}