Skip to content

Commit 3646296

Browse files
committed
changed the workings of the run number axis in histograms
1 parent 768072c commit 3646296

File tree

1 file changed

+45
-31
lines changed

1 file changed

+45
-31
lines changed

PWGUD/Tasks/upcRhoAnalysis.cxx

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ struct UpcRhoAnalysis {
122122

123123
SGSelector sgSelector;
124124

125-
float pcEtaCut = 0.9; // physics coordination recommendation
125+
const float pcEtaCut = 0.9; // physics coordination recommendation
126+
const std::vector<int> runNumbers = {544013, 544028, 544032, 544091, 544095, 544098, 544116, 544121, 544122, 544123, 544124, 544184, 544185, 544389, 544390, 544391, 544392, 544451, 544454, 544474, 544475, 544476, 544477, 544490, 544491, 544492, 544508, 544510, 544511, 544512, 544514, 544515, 544518, 544548, 544549, 544550, 544551, 544564, 544565, 544567, 544568, 544580, 544582, 544583, 544585, 544614, 544640, 544652, 544653, 544672, 544674, 544692, 544693, 544694, 544696, 544739, 544742, 544754, 544767, 544794, 544795, 544797, 544813, 544868, 544886, 544887, 544896, 544911, 544913, 544914, 544917, 544931, 544947, 544961, 544963, 544964, 544968, 544991, 544992, 545004, 545008, 545009, 545041, 545042, 545044, 545047, 545060, 545062, 545063, 545064, 545066, 545086, 545103, 545117, 545171, 545184, 545185, 545210, 545222, 545223, 545246, 545249, 545262, 545289, 545291, 545294, 545295, 545296, 545311, 545312, 545332, 545345, 545367};
127+
AxisSpec runNumberAxis = {runNumbers.size(), 0.5, static_cast<double>(runNumbers.size()) + 0.5, "run number"};
126128

127129
Configurable<int> numPions{"numPions", 2, "required number of pions in the event"};
128130

@@ -141,6 +143,9 @@ struct UpcRhoAnalysis {
141143
Configurable<bool> useRctFlag{"useRctFlag", false, "use RCT flags for event selection"};
142144
Configurable<int> cutRctFlag{"cutRctFlag", 0, "0 = off, 1 = CBT, 2 = CBT+ZDC, 3 = CBThadron, 4 = CBThadron+ZDC"};
143145

146+
Configurable<bool> selectRuns{"selectRuns", false, "select runs from the list"};
147+
Configurable<std::vector<int>> selectedRuns{"selectedRuns", {544013, 544028, 544032, 544091, 544095, 544098, 544116, 544121, 544122, 544123, 544124, 544184, 544185, 544389, 544390, 544391, 544392, 544451, 544454, 544474, 544475, 544476, 544477, 544490, 544491, 544492, 544508, 544510, 544511, 544512, 544514, 544515, 544518, 544548, 544549, 544550, 544551, 544564, 544565, 544567, 544568, 544580, 544582, 544583, 544585, 544614, 544640, 544652, 544653, 544672, 544674, 544692, 544693, 544694, 544696, 544739, 544742, 544754, 544767, 544794, 544795, 544797, 544813, 544868, 544886, 544887, 544896, 544913, 544914, 544917, 544931, 544947, 544961, 544963, 544964, 544968, 544992, 545009, 545044, 545047, 545063, 545064, 545066, 545185, 545210, 545223, 545249, 545291, 545294, 545295, 545296, 545312}, "list of selected runs (if empty, all runs are used)"};
148+
144149
Configurable<float> collisionsPosZMaxCut{"collisionsPosZMaxCut", 10.0, "max Z position cut on collisions"};
145150
Configurable<bool> cutNumContribs{"cutNumContribs", true, "cut on number of contributors"};
146151
Configurable<int> collisionsNumContribsMaxCut{"collisionsNumContribsMaxCut", 2, "max number of contributors cut on collisions"};
@@ -172,7 +177,6 @@ struct UpcRhoAnalysis {
172177
ConfigurableAxis deltaPhiAxis{"deltaPhiAxis", {182, -o2::constants::math::PI, o2::constants::math::PI}, "#Delta#it{#phi} (rad)"};
173178
ConfigurableAxis znCommonEnergyAxis{"znCommonEnergyAxis", {250, -5.0, 20.0}, "ZN common energy (TeV)"};
174179
ConfigurableAxis znTimeAxis{"znTimeAxis", {200, -10.0, 10.0}, "ZN time (ns)"};
175-
ConfigurableAxis runNumberAxis{"runNumberAxis", {1355, 544012.5, 545367.5}, "run number"};
176180
ConfigurableAxis nSigmaAxis{"nSigmaAxis", {600, -30.0, 30.0}, "TPC #it{n#sigma}"};
177181

178182
HistogramRegistry rQC{"rQC", {}, OutputObjHandlingPolicy::AnalysisObject};
@@ -237,6 +241,9 @@ struct UpcRhoAnalysis {
237241
rQC.get<TH1>(HIST("QC/tracks/hSelectionCounter"))->GetXaxis()->SetBinLabel(i + 1, selectionCounterLabels[i].c_str());
238242
rQC.get<TH2>(HIST("QC/tracks/hSelectionCounterPerRun"))->GetXaxis()->SetBinLabel(i + 1, selectionCounterLabels[i].c_str());
239243
}
244+
for (int i = 0; i < static_cast<int>(runNumbers.size()); ++i) {
245+
rQC.get<TH2>(HIST("QC/tracks/hSelectionCounterPerRun"))->GetYaxis()->SetBinLabel(i + 1, std::to_string(runNumbers[i]).c_str());
246+
}
240247
rQC.add("QC/tracks/hTofHitCheck", ";leading track TOF hit;subleading track TOF hit;counts", kTH2D, {{2, -0.5, 1.5}, {2, -0.5, 1.5}});
241248
rQC.get<TH2>(HIST("QC/tracks/hTofHitCheck"))->GetXaxis()->SetBinLabel(1, "no hit");
242249
rQC.get<TH2>(HIST("QC/tracks/hTofHitCheck"))->GetXaxis()->SetBinLabel(2, "hit");
@@ -284,7 +291,6 @@ struct UpcRhoAnalysis {
284291
rMC.add("MC/collisions/hPosZ", ";vertex #it{z} (cm);counts", kTH1D, {{400, -20.0, 20.0}});
285292
rMC.add("MC/collisions/hNPions", ";number of pions;counts", kTH1D, {{11, -0.5, 10.5}});
286293
rMC.add("MC/collisions/hNumOfCollisionRecos", ";number of collision reconstructions;counts", kTH1D, {{6, -0.5, 5.5}});
287-
rMC.add("MC/collisions/hRunNumberVsNumOfCollisionRecos", ";number of collision reconstructions;run number;counts", kTH2D, {{6, -0.5, 5.5}, runNumberAxis});
288294
// tracks
289295
rMC.add("MC/tracks/all/hPdgCode", ";pdg code;counts", kTH1D, {{2001, -1000.5, 1000.5}});
290296
rMC.add("MC/tracks/all/hMotherPdgCode", ";mother pdg code;counts", kTH1D, {{2001, -1000.5, 1000.5}});
@@ -316,10 +322,6 @@ struct UpcRhoAnalysis {
316322
rMC.addClone("MC/system/", "MC/system/selected/");
317323
}
318324

319-
std::unordered_set<int> goldenRuns = {544491, 544474, 544123, 544098, 544121, 544389, 544032, 544454, 544122,
320-
544510, 544476, 544091, 544095, 544490, 544124, 544508, 544391, 544013,
321-
544390, 544184, 544451, 544116, 544185, 544492, 544475, 544392, 544477, 544028};
322-
323325
static constexpr std::string_view AppliedSelections[3] = {"all/", "trackSelections/", "systemSelections/"};
324326
static constexpr std::string_view ChargeLabel[3] = {"unlike-sign/", "like-sign/positive/", "like-sign/negative/"};
325327
static constexpr std::string_view NeutronClass[5] = {"no-selection/", "0n0n/", "Xn0n/", "0nXn/", "XnXn/"};
@@ -453,78 +455,78 @@ struct UpcRhoAnalysis {
453455
return true;
454456
}
455457

456-
template <typename T, typename C>
457-
bool trackPassesCuts(const T& track, const C& collision) // track cuts (PID done separately)
458+
template <typename T>
459+
bool trackPassesCuts(const T& track, int runIndex) // track cuts (PID done separately)
458460
{
459461
if (!track.isPVContributor())
460462
return false;
461463
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 1);
462-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 1, collision.runNumber());
464+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 1, runIndex);
463465

464466
if (!track.hasITS())
465467
return false;
466468
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 2);
467-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 2, collision.runNumber());
469+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 2, runIndex);
468470

