Skip to content

Commit 930ecfc

Browse files
authored
[PWGDQ] fix a bug about fStatsList and add some comments (#8336)
1 parent a1b122f commit 930ecfc

File tree

2 files changed

+87
-64
lines changed

2 files changed

+87
-64
lines changed

PWGDQ/TableProducer/tableMaker.cxx

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
// The skimming can optionally produce just the barrel, muon, or both barrel and muon tracks
1818
// The event filtering (filterPP), centrality, and V0Bits (from v0-selector) can be switched on/off by selecting one
1919
// of the process functions
20+
// C++ includes
2021
#include <iostream>
22+
#include <map>
23+
#include <memory>
24+
#include <string>
25+
#include <vector>
26+
// other includes
2127
#include "Framework/AnalysisTask.h"
2228
#include "Framework/AnalysisDataModel.h"
2329
#include "Framework/ASoAHelpers.h"
@@ -413,7 +419,7 @@ struct TableMaker {
413419
// if the BC found by event selection does not coincide with the collision.bc()
414420
auto bcEvSel = collision.template foundBC_as<aod::BCsWithTimestamps>();
415421
if (bcEvSel.globalIndex() != bc.globalIndex()) {
416-
tag |= (uint64_t(1) << 0);
422+
tag |= (static_cast<uint64_t>(1) << 0);
417423
}
418424
// Put the 8 first bits of the event filter in the last 8 bits of the tag
419425
if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0) {
@@ -437,7 +443,7 @@ struct TableMaker {
437443
uint32_t triggerAliases = collision.alias_raw();
438444
// fill stats information, before selections
439445
for (int i = 0; i < kNaliases; i++) {
440-
if (triggerAliases & (uint32_t(1) << i)) {
446+
if (triggerAliases & (static_cast<uint32_t>(1) << i)) {
441447
(reinterpret_cast<TH2F*>(fStatsList->At(0)))->Fill(2.0, static_cast<float>(i));
442448
}
443449
}
@@ -462,7 +468,7 @@ struct TableMaker {
462468

463469
// fill stats information, after selections
464470
for (int i = 0; i < kNaliases; i++) {
465-
if (triggerAliases & (uint32_t(1) << i)) {
471+
if (triggerAliases & (static_cast<uint32_t>(1) << i)) {
466472
(reinterpret_cast<TH2F*>(fStatsList->At(0)))->Fill(3.0, static_cast<float>(i));
467473
}
468474
}
@@ -524,7 +530,7 @@ struct TableMaker {
524530
}
525531
}
526532

527-
trackFilteringTag = uint64_t(0);
533+
trackFilteringTag = static_cast<uint64_t>(0);
528534
trackTempFilterMap = uint8_t(0);
529535
VarManager::FillTrack<TTrackFillMap>(track);
530536
if (fDoDetailedQA) {
@@ -560,35 +566,35 @@ struct TableMaker {
560566
trackFilteringTag |= (uint64_t(1) << 1); // BIT1: global track SSD
561567
}*/
562568
if constexpr (static_cast<bool>(TTrackFillMap & VarManager::ObjTypes::TrackV0Bits)) { // BIT0-4: V0Bits
563-
trackFilteringTag = uint64_t(track.pidbit());
569+
trackFilteringTag = static_cast<uint64_t>(track.pidbit());
564570
for (int iv0 = 0; iv0 < 5; iv0++) {
565571
if (track.pidbit() & (uint8_t(1) << iv0)) {
566572
(reinterpret_cast<TH1D*>(fStatsList->At(1)))->Fill(fTrackCuts.size() + static_cast<float>(iv0));
567573
}
568574
}
569575
if (fConfigIsOnlyforMaps) {
570-
if (trackFilteringTag & (uint64_t(1) << VarManager::kIsConversionLeg)) { // for electron
576+
if (trackFilteringTag & (static_cast<uint64_t>(1) << VarManager::kIsConversionLeg)) { // for electron
571577
fHistMan->FillHistClass("TrackBarrel_PostCalibElectron", VarManager::fgValues);
572578
}
573-
if (trackFilteringTag & (uint64_t(1) << VarManager::kIsK0sLeg)) { // for pion
579+
if (trackFilteringTag & (static_cast<uint64_t>(1) << VarManager::kIsK0sLeg)) { // for pion
574580
fHistMan->FillHistClass("TrackBarrel_PostCalibPion", VarManager::fgValues);
575581
}
576-
if ((static_cast<bool>(trackFilteringTag & (uint64_t(1) << VarManager::kIsLambdaLeg)) * (track.sign()) > 0)) { // for proton from Lambda
582+
if ((static_cast<bool>(trackFilteringTag & (static_cast<uint64_t>(1) << VarManager::kIsLambdaLeg)) * (track.sign()) > 0)) { // for proton from Lambda
577583
fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues);
578584
}
579-
if ((static_cast<bool>(trackFilteringTag & (uint64_t(1) << VarManager::kIsALambdaLeg)) * (track.sign()) < 0)) { // for proton from AntiLambda
585+
if ((static_cast<bool>(trackFilteringTag & (static_cast<uint64_t>(1) << VarManager::kIsALambdaLeg)) * (track.sign()) < 0)) { // for proton from AntiLambda
580586
fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues);
581587
}
582588
}
583589
}
584590
if constexpr (static_cast<bool>(TTrackFillMap & VarManager::ObjTypes::DalitzBits)) {
585-
trackFilteringTag |= (uint64_t(track.dalitzBits()) << VarManager::kDalitzBits); // BIT5-12: Dalitz selection bits
591+
trackFilteringTag |= (static_cast<uint64_t>(track.dalitzBits()) << VarManager::kDalitzBits); // BIT5-12: Dalitz selection bits
586592
}
587-
trackFilteringTag |= (uint64_t(trackTempFilterMap) << VarManager::kBarrelUserCutsBits); // BIT13-20...: user track filters
593+
trackFilteringTag |= (static_cast<uint64_t>(trackTempFilterMap) << VarManager::kBarrelUserCutsBits); // BIT13-20...: user track filters
588594

589595
if constexpr (static_cast<bool>(TTrackFillMap & VarManager::ObjTypes::TrackPID)) {
590596
if (fConfigComputeTPCpostCalib) {
591-
trackFilteringTag |= (uint64_t(1) << VarManager::kIsTPCPostcalibrated); // store the info on whether TPC pid is skimmed as postcalibrated
597+
trackFilteringTag |= (static_cast<uint64_t>(1) << VarManager::kIsTPCPostcalibrated); // store the info on whether TPC pid is skimmed as postcalibrated
592598
}
593599
}
594600

@@ -683,7 +689,7 @@ struct TableMaker {
683689
std::map<int, int> newMFTMatchIndex;
684690

685691
for (auto& muon : tracksMuon) {
686-
fwdFilteringTag = uint64_t(0);
692+
fwdFilteringTag = static_cast<uint64_t>(0);
687693
VarManager::FillTrack<TMuonFillMap>(muon);
688694
if (fPropMuon) {
689695
VarManager::FillPropagateMuon<TMuonFillMap>(muon, collision);
@@ -877,7 +883,7 @@ struct TableMaker {
877883
// if the BC found by event selection does not coincide with the collision.bc()
878884
auto bcEvSel = collision.template foundBC_as<aod::BCsWithTimestamps>();
879885
if (bcEvSel.globalIndex() != bc.globalIndex()) {
880-
tag |= (uint64_t(1) << 0);
886+
tag |= (static_cast<uint64_t>(1) << 0);
881887
}
882888
// Put the 8 first bits of the event filter in the last 8 bits of the tag
883889
if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0) {
@@ -900,7 +906,7 @@ struct TableMaker {
900906

901907
// fill stats information, before selections
902908
for (int i = 0; i < kNaliases; i++) {
903-
if (triggerAliases & (uint32_t(1) << i)) {
909+
if (triggerAliases & (static_cast<uint32_t>(1) << i)) {
904910
(reinterpret_cast<TH2F*>(fStatsList->At(0)))->Fill(2.0, static_cast<float>(i));
905911
}
906912
}
@@ -925,7 +931,7 @@ struct TableMaker {
925931

926932
// fill stats information, after selections
927933
for (int i = 0; i < kNaliases; i++) {
928-
if (triggerAliases & (uint32_t(1) << i)) {
934+
if (triggerAliases & (static_cast<uint32_t>(1) << i)) {
929935
(reinterpret_cast<TH2F*>(fStatsList->At(0)))->Fill(3.0, static_cast<float>(i));
930936
}
931937
}
@@ -973,7 +979,7 @@ struct TableMaker {
973979
isAmbiguous = (track.compatibleCollIds().size() != 1);
974980
}
975981
}
976-
trackFilteringTag = uint64_t(0);
982+
trackFilteringTag = static_cast<uint64_t>(0);
977983
trackTempFilterMap = uint8_t(0);
978984
VarManager::FillTrack<TTrackFillMap>(track);
979985
if (fDoDetailedQA) {
@@ -1003,37 +1009,37 @@ struct TableMaker {
10031009

10041010
// store filtering information
10051011
if (track.isGlobalTrack()) {
1006-
trackFilteringTag |= (uint64_t(1) << 0); // BIT0: global track
1012+
trackFilteringTag |= (static_cast<uint64_t>(1) << 0); // BIT0: global track
10071013
}
10081014
if (track.isGlobalTrackSDD()) {
1009-
trackFilteringTag |= (uint64_t(1) << 1); // BIT1: global track SSD
1015+
trackFilteringTag |= (static_cast<uint64_t>(1) << 1); // BIT1: global track SSD
10101016
}
10111017
if constexpr (static_cast<bool>(TTrackFillMap & VarManager::ObjTypes::TrackV0Bits)) { // BIT2-6: V0Bits
1012-
trackFilteringTag |= (uint64_t(track.pidbit()) << 2);
1018+
trackFilteringTag |= (static_cast<uint64_t>(track.pidbit()) << 2);
10131019
for (int iv0 = 0; iv0 < 5; iv0++) {
10141020
if (track.pidbit() & (uint8_t(1) << iv0)) {
10151021
(reinterpret_cast<TH1D*>(fStatsList->At(1)))->Fill(fTrackCuts.size() + static_cast<float>(iv0));
10161022
}
10171023
}
10181024
if (fConfigIsOnlyforMaps) {
1019-
if (trackFilteringTag & (uint64_t(1) << 2)) { // for electron
1025+
if (trackFilteringTag & (static_cast<uint64_t>(1) << 2)) { // for electron
10201026
fHistMan->FillHistClass("TrackBarrel_PostCalibElectron", VarManager::fgValues);
10211027
}
1022-
if (trackFilteringTag & (uint64_t(1) << 3)) { // for pion
1028+
if (trackFilteringTag & (static_cast<uint64_t>(1) << 3)) { // for pion
10231029
fHistMan->FillHistClass("TrackBarrel_PostCalibPion", VarManager::fgValues);
10241030
}
1025-
if ((static_cast<bool>(trackFilteringTag & (uint64_t(1) << 4)) * (track.sign()) > 0)) { // for proton from Lambda
1031+
if ((static_cast<bool>(trackFilteringTag & (static_cast<uint64_t>(1) << 4)) * (track.sign()) > 0)) { // for proton from Lambda
10261032
fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues);
10271033
}
1028-
if ((static_cast<bool>(trackFilteringTag & (uint64_t(1) << 5)) * (track.sign()) < 0)) { // for proton from AntiLambda
1034+
if ((static_cast<bool>(trackFilteringTag & (static_cast<uint64_t>(1) << 5)) * (track.sign()) < 0)) { // for proton from AntiLambda
10291035
fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues);
10301036
}
10311037
}
10321038
}
10331039
if constexpr (static_cast<bool>(TTrackFillMap & VarManager::ObjTypes::DalitzBits)) {
1034-
trackFilteringTag |= (uint64_t(track.dalitzBits()) << 7); // BIT7-14: Dalitz
1040+
trackFilteringTag |= (static_cast<uint64_t>(track.dalitzBits()) << 7); // BIT7-14: Dalitz
10351041
}
1036-
trackFilteringTag |= (uint64_t(trackTempFilterMap) << 15); // BIT15-...: user track filters
1042+
trackFilteringTag |= (static_cast<uint64_t>(trackTempFilterMap) << 15); // BIT15-...: user track filters
10371043

10381044
// create the track tables
10391045
trackBarrelInfo(track.collisionId(), collision.posX(), collision.posY(), collision.posZ(), track.globalIndex());
@@ -1087,7 +1093,7 @@ struct TableMaker {
10871093

10881094
for (const auto& muonId : fwdtrackIndices) { // start loop over tracks
10891095
auto muon = muonId.template fwdtrack_as<TMuons>();
1090-
trackFilteringTag = uint64_t(0);
1096+
trackFilteringTag = static_cast<uint64_t>(0);
10911097
VarManager::FillTrack<TMuonFillMap>(muon);
10921098

10931099
if (muon.index() > idxPrev + 1) { // checks if some muons are filtered even before the skimming function
@@ -1117,7 +1123,7 @@ struct TableMaker {
11171123
isAmbiguous = (muon.compatibleCollIds().size() != 1);
11181124
}
11191125
}
1120-
trackFilteringTag = uint64_t(0);
1126+
trackFilteringTag = static_cast<uint64_t>(0);
11211127
trackTempFilterMap = uint8_t(0);
11221128

11231129
VarManager::FillTrack<TMuonFillMap>(muon);
@@ -1257,7 +1263,13 @@ struct TableMaker {
12571263
}
12581264
}
12591265

1260-
// create statistics histograms (event, tracks, muons)
1266+
// create statistics histograms
1267+
// 0: Event statistics
1268+
// 1: Track statistics
1269+
// 2: Muon statistics
1270+
// 3: Zorro information
1271+
// 4: Zorro trigger selection
1272+
// NOTE: Please keep the order of the histograms in the list
12611273
fStatsList.setObject(new TList());
12621274
fStatsList->SetOwner(kTRUE);
12631275
std::vector<TString> eventLabels{"BCs", "Collisions before filtering", "Before cuts", "After cuts"};
@@ -1270,7 +1282,7 @@ struct TableMaker {
12701282
histEvents->GetYaxis()->SetBinLabel(ib, aliasLabels[ib - 1].data());
12711283
}
12721284
histEvents->GetYaxis()->SetBinLabel(kNaliases + 1, "Total");
1273-
fStatsList->Add(histEvents);
1285+
fStatsList->Add(histEvents); // At index 0
12741286

12751287
// Track statistics: one bin for each track selection and 5 bins for V0 tags (gamma, K0s, Lambda, anti-Lambda, Omega)
12761288
TH1D* histTracks = new TH1D("TrackStats", "Track statistics", fTrackCuts.size() + 5.0, -0.5, fTrackCuts.size() - 0.5 + 5.0);
@@ -1282,20 +1294,19 @@ struct TableMaker {
12821294
for (ib = 0; ib < 5; ib++) {
12831295
histTracks->GetXaxis()->SetBinLabel(fTrackCuts.size() + 1 + ib, v0TagNames[ib]);
12841296
}
1285-
fStatsList->Add(histTracks);
1297+
fStatsList->Add(histTracks); // At index 1
12861298
TH1D* histMuons = new TH1D("MuonStats", "Muon statistics", fMuonCuts.size(), -0.5, fMuonCuts.size() - 0.5);
12871299
ib = 1;
12881300
for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, ib++) {
12891301
histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName());
12901302
}
1291-
fStatsList->Add(histMuons);
1303+
fStatsList->Add(histMuons); // At index 2
12921304

1293-
if (useZorro.fConfigRunZorro) {
1294-
TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5);
1295-
fStatsList->Add(histZorroInfo);
1296-
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
1297-
fStatsList->Add(histZorroSel);
1298-
}
1305+
TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5);
1306+
fStatsList->Add(histZorroInfo); // At index 3
1307+
1308+
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
1309+
fStatsList->Add(histZorroSel); // At index 4
12991310
}
13001311

13011312
// Produce barrel + muon tables -------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)