Skip to content

Commit e530ae8

Browse files
fixed build errors spotted during the PR
1 parent 1f13e26 commit e530ae8

File tree

2 files changed

+66
-76
lines changed

2 files changed

+66
-76
lines changed

PWGLF/TableProducer/QC/nucleiQC.cxx

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,24 @@ struct nucleiQC {
142142
}
143143

144144
static_for<0, nuclei::kNspecies - 1>([&](auto iSpecies) {
145-
constexpr int iSpeciesCt = decltype(iSpecies)::value;
146-
const int iSpeciesRt = iSpeciesCt;
145+
constexpr int kSpeciesCt = decltype(iSpecies)::value;
146+
const int kSpeciesRt = kSpeciesCt;
147147

148-
if (std::find(mSpeciesToProcess.begin(), mSpeciesToProcess.end(), iSpeciesCt) == mSpeciesToProcess.end()) {
148+
if (std::find(mSpeciesToProcess.begin(), mSpeciesToProcess.end(), kSpeciesCt) == mSpeciesToProcess.end()) {
149149
return;
150150
}
151151

152152
float tpcBetheBlochParams[6];
153153
for (int iParam = 0; iParam < 6; iParam++) {
154-
tpcBetheBlochParams[iParam] = cfgBetheBlochParams->get(iSpeciesRt, iParam);
154+
tpcBetheBlochParams[iParam] = cfgBetheBlochParams->get(kSpeciesRt, iParam);
155155
}
156156

157157
nuclei::createHistogramRegistryNucleus<iSpeciesCt>(mHistograms);
158158

159-
if (cfgUseCentralTpcCalibration->get(static_cast<uint32_t>(iSpeciesRt), static_cast<uint32_t>(0)) == 0) {
160-
mPidManagers[iSpeciesRt] = nuclei::PidManager(iSpeciesRt, tpcBetheBlochParams);
159+
if (cfgUseCentralTpcCalibration->get(static_cast<uint32_t>(kSpeciesRt), static_cast<uint32_t>(0)) == 0) {
160+
mPidManagers[kSpeciesRt] = nuclei::PidManager(kSpeciesRt, tpcBetheBlochParams);
161161
} else {
162-
mPidManagers[iSpeciesRt] = nuclei::PidManager(iSpeciesRt);
162+
mPidManagers[kSpeciesRt] = nuclei::PidManager(kSpeciesRt);
163163
}
164164
});
165165
}
@@ -198,28 +198,28 @@ struct nucleiQC {
198198
template <int iSpecies, typename Ttrack, typename Tcollision>
199199
bool pidSelection(const Ttrack& track, const Tcollision& collision)
200200
{
201-
constexpr int index = iSpecies;
202-
if (!nuclei::checkSpeciesValidity(index)) {
203-
std::runtime_error("species contains invalid nucleus index");
201+
constexpr int kIndex = iSpecies;
202+
if (!nuclei::checkSpeciesValidity(kIndex)) {
203+
std::runtime_error("species contains invalid nucleus kIndex");
204204
}
205205

206-
const float centrality = nuclei::getCentrality(collision, cfgCentralityEstimator);
207-
const float nsigmaTPC = mPidManagers[index].getNSigmaTPC(track);
208-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3NsigmaTPC_preselectionVsCentrality"), track.pt(), nsigmaTPC, centrality);
209-
if (std::abs(nsigmaTPC) > cfgNsigmaTPC->get(index, 1))
206+
float centrality = nuclei::getCentrality(collision, cfgCentralityEstimator);
207+
float nsigmaTPC = mPidManagers[kIndex].getNSigmaTPC(track);
208+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3NsigmaTPC_preselectionVsCentrality"), track.pt(), nsigmaTPC, centrality);
209+
if (std::abs(nsigmaTPC) > cfgNsigmaTPC->get(kIndex, 1))
210210
return false;
211-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3NsigmaTPCVsCentrality"), track.pt(), nsigmaTPC, centrality);
211+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3NsigmaTPCVsCentrality"), track.pt(), nsigmaTPC, centrality);
212212

213-
const float nsigmaITS = mPidManagers[index].getNSigmaITS(track);
214-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3NsigmaITS_preselectionVsCentrality"), track.sign() * track.pt(), nsigmaITS, centrality);
213+
float nsigmaITS = mPidManagers[kIndex].getNSigmaITS(track);
214+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3NsigmaITS_preselectionVsCentrality"), track.sign() * track.pt(), nsigmaITS, centrality);
215215
// add nsigmaITS cut ?
216-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3NsigmaITSVsCentrality"), track.sign() * track.pt(), nsigmaITS, centrality);
216+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3NsigmaITSVsCentrality"), track.sign() * track.pt(), nsigmaITS, centrality);
217217

218-
const float nsigmaTOF = mPidManagers[index].getNSigmaTOF(track);
219-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3NsigmaTOF_preselectionVsCentrality"), track.pt(), nsigmaTOF, centrality);
220-
if (std::abs(nsigmaTOF) > cfgNsigmaTOF->get(index, 1))
218+
float nsigmaTOF = mPidManagers[kIndex].getNSigmaTOF(track);
219+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3NsigmaTOF_preselectionVsCentrality"), track.pt(), nsigmaTOF, centrality);
220+
if (std::abs(nsigmaTOF) > cfgNsigmaTOF->get(kIndex, 1))
221221
return false;
222-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3NsigmaTOFVsCentrality"), track.pt(), nsigmaTOF, centrality);
222+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3NsigmaTOFVsCentrality"), track.pt(), nsigmaTOF, centrality);
223223

224224
return true;
225225
}
@@ -234,7 +234,7 @@ struct nucleiQC {
234234

235235
// heavy flavour mother
236236
// if (particle.has_mothers()) {
237-
// for (auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
237+
// for (const auto& motherparticle : particle.mothers_as<aod::McParticles>()) {
238238
// if (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) {
239239
// flags |= kIsSecondaryFromWeakDecay;
240240
// motherPdgCode = motherparticle.pdgCode();
@@ -245,7 +245,7 @@ struct nucleiQC {
245245

246246
} else if (particle.has_mothers()) {
247247
candidate.flags |= nuclei::Flags::kIsSecondaryFromWeakDecay;
248-
for (auto& motherparticle : particle.template mothers_as<aod::McParticles>()) {
248+
for (const auto& motherparticle : particle.template mothers_as<aod::McParticles>()) {
249249
candidate.motherPdgCode = motherparticle.pdgCode();
250250
}
251251

@@ -362,25 +362,25 @@ struct nucleiQC {
362362
template <int iSpecies, const bool isGenerated>
363363
void fillHistograms(const nuclei::SlimCandidate& candidate)
364364
{
365-
constexpr int index = iSpecies;
366-
if (!nuclei::checkSpeciesValidity(index)) {
367-
std::runtime_error("species contains invalid nucleus index");
365+
constexpr int kIndex = iSpecies;
366+
if (!nuclei::checkSpeciesValidity(kIndex)) {
367+
std::runtime_error("species contains invalid nucleus kIndex");
368368
}
369369

370370
if (isGenerated) {
371-
const float ptGenerated = (index == nuclei::Species::kPr || index == nuclei::Species::kDe || index == nuclei::Species::kTr) ? candidate.ptGenerated : candidate.ptGenerated / 2.f;
372-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/hPtGenerated"), ptGenerated);
373-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3PtVsEtaVsCentralityGenerated"), ptGenerated, candidate.etaGenerated, candidate.centrality);
374-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3PhiVsEtaVsCentralityGenerated"), candidate.phiGenerated, candidate.etaGenerated, candidate.centrality);
371+
const float ptGenerated = (kIndex == nuclei::Species::kPr || kIndex == nuclei::Species::kDe || kIndex == nuclei::Species::kTr) ? candidate.ptGenerated : candidate.ptGenerated / 2.f;
372+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/hPtGenerated"), ptGenerated);
373+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3PtVsEtaVsCentralityGenerated"), ptGenerated, candidate.etaGenerated, candidate.centrality);
374+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3PhiVsEtaVsCentralityGenerated"), candidate.phiGenerated, candidate.etaGenerated, candidate.centrality);
375375
} else {
376-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/hPtReconstructed"), candidate.pt);
377-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3PtVsEtaVsCentralityReconstructed"), candidate.pt, candidate.eta, candidate.centrality);
378-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3PhiVsEtaVsCentralityReconstructed"), candidate.phi, candidate.eta, candidate.centrality);
379-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3DCAxyVsPtVsCentrality"), candidate.DCAxy, candidate.pt, candidate.centrality);
380-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3DCAzVsPtVsCentrality"), candidate.DCAz, candidate.pt, candidate.centrality);
381-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3BetaVsPtVsCentrality"), candidate.beta, candidate.pt, candidate.centrality);
382-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3dEdxVsPVsCentrality"), candidate.TPCsignal, candidate.pt, candidate.centrality);
383-
mHistograms.fill(HIST(nuclei::cNames[index]) + HIST("/h3ClusterSizeVsPtVsCentrality"), mPidManagers[index].getClusterSizeCosLambdaITS(candidate.clusterSizesITS, candidate.eta), candidate.pt, candidate.centrality);
376+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/hPtReconstructed"), candidate.pt);
377+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3PtVsEtaVsCentralityReconstructed"), candidate.pt, candidate.eta, candidate.centrality);
378+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3PhiVsEtaVsCentralityReconstructed"), candidate.phi, candidate.eta, candidate.centrality);
379+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3DCAxyVsPtVsCentrality"), candidate.DCAxy, candidate.pt, candidate.centrality);
380+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3DCAzVsPtVsCentrality"), candidate.DCAz, candidate.pt, candidate.centrality);
381+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3BetaVsPtVsCentrality"), candidate.beta, candidate.pt, candidate.centrality);
382+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3dEdxVsPVsCentrality"), candidate.TPCsignal, candidate.pt, candidate.centrality);
383+
mHistograms.fill(HIST(nuclei::cNames[kIndex]) + HIST("/h3ClusterSizeVsPtVsCentrality"), mPidManagers[kIndex].getClusterSizeCosLambdaITS(candidate.clusterSizesITS, candidate.eta), candidate.pt, candidate.centrality);
384384
}
385385
}
386386

PWGLF/Utils/nucleiUtils.h

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@
1515
#include "Framework/HistogramRegistry.h"
1616
#include "Framework/HistogramSpec.h"
1717

18+
#include "Common/DataModel/Centrality.h"
19+
#include "Common/DataModel/EventSelection.h"
20+
#include "Common/DataModel/PIDResponse.h"
21+
#include "Common/DataModel/PIDResponseITS.h"
22+
#include "Common/TableProducer/PID/pidTOFBase.h"
23+
24+
#include "DataFormatsTPC/BetheBlochAleph.h"
25+
1826
#include <string>
1927
#include <vector>
28+
#include <algorithm>
2029

2130
using namespace o2;
2231
using namespace o2::framework;
@@ -403,7 +412,7 @@ class PidManager
403412
{
404413

405414
public:
406-
PidManager(const int species, const float* tpcBetheBlochParams = nullptr)
415+
explicit PidManager(const int species, const float* tpcBetheBlochParams = nullptr)
407416
: mSpecies(species)
408417
{
409418
if (!checkSpeciesValidity(species)) {
@@ -426,19 +435,15 @@ class PidManager
426435
template <typename Ttrack>
427436
float getBetaTOF(const Ttrack& track)
428437
{
429-
if (!track.hasTOF()) {
430-
return -999.f;
431-
}
438+
if (!track.hasTOF()) return -999.f;
432439
float beta = o2::pid::tof::Beta::GetBeta(track);
433440
return std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked
434441
}
435442

436443
template <typename Ttrack>
437444
float getMassTOF(const Ttrack& track)
438445
{
439-
if (!track.hasTOF()) {
440-
return -999.f;
441-
}
446+
if (!track.hasTOF()) return -999.f;
442447
const float charge{1.f + static_cast<float>(mSpecies == Species::kHe || mSpecies == Species::kAl)};
443448
const float beta = getBetaTOF(track);
444449
return track.tpcInnerParam() * charge * std::sqrt(1.f / (beta * beta) - 1.f);
@@ -447,23 +452,15 @@ class PidManager
447452
template <typename Ttrack>
448453
float getNSigmaTOF(const Ttrack& track)
449454
{
450-
if (!track.hasTOF()) {
451-
return -999.f;
452-
}
455+
if (!track.hasTOF()) return -999.f;
453456

454457
switch (mSpecies) {
455-
case Species::kPr:
456-
return track.tofNSigmaPr();
457-
case Species::kDe:
458-
return track.tofNSigmaDe();
459-
case Species::kTr:
460-
return track.tofNSigmaTr();
461-
case Species::kHe:
462-
return track.tofNSigmaHe();
463-
case Species::kAl:
464-
return track.tofNSigmaAl();
465-
default:
466-
return -999.f;
458+
case Species::kPr: return track.tofNSigmaPr();
459+
case Species::kDe: return track.tofNSigmaDe();
460+
case Species::kTr: return track.tofNSigmaTr();
461+
case Species::kHe: return track.tofNSigmaHe();
462+
case Species::kAl: return track.tofNSigmaAl();
463+
default: return -999.f;
467464
}
468465
}
469466

@@ -500,9 +497,8 @@ class PidManager
500497
// TPC
501498
float getExpectedTPCsignal(const float p)
502499
{
503-
if (!mUseTpcCentralCalibration) {
504-
return -999.f;
505-
}
500+
if (!mUseTpcCentralCalibration) return -999.f;
501+
506502
float pScaled = p * mMomScaling[0] + mMomScaling[1];
507503
float betaGamma = pScaled / masses[mSpecies];
508504
return tpc::BetheBlochAleph(betaGamma,
@@ -530,18 +526,12 @@ class PidManager
530526
float getNSigmaTPCcentral(const Ttrack& track)
531527
{
532528
switch (mSpecies) {
533-
case Species::kPr:
534-
return track.tpcNSigmaPr();
535-
case Species::kDe:
536-
return track.tpcNSigmaDe();
537-
case Species::kTr:
538-
return track.tpcNSigmaTr();
539-
case Species::kHe:
540-
return track.tpcNSigmaHe();
541-
case Species::kAl:
542-
return track.tpcNSigmaAl();
543-
default:
544-
return -999.f;
529+
case Species::kPr: return track.tpcNSigmaPr();
530+
case Species::kDe: return track.tpcNSigmaDe();
531+
case Species::kTr: return track.tpcNSigmaTr();
532+
case Species::kHe: return track.tpcNSigmaHe();
533+
case Species::kAl: return track.tpcNSigmaAl();
534+
default: return -999.f;
545535
}
546536
}
547537

0 commit comments

Comments
 (0)