Skip to content

Commit 983f8fa

Browse files
committed
fixed o2linter and code check
1 parent 98c8537 commit 983f8fa

2 files changed

Lines changed: 87 additions & 81 deletions

File tree

PWGLF/Tasks/Resonances/k892hadronphoton.cxx

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static const std::vector<std::string> kshortSels = {"NoSel", "V0Radius", "DCADau
6666
static const std::vector<std::string> DirList = {"BeforeSel", "AfterSel"};
6767

6868
struct k892hadronphoton {
69-
Service<o2::ccdb::BasicCCDBManager> ccdb;
69+
Service<o2::ccdb::BasicCCDBManager> ccdb{};
7070
ctpRateFetcher rateFetcher;
7171

7272
//__________________________________________________
@@ -225,18 +225,18 @@ struct k892hadronphoton {
225225
ConfigurableAxis axisCosPA{"axisCosPA", {200, 0.5f, 1.0f}, "Cosine of pointing angle"};
226226
ConfigurableAxis axisPA{"axisPA", {100, 0.0f, 1}, "Pointing angle"};
227227
ConfigurableAxis axisPsiPair{"axisPsiPair", {250, -5.0f, 5.0f}, "Psipair for photons"};
228-
ConfigurableAxis axisPhi{"axisPhi", {200, 0, 2 * o2::constants::math::PI}, "Phi for photons"};
228+
ConfigurableAxis axisPhi{"axisPhi", {200, 0, o2::constants::math::TwoPI}, "Phi for photons"};
229229
ConfigurableAxis axisZ{"axisZ", {120, -120.0f, 120.0f}, "V0 Z position (cm)"};
230230

231231
ConfigurableAxis axisCandSel{"axisCandSel", {20, 0.5f, +20.5f}, "Candidate Selection"};
232232

233233
// ML
234-
ConfigurableAxis mlProb{"mlOutput", {100, 0.0f, 1.0f}, ""};
234+
ConfigurableAxis mlProb{"mlProb", {100, 0.0f, 1.0f}, ""};
235235

236236
void init(InitContext const&)
237237
{
238238
LOGF(info, "Initializing now: cross-checking correctness...");
239-
if (doprocessRealData + doprocessMonteCarlo > 1) {
239+
if (doprocessRealData && doprocessMonteCarlo) {
240240
LOGF(fatal, "You have enabled more than one process function. Please check your configuration! Aborting now.");
241241
}
242242

@@ -736,7 +736,6 @@ struct k892hadronphoton {
736736
histos.fill(HIST("Gen/hGenEventCentrality"), centrality);
737737
}
738738
}
739-
return;
740739
}
741740

742741
// ______________________________________________________
@@ -795,30 +794,38 @@ struct k892hadronphoton {
795794
}
796795
}
797796

798-
//__________________________________________
797+
// per-daughter detector code (bit 0: TPC, bit 1: ITS tracker)
798+
enum DauTrackCode : uint8_t {
799+
DauTPCOnly = 1, // hasTPC only
800+
DauITSTrackerOnly = 2, // hasITSTracker only, no TPC
801+
DauITSTPC = 3 // hasTPC | hasITSTracker
802+
};
803+
799804
template <bool isGamma, typename TKStarObject>
800805
int retrieveV0TrackCode(TKStarObject const& kstar)
801806
{
802807

803808
int trkCode = 10; // 1: TPC-only, 2: TPC+Something, 3: ITS-Only, 4: ITS+TPC + Something, 10: anything else
809+
auto photonPosTrackCode = kstar.photonPosTrackCode();
810+
auto photonNegTrackCode = kstar.photonNegTrackCode();
804811

805812
if (isGamma) {
806-
if (kstar.photonPosTrackCode() == 1 && kstar.photonNegTrackCode() == 1)
813+
if (photonPosTrackCode == DauTPCOnly && photonNegTrackCode == DauTPCOnly)
807814
trkCode = 1;
808-
if ((kstar.photonPosTrackCode() != 1 && kstar.photonNegTrackCode() == 1) || (kstar.photonPosTrackCode() == 1 && kstar.photonNegTrackCode() != 1))
815+
if ((photonPosTrackCode != DauTPCOnly && photonNegTrackCode == DauTPCOnly) || (photonPosTrackCode == DauTPCOnly && photonNegTrackCode != DauTPCOnly))
809816
trkCode = 2;
810-
if (kstar.photonPosTrackCode() == 3 && kstar.photonNegTrackCode() == 3)
817+
if (photonPosTrackCode == DauITSTPC && photonNegTrackCode == DauITSTPC)
811818
trkCode = 3;
812-
if (kstar.photonPosTrackCode() == 2 || kstar.photonNegTrackCode() == 2)
819+
if (photonPosTrackCode == DauITSTrackerOnly || photonNegTrackCode == DauITSTrackerOnly)
813820
trkCode = 4;
814821
} else {
815-
if (kstar.kshortPosTrackCode() == 1 && kstar.kshortNegTrackCode() == 1)
822+
if (photonPosTrackCode == DauTPCOnly && photonNegTrackCode == DauTPCOnly)
816823
trkCode = 1;
817-
if ((kstar.kshortPosTrackCode() != 1 && kstar.kshortNegTrackCode() == 1) || (kstar.kshortPosTrackCode() == 1 && kstar.kshortNegTrackCode() != 1))
824+
if ((photonPosTrackCode != DauTPCOnly && photonNegTrackCode == DauTPCOnly) || (photonPosTrackCode == DauTPCOnly && photonNegTrackCode != DauTPCOnly))
818825
trkCode = 2;
819-
if (kstar.kshortPosTrackCode() == 3 && kstar.kshortNegTrackCode() == 3)
826+
if (photonPosTrackCode == DauITSTPC && photonNegTrackCode == DauITSTPC)
820827
trkCode = 3;
821-
if (kstar.kshortPosTrackCode() == 2 || kstar.kshortNegTrackCode() == 2)
828+
if (photonPosTrackCode == DauITSTrackerOnly || photonNegTrackCode == DauITSTrackerOnly)
822829
trkCode = 4;
823830
}
824831

@@ -829,7 +836,7 @@ struct k892hadronphoton {
829836
void getResolution(TKStarObject const& kstar)
830837
{
831838
// Check whether it is before or after selections
832-
static constexpr std::string_view MainDir[] = {"BeforeSel", "AfterSel"};
839+
static constexpr std::array<std::string_view, 2> MainDir = {"BeforeSel", "AfterSel"};
833840

834841
//_______________________________________
835842
// Gamma MC association
@@ -863,7 +870,7 @@ struct k892hadronphoton {
863870
void runBkgAnalysis(TKStarObject const& kstar)
864871
{
865872
// Check whether it is before or after selections
866-
static constexpr std::string_view MainDir[] = {"BeforeSel", "AfterSel"};
873+
static constexpr std::array<std::string_view, 2> MainDir = {"BeforeSel", "AfterSel"};
867874

868875
bool fIsKStar = kstar.isKStar();
869876
int photonPDGCode = kstar.photonPDGCode();
@@ -931,7 +938,7 @@ struct k892hadronphoton {
931938
{
932939

933940
// Check whether it is before or after selections
934-
static constexpr std::string_view MainDir[] = {"BeforeSel", "AfterSel"};
941+
static constexpr std::array<std::string_view, 2> MainDir = {"BeforeSel", "AfterSel"};
935942

936943
// Get V0trackCode
937944
int gammaTrkCode = retrieveV0TrackCode<true>(kstar);
@@ -1150,14 +1157,14 @@ struct k892hadronphoton {
11501157
void fillSelHistos(TKStarObject const& kstar, int PDGRequired)
11511158
{
11521159

1153-
static constexpr std::string_view photonSelsLocal[] = {"NoSel", "V0Type", "DCADauToPV",
1154-
"DCADau", "DauTPCCR", "TPCNSigmaEl", "V0pT",
1155-
"Y", "V0Radius", "RZCut", "Armenteros", "CosPA",
1156-
"PsiPair", "Phi", "Mass"};
1160+
static constexpr std::array<std::string_view, 15> photonSelsLocal = {"NoSel", "V0Type", "DCADauToPV",
1161+
"DCADau", "DauTPCCR", "TPCNSigmaEl", "V0pT",
1162+
"Y", "V0Radius", "RZCut", "Armenteros", "CosPA",
1163+
"PsiPair", "Phi", "Mass"};
11571164

1158-
static constexpr std::string_view kshortSelsLocal[] = {"NoSel", "V0Radius", "DCADau", "Armenteros",
1159-
"CosPA", "Y", "TPCCR", "DauITSCls", "Lifetime",
1160-
"TPCTOFPID", "DCADauToPV", "Mass"};
1165+
static constexpr std::array<std::string_view, 12> kshortSelsLocal = {"NoSel", "V0Radius", "DCADau", "Armenteros",
1166+
"CosPA", "Y", "TPCCR", "DauITSCls", "Lifetime",
1167+
"TPCTOFPID", "DCADauToPV", "Mass"};
11611168

11621169
if (std::abs(PDGRequired) == PDG_t::kGamma) {
11631170
if constexpr (selection_index >= 0 && selection_index < static_cast<int>(std::size(photonSelsLocal))) {

PWGLF/Tasks/Resonances/k892hadronphotonBkg.cxx

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const std::vector<std::string> kshortSels = {"No Sel", "Mass", "Y", "Neg
6363
"CosPA", "TPCCR", "ITSNCls", "Lifetime", "TPC NSigma"};
6464

6565
struct k892hadronphotonBkg {
66-
Service<o2::ccdb::BasicCCDBManager> ccdb;
66+
Service<o2::ccdb::BasicCCDBManager> ccdb{};
6767
ctpRateFetcher rateFetcher;
6868
TRandom3 rotRng{12345}; // struct member; fixed seed for reproducibility across grid jobs
6969

@@ -494,79 +494,78 @@ struct k892hadronphotonBkg {
494494
if (useMLScores) {
495495
// if (kshort.k0ShortBDTScore() <= kshortSelections.kshortMLThreshold)
496496
return false;
497+
}
497498

498-
} else {
499-
// KShort basic selection criteria:
500-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 1.);
501-
if ((std::abs(kshort.mK0Short() - o2::constants::physics::MassK0Short) > kshortSelections.kshortWindow) && kshortSelections.kshortWindow > 0)
502-
return false;
499+
// KShort basic selection criteria:
500+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 1.);
501+
if ((std::abs(kshort.mK0Short() - o2::constants::physics::MassK0Short) > kshortSelections.kshortWindow) && kshortSelections.kshortWindow > 0)
502+
return false;
503503

504-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 2.);
505-
if ((kshort.yK0Short() < kshortSelections.kshortMinRapidity) || (kshort.yK0Short() > kshortSelections.kshortMaxRapidity))
506-
return false;
504+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 2.);
505+
if ((kshort.yK0Short() < kshortSelections.kshortMinRapidity) || (kshort.yK0Short() > kshortSelections.kshortMaxRapidity))
506+
return false;
507507

508-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 3.);
509-
if ((kshort.negativeeta() < kshortSelections.kshortDauEtaMin) || (kshort.negativeeta() > kshortSelections.kshortDauEtaMax))
510-
return false;
508+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 3.);
509+
if ((kshort.negativeeta() < kshortSelections.kshortDauEtaMin) || (kshort.negativeeta() > kshortSelections.kshortDauEtaMax))
510+
return false;
511511

512-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 4.);
513-
if ((kshort.positiveeta() < kshortSelections.kshortDauEtaMin) || (kshort.positiveeta() > kshortSelections.kshortDauEtaMax))
514-
return false;
512+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 4.);
513+
if ((kshort.positiveeta() < kshortSelections.kshortDauEtaMin) || (kshort.positiveeta() > kshortSelections.kshortDauEtaMax))
514+
return false;
515515

516-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 5.);
517-
if ((std::abs(kshort.dcapostopv()) < kshortSelections.kshortMinDCAPosToPv) || (std::abs(kshort.dcanegtopv()) < kshortSelections.kshortMinDCANegToPv))
518-
return false;
516+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 5.);
517+
if ((std::abs(kshort.dcapostopv()) < kshortSelections.kshortMinDCAPosToPv) || (std::abs(kshort.dcanegtopv()) < kshortSelections.kshortMinDCANegToPv))
518+
return false;
519519

520-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 6.);
521-
if ((kshort.v0radius() < kshortSelections.kshortMinv0radius) || (kshort.v0radius() > kshortSelections.kshortMaxv0radius))
522-
return false;
520+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 6.);
521+
if ((kshort.v0radius() < kshortSelections.kshortMinv0radius) || (kshort.v0radius() > kshortSelections.kshortMaxv0radius))
522+
return false;
523523

524-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 7.);
525-
if ((kshort.z() < kshortSelections.kshortMinZ) || (kshort.z() > kshortSelections.kshortMaxZ))
526-
return false;
524+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 7.);
525+
if ((kshort.z() < kshortSelections.kshortMinZ) || (kshort.z() > kshortSelections.kshortMaxZ))
526+
return false;
527527

528-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 8.);
529-
if (std::abs(kshort.dcaV0daughters()) > kshortSelections.kshortMaxDCAV0Dau)
530-
return false;
528+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 8.);
529+
if (std::abs(kshort.dcaV0daughters()) > kshortSelections.kshortMaxDCAV0Dau)
530+
return false;
531531

