Skip to content

Commit 0e0d7d0

Browse files
committed
modify following o2 code-check
1 parent 59162d8 commit 0e0d7d0

1 file changed

Lines changed: 68 additions & 41 deletions

File tree

PWGCF/Flow/Tasks/flowMc.cxx

Lines changed: 68 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ using namespace o2::framework;
6868
using namespace o2::framework::expressions;
6969
using namespace o2::aod::rctsel;
7070

71-
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
71+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) \
72+
using ConfigTmp_##NAME = TYPE; \
73+
Configurable<ConfigTmp_##NAME> NAME{#NAME, (DEFAULT), HELP};
7274

7375
struct FlowMc {
7476
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
@@ -84,10 +86,10 @@ struct FlowMc {
8486
O2_DEFINE_CONFIGURABLE(cfgCutPtRefMax, float, 3.0f, "Maximal pT for ref tracks")
8587
O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks")
8688
O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks")
87-
O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 50.0f, "minimum TPC clusters")
88-
O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters")
89+
O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, int, 50, "minimum TPC clusters")
90+
O2_DEFINE_CONFIGURABLE(cfgCutITSclu, int, 5, "minimum ITS clusters")
8991
O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters")
90-
O2_DEFINE_CONFIGURABLE(cfgCutTPCcrossedrows, float, 70.0f, "minimum TPC crossed rows")
92+
O2_DEFINE_CONFIGURABLE(cfgCutTPCcrossedrows, int, 70, "minimum TPC crossed rows")
9193
O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "DCAxy cut for tracks")
9294
O2_DEFINE_CONFIGURABLE(cfgDCAxyNSigma, float, 7, "Cut on number of sigma deviations from expected DCA in the transverse direction");
9395
O2_DEFINE_CONFIGURABLE(cfgDCAxyFunction, std::string, "(0.0015+0.005/(x^1.1))", "Functional form of pt-dependent DCAxy cut");
@@ -177,7 +179,7 @@ struct FlowMc {
177179
};
178180

179181
// Connect to ccdb
180-
Service<ccdb::BasicCCDBManager> ccdb;
182+
Service<ccdb::BasicCCDBManager> ccdb{};
181183
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
182184

183185
OutputObj<GFWWeights> fWeights{GFWWeights("weights")};
@@ -271,7 +273,7 @@ struct FlowMc {
271273

272274
o2::framework::AxisSpec axis = axisPt;
273275
int nPtBins = axis.binEdges.size() - 1;
274-
double* ptBins = &(axis.binEdges)[0];
276+
double* ptBins = axis.binEdges.data();
275277
fPtAxis = new TAxis(nPtBins, ptBins);
276278

277279
if (cfgOutputNUAWeights) {
@@ -280,13 +282,15 @@ struct FlowMc {
280282
}
281283

282284
if (cfgFlowCumulantEnabled) {
283-
TObjArray* oba = new TObjArray();
285+
auto oba = new TObjArray();
284286
oba->Add(new TNamed("ChFull22", "ChFull22"));
285-
for (auto i = 0; i < fPtAxis->GetNbins(); i++)
287+
for (auto i = 0; i < fPtAxis->GetNbins(); i++) {
286288
oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff"));
289+
}
287290
oba->Add(new TNamed("Ch10Gap22", "Ch10Gap22"));
288-
for (auto i = 0; i < fPtAxis->GetNbins(); i++)
291+
for (auto i = 0; i < fPtAxis->GetNbins(); i++) {
289292
oba->Add(new TNamed(Form("Ch10Gap22_pt_%i", i + 1), "Ch10Gap22_pTDiff"));
293+
}
290294
fFCTrue->SetName("FlowContainerTrue");
291295
fFCTrue->SetXAxis(fPtAxis);
292296
fFCTrue->Initialize(oba, axisCentrality, cfgFlowCumulantNbootstrap);
@@ -339,8 +343,9 @@ struct FlowMc {
339343
}
340344
myTrackSel.SetMinNClustersTPC(cfgCutTPCclu);
341345
myTrackSel.SetMinNCrossedRowsTPC(cfgCutTPCcrossedrows);
342-
if (cfgEnableITSCuts)
346+
if (cfgEnableITSCuts) {
343347
myTrackSel.SetMinNClustersITS(cfgCutITSclu);
348+
}
344349
if (!cfgCutDCAzPtDepEnabled) {
345350
myTrackSel.SetMaxDcaZ(cfgCutDCAz);
346351
} else {
@@ -350,7 +355,7 @@ struct FlowMc {
350355
}
351356
if (cfgTrackDensityCorrUse) {
352357
std::vector<double> pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0};
353-
hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]);
358+
hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, pTEffBins.data());
354359
funcEff.resize(pTEffBins.size() - 1);
355360
// LHC24g3 Eff
356361
std::vector<double> f1p0 = cfgTrackDensityP0;
@@ -367,22 +372,25 @@ struct FlowMc {
367372
funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10);
368373
}
369374
if (!cfgEvSelRCTflags.value.empty()) {
370-
rctChecker.init(cfgEvSelRCTflags.value.c_str()); // override initialzation
375+
rctChecker.init(cfgEvSelRCTflags.value); // override initialzation
371376
}
372377
}
373378

