From e6f0540f647dea424526dd4a840a16f602d4bcf1 Mon Sep 17 00:00:00 2001 From: ariffero Date: Fri, 7 Feb 2025 10:50:10 +0100 Subject: [PATCH 1/9] Add finer pt binning histo --- PWGUD/Tasks/FwdMuonsUPC.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index b35a2d8167c..e6044242387 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -237,9 +237,20 @@ struct FwdMuonsUPC { 0.60, 0.70, 0.80, 0.90, 1.00, 1.20, 1.40, 1.60, 1.80, 2.00, 2.50, 3.00, 3.50}; + std::vector ptFitBinningHalfWidth = { + 0.00, 0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045, 0.05, + 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.10, + 0.105, 0.11, 0.115, 0.12, 0.125, 0.13, 0.135, 0.14, 0.145, 0.15, + 0.1625, 0.175, 0.1875, 0.20, 0.225, 0.25, 0.275, 0.30, 0.35, 0.40, + 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, + 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.25, + 2.50, 2.75, 3.00, 3.25, 3.50 + }; + // axis const AxisSpec axisPt{nBinsPt, lowPt, highPt, "#it{p}_{T} GeV/#it{c}"}; const AxisSpec axisPtFit = {ptFitBinning, "#it{p}_{T} (GeV/c)"}; + const AxisSpec axisPtFit2 = {ptFitBinningHalfWidth, "#it{p}_{T} (GeV/c)"}; const AxisSpec axisMass{nBinsMass, lowMass, highMass, "m_{#mu#mu} GeV/#it{c}^{2}"}; const AxisSpec axisEta{nBinsEta, lowEta, highEta, "#eta"}; const AxisSpec axisRapidity{nBinsRapidity, lowRapidity, highRapidity, "Rapidity"}; @@ -256,6 +267,7 @@ struct FwdMuonsUPC { registry.add("hMass", "Invariant mass of muon pairs;;#counts", kTH1D, {axisMass}); registry.add("hPt", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPt}); registry.add("hPtFit", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit}); + registry.add("hPtFit2", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit2}); registry.add("hEta", "Pseudorapidty of muon pairs;;#counts", kTH1D, {axisEta}); registry.add("hRapidity", "Rapidty of muon pairs;;#counts", kTH1D, {axisRapidity}); registry.add("hPhi", "#varphi of muon pairs;;#counts", kTH1D, {axisPhi}); @@ -314,6 +326,7 @@ struct FwdMuonsUPC { mcRecoRegistry.add("hMass", "Invariant mass of muon pairs;;#counts", kTH1D, {axisMass}); mcRecoRegistry.add("hPt", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPt}); mcRecoRegistry.add("hPtFit", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit}); + mcRecoRegistry.add("hPtFit2", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit2}); mcRecoRegistry.add("hEta", "Pseudorapidty of muon pairs;;#counts", kTH1D, {axisEta}); mcRecoRegistry.add("hRapidity", "Rapidty of muon pairs;;#counts", kTH1D, {axisRapidity}); mcRecoRegistry.add("hPhi", "#varphi of muon pairs;;#counts", kTH1D, {axisPhi}); @@ -615,6 +628,7 @@ struct FwdMuonsUPC { registry.fill(HIST("hMass"), p.M()); registry.fill(HIST("hPt"), p.Pt()); registry.fill(HIST("hPtFit"), p.Pt()); + registry.fill(HIST("hPtFit2"), p.Pt()); registry.fill(HIST("hEta"), p.Eta()); registry.fill(HIST("hRapidity"), p.Rapidity()); registry.fill(HIST("hPhi"), p.Phi()); @@ -812,6 +826,7 @@ struct FwdMuonsUPC { mcRecoRegistry.fill(HIST("hMass"), p.M()); mcRecoRegistry.fill(HIST("hPt"), p.Pt()); mcRecoRegistry.fill(HIST("hPtFit"), p.Pt()); + mcRecoRegistry.fill(HIST("hPtFit2"), p.Pt()); mcRecoRegistry.fill(HIST("hEta"), p.Eta()); mcRecoRegistry.fill(HIST("hRapidity"), p.Rapidity()); mcRecoRegistry.fill(HIST("hPhi"), p.Phi()); From 34611b4ba62850b38576b7757ccfce0ace479e42 Mon Sep 17 00:00:00 2001 From: ariffero Date: Thu, 6 Mar 2025 10:40:55 +0100 Subject: [PATCH 2/9] Modify names of saved gen varaibles. The names of the varaibles in the gen tree are now the same as the name of the gen varaibles in the reco tree. --- PWGUD/Tasks/FwdMuonsUPC.cxx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index e6044242387..a61f975cdab 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -86,28 +86,28 @@ DECLARE_SOA_TABLE(DiMu, "AOD", "DIMU", namespace gendimu { // dimuon -DECLARE_SOA_COLUMN(M, m, float); -DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(Rap, rap, float); -DECLARE_SOA_COLUMN(Phi, phi, float); -DECLARE_SOA_COLUMN(PhiAv, phiAv, float); -DECLARE_SOA_COLUMN(PhiCh, phiCh, float); +DECLARE_SOA_COLUMN(GenM, genM, float); +DECLARE_SOA_COLUMN(GenPt, genPt, float); +DECLARE_SOA_COLUMN(GenRap, genRap, float); +DECLARE_SOA_COLUMN(GenPhi, genPhi, float); +DECLARE_SOA_COLUMN(GenPhiAv, genPhiAv, float); +DECLARE_SOA_COLUMN(GenPhiCh, genPhiCh, float); // tracks positive (p) and negative (n) -DECLARE_SOA_COLUMN(Ptp, ptp, float); -DECLARE_SOA_COLUMN(Etap, etap, float); -DECLARE_SOA_COLUMN(Phip, phip, float); -DECLARE_SOA_COLUMN(Ptn, ptn, float); -DECLARE_SOA_COLUMN(Etan, etan, float); -DECLARE_SOA_COLUMN(Phin, phin, float); +DECLARE_SOA_COLUMN(GenPtp, genPtp, float); +DECLARE_SOA_COLUMN(GenEtap, genEtap, float); +DECLARE_SOA_COLUMN(GenPhip, genPhip, float); +DECLARE_SOA_COLUMN(GenPtn, genPtn, float); +DECLARE_SOA_COLUMN(GenEtan, genEtan, float); +DECLARE_SOA_COLUMN(GenPhin, genPhin, float); } // namespace gendimu namespace o2::aod { DECLARE_SOA_TABLE(GenDimu, "AOD", "GENDIMU", - gendimu::M, gendimu::Pt, gendimu::Rap, gendimu::Phi, - gendimu::PhiAv, gendimu::PhiCh, - gendimu::Ptp, gendimu::Etap, gendimu::Phip, - gendimu::Ptn, gendimu::Etan, gendimu::Phin); + gendimu::GenM, gendimu::GenPt, gendimu::GenRap, gendimu::GenPhi, + gendimu::GenPhiAv, gendimu::GenPhiCh, + gendimu::GenPtp, gendimu::GenEtap, gendimu::GenPhip, + gendimu::GenPtn, gendimu::GenEtan, gendimu::GenPhin); } // namespace o2::aod // for saving tree with info on reco MC From 96b879f82c6260104c9a54f1627b7067b53c7bb6 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Fri, 28 Mar 2025 13:13:30 +0000 Subject: [PATCH 3/9] Please consider the following formatting changes --- PWGUD/Tasks/FwdMuonsUPC.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index a61f975cdab..ee5e578161c 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -86,17 +86,17 @@ DECLARE_SOA_TABLE(DiMu, "AOD", "DIMU", namespace gendimu { // dimuon -DECLARE_SOA_COLUMN(GenM, genM, float); -DECLARE_SOA_COLUMN(GenPt, genPt, float); -DECLARE_SOA_COLUMN(GenRap, genRap, float); -DECLARE_SOA_COLUMN(GenPhi, genPhi, float); +DECLARE_SOA_COLUMN(GenM, genM, float); +DECLARE_SOA_COLUMN(GenPt, genPt, float); +DECLARE_SOA_COLUMN(GenRap, genRap, float); +DECLARE_SOA_COLUMN(GenPhi, genPhi, float); DECLARE_SOA_COLUMN(GenPhiAv, genPhiAv, float); DECLARE_SOA_COLUMN(GenPhiCh, genPhiCh, float); // tracks positive (p) and negative (n) -DECLARE_SOA_COLUMN(GenPtp, genPtp, float); +DECLARE_SOA_COLUMN(GenPtp, genPtp, float); DECLARE_SOA_COLUMN(GenEtap, genEtap, float); DECLARE_SOA_COLUMN(GenPhip, genPhip, float); -DECLARE_SOA_COLUMN(GenPtn, genPtn, float); +DECLARE_SOA_COLUMN(GenPtn, genPtn, float); DECLARE_SOA_COLUMN(GenEtan, genEtan, float); DECLARE_SOA_COLUMN(GenPhin, genPhin, float); } // namespace gendimu @@ -104,10 +104,10 @@ DECLARE_SOA_COLUMN(GenPhin, genPhin, float); namespace o2::aod { DECLARE_SOA_TABLE(GenDimu, "AOD", "GENDIMU", - gendimu::GenM, gendimu::GenPt, gendimu::GenRap, gendimu::GenPhi, + gendimu::GenM, gendimu::GenPt, gendimu::GenRap, gendimu::GenPhi, gendimu::GenPhiAv, gendimu::GenPhiCh, - gendimu::GenPtp, gendimu::GenEtap, gendimu::GenPhip, - gendimu::GenPtn, gendimu::GenEtan, gendimu::GenPhin); + gendimu::GenPtp, gendimu::GenEtap, gendimu::GenPhip, + gendimu::GenPtn, gendimu::GenEtan, gendimu::GenPhin); } // namespace o2::aod // for saving tree with info on reco MC @@ -244,8 +244,7 @@ struct FwdMuonsUPC { 0.1625, 0.175, 0.1875, 0.20, 0.225, 0.25, 0.275, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.25, - 2.50, 2.75, 3.00, 3.25, 3.50 - }; + 2.50, 2.75, 3.00, 3.25, 3.50}; // axis const AxisSpec axisPt{nBinsPt, lowPt, highPt, "#it{p}_{T} GeV/#it{c}"}; From 61b5bf132b60a11e1daca7b01cd3ec17659ed35b Mon Sep 17 00:00:00 2001 From: ariffero Date: Mon, 19 May 2025 16:22:01 +0200 Subject: [PATCH 4/9] Add track type Add myTrackType as configurable to allow the selection of MCH-MID(3) or MFT-MCH-MID(0) tracks. --- PWGUD/Tasks/FwdMuonsUPC.cxx | 92 ++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index ee5e578161c..3747848ca62 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -56,6 +56,7 @@ DECLARE_SOA_COLUMN(Pzp, pzp, float); DECLARE_SOA_COLUMN(Ptp, ptp, float); DECLARE_SOA_COLUMN(Etap, etap, float); DECLARE_SOA_COLUMN(Phip, phip, float); +DECLARE_SOA_COLUMN(TrackTypep, tracktypep, int); DECLARE_SOA_COLUMN(EnergyN, energyN, float); DECLARE_SOA_COLUMN(Pxn, pxn, float); DECLARE_SOA_COLUMN(Pyn, pyn, float); @@ -63,6 +64,7 @@ DECLARE_SOA_COLUMN(Pzn, pzn, float); DECLARE_SOA_COLUMN(Ptn, ptn, float); DECLARE_SOA_COLUMN(Etan, etan, float); DECLARE_SOA_COLUMN(Phin, phin, float); +DECLARE_SOA_COLUMN(TrackTypen, tracktypen, int); // zn DECLARE_SOA_COLUMN(Tzna, tzna, float); DECLARE_SOA_COLUMN(Ezna, ezna, float); @@ -77,8 +79,8 @@ DECLARE_SOA_TABLE(DiMu, "AOD", "DIMU", dimu::RunNumber, dimu::M, dimu::Energy, dimu::Px, dimu::Py, dimu::Pz, dimu::Pt, dimu::Rap, dimu::Phi, dimu::PhiAv, dimu::PhiCh, - dimu::EnergyP, dimu::Pxp, dimu::Pyp, dimu::Pzp, dimu::Ptp, dimu::Etap, dimu::Phip, - dimu::EnergyN, dimu::Pxn, dimu::Pyn, dimu::Pzn, dimu::Ptn, dimu::Etan, dimu::Phin, + dimu::EnergyP, dimu::Pxp, dimu::Pyp, dimu::Pzp, dimu::Ptp, dimu::Etap, dimu::Phip, dimu::TrackTypep, + dimu::EnergyN, dimu::Pxn, dimu::Pyn, dimu::Pzn, dimu::Ptn, dimu::Etan, dimu::Phin, dimu::TrackTypen, dimu::Tzna, dimu::Ezna, dimu::Tznc, dimu::Eznc, dimu::Nclass); } // namespace o2::aod @@ -125,9 +127,11 @@ DECLARE_SOA_COLUMN(PhiCh, phiCh, float); DECLARE_SOA_COLUMN(Ptp, ptp, float); DECLARE_SOA_COLUMN(Etap, etap, float); DECLARE_SOA_COLUMN(Phip, phip, float); +DECLARE_SOA_COLUMN(TrackTypep, tracktypep, int); DECLARE_SOA_COLUMN(Ptn, ptn, float); DECLARE_SOA_COLUMN(Etan, etan, float); DECLARE_SOA_COLUMN(Phin, phin, float); +DECLARE_SOA_COLUMN(TrackTypen, tracktypen, int); // gen info dimuon DECLARE_SOA_COLUMN(GenPt, genPt, float); DECLARE_SOA_COLUMN(GenRap, genRap, float); @@ -147,8 +151,8 @@ DECLARE_SOA_TABLE(RecoDimu, "AOD", "RECODIMU", recodimu::RunNumber, recodimu::M, recodimu::Pt, recodimu::Rap, recodimu::Phi, recodimu::PhiAv, recodimu::PhiCh, - recodimu::Ptp, recodimu::Etap, recodimu::Phip, - recodimu::Ptn, recodimu::Etan, recodimu::Phin, + recodimu::Ptp, recodimu::Etap, recodimu::Phip, recodimu::TrackTypep, + recodimu::Ptn, recodimu::Etan, recodimu::Phin, recodimu::TrackTypen, recodimu::GenPt, recodimu::GenRap, recodimu::GenPhi, recodimu::GenPtp, recodimu::GenEtap, recodimu::GenPhip, recodimu::GenPtn, recodimu::GenEtan, recodimu::GenPhin); @@ -164,8 +168,8 @@ const float kRAbsMid = 26.5; const float kRAbsMax = 89.5; const float kPDca1 = 200.; const float kPDca2 = 200.; -const float kEtaMin = -4.0; -const float kEtaMax = -2.5; +float kEtaMin = -4.0; +float kEtaMax = -2.5; const float kPtMin = 0.; struct FwdMuonsUPC { @@ -227,6 +231,10 @@ struct FwdMuonsUPC { Configurable nBinsZDCen{"nBinsZDCen", 200, "N bins in ZN energy"}; Configurable lowEnZN{"lowEnZN", -50., "lower limit in ZN energy histo"}; Configurable highEnZN{"highEnZN", 250., "upper limit in ZN energy histo"}; + // my track type + // 0 = MCH-MID-MFT + // 1 = MCH-MID + Configurable myTrackType{"myTrackType",3,"My track type"}; void init(InitContext&) { @@ -459,7 +467,7 @@ struct FwdMuonsUPC { float eta = p.Eta(); float pt = p.Pt(); float pDcaMax = rAbs < kRAbsMid ? kPDca1 : kPDca2; - + LOGF(info,"eta min = %f",kEtaMin); if (eta < kEtaMin || eta > kEtaMax) return false; if (pt < kPtMin) @@ -521,12 +529,6 @@ struct FwdMuonsUPC { return; } - // track selection - if (!isMuonSelected(*tr1)) - return; - if (!isMuonSelected(*tr2)) - return; - // MCH-MID match selection int nMIDs = 0; if (tr1.chi2MatchMCHMID() > 0) @@ -536,6 +538,27 @@ struct FwdMuonsUPC { if (nMIDs != 2) return; + // MFT-MID match selection (if MFT is requested by the trackType) + if(myTrackType==0){ + // if MFT is requested check that the tracks is inside the MFT acceptance + kEtaMin = -3.6; + kEtaMax = -2.5; + + int nMFT = 0; + if(tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) + nMFT++; + if(tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) + nMFT++; + if(nMFT != 2) + return; + } + + // track selection + if (!isMuonSelected(*tr1)) + return; + if (!isMuonSelected(*tr2)) + return; + // form Lorentz vectors TLorentzVector p1, p2; auto mMu = particleMass(13); @@ -641,15 +664,15 @@ struct FwdMuonsUPC { dimuSel(cand.runNumber(), p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), - p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), + p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, + p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); } else { dimuSel(cand.runNumber(), p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), - p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), + p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, + p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); } } @@ -749,12 +772,6 @@ struct FwdMuonsUPC { return; } - // track selection - if (!isMuonSelected(*tr1)) - return; - if (!isMuonSelected(*tr2)) - return; - // MCH-MID match selection int nMIDs = 0; if (tr1.chi2MatchMCHMID() > 0) @@ -764,6 +781,27 @@ struct FwdMuonsUPC { if (nMIDs != 2) return; + // MFT-MID match selection (if MFT is requested by the trackType) + if(myTrackType==0){ + // if MFT is requested check that the tracks is inside the MFT acceptance + kEtaMin = -3.6; + kEtaMax = -2.5; + + int nMFT = 0; + if(tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) + nMFT++; + if(tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) + nMFT++; + if(nMFT != 2) + return; + } + + // track selection + if (!isMuonSelected(*tr1)) + return; + if (!isMuonSelected(*tr2)) + return; + // form Lorentz vectors TLorentzVector p1, p2; auto mMu = particleMass(13); @@ -859,8 +897,8 @@ struct FwdMuonsUPC { dimuReco(cand.runNumber(), p.M(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p1.Pt(), p1.PseudoRapidity(), p1.Phi(), - p2.Pt(), p2.PseudoRapidity(), p2.Phi(), + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, // gen info pMc.Pt(), pMc.Rapidity(), pMc.Phi(), p1Mc.Pt(), p1Mc.PseudoRapidity(), p1Mc.Phi(), @@ -869,8 +907,8 @@ struct FwdMuonsUPC { dimuReco(cand.runNumber(), p.M(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p2.Pt(), p2.PseudoRapidity(), p2.Phi(), - p1.Pt(), p1.PseudoRapidity(), p1.Phi(), + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, // gen info pMc.Pt(), pMc.Rapidity(), pMc.Phi(), p2Mc.Pt(), p2Mc.PseudoRapidity(), p2Mc.Phi(), From d68828d5babaf50c936bd94272365d6d0b3b728a Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 21 May 2025 13:03:40 +0000 Subject: [PATCH 5/9] Please consider the following formatting changes --- PWGUD/Tasks/FwdMuonsUPC.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index 3747848ca62..80190d12346 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -234,7 +234,7 @@ struct FwdMuonsUPC { // my track type // 0 = MCH-MID-MFT // 1 = MCH-MID - Configurable myTrackType{"myTrackType",3,"My track type"}; + Configurable myTrackType{"myTrackType", 3, "My track type"}; void init(InitContext&) { @@ -467,7 +467,7 @@ struct FwdMuonsUPC { float eta = p.Eta(); float pt = p.Pt(); float pDcaMax = rAbs < kRAbsMid ? kPDca1 : kPDca2; - LOGF(info,"eta min = %f",kEtaMin); + LOGF(info, "eta min = %f", kEtaMin); if (eta < kEtaMin || eta > kEtaMax) return false; if (pt < kPtMin) @@ -539,17 +539,17 @@ struct FwdMuonsUPC { return; // MFT-MID match selection (if MFT is requested by the trackType) - if(myTrackType==0){ + if (myTrackType == 0) { // if MFT is requested check that the tracks is inside the MFT acceptance kEtaMin = -3.6; kEtaMax = -2.5; int nMFT = 0; - if(tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) + if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) nMFT++; - if(tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) + if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) nMFT++; - if(nMFT != 2) + if (nMFT != 2) return; } @@ -782,17 +782,17 @@ struct FwdMuonsUPC { return; // MFT-MID match selection (if MFT is requested by the trackType) - if(myTrackType==0){ + if (myTrackType == 0) { // if MFT is requested check that the tracks is inside the MFT acceptance kEtaMin = -3.6; kEtaMax = -2.5; int nMFT = 0; - if(tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) + if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) nMFT++; - if(tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) + if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) nMFT++; - if(nMFT != 2) + if (nMFT != 2) return; } From 7ee5101f82eac2b7b5d3fb193a635acb49d17a5d Mon Sep 17 00:00:00 2001 From: ariffero Date: Wed, 21 May 2025 15:26:17 +0200 Subject: [PATCH 6/9] Fix MegaLinter errors --- PWGUD/Tasks/FwdMuonsUPC.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index 80190d12346..d8fb035d7d3 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -664,15 +664,15 @@ struct FwdMuonsUPC { dimuSel(cand.runNumber(), p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, - p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, + p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), + p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); } else { dimuSel(cand.runNumber(), p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, - p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, + p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), + p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); } } @@ -897,8 +897,8 @@ struct FwdMuonsUPC { dimuReco(cand.runNumber(), p.M(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, - p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), // gen info pMc.Pt(), pMc.Rapidity(), pMc.Phi(), p1Mc.Pt(), p1Mc.PseudoRapidity(), p1Mc.Phi(), @@ -907,8 +907,8 @@ struct FwdMuonsUPC { dimuReco(cand.runNumber(), p.M(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p2.Pt(), p2.PseudoRapidity(), p2.Phi(), (int)myTrackType, - p1.Pt(), p1.PseudoRapidity(), p1.Phi(), (int)myTrackType, + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), // gen info pMc.Pt(), pMc.Rapidity(), pMc.Phi(), p2Mc.Pt(), p2Mc.PseudoRapidity(), p2Mc.Phi(), From d65a7560c929f08d968c3e6f2acc00b039eafedc Mon Sep 17 00:00:00 2001 From: ariffero Date: Thu, 22 May 2025 10:51:24 +0200 Subject: [PATCH 7/9] Remove debug LOGF --- PWGUD/Tasks/FwdMuonsUPC.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index d8fb035d7d3..4ea4e074efd 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -467,7 +467,7 @@ struct FwdMuonsUPC { float eta = p.Eta(); float pt = p.Pt(); float pDcaMax = rAbs < kRAbsMid ? kPDca1 : kPDca2; - LOGF(info, "eta min = %f", kEtaMin); + if (eta < kEtaMin || eta > kEtaMax) return false; if (pt < kPtMin) From cf72014da814e884a3c1b0fc8fc2d9c7522f247e Mon Sep 17 00:00:00 2001 From: ariffero Date: Thu, 22 May 2025 11:17:03 +0200 Subject: [PATCH 8/9] Use lowerCamelCase for getters --- PWGUD/Tasks/FwdMuonsUPC.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index 4ea4e074efd..e3bbc7ab561 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -56,7 +56,7 @@ DECLARE_SOA_COLUMN(Pzp, pzp, float); DECLARE_SOA_COLUMN(Ptp, ptp, float); DECLARE_SOA_COLUMN(Etap, etap, float); DECLARE_SOA_COLUMN(Phip, phip, float); -DECLARE_SOA_COLUMN(TrackTypep, tracktypep, int); +DECLARE_SOA_COLUMN(TrackTypep, trackTypep, int); DECLARE_SOA_COLUMN(EnergyN, energyN, float); DECLARE_SOA_COLUMN(Pxn, pxn, float); DECLARE_SOA_COLUMN(Pyn, pyn, float); @@ -64,7 +64,7 @@ DECLARE_SOA_COLUMN(Pzn, pzn, float); DECLARE_SOA_COLUMN(Ptn, ptn, float); DECLARE_SOA_COLUMN(Etan, etan, float); DECLARE_SOA_COLUMN(Phin, phin, float); -DECLARE_SOA_COLUMN(TrackTypen, tracktypen, int); +DECLARE_SOA_COLUMN(TrackTypen, trackTypen, int); // zn DECLARE_SOA_COLUMN(Tzna, tzna, float); DECLARE_SOA_COLUMN(Ezna, ezna, float); @@ -127,11 +127,11 @@ DECLARE_SOA_COLUMN(PhiCh, phiCh, float); DECLARE_SOA_COLUMN(Ptp, ptp, float); DECLARE_SOA_COLUMN(Etap, etap, float); DECLARE_SOA_COLUMN(Phip, phip, float); -DECLARE_SOA_COLUMN(TrackTypep, tracktypep, int); +DECLARE_SOA_COLUMN(TrackTypep, trackTypep, int); DECLARE_SOA_COLUMN(Ptn, ptn, float); DECLARE_SOA_COLUMN(Etan, etan, float); DECLARE_SOA_COLUMN(Phin, phin, float); -DECLARE_SOA_COLUMN(TrackTypen, tracktypen, int); +DECLARE_SOA_COLUMN(TrackTypen, trackTypen, int); // gen info dimuon DECLARE_SOA_COLUMN(GenPt, genPt, float); DECLARE_SOA_COLUMN(GenRap, genRap, float); From 993d58c64eff68076e6933f17ccc491206fc7670 Mon Sep 17 00:00:00 2001 From: ariffero Date: Thu, 22 May 2025 11:28:54 +0200 Subject: [PATCH 9/9] Avoid magic numbers --- PWGUD/Tasks/FwdMuonsUPC.cxx | 54 +++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/PWGUD/Tasks/FwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx index e3bbc7ab561..0c4b3d81e3b 100644 --- a/PWGUD/Tasks/FwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -172,6 +172,14 @@ float kEtaMin = -4.0; float kEtaMax = -2.5; const float kPtMin = 0.; +const float kMaxAmpV0A = 100.; +const int kReqMatchMIDTracks = 2; +const int kReqMatchMFTTracks = 2; +const int kMaxChi2MFTMatch = 30; +const float kMaxZDCTime = 2.; +const float kMaxZDCTimeHisto = 10.; +const int kMuonPDG = 13; + struct FwdMuonsUPC { // a pdg object @@ -462,7 +470,7 @@ struct FwdMuonsUPC { float rAbs = fwdTrack.rAtAbsorberEnd(); float pDca = fwdTrack.pDca(); TLorentzVector p; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p.SetXYZM(fwdTrack.px(), fwdTrack.py(), fwdTrack.pz(), mMu); float eta = p.Eta(); float pt = p.Pt(); @@ -482,18 +490,18 @@ struct FwdMuonsUPC { // function to compute phi for azimuth anisotropy void computePhiAnis(TLorentzVector p1, TLorentzVector p2, int sign1, float& phiAverage, float& phiCharge) { - TLorentzVector tSum, tDiffAv, tDiffCh; tSum = p1 + p2; + float halfUnity = 0.5; if (sign1 > 0) { tDiffCh = p1 - p2; - if (gRandom->Rndm() > 0.5) + if (gRandom->Rndm() > halfUnity) tDiffAv = p1 - p2; else tDiffAv = p2 - p1; } else { tDiffCh = p2 - p1; - if (gRandom->Rndm() > 0.5) + if (gRandom->Rndm() > halfUnity) tDiffAv = p2 - p1; else tDiffAv = p1 - p2; @@ -518,7 +526,7 @@ struct FwdMuonsUPC { const auto& ampsRelBCsV0A = cand.ampRelBCsV0A(); for (unsigned int i = 0; i < ampsV0A.size(); ++i) { if (std::abs(ampsRelBCsV0A[i]) <= 1) { - if (ampsV0A[i] > 100.) + if (ampsV0A[i] > kMaxAmpV0A) return; } } @@ -535,7 +543,7 @@ struct FwdMuonsUPC { nMIDs++; if (tr2.chi2MatchMCHMID() > 0) nMIDs++; - if (nMIDs != 2) + if (nMIDs != kReqMatchMIDTracks) return; // MFT-MID match selection (if MFT is requested by the trackType) @@ -545,11 +553,11 @@ struct FwdMuonsUPC { kEtaMax = -2.5; int nMFT = 0; - if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) + if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch) nMFT++; - if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) + if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch) nMFT++; - if (nMFT != 2) + if (nMFT != kReqMatchMFTTracks) return; } @@ -561,7 +569,7 @@ struct FwdMuonsUPC { // form Lorentz vectors TLorentzVector p1, p2; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu); p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu); TLorentzVector p = p1 + p2; @@ -589,9 +597,9 @@ struct FwdMuonsUPC { computePhiAnis(p1, p2, tr1.sign(), phiAverage, phiCharge); // zdc info - if (std::abs(zdc.timeA) < 10) + if (std::abs(zdc.timeA) < kMaxZDCTimeHisto) registry.fill(HIST("hTimeZNA"), zdc.timeA); - if (std::abs(zdc.timeC) < 10) + if (std::abs(zdc.timeC) < kMaxZDCTimeHisto) registry.fill(HIST("hTimeZNC"), zdc.timeC); registry.fill(HIST("hEnergyZN"), zdc.enA, zdc.enC); @@ -600,9 +608,9 @@ struct FwdMuonsUPC { bool neutronC = false; int znClass = -1; - if (std::abs(zdc.timeA) < 2) + if (std::abs(zdc.timeA) < kMaxZDCTime) neutronA = true; - if (std::abs(zdc.timeC) < 2) + if (std::abs(zdc.timeC) < kMaxZDCTime) neutronC = true; if (std::isinf(zdc.timeC)) @@ -684,12 +692,12 @@ struct FwdMuonsUPC { { // check that all pairs are mu+mu- - if (std::abs(McPart1.pdgCode()) != 13 && std::abs(McPart2.pdgCode()) != 13) + if (std::abs(McPart1.pdgCode()) != kMuonPDG && std::abs(McPart2.pdgCode()) != kMuonPDG) LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode()); // create Lorentz vectors TLorentzVector p1, p2; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p1.SetXYZM(McPart1.px(), McPart1.py(), McPart1.pz(), mMu); p2.SetXYZM(McPart2.px(), McPart2.py(), McPart2.pz(), mMu); TLorentzVector p = p1 + p2; @@ -753,7 +761,7 @@ struct FwdMuonsUPC { { // check that all pairs are mu+mu- - if (std::abs(McPart1.pdgCode()) != 13 && std::abs(McPart2.pdgCode()) != 13) + if (std::abs(McPart1.pdgCode()) != kMuonPDG && std::abs(McPart2.pdgCode()) != kMuonPDG) LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode()); // V0 selection @@ -761,7 +769,7 @@ struct FwdMuonsUPC { const auto& ampsRelBCsV0A = cand.ampRelBCsV0A(); for (unsigned int i = 0; i < ampsV0A.size(); ++i) { if (std::abs(ampsRelBCsV0A[i]) <= 1) { - if (ampsV0A[i] > 100.) + if (ampsV0A[i] > kMaxAmpV0A) return; } } @@ -778,7 +786,7 @@ struct FwdMuonsUPC { nMIDs++; if (tr2.chi2MatchMCHMID() > 0) nMIDs++; - if (nMIDs != 2) + if (nMIDs != kReqMatchMIDTracks) return; // MFT-MID match selection (if MFT is requested by the trackType) @@ -788,11 +796,11 @@ struct FwdMuonsUPC { kEtaMax = -2.5; int nMFT = 0; - if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < 30) + if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch) nMFT++; - if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < 30) + if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch) nMFT++; - if (nMFT != 2) + if (nMFT != kReqMatchMFTTracks) return; } @@ -804,7 +812,7 @@ struct FwdMuonsUPC { // form Lorentz vectors TLorentzVector p1, p2; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu); p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu); TLorentzVector p = p1 + p2;