forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHFFilterHelpers.h
More file actions
2962 lines (2673 loc) · 131 KB
/
HFFilterHelpers.h
File metadata and controls
2962 lines (2673 loc) · 131 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.
// O2 includes
/// \file HFFilterHelpers.h
/// \brief Header file with definition of variables, methods, and tables used in the HFFilter.cxx task
///
/// \author Fabrizio Grosa <fabrizio.grosa@cern.ch>, CERN
/// \author Marcel Lesch <marcel.lesch@tum.de>, TUM
/// \author Alexandre Bigot <alexandre.bigot@cern.ch>, Strasbourg University
/// \author Biao Zhang <biao.zhang@cern.ch>, CCNU
/// \author Federica Zanone <federica.zanone@cern.ch>, Heidelberg University
/// \author Antonio Palasciano <antonio.palasciano@cern.ch>, INFN Bari
#ifndef EVENTFILTERING_PWGHF_HFFILTERHELPERS_H_
#define EVENTFILTERING_PWGHF_HFFILTERHELPERS_H_
#include <algorithm>
#include <array>
#include <cmath>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "Math/GenVector/Boost.h"
#include "Math/Vector3D.h"
#include "Math/Vector4D.h"
#include "CCDB/CcdbApi.h"
#include "CCDB/BasicCCDBManager.h"
#include "CommonConstants/MathConstants.h"
#include "CommonConstants/PhysicsConstants.h"
#include "DataFormatsTPC/BetheBlochAleph.h"
#include "DCAFitter/DCAFitterN.h"
#include "DetectorsBase/Propagator.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/DataTypes.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/AnalysisHelpers.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Common/Core/RecoDecay.h"
#include "Common/Core/trackUtilities.h"
#include "PWGHF/Core/SelectorCuts.h"
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
#include "PWGHF/DataModel/CandidateSelectionTables.h"
#include "EventFiltering/filterTables.h"
namespace o2::aod
{
namespace hffilters
{
enum HfTriggers {
kHighPt2P = 0,
kHighPt3P,
kBeauty3P,
kBeauty4P,
kFemto2P,
kFemto3P,
kDoubleCharm2P,
kDoubleCharm3P,
kDoubleCharmMix,
kV0Charm2P,
kV0Charm3P,
kCharmBarToXiBach,
kSigmaCPPK,
kSigmaC0K0,
kPhotonCharm2P,
kPhotonCharm3P,
kSingleCharm2P,
kSingleCharm3P,
kSingleNonPromptCharm2P,
kSingleNonPromptCharm3P,
kCharmBarToXi2Bach,
kPrCharm2P,
kBtoJPsiKa,
kBtoJPsiKstar,
kBtoJPsiPhi,
kBtoJPsiPrKa,
kBtoJPsiPi,
kNtriggersHF
};
enum charmParticles {
kD0 = 0,
kDplus,
kDs,
kLc,
kXic,
kNCharmParticles
};
enum beautyParticles {
kBplus = 0,
kB0toDStar,
kBc,
kB0,
kBs,
kLb,
kXib,
kNBeautyParticles
};
enum beautyToJPsiParticles {
kBplusToJPsi = 0,
kB0ToJPsi,
kBsToJPsi,
kLbToJPsi,
kBcToJPsi,
kNBeautyParticlesToJPsi
};
enum bachelorTrackSelection {
kRejected = 0,
kSoftPion,
kForBeauty,
kSoftPionForBeauty,
kPionForCharmBaryon,
kKaonForCharmBaryon,
kProtonForCharmBaryon,
kSoftPionForSigmaC
};
enum PIDSpecies {
kEl = 0,
kPi,
kAntiPi,
kKa,
kAntiKa,
kPr,
kAntiPr,
kDe,
kAntiDe
};
enum trackSpecies {
kProtonForFemto,
kDeuteronForFemto
};
enum V0Species {
kPhoton = 0,
kK0S,
kLambda,
kAntiLambda,
kNV0
};
enum HfVtxStage : uint8_t {
Skimmed = 0,
BeautyVertex,
CharmHadPiSelected,
kNHfVtxStage
};
// Helper struct to pass V0 informations
struct V0Cand {
std::array<float, 3> mom;
std::array<float, 3> vtx;
std::array<float, 21> cov;
float etaPos;
float etaNeg;
float ptPos;
float ptNeg;
float pinTpcPos;
float pinTpcNeg;
float nClsFoundTpcPos;
float nClsFoundTpcNeg;
float nClsCrossedRowsTpcPos;
float nClsCrossedRowsTpcNeg;
float crossedRowsOverFindableClsTpcPos;
float crossedRowsOverFindableClsTpcNeg;
float signalTpcPos;
float signalTpcNeg;
float v0cosPA;
float dcav0topv;
float dcaV0daughters;
float dcapostopv;
float dcanegtopv;
float alpha;
float qtarm;
float v0radius;
float mK0Short;
float mLambda;
float mAntiLambda;
float nSigmaPrTpcPos;
float nSigmaPrTofPos;
float nSigmaPrTpcNeg;
float nSigmaPrTofNeg;
float nSigmaPiTpcPos;
float nSigmaPiTofPos;
float nSigmaPiTpcNeg;
float nSigmaPiTofNeg;
bool hasTofPos;
bool hasTofNeg;
};
// Helper struct to pass Cascade informations
struct CascCand {
std::array<float, 3> mom;
std::array<float, 3> vtx;
std::array<float, 21> cov;
V0Cand v0;
float ptBach;
float etaBach;
float pinTpcBach;
float nClsFoundTpcBach;
float nClsCrossedRowsTpcBach;
float crossedRowsOverFindableClsTpcBach;
float signalTpcBach;
float pt;
float casccosPA;
float cascradius;
float dcaXYCascToPV;
float dcacascdaughters;
float mXi;
float mOmega;
float nSigmaPiTpcBach;
float nSigmaPiTofBach;
bool hasTofBach;
int sign;
};
static const std::array<std::string, kNCharmParticles> charmParticleNames{"D0", "Dplus", "Ds", "Lc", "Xic"};
static const int nTotBeautyParts = static_cast<int>(kNBeautyParticles) + static_cast<int>(kNBeautyParticlesToJPsi);
static const std::array<std::string, nTotBeautyParts> beautyParticleNames{"Bplus", "B0toDStar", "Bc", "B0", "Bs", "Lb", "Xib", "BplusToJPsi", "B0ToJPsi", "BsToJPsi", "LbToJPsi", "BcToJPsi"};
static const std::array<int, kNCharmParticles> pdgCodesCharm{421, 411, 431, 4122, 4232};
static const std::array<std::string, 2> eventTitles = {"all", "rejected"};
static const std::vector<std::string> hfTriggerNames{filtering::HfHighPt2P::columnLabel(), filtering::HfHighPt3P::columnLabel(), filtering::HfBeauty3P::columnLabel(), filtering::HfBeauty4P::columnLabel(), filtering::HfFemto2P::columnLabel(), filtering::HfFemto3P::columnLabel(), filtering::HfDoubleCharm2P::columnLabel(), filtering::HfDoubleCharm3P::columnLabel(), filtering::HfDoubleCharmMix::columnLabel(), filtering::HfV0Charm2P::columnLabel(), filtering::HfV0Charm3P::columnLabel(), filtering::HfCharmBarToXiBach::columnLabel(), filtering::HfSigmaCPPK::columnLabel(), filtering::HfSigmaC0K0::columnLabel(), filtering::HfPhotonCharm2P::columnLabel(), filtering::HfPhotonCharm3P::columnLabel(), filtering::HfSingleCharm2P::columnLabel(), filtering::HfSingleCharm3P::columnLabel(), filtering::HfSingleNonPromptCharm2P::columnLabel(), filtering::HfSingleNonPromptCharm3P::columnLabel(), filtering::HfCharmBarToXi2Bach::columnLabel(), filtering::HfPrCharm2P::columnLabel(), filtering::HfBtoJPsiKa::columnLabel(), filtering::HfBtoJPsiKstar::columnLabel(), filtering::HfBtoJPsiPhi::columnLabel(), filtering::HfBtoJPsiPrKa::columnLabel(), filtering::HfBtoJPsiPi::columnLabel()};
static const std::array<std::string, kNV0> v0Labels{"#gamma", "K_{S}^{0}", "#Lambda", "#bar{#Lambda}"};
static const std::array<std::string, kNV0> v0Names{"Photon", "K0S", "Lambda", "AntiLambda"};
static const std::tuple pdgCharmDaughters{
std::array{-321, 211}, // D0
std::array{-321, 211, 211}, // Dplus
std::array{321, -321, 211}, // Ds
std::array{2212, -321, 211}, // Lc
std::array{2212, -321, 211}}; // Xic
constexpr float massPi = o2::constants::physics::MassPiPlus;
constexpr float massKa = o2::constants::physics::MassKPlus;
constexpr float massProton = o2::constants::physics::MassProton;
constexpr float massMu = o2::constants::physics::MassMuon;
constexpr float massDeuteron = o2::constants::physics::MassDeuteron;
constexpr float massGamma = o2::constants::physics::MassGamma;
constexpr float massK0S = o2::constants::physics::MassK0Short;
constexpr float massLambda = o2::constants::physics::MassLambda0;
constexpr float massXi = o2::constants::physics::MassXiMinus;
constexpr float massPhi = o2::constants::physics::MassPhi;
constexpr float massD0 = o2::constants::physics::MassD0;
constexpr float massDPlus = o2::constants::physics::MassDPlus;
constexpr float massDs = o2::constants::physics::MassDS;
constexpr float massLc = o2::constants::physics::MassLambdaCPlus;
constexpr float massXic = o2::constants::physics::MassXiCPlus;
constexpr float massDStar = o2::constants::physics::MassDStar;
constexpr float massBPlus = o2::constants::physics::MassBPlus;
constexpr float massB0 = o2::constants::physics::MassB0;
constexpr float massBs = o2::constants::physics::MassBS;
constexpr float massLb = o2::constants::physics::MassLambdaB0;
constexpr float massXib = o2::constants::physics::MassXiB0;
constexpr float massBc = 6.2744700f; // TODO add Bc mass to o2::constants::physics
constexpr float massSigmaCPlusPlus = o2::constants::physics::MassSigmaCPlusPlus;
constexpr float massSigmaC0 = o2::constants::physics::MassSigmaC0;
constexpr float massK0Star892 = o2::constants::physics::MassK0Star892;
constexpr float massJPsi = o2::constants::physics::MassJPsi;
static const o2::framework::AxisSpec ptAxis{50, 0.f, 50.f};
static const o2::framework::AxisSpec pAxis{50, 0.f, 10.f};
static const o2::framework::AxisSpec kstarAxis{100, 0.f, 1.f};
static const o2::framework::AxisSpec etaAxis{30, -1.5f, 1.5f};
static const o2::framework::AxisSpec nSigmaAxis{100, -10.f, 10.f};
static const o2::framework::AxisSpec alphaAxis{100, -1.f, 1.f};
static const o2::framework::AxisSpec qtAxis{100, 0.f, 0.25f};
static const o2::framework::AxisSpec bdtAxis{100, 0.f, 1.f};
static const o2::framework::AxisSpec phiAxis{36, 0., o2::constants::math::TwoPI};
static const std::array<o2::framework::AxisSpec, kNCharmParticles + 23> massAxisC = {o2::framework::AxisSpec{250, 1.65f, 2.15f}, o2::framework::AxisSpec{250, 1.65f, 2.15f}, o2::framework::AxisSpec{250, 1.75f, 2.25f}, o2::framework::AxisSpec{250, 2.05f, 2.55f}, o2::framework::AxisSpec{250, 2.25f, 2.75f}, o2::framework::AxisSpec{200, 0.139f, 0.159f}, o2::framework::AxisSpec{250, 0.f, 0.25f}, o2::framework::AxisSpec{250, 0.f, 0.25f}, o2::framework::AxisSpec{200, 0.48f, 0.88f}, o2::framework::AxisSpec{200, 0.48f, 0.88f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{170, 0.13f, 0.3f}, o2::framework::AxisSpec{170, 0.13f, 0.3f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{350, 2.3f, 3.0f}, o2::framework::AxisSpec{350, 2.3f, 3.0f}, o2::framework::AxisSpec{350, 2.3f, 3.0f}, o2::framework::AxisSpec{240, 2.4f, 3.6f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}};
static const std::array<o2::framework::AxisSpec, nTotBeautyParts> massAxisB = {o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 5.4f, 7.4f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.4f, 6.4f}, o2::framework::AxisSpec{400, 5.0f, 6.6f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{400, 5.0f, 6.6f}, o2::framework::AxisSpec{240, 5.8f, 7.0f}};
// default values for configurables
// channels to trigger on for femto
constexpr int activeFemtoChannels[2][5] = {{1, 1, 1, 1, 0}, // pD0, pD+, pDs, pLc, pXic
{0, 0, 0, 1, 0}}; // only for deLc
static const std::vector<std::string> labelsColumnsFemtoChannels = {"DZero", "DPlus", "Ds", "Lc", "Xic"};
static const std::vector<std::string> labelsRowsFemtoChannels = {"protonCharmFemto", "deuteronCharmFemto"};
constexpr float cutsPtThresholdsForFemto[1][2] = {{8., 1.4}}; // proton, deuteron
static const std::vector<std::string> labelsColumnsPtThresholdsForFemto = {"Proton", "Deuteron"};
// min and max pT for all tracks combined (except for V0 and cascades)
constexpr float cutsPt[2][10] = {{1., 0.1, 0.8, 0.5, 0.1, 0.2, 0.4, 0.5, 0.3, 0.3},
{100000., 100000., 5., 100000., 100000., 100000., 100000., 100000., 100000., 100000.}}; // beauty, D*, femto, SigmaC, Xic*+ -> SigmaC++K-, beauty to JPsi, Lc*->D0p
static const std::vector<std::string> labelsColumnsCutsPt = {"Beauty", "DstarPlus", "PrForFemto", "CharmBaryon", "SoftPiSigmaC", "SoftKaonXicResoToSigmaC", "DeForFemto", "BeautyToJPsi", "PrForLcReso", "PrForThetaC"};
static const std::vector<std::string> labelsRowsCutsPt = {"Minimum", "Maximum"};
// PID cuts
constexpr float cutsNsigma[4][8] = {
{3., 3., 3., 5., 3., 3., 5., 3.}, // TPC proton from Lc, pi/K from D0, K from 3-prong, femto selected proton, pi/K from Xic/Omegac, K from Xic*->SigmaC-Kaon, femto selected deuteron, K/p from beauty->JPsiX
{3., 3., 3., 2.5, 3., 3., 5., 3.}, // TOF proton from Lc, pi/K from D0, K from 3-prong, femto selected proton, pi/K from Xic/Omegac, K from Xic*->SigmaC-Kaon, femto selected deuteron, K/p from beauty->JPsiX
{999., 999., 999., 2.5, 999., 999., 5., 999.}, // Sum in quadrature of TPC and TOF (used only for femto selected proton and deuteron for pT < 4 GeV/c)
{999., 999., 999., 999., 999., 999., -4., 999.} // ITS used only for femto selected deuteron for less than pt threshold
};
static const std::vector<std::string> labelsColumnsNsigma = {"PrFromLc", "PiKaFromDZero", "KaFrom3Prong", "PrForFemto", "PiKaFromCharmBaryon", "SoftKaonFromXicResoToSigmaC", "DeForFemto", "KaPrFromBeautyToJPsi"};
static const std::vector<std::string> labelsRowsNsigma = {"TPC", "TOF", "Comb", "ITS"};
// high pt
constexpr float cutsHighPtThresholds[1][2] = {{8., 8.}}; // 2-prongs, 3-prongs
static const std::vector<std::string> labelsColumnsHighPtThresholds = {"2Prongs", "3Prongs"};
namespace hf_trigger_cuts_presel_beauty
{
static constexpr int nBinsPt = 2;
static constexpr int nCutVars = 4;
static constexpr int nCutVarsBtoJPsi = 6;
// default values for the pT bin edges (can be used to configure histogram axis)
// common for any beauty candidate
constexpr double binsPt[nBinsPt + 1] = {
0.,
5.,
1000.0};
auto vecBinsPt = std::vector<double>{binsPt, binsPt + nBinsPt + 1};
// default values for the cuts
constexpr double cuts[nBinsPt][nCutVars] = {{0.4, -1, -1, 10.}, /* 0 < pt < 5 */
{0.4, -1, -1, 10.}}; /* 5 < pt < 1000 */
constexpr double cutsBtoJPsi[nBinsPt][nCutVarsBtoJPsi] = {{1., 0.6, 0.9, 0.02, 0.02, 0.1}, /* 0 < pt < 5 */
{1., 0.8, 0.9, 0.02, 0.02, 0.1}}; /* 5 < pt < 1000 */
// row labels
static const std::vector<std::string> labelsPt{};
// column labels
static const std::vector<std::string> labelsColumnsTopolBeauty = {"DeltaMassB", "minCPA", "minDecayLength", "maxImpParProd"};
static const std::vector<std::string> labelsColumnsCutsBeautyToJPsi = {"minPtMuon", "DeltaMassB", "minCPA", "minDecayLength", "DeltaMassKK", "DeltaMassKPi"};
} // namespace hf_trigger_cuts_presel_beauty
// double charm
constexpr int activeDoubleCharmChannels[2][3] = {{1, 1, 1}, {1, 1, 0}}; // kDoubleCharm2P, kDoubleCharm3P, kDoubleCharmMix (second column to keep non-prompt)
static const std::vector<std::string> labelsColumnsDoubleCharmChannels = {"DoubleCharm2Prong", "DoubleCharm3Prong", "DoubleCharmMix"};
static const std::vector<std::string> labelsRowsDoubleCharmChannels = {"", "KeepNonprompt"};
// charm resonances
constexpr float cutsCharmReso[4][13] = {{0.0, 0.0, 0.0, 0.0, 0.4, 0., 0.0, 0.00, 0.21, 0.21, 0.0, 0.7, 0.7},
{0.155, 0.3, 0.3, 0.88, 0.88, 1.35, 0.18, 0.18, 0.25, 0.25, 0.8, 1.3, 1.3},
{0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0, 0.0, 6.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; // D*+, D*0, Ds*0, Ds1+, Ds2*+, Xic*->D, SigmaC0, SigmaC++, SigmaC(2520)0, SigmaC(2520)++, Xic*->SigmaC, Lc*->D0P, Lc*->D*+P
static const std::vector<std::string> labelsColumnsDeltaMassCharmReso = {"DstarPlus", "DstarZero", "DsStarZero", "Ds1Plus", "Ds2StarPlus", "XicResoToD", "SigmaC0", "SigmaCPlusPlus", "SigmaC02520", "SigmaCPlusPlus2520", "XicResoToSigmaC", "LcResoToD0Pr", "ThetaC"};
static const std::vector<std::string> labelsRowsDeltaMassCharmReso = {"deltaMassMin", "deltaMassMax", "ptMin", "ptMinCharmDaugh"};
// V0s for charm resonances
constexpr float cutsV0s[1][6] = {{0.85, 0.97, 0.5, 4., 0.02, 0.01}}; // cosPaGamma, cosPaK0sLambda, radiusK0sLambda, nSigmaPrLambda, deltaMassK0S, deltaMassLambda
static const std::vector<std::string> labelsColumnsV0s = {"CosPaGamma", "CosPaK0sLambda", "RadiusK0sLambda", "NSigmaPrLambda", "DeltaMassK0s", "DeltaMassLambda"};
// cascades for Xi + bachelor triggers
constexpr float cutsCascades[1][8] = {{0.2, 1., 0.01, 0.01, 0.99, 0.99, 0.3, 3.}}; // ptXiBachelor, deltaMassXi, deltaMassLambda, cosPaXi, cosPaLambda, DCAxyXi, nSigmaPid
static const std::vector<std::string> labelsColumnsCascades = {"PtBachelor", "PtXi", "DeltaMassXi", "DeltaMassLambda", "CosPAXi", "CosPaLambda", "DCAxyXi", "NsigmaPid"};
constexpr float cutsCharmBaryons[1][11] = {{5., 5., 1000., 2.35, 2.60, 2.35, 3., 3., 2.7, -2., -2.}}; // MinPtXiPi, MinPtXiKa, MinPtXiPiPi, MinMassXiPi, MinMassXiKa, MinMassXiPiPi, MaxMassXiPi, MaxMassXiKa, MaxMassXiPiPi, CosPaXiBach, CosPaXiBachBach
static const std::vector<std::string> labelsColumnsCharmBarCuts = {"MinPtXiPi", "MinPtXiKa", "MinPtXiPiPi", "MinMassXiPi", "MinMassXiKa", "MinMassXiPiPi", "MaxMassXiPi", "MaxMassXiKa", "MaxMassXiPiPi", "CosPaXiBach", "CosPaXiBachBach"};
constexpr int requireStrangenessTrackedXi[1][2] = {{1, 0}};
static const std::vector<std::string> labelsColumnsCharmBaryons = {"CharmBarToXiBach", "CharmBarToXiBachBach"};
// dummy array
static const std::vector<std::string> labelsEmpty{};
static constexpr double cutsTrackDummy[o2::analysis::hf_cuts_single_track::NBinsPtTrack][o2::analysis::hf_cuts_single_track::NCutVarsTrack] = {{0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}};
o2::framework::LabeledArray<double> cutsSingleTrackDummy{cutsTrackDummy[0], o2::analysis::hf_cuts_single_track::NBinsPtTrack, o2::analysis::hf_cuts_single_track::NCutVarsTrack, o2::analysis::hf_cuts_single_track::labelsPtTrack, o2::analysis::hf_cuts_single_track::labelsCutVarTrack};
// manual downscale factors for tests
constexpr double defDownscaleFactors[kNtriggersHF][1] = {{1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}}; // one for each trigger
static const std::vector<std::string> labelsDownscaleFactor = {"Downscale factor"};
// Main helper class
class HfFilterHelper
{
public:
/// Default constructor
HfFilterHelper() = default;
// setters
void setHighPtTriggerThresholds(float threshold2Prongs, float threshold3Prongs)
{
mPtThresholdHighPt2Prongs = threshold2Prongs;
mPtThresholdHighPt3Prongs = threshold3Prongs;
}
void setPtTriggerThresholdsForFemto(float thresholdProtons, float thresholdDeuterons)
{
mPtThresholdProtonForFemto = thresholdProtons;
mPtThresholdDeuteronForFemto = thresholdDeuterons;
}
void setForceTofForFemto(bool forceTofProtons, bool forceTofDeuterons)
{
mForceTofProtonForFemto = forceTofProtons;
mForceTofDeuteronForFemto = forceTofDeuterons;
}
void setPtBinsSingleTracks(std::vector<double> ptBins) { mPtBinsTracks = ptBins; }
void setPtBinsBeautyHadrons(std::vector<double> ptBins) { mPtBinsBeautyHadrons = ptBins; }
void setCutsSingleTrackBeauty(o2::framework::LabeledArray<double> cutsSingleTrack3P, o2::framework::LabeledArray<double> cutsSingleTrack4P, o2::framework::LabeledArray<double> cutsSingleToJPsi)
{
mCutsSingleTrackBeauty3Prong = cutsSingleTrack3P;
mCutsSingleTrackBeauty4Prong = cutsSingleTrack4P;
mCutsSingleTrackBeautyToJPsi = cutsSingleToJPsi;
}
void setCutsBhadrons(o2::framework::LabeledArray<double> cutsBplus, o2::framework::LabeledArray<double> cutsB0toDstar, o2::framework::LabeledArray<double> cutsBc, o2::framework::LabeledArray<double> cutsB0, o2::framework::LabeledArray<double> cutsBs, o2::framework::LabeledArray<double> cutsLb, o2::framework::LabeledArray<double> cutsXib)
{
mCutsBhad[kBplus] = cutsBplus;
mCutsBhad[kB0toDStar] = cutsB0toDstar;
mCutsBhad[kBc] = cutsBc;
mCutsBhad[kB0] = cutsB0;
mCutsBhad[kBs] = cutsBs;
mCutsBhad[kLb] = cutsLb;
mCutsBhad[kXib] = cutsXib;
}
void setCutsBtoJPsi(o2::framework::LabeledArray<double> cuts)
{
mCutsBhadToJPsi = cuts;
}
void setPtLimitsProtonForFemto(float minPt, float maxPt)
{
mPtMinProtonForFemto = minPt;
mPtMaxProtonForFemto = maxPt;
}
void setPtLimitsDeuteronForFemto(float minPt, float maxPt)
{
mPtMinDeuteronForFemto = minPt;
mPtMaxDeuteronForFemto = maxPt;
}
void setPtLimitsBeautyBachelor(float minPt, float maxPt, float minPtBtoJPsiBach, float maxPtBtoJPsiBach)
{
mPtMinBeautyBachelor = minPt;
mPtMaxBeautyBachelor = maxPt;
mPtMinBeautyToJPsiBachelor = minPtBtoJPsiBach;
mPtMaxBeautyToJPsiBachelor = maxPtBtoJPsiBach;
}
void setPtLimitsDstarSoftPion(float minPt, float maxPt)
{
mPtMinSoftPionForDstar = minPt;
mPtMaxSoftPionForDstar = maxPt;
}
void setPtRangeSoftPiSigmaC(float minPt, float maxPt)
{
mPtMinSoftPionForSigmaC = minPt;
mPtMaxSoftPionForSigmaC = maxPt;
}
void setPtDeltaMassRangeSigmaC(float minDeltaMassSigmaCZero, float maxDeltaMassSigmaCZero, float minDeltaMassSigmaCPlusPlus, float maxDeltaMassSigmaCPlusPlus, float minDeltaMassSigmaC2520Zero, float maxDeltaMassSigmaC2520Zero, float minDeltaMassSigmaC2520PlusPlus, float maxDeltaMassSigmaC2520PlusPlus, float minPtSigmaCZero, float minPtSigmaCPlusPlus, float minPtSigmaC2520Zero, float minPtSigmaC2520PlusPlus)
{
mDeltaMassMinSigmaCZero = minDeltaMassSigmaCZero;
mDeltaMassMaxSigmaCZero = maxDeltaMassSigmaCZero;
mDeltaMassMinSigmaC2520Zero = minDeltaMassSigmaC2520Zero;
mDeltaMassMaxSigmaC2520Zero = maxDeltaMassSigmaC2520Zero;
mDeltaMassMinSigmaCPlusPlus = minDeltaMassSigmaCPlusPlus;
mDeltaMassMaxSigmaCPlusPlus = maxDeltaMassSigmaCPlusPlus;
mDeltaMassMinSigmaC2520PlusPlus = minDeltaMassSigmaC2520PlusPlus;
mDeltaMassMaxSigmaC2520PlusPlus = maxDeltaMassSigmaC2520PlusPlus;
mPtMinSigmaCZero = minPtSigmaCZero;
mPtMinSigmaC2520Zero = minPtSigmaC2520Zero;
mPtMinSigmaCPlusPlus = minPtSigmaCPlusPlus;
mPtMinSigmaC2520PlusPlus = minPtSigmaC2520PlusPlus;
}
void setPtRangeSoftKaonXicResoToSigmaC(float minPt, float maxPt)
{
mPtMinSoftKaonForXicResoToSigmaC = minPt;
mPtMaxSoftKaonForXicResoToSigmaC = maxPt;
}
void setPtLimitsCharmBaryonBachelor(float minPt, float maxPt)
{
mPtMinCharmBaryonBachelor = minPt;
mPtMaxCharmBaryonBachelor = maxPt;
}
void setPtLimitsLcResonanceBachelor(float minPt, float maxPt)
{
mPtMinLcResonanceBachelor = minPt;
mPtMaxLcResonanceBachelor = maxPt;
}
void setPtLimitsThetaCBachelor(float minPt, float maxPt)
{
mPtMinThetaCBachelor = minPt;
mPtMaxThetaCBachelor = maxPt;
}
void setNsigmaProtonCutsForFemto(std::array<float, 4> nSigmaCuts) { mNSigmaPrCutsForFemto = nSigmaCuts; }
void setNsigmaDeuteronCutsForFemto(std::array<float, 4> nSigmaCuts) { mNSigmaDeCutsForFemto = nSigmaCuts; }
void setNsigmaProtonCutsForCharmBaryons(float nSigmaTpc, float nSigmaTof)
{
mNSigmaTpcPrCutForCharmBaryons = nSigmaTpc;
mNSigmaTofPrCutForCharmBaryons = nSigmaTof;
}
void setNsigmaKaonCutsFor3Prongs(float nSigmaTpc, float nSigmaTof)
{
mNSigmaTpcKaCutFor3Prongs = nSigmaTpc;
mNSigmaTofKaCutFor3Prongs = nSigmaTof;
}
void setNsigmaPionKaonCutsForDzero(float nSigmaTpc, float nSigmaTof)
{
mNSigmaTpcPiKaCutForDzero = nSigmaTpc;
mNSigmaTofPiKaCutForDzero = nSigmaTof;
}
void setNsigmaKaonProtonCutsForBeautyToJPsi(float nSigmaTpc, float nSigmaTof)
{
mNSigmaTpcPrKaCutForBeautyToJPsi = nSigmaTpc;
mNSigmaTofPrKaCutForBeautyToJPsi = nSigmaTof;
}
void setV0Selections(float minGammaCosPa, float minK0sLambdaCosPa, float minK0sLambdaRadius, float nSigmaPrFromLambda, float deltaMassK0s, float deltaMassLambda)
{
mMinGammaCosinePa = minGammaCosPa;
mMinK0sLambdaCosinePa = minK0sLambdaCosPa;
mMinK0sLambdaRadius = minK0sLambdaRadius;
mMaxNsigmaPrForLambda = nSigmaPrFromLambda;
mDeltaMassK0s = deltaMassK0s;
mDeltaMassLambda = deltaMassLambda;
}
void setXiSelections(float minPtXiBachelor, float minPtXi, float deltaMassXi, float deltaMassLambda, float cosPaXi, float cosPaLambdaFromXi, float maxDcaxyXi, float nSigma)
{
mMinPtXiBachelor = minPtXiBachelor;
mMinPtXi = minPtXi;
mDeltaMassXi = deltaMassXi;
mDeltaMassLambdaFromXi = deltaMassLambda;
mCosPaXi = cosPaXi;
mCosPaLambdaFromXi = cosPaLambdaFromXi;
mMaxDcaXyXi = maxDcaxyXi;
mMaxNsigmaXiDau = nSigma;
}
void setCutsSingleTrackCharmBaryonBachelor(o2::framework::LabeledArray<double> cutsSingleTrack) { mCutsSingleTrackCharmBaryonBachelor = cutsSingleTrack; }
void setNsigmaPiCutsForCharmBaryonBachelor(float nSigmaTpc, float nSigmaTof)
{
mNSigmaTpcPiCharmBaryonBachelor = nSigmaTpc;
mNSigmaTofPiCharmBaryonBachelor = nSigmaTof;
}
void setNsigmaTpcKaonFromXicResoToSigmaC(float nSigmaTpc, float nSigmaTof)
{
mNSigmaTpcKaonFromXicResoToSigmaC = nSigmaTpc;
mNSigmaTofKaonFromXicResoToSigmaC = nSigmaTof;
}
void setXiBachelorSelections(float ptMinXiPi, float ptMinXiKa, float ptMinXiPiPi, float massMinXiPi, float massMinXiKa, float massMinXiPiPi, float massMaxXiPi, float massMaxXiKa, float massMaxXiPiPi, float cosPaMinXiBach, float cosPaMinXiBachBach)
{
mPtMinXiBach[0] = ptMinXiPi;
mPtMinXiBach[1] = ptMinXiKa;
mPtMinXiBach[2] = ptMinXiPiPi;
mMassMinXiBach[0] = massMinXiPi;
mMassMinXiBach[1] = massMinXiKa;
mMassMinXiBach[2] = massMinXiPiPi;
mMassMaxXiBach[0] = massMaxXiPi;
mMassMaxXiBach[1] = massMaxXiKa;
mMassMaxXiBach[2] = massMaxXiPiPi;
mCosPaMinXiBach[0] = cosPaMinXiBach;
mCosPaMinXiBach[1] = cosPaMinXiBachBach;
}
void setTpcPidCalibrationOption(int opt) { mTpcPidCalibrationOption = opt; }
void setMassResolParametrisation(std::string recoPass)
{
if (recoPass == "2023_pass3") {
mSigmaPars2Prongs[0] = 0.01424f;
mSigmaPars2Prongs[1] = 0.00178f;
mDeltaMassPars2Prongs[0] = -0.0025f;
mDeltaMassPars2Prongs[1] = 0.0001f;
mSigmaPars3Prongs[0] = 0.00796f;
mSigmaPars3Prongs[1] = 0.00176f;
mDeltaMassPars3Prongs[0] = -0.0025f;
mDeltaMassPars3Prongs[1] = 0.0001f;
} else {
LOGP(fatal, "Mass resolution parametrisation {} not supported! Please set 2023_pass3", recoPass.data());
}
}
void setNumSigmaForDeltaMassCharmHadCut(float nSigma) { mNumSigmaDeltaMassCharmHad = nSigma; }
// helper functions for selections
template <typename T>
bool isSelectedHighPt2Prong(const T& pt);
template <typename T>
bool isSelectedHighPt3Prong(const T& pt);
template <o2::aod::hffilters::HfTriggers whichTrigger, typename T, typename T1, typename T2>
int16_t isSelectedTrackForSoftPionOrBeauty(const T& track, const T1& trackPar, const T2& dca);
template <typename T1, typename T2, typename H2>
bool isSelectedTrack4Femto(const T1& track, const T2& trackPar, const int& activateQA, H2 hTPCPID, H2 hTOFPID, const int& trackSpecies);
template <typename T>
int8_t isDzeroPreselected(const T& trackPos, const T& trackNeg);
template <typename T>
int8_t isDplusPreselected(const T& trackOppositeCharge);
template <typename P, typename T>
int8_t isDsPreselected(const P& pTrackSameChargeFirst, const P& pTrackSameChargeSecond, const P& pTrackOppositeCharge, const T& trackOppositeCharge);
template <typename T>
int8_t isCharmBaryonPreselected(const T& trackSameChargeFirst, const T& trackSameChargeSecond, const T& trackOppositeCharge);
template <typename T, typename H2>
int8_t isSelectedD0InMassRange(const T& pTrackPos, const T& pTrackNeg, const float& ptD, int8_t isSelected, const int& activateQA, H2 hMassVsPt);
template <typename T, typename H2>
int8_t isSelectedDplusInMassRange(const T& pTrackSameChargeFirst, const T& pTrackSameChargeSecond, const T& pTrackOppositeCharge, const float& ptD, const int& activateQA, H2 hMassVsPt);
template <typename T, typename H2>
int8_t isSelectedDsInMassRange(const T& pTrackSameChargeFirst, const T& pTrackSameChargeSecond, const T& pTrackOppositeCharge, const float& ptD, int8_t isSelected, const int& activateQA, H2 hMassVsPt);
template <typename T, typename H2>
int8_t isSelectedLcInMassRange(const T& pTrackSameChargeFirst, const T& pTrackSameChargeSecond, const T& pTrackOppositeCharge, const float& ptLc, const int8_t isSelected, const int& activateQA, H2 hMassVsPt);
template <int charge, typename T, typename H2>
int8_t isSelectedSigmaCInDeltaMassRange(const T& pTrackSameChargeFirst, const T& pTrackSameChargeSecond, const T& pTrackOppositeCharge, const T& pTrackSoftPi, const float ptSigmaC, const int8_t isSelectedLc, H2 hMassVsPt, const int& activateQA);
template <typename T, typename H2>
int8_t isSelectedXicInMassRange(const T& pTrackSameChargeFirst, const T& pTrackSameChargeSecond, const T& pTrackOppositeCharge, const float& ptXic, const int8_t isSelected, const int& activateQA, H2 hMassVsPt);
template <typename V0, typename H2>
int8_t isSelectedV0(const V0& v0, const int& activateQA, H2 hV0Selected, std::array<H2, 4>& hArmPod);
template <typename Photon, typename T, typename H2>
bool isSelectedPhoton(const Photon& photon, const std::array<T, 2>& dauTracks, const int& activateQA, H2 hV0Selected, std::array<H2, 4>& hArmPod);
template <typename Casc>
bool isSelectedCascade(const Casc& casc);
template <typename T, typename T2>
int16_t isSelectedBachelorForCharmBaryon(const T& track, const T2& dca);
template <bool is4beauty = false, typename T>
bool isSelectedProton4CharmOrBeautyBaryons(const T& track);
template <typename T, typename U>
int8_t isBDTSelected(const T& scores, const U& thresholdBDTScores);
template <bool isKaonTrack, typename T>
bool isSelectedKaonFromXicResoToSigmaC(const T& track);
template <typename T1, typename T2, typename T3, typename T4>
bool isSelectedBhadron(T1 const& pVecTrack0, T1 const& pVecTrack1, T2 const& dcaTrack0, T2 const& dcaTrack1, const T3& primVtx, const T4& secVtx, const int whichB);
template <typename T1, typename T2>
bool isSelectedBhadronInMassRange(T1 const& ptCand, T2 const& massCand, const int whichB);
template <typename T1, typename T2, typename T3>
bool isSelectedBzeroToDstar(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, const T2& primVtx, const T3& secVtx);
template <int Nprongs, typename T1, typename T2, typename T3, typename T4, typename H2>
int8_t isSelectedBhadronToJPsi(std::array<T1, Nprongs> pVecDauTracks, std::array<T2, Nprongs - 2> tracksDauNoMu, const T3& primVtx, const T4& secVtx, const int& activateQA, std::array<H2, nTotBeautyParts>& hMassVsPt);
template <typename T1>
bool isCharmHadronMassInSbRegions(T1 const& massHypo1, T1 const& massHypo2, const float& lowLimitSB, const float& upLimitSB);
template <typename T, typename C, typename H2>
bool isSelectedXiBach(T const& trackParCasc, T const& trackParBachelor, int8_t isSelBachelor, C const& collision, o2::vertexing::DCAFitterN<2>& dcaFitter, const int& activateQA, H2 hMassVsPtXiPi, H2 hMassVsPtXiKa);
template <int Nprongs, typename T, typename C, typename H2>
bool isSelectedXiBachBach(T const& trackParCasc, std::array<T, 2> const& trackParBachelor, C const& collision, o2::vertexing::DCAFitterN<Nprongs>& dcaFitter, const int& activateQA, H2 hMassVsPtXiPiPi);
template <bool is4ThetaC = false, typename T>
bool isSelectedProtonFromLcResoOrThetaC(const T& track);
// helpers
template <typename T>
T computeRelativeMomentum(const std::array<T, 3>& pTrack, const std::array<T, 3>& CharmCandMomentum, const T& CharmMass);
template <typename T>
int computeNumberOfCandidates(std::vector<std::vector<T>> indices);
template <typename T1>
int setVtxConfiguration(T1 vertexer, bool useAbsDCA);
template <typename V, typename T, typename C>
bool buildV0(V const& v0Indices, T const& tracks, C const& collision, o2::vertexing::DCAFitterN<2>& dcaFitter, const std::vector<int>& vetoedTrackIds, V0Cand& v0Cand);
template <typename Casc, typename T, typename C, typename V>
bool buildCascade(Casc const& cascIndices, V const& v0Indices, T const& tracks, C const& collision, o2::vertexing::DCAFitterN<2>& dcaFitter, const std::vector<int>& vetoedTrackIds, CascCand& cascCand);
// PID
void setValuesBB(o2::ccdb::CcdbApi& ccdbApi, aod::BCsWithTimestamps::iterator const& bunchCrossing, const std::array<std::string, 8>& ccdbPaths);
void setTpcRecalibMaps(o2::framework::Service<o2::ccdb::BasicCCDBManager> const& ccdb, aod::BCsWithTimestamps::iterator const& bunchCrossing, const std::string& ccdbPath);
private:
// selections
template <bool is4beauty = false, typename T>
bool isSelectedKaon4Charm3ProngOrBeautyToJPsi(const T& track);
// PID
float getTPCSplineCalib(const float tpcPin, const float dEdx, const int& pidSpecies);
template <typename T>
float getTPCSplineCalib(const T& track, const int& pidSpecies);
float getTPCPostCalib(const float tpcPin, const float tpcNCls, const float eta, const float tpcNSigma, const int& pidSpecies);
template <typename T>
float getTPCPostCalib(const T& track, const int& pidSpecies);
// helpers
template <typename T1, typename T2>
int findBin(T1 const& binsPt, T2 value);
template <typename T>
std::array<T, 2> alphaAndQtAP(std::array<T, 3> const& momPos, std::array<T, 3> const& momNeg);
// selections
std::vector<double> mPtBinsTracks{}; // vector of pT bins for single track cuts
std::vector<double> mPtBinsBeautyHadrons{}; // vector of pT bins for beauty hadron candidates
o2::framework::LabeledArray<double> mCutsSingleTrackBeauty3Prong{}; // dca selections for the 3-prong b-hadron pion daughter
o2::framework::LabeledArray<double> mCutsSingleTrackBeauty4Prong{}; // dca selections for the 4-prong b-hadron pion daughter
o2::framework::LabeledArray<double> mCutsSingleTrackBeautyToJPsi{}; // dca selections for the b-hadron -> JPsi X daughters (not the muons)
float mPtMinSoftPionForDstar{0.1}; // minimum pt for the D*+ soft pion
float mPtMinSoftPionForSigmaC{0.1}; // minimum pt for the Σ0,++ soft pion
float mPtMaxSoftPionForSigmaC{10000.f}; // maximum pt for the Σ0,++ soft pion
float mPtMinSoftKaonForXicResoToSigmaC{0.1}; // minimum pt for the soft kaon of Xic* to SigmaC-Kaon
float mPtMaxSoftKaonForXicResoToSigmaC{10000.f}; // maximum pt for the soft kaon of Xic* to SigmaC-Kaon
float mPtMinBeautyBachelor{0.5}; // minimum pt for the b-hadron pion daughter
float mPtMinBeautyToJPsiBachelor{0.5}; // minimum pt for the b-hadron -> JPsi X daughters (not the muons)
float mPtMinProtonForFemto{0.8}; // minimum pt for the proton for femto
float mPtMinDeuteronForFemto{0.8}; // minimum pt for the deuteron for femto
float mPtMinCharmBaryonBachelor{0.5}; // minimum pt for the bachelor pion from Xic/Omegac decays
float mPtMinLcResonanceBachelor{0.3}; // minimum pt for the bachelor proton from Lc resonance decays
float mPtMinThetaCBachelor{0.3}; // minimum pt for the bachelor proton from ThetaC decays
float mPtMaxSoftPionForDstar{2.}; // maximum pt for the D*+ soft pion
float mPtMaxBeautyBachelor{100000.}; // maximum pt for the b-hadron pion daughter
float mPtMaxBeautyToJPsiBachelor{100000.}; // maximum pt for the b-hadron -> JPsi X daughters (not the muons)
float mPtMaxProtonForFemto{5.0}; // maximum pt for the proton for femto
float mPtMaxDeuteronForFemto{5.0}; // maximum pt for the deuteron for femto
float mPtMaxCharmBaryonBachelor{100000.}; // maximum pt for the bachelor pion from Xic/Omegac decays
float mPtMaxLcResonanceBachelor{100000.}; // maximum pt for the bachelor proton from Lc resonance decays
float mPtMaxThetaCBachelor{100000.}; // maximum pt for the bachelor proton from ThetaC decays
float mPtThresholdProtonForFemto{8.}; // pt threshold to change strategy for proton PID for femto
float mPtThresholdDeuteronForFemto{1.4}; // pt threshold to change strategy for deuteron PID for femto
float mPtMinSigmaCZero{0.f}; // pt min SigmaC0 candidate
float mPtMinSigmaC2520Zero{0.f}; // pt min SigmaC(2520)0 candidate
float mPtMinSigmaCPlusPlus{0.f}; // pt min SigmaC++ candidate
float mPtMinSigmaC2520PlusPlus{0.f}; // pt min SigmaC(2520)++ candidate
std::array<float, 4> mNSigmaPrCutsForFemto{3., 3., 3., -4.}; // cut values for Nsigma TPC, TOF, combined, ITS for femto protons
std::array<float, 4> mNSigmaDeCutsForFemto{3., 3., 3., -4.}; // cut values for Nsigma TPC, TOF, combined, ITS for femto deuterons
float mNSigmaTpcPrCutForCharmBaryons{3.}; // maximum Nsigma TPC for protons in Lc and Xic decays
float mNSigmaTofPrCutForCharmBaryons{3.}; // maximum Nsigma TOF for protons in Lc and Xic decays
float mNSigmaTpcKaCutFor3Prongs{3.}; // maximum Nsigma TPC for kaons in 3-prong decays
float mNSigmaTofKaCutFor3Prongs{3.}; // maximum Nsigma TOF for kaons in 3-prong decays
float mNSigmaTpcPiKaCutForDzero{3.}; // maximum Nsigma TPC for pions/kaons in D0 decays
float mNSigmaTofPiKaCutForDzero{3.}; // maximum Nsigma TOF for pions/kaons in D0 decays
float mNSigmaTpcPrKaCutForBeautyToJPsi{3.}; // maximum Nsigma TPC for kaons and protons in B->JPsiX decays
float mNSigmaTofPrKaCutForBeautyToJPsi{3.}; // maximum Nsigma TPC for kaons and protons in B->JPsiX decays
float mDeltaMassMinSigmaCZero{0.155}; // minimum delta mass M(pKpipi)-M(pKpi) of SigmaC0 candidates
float mDeltaMassMaxSigmaCZero{0.18}; // maximum delta mass M(pKpipi)-M(pKpi) of SigmaC0 candidates
float mDeltaMassMinSigmaC2520Zero{0.2}; // minimum delta mass M(pKpipi)-M(pKpi) of SigmaC(2520)0 candidates
float mDeltaMassMaxSigmaC2520Zero{0.26}; // maximum delta mass M(pKpipi)-M(pKpi) of SigmaC(2520)0 candidates
float mDeltaMassMinSigmaCPlusPlus{0.155}; // minimum delta mass M(pKpipi)-M(pKpi) of SigmaC++ candidates
float mDeltaMassMaxSigmaCPlusPlus{0.18}; // maximum delta mass M(pKpipi)-M(pKpi) of SigmaC++ candidates
float mDeltaMassMinSigmaC2520PlusPlus{0.2}; // minimum delta mass M(pKpipi)-M(pKpi) of SigmaC(2520)++ candidates
float mDeltaMassMaxSigmaC2520PlusPlus{0.26}; // maximum delta mass M(pKpipi)-M(pKpi) of SigmaC(2520)++ candidates
float mMinGammaCosinePa{0.85}; // minimum cosp for gammas
float mMinK0sLambdaCosinePa{0.97}; // minimum cosp for K0S and Lambda in charm excited decays
float mMinK0sLambdaRadius{0.5}; // minimum radius for K0S and Lambda in charm excited decays
float mMaxNsigmaPrForLambda{4.}; // maximum Nsigma TPC and TOF for protons in Lambda decays
float mDeltaMassK0s{0.02}; // delta mass cut for K0S in charm excited decays
float mDeltaMassLambda{0.01}; // delta mass cut for Lambda in charm excited decays
float mMinPtXiBachelor{0.1}; // minimum pt for Xi bachelor in Xic/Omegac decays
float mMinPtXi{1.}; // minimum pt for Xi in Xic/Omegac decays
float mDeltaMassXi{0.01}; // delta mass cut for Xi in Xic/Omegac decays
float mDeltaMassLambdaFromXi{0.01}; // delta mass cut for Lambda <- Xi in Xic/Omegac decays
float mCosPaXi{0.99}; // minimum cosp for Xi in Xic/Omegac decays
float mCosPaLambdaFromXi{0.99}; // minimum cosp for Xi in Xic/Omegac decays
float mMaxDcaXyXi{0.3}; // maximum dca for Xi in Xic/Omegac decays
float mMaxNsigmaXiDau{3.}; // maximum Nsigma TPC and TOF for Xi daughter tracks
o2::framework::LabeledArray<double> mCutsSingleTrackCharmBaryonBachelor{}; // dca selections for the bachelor pion from Xic/Omegac decays
float mNSigmaTpcPiCharmBaryonBachelor{3.}; // maximum Nsigma TPC for pions in Xic/Omegac decays
float mNSigmaTofPiCharmBaryonBachelor{3.}; // maximum Nsigma TOF for pions in Xic/Omegac decays
float mNumSigmaDeltaMassCharmHad{2.5}; // number of sigmas for delta mass cut for charm hadrons in B and charm excited decays
std::array<float, 2> mSigmaPars2Prongs{}; // parameters (intercept, slope) for parametrisation of mass sigma vs pT for 2-prongs
std::array<float, 2> mDeltaMassPars2Prongs{}; // parameters (intercept, slope) for parametrisation of mass delta wrt PDG vs pT for 2-prongs
std::array<float, 2> mSigmaPars3Prongs{}; // parameters (intercept, slope) for parametrisation of mass sigma vs pT for 3-prongs
std::array<float, 2> mDeltaMassPars3Prongs{}; // parameters (intercept, slope) for parametrisation of mass delta wrt PDG vs pT for 3-prongs
float mPtThresholdHighPt2Prongs{8.}; // threshold for high pT triggers for 2-prongs
float mPtThresholdHighPt3Prongs{8.}; // threshold for high pT triggers for 3-prongs
float mNSigmaTpcKaonFromXicResoToSigmaC{3.}; // maximum Nsigma TPC for kaons in Xic*->SigmaC-Kaon
float mNSigmaTofKaonFromXicResoToSigmaC{3.}; // maximum Nsigma TOF for kaons in Xic*->SigmaC-Kaon
bool mForceTofProtonForFemto = true; // flag to force TOF PID for protons
bool mForceTofDeuteronForFemto = false; // flag to force TOF PID for deuterons
std::array<float, 3> mPtMinXiBach{5., 5., 5.}; // minimum pT for XiBachelor candidates
std::array<float, 3> mMassMinXiBach{2.35, 2.6, 2.35}; // minimum invariant-mass for XiBachelor candidates
std::array<float, 3> mMassMaxXiBach{3.0, 3.0, 2.7}; // maximum invariant-mass for XiBachelor candidates
std::array<float, 2> mCosPaMinXiBach{-2.f, -2.f}; // minimum cosine of pointing angle for XiBachelor candidates
std::array<o2::framework::LabeledArray<double>, kNBeautyParticles> mCutsBhad{}; // selections for B-hadron candidates (DeltaMass, CPA, DecayLength, ImpactParameterProduct)
o2::framework::LabeledArray<double> mCutsBhadToJPsi{}; // selections for B->JPsi candidates (PtMinMu, DeltaMass, CPA, DecayLength)
// PID recalibrations
int mTpcPidCalibrationOption{0}; // Option for TPC PID calibration (0 -> AO2D, 1 -> postcalibrations, 2 -> alternative bethe bloch parametrisation)
std::array<TH3F*, 8> mHistMapPiPrKaDe{}; // Map for TPC PID postcalibrations for pions, kaon, protons and deuterons
std::array<std::vector<double>, 8> mBetheBlochPiKaPrDe{}; // Bethe-Bloch parametrisations for pions, antipions, kaons, antikaons, protons, antiprotons, deuterons, antideuterons in TPC
};
/// Selection of high-pt 2-prong candidates
/// \param pt is the pt of the 2-prong candidate
template <typename T>
inline bool HfFilterHelper::isSelectedHighPt2Prong(const T& pt)
{
if (pt < mPtThresholdHighPt2Prongs) {
return false;
}
return true;
}
/// Selection of high-pt 3-prong candidates
/// \param pt is the pt of the 3-prong candidate
template <typename T>
inline bool HfFilterHelper::isSelectedHighPt3Prong(const T& pt)
{
if (pt < mPtThresholdHighPt3Prongs) {
return false;
}
return true;
}
/// Single-track cuts for bachelor track of beauty candidates
/// \param track is a track parameter
/// \param trackPar is a track parameter
/// \param dca is the 2d array with dcaXY and dcaZ of the track
/// \return a flag that encodes the selection for soft pions BIT(kSoftPion), tracks for beauty BIT(kForBeauty), or soft pions for beauty BIT(kSoftPionForBeauty)
template <o2::aod::hffilters::HfTriggers whichTrigger, typename T, typename T1, typename T2>
inline int16_t HfFilterHelper::isSelectedTrackForSoftPionOrBeauty(const T& track, const T1& trackPar, const T2& dca)
{
int16_t retValue{BIT(kSoftPion) | BIT(kForBeauty) | BIT(kSoftPionForBeauty) | BIT(kSoftPionForSigmaC)};
if (!track.isGlobalTrackWoDCA()) {
return kRejected;
}
auto pT = trackPar.getPt();
auto pTBinTrack = findBin(mPtBinsTracks, pT);
if (pTBinTrack == -1) {
return kRejected;
}
// D*+ soft pion pt cut
// We can keep ot for all triggers (SigmaC ones included), assuming that the D* soft pion is the softest
if (pT < mPtMinSoftPionForDstar) { // soft pion min pT cut should be less stringent than usual tracks
return kRejected;
}
if (std::fabs(trackPar.getEta()) > 0.8) {
return kRejected;
}
if (std::fabs(dca[1]) > 2.f) {
return kRejected;
}
if constexpr (whichTrigger == kSigmaCPPK || whichTrigger == kSigmaC0K0) {
// SigmaC0,++ soft pion pt cut
if (pT < mPtMinSoftPionForSigmaC || pT > mPtMaxSoftPionForSigmaC) {
return kRejected;
}
// We do not need any further selection for SigmaC soft-pi
// The current track is a good SigmaC soft-pi candidate
return retValue;
}
if (pT > mPtMaxSoftPionForDstar) {
CLRBIT(retValue, kSoftPion);
CLRBIT(retValue, kSoftPionForBeauty);
}
// below only regular beauty tracks, not required for soft pions
float ptMin{-1.f}, ptMax{1000.f};
if constexpr (whichTrigger == kBeauty3P || whichTrigger == kBeauty4P) {
ptMin = mPtMinBeautyBachelor;
ptMax = mPtMaxBeautyBachelor;
} else if constexpr (whichTrigger == kBtoJPsiKa || whichTrigger == kBtoJPsiPi || whichTrigger == kBtoJPsiKstar || whichTrigger == kBtoJPsiPhi || whichTrigger == kBtoJPsiPrKa) {
ptMin = mPtMinBeautyToJPsiBachelor;
ptMax = mPtMaxBeautyToJPsiBachelor;
}
if (pT < ptMin || pT > ptMax) {
CLRBIT(retValue, kForBeauty);
}
float minDca{1000.f}, maxDca{0.f};
if constexpr (whichTrigger == kBeauty3P) {
minDca = mCutsSingleTrackBeauty3Prong.get(pTBinTrack, 0u);
maxDca = mCutsSingleTrackBeauty3Prong.get(pTBinTrack, 1u);
} else if constexpr (whichTrigger == kBeauty4P) {
minDca = mCutsSingleTrackBeauty4Prong.get(pTBinTrack, 0u);
maxDca = mCutsSingleTrackBeauty4Prong.get(pTBinTrack, 1u);
} else if constexpr (whichTrigger == kBtoJPsiKa || whichTrigger == kBtoJPsiPi || whichTrigger == kBtoJPsiKstar || whichTrigger == kBtoJPsiPhi || whichTrigger == kBtoJPsiPrKa) {
minDca = mCutsSingleTrackBeautyToJPsi.get(pTBinTrack, 0u);
maxDca = mCutsSingleTrackBeautyToJPsi.get(pTBinTrack, 1u);
}
if (std::fabs(dca[0]) < minDca) { // minimum DCAxy
CLRBIT(retValue, kForBeauty);
CLRBIT(retValue, kSoftPionForBeauty);
}
if (std::fabs(dca[0]) > maxDca) { // maximum DCAxy
CLRBIT(retValue, kForBeauty);
CLRBIT(retValue, kSoftPionForBeauty);
}
return retValue;
}
/// Basic selection of proton or deuteron candidates
/// \param track is a track
/// \param trackPar is a track parameter
/// \param activateQA flag to activate the filling of QA histos
/// \param hProtonTPCPID histo with NsigmaTPC vs. p
/// \param hProtonTOFPID histo with NsigmaTOF vs. p
/// \param trackSpecies flag to choose proton or deuteron
/// \return true if track passes all cuts
template <typename T1, typename T2, typename H2>
inline bool HfFilterHelper::isSelectedTrack4Femto(const T1& track, const T2& trackPar, const int& activateQA, H2 hTPCPID, H2 hTOFPID, const int& trackSpecies)
{
float pt = trackPar.getPt();
float ptMin, ptMax, ptThresholdPidStrategy;
std::array<float, 4> nSigmaCuts;
bool forceTof = false; // flag to force TOF PID
// Assign particle-specific parameters
switch (trackSpecies) {
case kProtonForFemto:
ptMin = mPtMinProtonForFemto;
ptMax = mPtMaxProtonForFemto;
nSigmaCuts = mNSigmaPrCutsForFemto;
forceTof = mForceTofProtonForFemto;
ptThresholdPidStrategy = mPtThresholdProtonForFemto;
break;
case kDeuteronForFemto:
ptMin = mPtMinDeuteronForFemto;
ptMax = mPtMaxDeuteronForFemto;
nSigmaCuts = mNSigmaDeCutsForFemto;
forceTof = mForceTofDeuteronForFemto;
ptThresholdPidStrategy = mPtThresholdDeuteronForFemto;
break;
default:
return false; // Unknown particle type
}
// Common selection criteria
if (pt < ptMin || pt > ptMax) {
return false;
}
if (std::fabs(trackPar.getEta()) > 0.8) {
return false;
}
if (!track.isGlobalTrack()) {
return false; // use only global tracks
}
// PID evaluation
float NSigmaITS = (trackSpecies == kProtonForFemto) ? track.itsNSigmaPr() : track.itsNSigmaDe(); // only used for deuteron
float NSigmaTPC = (trackSpecies == kProtonForFemto) ? track.tpcNSigmaPr() : track.tpcNSigmaDe();
float NSigmaTOF = (trackSpecies == kProtonForFemto) ? track.tofNSigmaPr() : track.tofNSigmaDe();
if (!forceTof && !track.hasTOF()) {
NSigmaTOF = 0.; // always accepted
}
// Apply TPC PID post-calibration(only available for proton, dummy for deuteron)
if (mTpcPidCalibrationOption == 1) {
NSigmaTPC = getTPCPostCalib(track, trackSpecies == kProtonForFemto ? kPr : kDe);
} else if (mTpcPidCalibrationOption == 2) {
if (track.sign() > 0) {
NSigmaTPC = getTPCSplineCalib(track, trackSpecies == kProtonForFemto ? kPr : kDe);
} else {
NSigmaTPC = getTPCSplineCalib(track, trackSpecies == kProtonForFemto ? kAntiPr : kAntiDe);
}
}
float NSigma = std::sqrt(NSigmaTPC * NSigmaTPC + NSigmaTOF * NSigmaTOF);
if (trackSpecies == kProtonForFemto) {
if (pt <= ptThresholdPidStrategy) {
if (NSigma > nSigmaCuts[2]) {
return false;
}
} else {
if (std::fabs(NSigmaTPC) > nSigmaCuts[0] || std::fabs(NSigmaTOF) > nSigmaCuts[1]) {
return false;
}
}
}
// For deuterons: Determine whether to apply TOF based on pt threshold
if (trackSpecies == kDeuteronForFemto) {
// Apply different PID strategy in different pt range
// one side selection only
if (pt <= ptThresholdPidStrategy) {
if (NSigmaTPC < -nSigmaCuts[0] || NSigmaITS < -nSigmaCuts[3]) { // Use TPC and ITS below the threshold, NSigmaITS for deuteron with a lower limit
return false;
}
} else {
if (NSigmaTOF < -nSigmaCuts[1] || NSigmaTPC < -nSigmaCuts[0]) { // Use combined TPC and TOF above the threshold
return false;
}
}
}
if (activateQA > 1) {
hTPCPID->Fill(track.p(), NSigmaTPC);
if ((forceTof || track.hasTOF())) {
if (trackSpecies == kProtonForFemto)
hTOFPID->Fill(track.p(), NSigmaTOF);
else if (trackSpecies == kDeuteronForFemto && pt > ptThresholdPidStrategy)
hTOFPID->Fill(track.p(), NSigmaTOF);
}
}
return true;
}
/// Basic additional selection of D+ candidates
/// \param trackOppositeCharge is the opposite charge track
/// \param mNSigmaTpcKaCutFor3Prongs max NsigmaTPC for kaon candidates
/// \param mNSigmaTofKaCutFor3Prongs max NsigmaTOF for kaon candidates
/// \return BIT(0) for Kpipi
template <typename T>
inline int8_t HfFilterHelper::isDplusPreselected(const T& trackOppositeCharge)
{
int8_t retValue = 0;
// check PID of opposite charge track
if (!isSelectedKaon4Charm3ProngOrBeautyToJPsi(trackOppositeCharge)) {
return retValue;
}