374379
void loadCorrections(uint64_t timestamp)
375380
{
376-
if (correctionsLoaded)
381+
if (correctionsLoaded) {
377382
return;
378-
if (cfgFlowAcceptance.value.empty() == false) {
383+
}
384+
if (!cfgFlowAcceptance.value.empty()) {
379385
mAcceptance = ccdb->getForTimeStamp<GFWWeights>(cfgFlowAcceptance, timestamp);
380-
if (mAcceptance)
386+
if (mAcceptance) {
381387
LOGF(info, "Loaded acceptance weights from %s (%p)", cfgFlowAcceptance.value.c_str(), static_cast<void*>(mAcceptance));
382-
else
388+
}
389+
else {
383390
LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgFlowAcceptance.value.c_str(), static_cast<void*>(mAcceptance));
391+
}
384392
}
385-
if (cfgFlowEfficiency.value.empty() == false) {
393+
if (!cfgFlowEfficiency.value.empty()) {
386394
mEfficiency = ccdb->getForTimeStamp<TH1D>(cfgFlowEfficiency, timestamp);
387395
if (mEfficiency == nullptr) {
388396
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgFlowEfficiency.value.c_str());
@@ -395,60 +403,74 @@ struct FlowMc {
395403
bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz)
396404
{
397405
float eff = 1.;
398-
if (mEfficiency)
406+
if (mEfficiency) {
399407
eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt));
400-
else
408+
}
409+
else {
401410
eff = 1.0;
402-
if (eff == 0)
411+
}
412+
if (eff == 0) {
403413
return false;
414+
}
404415
weight_nue = 1. / eff;
405-
if (mAcceptance)
416+
if (mAcceptance) {
406417
weight_nua = mAcceptance->getNUA(phi, eta, vtxz);
407-
else
418+
}
419+
else {
408420
weight_nua = 1;
421+
}
409422
return true;
410423
}
411424

412425
void fillFC(GFW* fGFW, bool isMCTruth, const GFW::CorrConfig& corrconf, const double& cent, const double& rndm)
413426
{
414-
double dnx, val = 0;
427+
double dnx = 0, val = 0;
415428
dnx = fGFW->Calculate(corrconf, 0, kTRUE).real();
416429
if (!corrconf.pTDif) {
417-
if (dnx == 0)
430+
if (dnx == 0) {
418431
return;
432+
}
419433
val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx;
420434
if (std::fabs(val) < 1) {
421-
if (isMCTruth)
435+
if (isMCTruth) {
422436
fFCTrue->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm);
423-
else
437+
}
438+
else {
424439
fFCReco->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm);
440+
}
425441
}
426442
return;
427443
}
428444
for (auto i = 1; i <= fPtAxis->GetNbins(); i++) {
429445
dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real();
430-
if (dnx == 0)
446+
if (dnx == 0) {
431447
continue;
448+
}
432449
val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx;
433450
if (std::fabs(val) < 1) {
434-
if (isMCTruth)
451+
if (isMCTruth) {
435452
fFCTrue->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm);
436-
else
453+
}
454+
else {
437455
fFCReco->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm);
456+
}
438457
}
439458
}
440459
}
441460

