Skip to content

Commit 9a93859

Browse files
committed
Improve code
1 parent 2343113 commit 9a93859

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

Tutorials/PWGHF/skimCreatorMini.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ struct HfSkimCreatorMiniTagSelTracks {
5050
Produces<aod::HfTSelTrack> rowSelectedTrack;
5151

5252
// 2-prong cuts
53-
Configurable<float> ptTrackMin{"ptTrackMin", 0.3f, "min. track pT for 2 prong candidate [GeV/c]"};
54-
Configurable<float> etaTrackMax{"etaTrackMax", 0.8f, "max. pseudorapidity for 2 prong candidate"};
55-
Configurable<float> dcaTrackMin{"dcaTrackMin", 0.0025f, "min. DCA for 2 prong candidate [cm]"};
53+
Configurable<float> ptTrackMin{"ptTrackMin", 0.3f, "Min. track pT for 2-prong candidate [GeV/c]"};
54+
Configurable<float> etaTrackMax{"etaTrackMax", 0.8f, "Max. pseudorapidity for 2-prong candidate"};
55+
Configurable<float> dcaTrackMin{"dcaTrackMin", 0.0025f, "Min. DCA for 2-prong candidate [cm]"};
5656

5757
using TracksWDcaSel = soa::Join<aod::Tracks, aod::TracksDCA, aod::TrackSelection>;
5858

@@ -141,7 +141,7 @@ struct HfSkimCreatorMini {
141141
registry.add("hVtx2ProngZ", "2-prong candidates;#it{z}_{sec. vtx.} (cm);entries", {HistType::kTH1F, {{1000, -20., 20.}}});
142142
registry.add("hMassD0ToPiK", "D^{0} candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}});
143143

144-
// Configure the vertexer
144+
// Configure the vertexer.
145145
fitter.setBz(magneticField);
146146
fitter.setPropagateToPCA(propagateToPCA);
147147
fitter.setMaxR(maxR);
@@ -177,11 +177,11 @@ struct HfSkimCreatorMini {
177177
if (nVtxFromFitter == 0) {
178178
continue;
179179
}
180-
// get secondary vertex
180+
// get secondary vertex
181181
const auto& secondaryVertex = fitter.getPCACandidate();
182182
// get track momenta
183-
std::array<float, 3> pVec0;
184-
std::array<float, 3> pVec1;
183+
std::array<float, 3> pVec0{};
184+
std::array<float, 3> pVec1{};
185185
fitter.getTrack(0).getPxPyPzGlo(pVec0);
186186
fitter.getTrack(1).getPxPyPzGlo(pVec1);
187187

@@ -195,8 +195,8 @@ struct HfSkimCreatorMini {
195195
registry.fill(HIST("hVtx2ProngZ"), secondaryVertex[2]);
196196
const std::array arrayMomenta{pVec0, pVec1};
197197
const auto massPiK{RecoDecay::m(arrayMomenta, std::array{MassPiPlus, MassKPlus})};
198-
// const auto massKPi{RecoDecay::m(arrayMomenta, std::array{MassKPlus, MassPiPlus})};
199198
registry.fill(HIST("hMassD0ToPiK"), massPiK);
199+
// const auto massKPi{RecoDecay::m(arrayMomenta, std::array{MassKPlus, MassPiPlus})};
200200
// registry.fill(HIST("hMassD0ToPiK"), massKPi);
201201
}
202202
}

Tutorials/PWGHF/taskMini.cxx

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ struct HfTaskMiniCandidateCreator2Prong {
5656

5757
// vertexing parameters
5858
Configurable<float> magneticField{"magneticField", 5.f, "magnetic field [kG]"};
59-
Configurable<bool> propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"};
59+
Configurable<bool> propagateToPCA{"propagateToPCA", true, "Create tracks version propagated to PCA"};
6060
Configurable<bool> useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"};
61-
Configurable<float> maxR{"maxR", 200.f, "reject PCA's above this radius"};
62-
Configurable<float> maxDZIni{"maxDZIni", 4.f, "reject (if>0) PCA candidate if tracks DZ exceeds threshold"};
63-
Configurable<float> minParamChange{"minParamChange", 1.e-3f, "stop iterations if largest change of any X is smaller than this"};
64-
Configurable<float> minRelChi2Change{"minRelChi2Change", 0.9f, "stop iterations if chi2/chi2old > this"};
61+
Configurable<float> maxR{"maxR", 200.f, "Reject PCA's above this radius"};
62+
Configurable<float> maxDZIni{"maxDZIni", 4.f, "Reject (if>0) PCA candidate if tracks DZ exceeds threshold"};
63+
Configurable<float> minParamChange{"minParamChange", 1.e-3f, "Stop iterations if largest change of any X is smaller than this"};
64+
Configurable<float> minRelChi2Change{"minRelChi2Change", 0.9f, "Stop iterations if chi2/chi2old > this"};
6565

6666
o2::vertexing::DCAFitterN<2> fitter{}; // 2-prong vertex fitter
6767

@@ -71,9 +71,9 @@ struct HfTaskMiniCandidateCreator2Prong {
7171

7272
void init(InitContext&)
7373
{
74-
registry.add("hMass", "D^{0} candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}});
74+
registry.add("hMass", "D^{0} candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}});
7575

76-
// Configure the vertexer
76+
// Configure the vertexer.
7777
fitter.setBz(magneticField);
7878
fitter.setPropagateToPCA(propagateToPCA);
7979
fitter.setMaxR(maxR);
@@ -99,17 +99,15 @@ struct HfTaskMiniCandidateCreator2Prong {
9999
if (fitter.process(trackParVarPos1, trackParVarNeg1) == 0) {
100100
continue;
101101
}
102+
// get secondary vertex
102103
const auto& secondaryVertex = fitter.getPCACandidate();
103-
auto& trackParVar0{fitter.getTrack(0)};
104-
auto& trackParVar1{fitter.getTrack(1)};
105-
106104
// get track momenta
107105
std::array<float, 3> pVec0{};
108106
std::array<float, 3> pVec1{};
109-
trackParVar0.getPxPyPzGlo(pVec0);
110-
trackParVar1.getPxPyPzGlo(pVec1);
107+
fitter.getTrack(0).getPxPyPzGlo(pVec0);
108+
fitter.getTrack(1).getPxPyPzGlo(pVec1);
111109

112-
// fill candidate table rows
110+
// fill candidate table row
113111
rowCandidateBase(collision.globalIndex(),
114112
collision.posX(), collision.posY(), collision.posZ(),
115113
secondaryVertex[0], secondaryVertex[1], secondaryVertex[2],
@@ -121,8 +119,8 @@ struct HfTaskMiniCandidateCreator2Prong {
121119
// calculate invariant masses
122120
const std::array arrayMomenta{pVec0, pVec1};
123121
const auto massPiK{RecoDecay::m(arrayMomenta, std::array{MassPiPlus, MassKPlus})};
124-
// const auto massKPi{RecoDecay::m(arrayMomenta, std::array{MassKPlus, MassPiPlus})};
125122
registry.fill(HIST("hMass"), massPiK);
123+
// const auto massKPi{RecoDecay::m(arrayMomenta, std::array{MassKPlus, MassPiPlus})};
126124
// registry.fill(HIST("hMass"), massKPi);
127125
}
128126
}
@@ -141,15 +139,15 @@ struct HfTaskMiniCandidateCreator2ProngExpressions {
141139
struct HfTaskMiniCandidateSelectorD0 {
142140
Produces<aod::HfTSelD0> hfSelD0Candidate;
143141

144-
Configurable<float> ptCandMin{"ptCandMin", 0.f, "Lower bound of candidate pT"};
145-
Configurable<float> ptCandMax{"ptCandMax", 50.f, "Upper bound of candidate pT"};
142+
Configurable<float> ptCandMin{"ptCandMin", 0.f, "Min. candidate pT [GeV/c] "};
143+
Configurable<float> ptCandMax{"ptCandMax", 50.f, "Max. candidate pT [GeV/c]"};
146144
// TPC
147-
Configurable<float> ptPidTpcMin{"ptPidTpcMin", 0.15f, "Lower bound of track pT for TPC PID"};
148-
Configurable<float> ptPidTpcMax{"ptPidTpcMax", 5.f, "Upper bound of track pT for TPC PID"};
149-
Configurable<float> nSigmaTpcMax{"nSigmaTpcMax", 3.f, "Nsigma cut on TPC only"};
145+
Configurable<float> ptPidTpcMin{"ptPidTpcMin", 0.15f, "Min. track pT for TPC PID [GeV/c]"};
146+
Configurable<float> ptPidTpcMax{"ptPidTpcMax", 5.f, "Max. track pT for TPC PID [GeV/c]"};
147+
Configurable<float> nSigmaTpcMax{"nSigmaTpcMax", 3.f, "Max. TPC N_sigma"};
150148
// topological cuts
151149
Configurable<float> cpaMin{"cpaMin", 0.98f, "Min. cosine of pointing angle"};
152-
Configurable<float> massWindow{"massWindow", 0.4f, "Half-width of the invariant-mass window"};
150+
Configurable<float> massWindow{"massWindow", 0.4f, "Half-width of the invariant-mass window [Gev/c^2]"};
153151

154152
TrackSelectorPi selectorPion{};
155153
TrackSelectorKa selectorKaon{};
@@ -214,18 +212,18 @@ struct HfTaskMiniCandidateSelectorD0 {
214212
int statusD0 = 0;
215213
int statusD0bar = 0;
216214

217-
const auto& trackPos = candidate.prong0_as<TracksWithPid>(); // positive daughter
218-
const auto& trackNeg = candidate.prong1_as<TracksWithPid>(); // negative daughter
219-
220215
// conjugate-independent topological selection
221216
if (!selectionTopol(candidate)) {
222217
hfSelD0Candidate(statusD0, statusD0bar);
223218
continue;
224219
}
225220

226-
// conjugate-dependent topological selection for D0
221+
// conjugate-dependent topological selection
222+
const auto& trackPos = candidate.prong0_as<TracksWithPid>(); // positive daughter
223+
const auto& trackNeg = candidate.prong1_as<TracksWithPid>(); // negative daughter
224+
// D0 hypothesis
227225
const auto topolD0 = selectionTopolConjugate(candidate, trackPos, trackNeg);
228-
// conjugate-dependent topological selection for D0bar
226+
// D0bar hypothesis
229227
const auto topolD0bar = selectionTopolConjugate(candidate, trackNeg, trackPos);
230228

231229
if (!topolD0 && !topolD0bar) {
@@ -295,8 +293,8 @@ struct HfTaskMiniD0 {
295293
const TString strTitle = "D^{0} candidates";
296294
const TString strPt = "#it{p}_{T} (GeV/#it{c})";
297295
const TString strEntries = "entries";
298-
registry.add("hPtCand", strTitle + ";" + strPt + ";" + strEntries, {HistType::kTH1D, {{100, 0., 10.}}});
299-
registry.add("hMass", strTitle + ";" + "inv. mass (#pi K) (GeV/#it{c}^{2})" + ";" + strEntries, {HistType::kTH1D, {{500, 0., 5.}}});
296+
registry.add("hPtCand", strTitle + ";" + strPt + ";" + strEntries, {HistType::kTH1F, {{100, 0., 10.}}});
297+
registry.add("hMass", strTitle + ";" + "inv. mass (#pi K) (GeV/#it{c}^{2})" + ";" + strEntries, {HistType::kTH1F, {{500, 0., 5.}}});
300298
registry.add("hCpaVsPtCand", strTitle + ";" + "cosine of pointing angle" + ";" + strPt + ";" + strEntries, {HistType::kTH2F, {{110, -1.1, 1.1}, {100, 0., 10.}}});
301299
}
302300

0 commit comments

Comments
 (0)