Skip to content

Commit 365ada8

Browse files
committed
add event slection switch
1 parent db57fce commit 365ada8

2 files changed

Lines changed: 82 additions & 45 deletions

File tree

PWGUD/Tasks/flowCorrelationsUpc.cxx

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include <TH1.h>
4141
#include <TH3.h>
4242
#include <TRandom3.h>
43-
#include <TString.h>
4443

4544
#include <array>
4645
#include <chrono>
@@ -57,7 +56,7 @@ using namespace o2::framework::expressions;
5756
using namespace o2::constants::math;
5857

5958
// define the filtered collisions and tracks
60-
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
59+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, (DEFAULT), (HELP)}; // NOLINT(bugprone-macro-parentheses)
6160

6261
struct FlowCorrelationsUpc {
6362
O2_DEFINE_CONFIGURABLE(cfgZVtxCut, float, 10.0f, "Accepted z-vertex range")
@@ -94,6 +93,10 @@ struct FlowCorrelationsUpc {
9493
O2_DEFINE_CONFIGURABLE(cfgIRMaxCut, double, 50, "maximum interaction rate for UPC events")
9594
O2_DEFINE_CONFIGURABLE(cfgZdcTime, bool, false, "choose zdc time cut")
9695
O2_DEFINE_CONFIGURABLE(cfgZdcTimeCut, float, 2.0, "zdc time cut")
96+
O2_DEFINE_CONFIGURABLE(cfgSbp, bool, true, "choose sbp")
97+
O2_DEFINE_CONFIGURABLE(cfgvtxITSTPC, bool, true, "choose vtxITSTPC")
98+
O2_DEFINE_CONFIGURABLE(cfgItsROFb, bool, true, "choose itsROFb")
99+
O2_DEFINE_CONFIGURABLE(cfgTfb, bool, true, "choose tfb")
97100

98101
ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"};
99102
ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"};
@@ -119,7 +122,7 @@ struct FlowCorrelationsUpc {
119122

120123
// make the filters and cuts.
121124
Filter trackFilter = (aod::udtrack::isPVContributor == true);
122-
Filter collisionFilter = (cfgGapSideMerge == true)
125+
Filter collisionFilter = cfgGapSideMerge
123126
? ((aod::udcollision::gapSide == (uint8_t)0 || aod::udcollision::gapSide == (uint8_t)1) &&
124127
(aod::upcservice::truegapside == 0 || aod::upcservice::truegapside == 1))
125128
: ((aod::udcollision::gapSide == (uint8_t)cfgGapSide) &&
@@ -209,8 +212,9 @@ struct FlowCorrelationsUpc {
209212

210213
float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2);
211214

212-
if (dPhiStar > constants::math::PI)
215+
if (dPhiStar > constants::math::PI) {
213216
dPhiStar = constants::math::TwoPI - dPhiStar;
217+
}
214218
return dPhiStar;
215219
}
216220

@@ -241,14 +245,18 @@ struct FlowCorrelationsUpc {
241245
int neutronClass = -1;
242246
float energyCommonZNA = collision.energyCommonZNA(), energyCommonZNC = collision.energyCommonZNC();
243247
float timeZNA = collision.timeZNA(), timeZNC = collision.timeZNC();
244-
if (std::isinf(energyCommonZNA))
248+
if (std::isinf(energyCommonZNA)) {
245249
energyCommonZNA = -999;
246-
if (std::isinf(energyCommonZNC))
250+
}
251+
if (std::isinf(energyCommonZNC)) {
247252
energyCommonZNC = -999;
248-
if (std::isinf(timeZNA))
253+
}
254+
if (std::isinf(timeZNA)) {
249255
timeZNA = -999;
250-
if (std::isinf(timeZNC))
256+
}
257+
if (std::isinf(timeZNC)) {
251258
timeZNC = -999;
259+
}
252260
registry.fill(HIST("ZDCEnergy"), energyCommonZNC, energyCommonZNA);
253261
registry.fill(HIST("ZDCTime"), timeZNC, timeZNA);
254262
if (std::abs(timeZNA) > cfgZdcTimeCut && std::abs(timeZNC) > cfgZdcTimeCut) {
@@ -290,19 +298,19 @@ struct FlowCorrelationsUpc {
290298
if (cfgIfVertex && std::abs(collision.posZ()) > cfgZVtxCut) {
291299
return false;
292300
}
293-
if (!collision.vtxITSTPC()) {
301+
if (cfgvtxITSTPC && !collision.vtxITSTPC()) {
294302
return false;
295303
}
296304

297-
if (!collision.sbp()) {
305+
if (cfgSbp && !collision.sbp()) {
298306
return false;
299307
}
300308

301-
if (!collision.itsROFb()) {
309+
if (cfgItsROFb && !collision.itsROFb()) {
302310
return false;
303311
}
304312

305-
if (!collision.tfb()) {
313+
if (cfgTfb && !collision.tfb()) {
306314
return false;
307315
}
308316

@@ -311,8 +319,9 @@ struct FlowCorrelationsUpc {
311319
}
312320

313321
if (cfgRctFlagEnabled) {
314-
if (!isGoodRctFlag(collision)) // check RCT flags
322+
if (!isGoodRctFlag(collision)) { // check RCT flags
315323
return false;
324+
}
316325
}
317326

318327
if (!zdcTimeCut(collision)) {
@@ -323,7 +332,7 @@ struct FlowCorrelationsUpc {
323332
}
324333

325334
template <typename TTrack>
326-
bool trackSelected(TTrack track)
335+
bool trackSelected(const TTrack& track)
327336
{
328337
// registry.fill(HIST("hTrackCount"), 0.5);
329338
auto momentum = std::array<double, 3>{track.px(), track.py(), track.pz()};
@@ -371,7 +380,7 @@ struct FlowCorrelationsUpc {
371380
if (correctionsLoaded) {
372381
return;
373382
}
374-
if (cfgEfficiency.value.empty() == false) {
383+
if (!cfgEfficiency.value.empty()) {
375384
mEfficiency = ccdb->getForTimeStamp<TH3D>(cfgEfficiency, timestamp);
376385
if (mEfficiency == nullptr) {
377386
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str());
@@ -392,28 +401,31 @@ struct FlowCorrelationsUpc {
392401
} else {
393402
eff = 1.0;
394403
}
395-
if (eff <= 0)
404+
if (eff <= 0) {
396405
return false;
406+
}
397407
weight_nue = 1. / eff;
398408
return true;
399409
}
400410
// fill multiple histograms
401411
template <typename TCollision, typename TTracks>
402-
void fillYield(TCollision collision, TTracks tracks, float vtxz) // function to fill the yield and etaphi histograms.
412+
void fillYield(const TCollision& collision, const TTracks& tracks, float vtxz) // function to fill the yield and etaphi histograms.
403413
{
404414
registry.fill(HIST("Nch"), tracks.size());
405415
registry.fill(HIST("zVtx"), collision.posZ());
406416

407417
for (auto const& track1 : tracks) {
408-
if (!trackSelected(track1))
418+
if (!trackSelected(track1)) {
409419
continue;
420+
}
410421
auto momentum = std::array<double, 3>{track1.px(), track1.py(), track1.pz()};
411422
double pt = RecoDecay::pt(momentum);
412423
double phi = RecoDecay::phi(momentum);
413424
double eta = RecoDecay::eta(momentum);
414425
float weff = 1.;
415-
if (!getEfficiencyCorrection(weff, eta, pt, vtxz))
426+
if (!getEfficiencyCorrection(weff, eta, pt, vtxz)) {
416427
continue;
428+
}
417429

418430
registry.fill(HIST("Phi"), phi);
419431
registry.fill(HIST("Eta"), eta);
@@ -424,7 +436,7 @@ struct FlowCorrelationsUpc {
424436
}
425437

426438
template <typename TTracks>
427-
void fillCorrelations(TTracks tracks1, TTracks tracks2, float posZ, int system, int runnum, float vtxz, float eventWeight, double independent) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
439+
void fillCorrelations(const TTracks& tracks1, const TTracks& tracks2, float posZ, int system, int runnum, float vtxz, float eventWeight, double independent) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
428440
{
429441

430442
if (mEfficiency) {
@@ -440,12 +452,13 @@ struct FlowCorrelationsUpc {
440452
}
441453
}
442454

443-
int fSampleIndex = gRandom->Uniform(0, cfgSampleSize);
455+
const int fSampleIndex = static_cast<int>(gRandom->Uniform(0., cfgSampleSize));
444456

445457
// loop over all tracks
446458
for (auto const& track1 : tracks1) {
447-
if (!trackSelected(track1))
459+
if (!trackSelected(track1)) {
448460
continue;
461+
}
449462

450463
auto momentum1 = std::array<double, 3>{track1.px(), track1.py(), track1.pz()};
451464
double pt1 = RecoDecay::pt(momentum1);
@@ -459,15 +472,19 @@ struct FlowCorrelationsUpc {
459472
}
460473

461474
for (auto const& track2 : tracks2) {
462-
if (!trackSelected(track2))
475+
if (!trackSelected(track2)) {
463476
continue;
477+
}
464478

465-
if (track1.globalIndex() == track2.globalIndex())
479+
if (track1.globalIndex() == track2.globalIndex()) {
466480
continue;
467-
if (system == SameEvent && cfgUsePtOrder && pt1 <= track2.pt())
481+
}
482+
if (system == SameEvent && cfgUsePtOrder && pt1 <= track2.pt()) {
468483
continue;
469-
if (system == MixedEvent && cfgUsePtOrderInMixEvent && pt1 <= track2.pt())
484+
}
485+
if (system == MixedEvent && cfgUsePtOrderInMixEvent && pt1 <= track2.pt()) {
470486
continue;
487+
}
471488

472489
auto momentum2 = std::array<double, 3>{track2.px(), track2.py(), track2.pz()};
473490
double pt2 = RecoDecay::pt(momentum2);
@@ -494,15 +511,20 @@ struct FlowCorrelationsUpc {
494511
bool bIsBelow = false;
495512

496513
if (std::abs(dPhiStarLow) < kLimit || std::abs(dPhiStarHigh) < kLimit || dPhiStarLow * dPhiStarHigh < 0) {
497-
for (double rad(cfgRadiusLow); rad < cfgRadiusHigh; rad += 0.01) {
514+
constexpr float kRadiusStep = 0.01f;
515+
const float radiusLow = cfgRadiusLow;
516+
const float radiusHigh = cfgRadiusHigh;
517+
for (int iRadius = 0; radiusLow + static_cast<float>(iRadius) * kRadiusStep < radiusHigh; ++iRadius) {
518+
const float rad = radiusLow + static_cast<float>(iRadius) * kRadiusStep;
498519
double dPhiStar = getDPhiStar(track1, track2, rad, runnum, phi1, phi2);
499520
if (std::abs(dPhiStar) < kLimit) {
500521
bIsBelow = true;
501522
break;
502523
}
503524
}
504-
if (bIsBelow)
525+
if (bIsBelow) {
505526
continue;
527+
}
506528
}
507529
}
508530

@@ -528,8 +550,9 @@ struct FlowCorrelationsUpc {
528550
auto currentRunNumber = collision.runNumber();
529551
auto runDuration = ccdb->getRunDuration(currentRunNumber);
530552

531-
if (!eventSelected(collision))
553+
if (!eventSelected(collision)) {
532554
return;
555+
}
533556

534557
loadCorrections(runDuration.first);
535558

@@ -540,8 +563,9 @@ struct FlowCorrelationsUpc {
540563
double nTracksCorrected = 0.;
541564

542565
for (const auto& track : tracks) {
543-
if (!trackSelected(track))
566+
if (!trackSelected(track)) {
544567
continue;
568+
}
545569

546570
auto momentum = std::array<double, 3>{track.px(), track.py(), track.pz()};
547571
double pt = RecoDecay::pt(momentum);
@@ -594,8 +618,9 @@ struct FlowCorrelationsUpc {
594618
tracks2.size() < cfgMinMult || tracks2.size() > cfgMaxMult) {
595619
continue;
596620
}
597-
if (!eventSelected(collision1) || !eventSelected(collision2))
621+
if (!eventSelected(collision1) || !eventSelected(collision2)) {
598622
continue;
623+
}
599624

600625
auto runDuration1 = ccdb->getRunDuration(collision1.runNumber());
601626
loadCorrections(runDuration1.first);
@@ -606,8 +631,9 @@ struct FlowCorrelationsUpc {
606631
double nTracksCorrected = 0.;
607632

608633
for (const auto& track : tracks1) {
609-
if (!trackSelected(track))
634+
if (!trackSelected(track)) {
610635
continue;
636+
}
611637

612638
auto momentum = std::array<double, 3>{track.px(), track.py(), track.pz()};
613639
double pt = RecoDecay::pt(momentum);

PWGUD/Tasks/flowMcUpc.cxx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// or submit itself to any jurisdiction.
1111

1212
/// \file flowMcUpc.cxx
13-
/// \author Zhiyong Lu (zhiyong.lu@cern.ch)
14-
/// \since Feb/5/2025
13+
/// \author Zhiyong Lu (zhiyong.lu@cern.ch) Yongxi Du (yongxi.du@cern.ch)
14+
/// \since Aug/04/2026
1515
/// \brief QC of synthetic flow exercise
1616

1717
#include "PWGCF/GenericFramework/Core/FlowContainer.h"
@@ -864,21 +864,26 @@ struct FlowMcUpc {
864864
histos.fill(HIST("hPtNchGlobalLambdaPions"), mcParticle.pt(), nChGlobal);
865865
}
866866
}
867-
if (pdgCode == PDG_t::kProton && m.pdgCode() == PDG_t::kLambda0)
867+
if (pdgCode == PDG_t::kProton && m.pdgCode() == PDG_t::kLambda0) {
868868
histos.fill(HIST("hPtNchGlobalLambdaProtons"), mcParticle.pt(), nChGlobal);
869+
}
869870
}
870871
}
871872
}
872873
}
873874
// if any track present, fill
874-
if (validTrack)
875+
if (validTrack) {
875876
histos.fill(HIST("hBVsPtVsPhiAny"), imp, deltaPhi, mcParticle.pt(), wacc * weff);
876-
if (validTPCTrack)
877+
}
878+
if (validTPCTrack) {
877879
histos.fill(HIST("hBVsPtVsPhiTPCTrack"), imp, deltaPhi, mcParticle.pt(), wacc * weff);
878-
if (validITSTrack)
880+
}
881+
if (validITSTrack) {
879882
histos.fill(HIST("hBVsPtVsPhiITSTrack"), imp, deltaPhi, mcParticle.pt(), wacc * weff);
880-
if (validITSABTrack)
883+
}
884+
if (validITSABTrack) {
881885
histos.fill(HIST("hBVsPtVsPhiITSABTrack"), imp, deltaPhi, mcParticle.pt(), wacc * weff);
886+
}
882887
}
883888

884889
if (cfgFlowCumulantEnabled) {
@@ -897,28 +902,34 @@ struct FlowMcUpc {
897902
void processReco(soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels>::iterator const& collision, aod::BCsWithTimestamps const&, FilteredTracks const& tracks, aod::McParticles const&, aod::McCollisions const&)
898903
{
899904
histos.fill(HIST("RecoProcessEventCounter"), 0.5);
900-
if (!eventSelected(collision))
905+
if (!eventSelected(collision)) {
901906
return;
907+
}
902908
histos.fill(HIST("RecoProcessEventCounter"), 1.5);
903-
if (tracks.size() < 1)
909+
if (tracks.size() < 1) {
904910
return;
911+
}
905912
histos.fill(HIST("RecoProcessEventCounter"), 2.5);
906913
for (const auto& track : tracks) {
907-
if (!trackSelected(track))
914+
if (!trackSelected(track)) {
908915
continue;
916+
}
909917
histos.fill(HIST("hPtReco"), track.pt());
910918
auto mcParticle = track.mcParticle();
911919
int pdgCode = std::abs(mcParticle.pdgCode());
912920
bool extraPDGType = true;
913921
if (cfgK0Lambda0Enabled) {
914922
extraPDGType = (pdgCode != PDG_t::kK0Short && pdgCode != PDG_t::kLambda0);
915923
}
916-
if (extraPDGType && pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != kKPlus && pdgCode != PDG_t::kProton)
924+
if (extraPDGType && pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != kKPlus && pdgCode != PDG_t::kProton) {
917925
continue;
918-
if (!mcParticle.isPhysicalPrimary())
926+
}
927+
if (!mcParticle.isPhysicalPrimary()) {
919928
continue;
920-
if (std::fabs(mcParticle.eta()) > cfgCutEta) // main acceptance
929+
}
930+
if (std::fabs(mcParticle.eta()) > cfgCutEta) { // main acceptance
921931
continue;
932+
}
922933
histos.fill(HIST("hPtReco_PhysicalPrimary"), track.pt());
923934
}
924935
}

0 commit comments

Comments
 (0)