442461
void loadCentVsIPTruth(uint64_t timestamp)
443462
{
444-
if (centVsIPTruthLoaded)
463+
if (centVsIPTruthLoaded) {
445464
return;
446-
if (cfgCentVsIPTruth.value.empty() == false) {
465+
}
466+
if (!cfgCentVsIPTruth.value.empty()) {
447467
mCentVsIPTruth = ccdb->getForTimeStamp<TH1D>(cfgCentVsIPTruth, timestamp);
448-
if (mCentVsIPTruth)
468+
if (mCentVsIPTruth) {
449469
LOGF(info, "Loaded CentVsIPTruth weights from %s (%p)", cfgCentVsIPTruth.value.c_str(), static_cast<void*>(mCentVsIPTruth));
450-
else
470+
}
471+
else {
451472
LOGF(fatal, "Failed to load CentVsIPTruth weights from %s", cfgCentVsIPTruth.value.c_str());
473+
}
452474

453475
centVsIPTruthLoaded = true;
454476
} else {
@@ -462,7 +484,7 @@ struct FlowMc {
462484
return;
463485
}
464486
mRunNumber = bc.runNumber();
465-
if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) {
487+
if (!gHadronicRate.contains(mRunNumber)) {
466488
auto runDuration = ccdb->getRunDuration(mRunNumber);
467489
mSOR = runDuration.first;
468490
mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR
@@ -474,7 +496,7 @@ struct FlowMc {
474496
}
475497

476498
template <typename TCollision>
477-
bool eventSelected(TCollision collision)
499+
bool eventSelected(const TCollision& collision)
478500
{
479501
if (std::fabs(collision.posZ()) > cfgCutVertex) {
480502
return 0;
@@ -484,11 +506,13 @@ struct FlowMc {
484506
}
485507
if (cfgOccupancyEnabled) {
486508
auto occupancy = collision.trackOccupancyInTimeRange();
487-
if (occupancy < cfgOccupancyMin || occupancy > cfgOccupancyMax)
509+
if (occupancy < cfgOccupancyMin || occupancy > cfgOccupancyMax) {
488510
return 0;
511+
}
489512
}
490-
if (!cfgEvSelRCTflags.value.empty() && !rctChecker(*collision))
513+
if (!cfgEvSelRCTflags.value.empty() && !rctChecker(*collision)) {
491514
return 0;
515+
}
492516
if (cfgRecoEvkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) {
493517
// rejects collisions which are associated with the same "found-by-T0" bunch crossing
494518
// https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof
@@ -497,12 +521,15 @@ struct FlowMc {
497521
if (cfgRecoEvkIsGoodITSLayers) {
498522
// from Jan 9 2025 AOT meeting
499523
// cut time intervals with dead ITS staves
500-
if (cfgRecoEvkIsGoodITSLayersFlag == kITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))
524+
if (cfgRecoEvkIsGoodITSLayersFlag == kITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) {
501525
return 0;
502-
if (cfgRecoEvkIsGoodITSLayersFlag == kITSLayer0123 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123))
526+
}
527+
if (cfgRecoEvkIsGoodITSLayersFlag == kITSLayer0123 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) {
503528
return 0;
504-
if (cfgRecoEvkIsGoodITSLayersFlag == kITSLayer3 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3))
529+
}
530+
if (cfgRecoEvkIsGoodITSLayersFlag == kITSLayer3 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) {
505531
return 0;
532+
}
506533
}
507534
if (cfgRecoEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) {
508535
// removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference
@@ -531,7 +558,7 @@ struct FlowMc {
531558
}
532559

533560
template <typename TTrack>
534-
bool trackSelected(TTrack track)
561+
bool trackSelected(const TTrack& track)
535562
{
536563
if (cfgCutDCAzPtDepEnabled && (std::fabs(track.dcaZ()) > fPtDepDCAz->Eval(track.pt()))) {
537564
return false;

0 commit comments

Comments
 (0)