469471
if (track.itsNCls() < tracksMinItsNClsCut)
470472
return false;
471473
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 3);
472-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 3, collision.runNumber());
474+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 3, runIndex);
473475

474476
if (!cutItsLayers(track.itsClusterMap()))
475477
return false;
476478
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 4);
477-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 4, collision.runNumber());
479+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 4, runIndex);
478480

479481
if (track.itsChi2NCl() > tracksMaxItsChi2NClCut)
480482
return false;
481483
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 5);
482-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 5, collision.runNumber());
484+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 5, runIndex);
483485

484486
if (!track.hasTPC())
485487
return false;
486488
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 6);
487-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 6, collision.runNumber());
489+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 6, runIndex);
488490

489491
if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < tracksMinTpcNClsCut)
490492
return false;
491493
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 7);
492-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 7, collision.runNumber());
494+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 7, runIndex);
493495

494496
if (track.tpcChi2NCl() > tracksMaxTpcChi2NClCut || track.tpcChi2NCl() < tracksMinTpcChi2NClCut)
495497
return false;
496498
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 8);
497-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 8, collision.runNumber());
499+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 8, runIndex);
498500

499501
if (track.tpcNClsCrossedRows() < tracksMinTpcNClsCrossedRowsCut)
500502
return false;
501503
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 9);
502-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 9, collision.runNumber());
504+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 9, runIndex);
503505