532-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 9.);
533-
if (kshort.qtarm() < kshortSelections.kshortArmenterosCoefficient * std::abs(kshort.alpha()))
534-
return false;
532+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 9.);
533+
if (kshort.qtarm() < kshortSelections.kshortArmenterosCoefficient * std::abs(kshort.alpha()))
534+
return false;
535535

536-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 10.);
537-
if (kshort.v0cosPA() < kshortSelections.kshortMinv0cospa)
538-
return false;
536+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 10.);
537+
if (kshort.v0cosPA() < kshortSelections.kshortMinv0cospa)
538+
return false;
539539

540-
auto posTrackKShort = kshort.template posTrackExtra_as<dauTracks>();
541-
auto negTrackKShort = kshort.template negTrackExtra_as<dauTracks>();
540+
auto posTrackKShort = kshort.template posTrackExtra_as<dauTracks>();
541+
auto negTrackKShort = kshort.template negTrackExtra_as<dauTracks>();
542542

543-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 11.);
544-
if ((posTrackKShort.tpcCrossedRows() < kshortSelections.kshortMinTPCCrossedRows) || (negTrackKShort.tpcCrossedRows() < kshortSelections.kshortMinTPCCrossedRows))
545-
return false;
543+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 11.);
544+
if ((posTrackKShort.tpcCrossedRows() < kshortSelections.kshortMinTPCCrossedRows) || (negTrackKShort.tpcCrossedRows() < kshortSelections.kshortMinTPCCrossedRows))
545+
return false;
546546