504506
if ((static_cast<double>(track.tpcNClsCrossedRows()) / static_cast<double>(track.tpcNClsFindable())) < tracksMinTpcNClsCrossedOverFindableCut)
505507
return false;
506508
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 10);
507-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 10, collision.runNumber());
509+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 10, runIndex);
508510

509511
if (requireTof && !track.hasTOF())
510512
return false;
511513
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 11);
512-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 11, collision.runNumber());
514+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 11, runIndex);
513515

514516
if (track.pt() < tracksMinPtCut)
515517
return false;
516518
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 12);
517-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 12, collision.runNumber());
519+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 12, runIndex);
518520

519521
if (std::abs(track.dcaZ()) > tracksDcaMaxCut || std::abs(track.dcaXY()) > (0.0105 + 0.0350 / std::pow(track.pt(), 1.01)))
520522
return false;
521523
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 13);
522-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 13, collision.runNumber());
524+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 13, runIndex);
523525

524526
if (std::abs(eta(track.px(), track.py(), track.pz())) > pcEtaCut)
525527
return false;
526528
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 14);
527-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 14, collision.runNumber());
529+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 14, runIndex);
528530
// if all selections passed
529531
return true;
530532
}
@@ -619,12 +621,25 @@ struct UpcRhoAnalysis {
619621
return deltaPhi(pPlus, pMinus);
620622
}
621623

624+
// function to obtain index of run from the run number vector
625+
// search for passed run number in the vector and return its index +1 to use in the filling of a histogram
626+
int getRunIndex(int runNumber, const std::vector<int>& runNumbers)
627+
{
628+
auto it = std::find(runNumbers.begin(), runNumbers.end(), runNumber);
629+
if (it != runNumbers.end()) {
630+
return std::distance(runNumbers.begin(), it) + 1; // +1 to avoid 0 bin in histogram
631+
} else {
632+
return 0; // return 0 if run number not found
633+
}
634+
}
635+
622636
template <typename C, typename T>
623637
void processReco(C const& collision, T const& tracks)
624638
{
625-
// check if the collision run number is contained within the goldenRuns set
626-
if (onlyGoldenRuns && !goldenRuns.contains(collision.runNumber()))
627-
return;
639+
// check if the collision run number is contained within the selectedRuns vector
640+
if (selectRuns && getRunIndex(collision.runNumber(), selectedRuns) == 0)
641+
return;
642+
int runIndex = getRunIndex(collision.runNumber(), runNumbers);
628643

629644
fillCollisionQcHistos<0>(collision); // fill QC histograms before cuts
630645
if (!collisionPassesCuts(collision))
@@ -664,10 +679,10 @@ struct UpcRhoAnalysis {
664679
std::vector<decltype(tracks.begin())> cutTracks; // store selected tracks
665680
for (const auto& track : tracks) {
666681
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 0);
667-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 0, collision.runNumber());
682+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 0, runIndex);
668683
fillTrackQcHistos<0>(track); // fill QC histograms before cuts
669684

670-
if (!trackPassesCuts(track, collision)) // apply track cuts
685+
if (!trackPassesCuts(track, runIndex)) // apply track cuts
671686
continue;
672687
cutTracks.push_back(track);
673688
}
@@ -677,7 +692,7 @@ struct UpcRhoAnalysis {
677692
return;
678693
for (int i = 0; i < numPions; i++) {
679694
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 15);
680-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 15, collision.runNumber());
695+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 15, runIndex);
681696
}
682697
rQC.fill(HIST("QC/tracks/trackSelections/hTpcNSigmaPi2D"), cutTracks[0].tpcNSigmaPi(), cutTracks[1].tpcNSigmaPi());
683698
rQC.fill(HIST("QC/tracks/trackSelections/hTpcNSigmaEl2D"), cutTracks[0].tpcNSigmaEl(), cutTracks[1].tpcNSigmaEl());
@@ -728,7 +743,7 @@ struct UpcRhoAnalysis {
728743

729744
for (const auto& cutTrack : cutTracks) {
730745
rQC.fill(HIST("QC/tracks/hSelectionCounter"), 16);
731-
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 16, collision.runNumber());
746+
rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 16, runIndex);
732747
fillTrackQcHistos<1>(cutTrack); // fill QC histograms after cuts
733748
}
734749
rQC.fill(HIST("QC/tracks/hTofHitCheck"), leadingMomentumTrack.hasTOF(), subleadingMomentumTrack.hasTOF());
@@ -926,7 +941,6 @@ struct UpcRhoAnalysis {
926941
void checkNumberOfCollisionReconstructions(C const& collisions)
927942
{
928943
rMC.fill(HIST("MC/collisions/hNumOfCollisionRecos"), collisions.size());
929-
rMC.fill(HIST("MC/collisions/hRunNumberVsNumOfCollisionRecos"), collisions.size(), collisions.begin().runNumber());
930944
}
931945

932946
void processSGdata(FullUdSgCollision const& collision, FullUdTracks const& tracks)

0 commit comments

Comments
 (0)