547-
// MinITSCls
548-
bool posIsFromAfterburner = posTrackKShort.itsChi2PerNcl() < 0;
549-
bool negIsFromAfterburner = negTrackKShort.itsChi2PerNcl() < 0;
547+
// MinITSCls
548+
bool posIsFromAfterburner = posTrackKShort.itsChi2PerNcl() < 0;
549+
bool negIsFromAfterburner = negTrackKShort.itsChi2PerNcl() < 0;
550550

551-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 12.);
552-
if (posTrackKShort.itsNCls() < kshortSelections.kshortMinITSclusters && (!kshortSelections.kshortRejectPosITSafterburner || posIsFromAfterburner))
553-
return false;
554-
if (negTrackKShort.itsNCls() < kshortSelections.kshortMinITSclusters && (!kshortSelections.kshortRejectNegITSafterburner || negIsFromAfterburner))
555-
return false;
551+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 12.);
552+
if (posTrackKShort.itsNCls() < kshortSelections.kshortMinITSclusters && (!kshortSelections.kshortRejectPosITSafterburner || posIsFromAfterburner))
553+
return false;
554+
if (negTrackKShort.itsNCls() < kshortSelections.kshortMinITSclusters && (!kshortSelections.kshortRejectNegITSafterburner || negIsFromAfterburner))
555+
return false;
556556

557-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 13.);
558-
float fKShortLifeTime = kshort.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short;
559-
if (fKShortLifeTime > kshortSelections.kshortMaxLifeTime)
560-
return false;
557+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 13.);
558+
float fKShortLifeTime = kshort.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short;
559+
if (fKShortLifeTime > kshortSelections.kshortMaxLifeTime)
560+
return false;
561561

562-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 14.);
563-
// TPC PID selection on the K0S pion daughters (same convention as posTrackKShort.tpcNSigmaPi())
564-
if (((std::abs(posTrackKShort.tpcNSigmaPi()) > kshortSelections.kshortMaxTPCNSigmas) ||
565-
(std::abs(negTrackKShort.tpcNSigmaPi()) > kshortSelections.kshortMaxTPCNSigmas)))
566-
return false;
562+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 14.);
563+
// TPC PID selection on the K0S pion daughters (same convention as posTrackKShort.tpcNSigmaPi())
564+
if (((std::abs(posTrackKShort.tpcNSigmaPi()) > kshortSelections.kshortMaxTPCNSigmas) ||
565+
(std::abs(negTrackKShort.tpcNSigmaPi()) > kshortSelections.kshortMaxTPCNSigmas)))
566+
return false;
567567

568-
histos.fill(HIST("KShortSel/hSelectionStatistics"), 15.);
569-
}
568+
histos.fill(HIST("KShortSel/hSelectionStatistics"), 15.);
570569
return true;
571570
}
572571

0 commit comments

Comments
 (0)