Skip to content

Commit a90efb7

Browse files
author
Pei-Ying Kuan
committed
fix clang error, will fix other errors later
1 parent 2d61bf0 commit a90efb7

1 file changed

Lines changed: 29 additions & 21 deletions

File tree

PWGCF/MultiparticleCorrelations/Tasks/multiparticleCumulants.cxx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
#include <cmath>
4747
#include <cstddef>
48+
#include <map>
4849
#include <string>
4950
#include <vector>
5051

@@ -305,13 +306,13 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
305306
bool fWeightSwitch = kTRUE;
306307
TList* fWeightHistogramsList = NULL;
307308
// Fill phi/pt histograms with that run number:
308-
std::map<int, TH1F*> fPtRealByRunMap; // MC rec (too lazy to change name) data pt histograms, valid if processMonteCarlo
309-
std::map<int, TH1F*> fPtMCByRunMap; // MC sim (too lazy to change name) data pt histograms, valid if processMonteCarlo
310-
std::map<int, TH1F*> fPhiByRunMap; // Phi histograms, valid if processRealData
309+
std::map<int, TH1F*> fPtRealByRunMap; // MC rec (too lazy to change name) data pt histograms, valid if processMonteCarlo
310+
std::map<int, TH1F*> fPtMCByRunMap; // MC sim (too lazy to change name) data pt histograms, valid if processMonteCarlo
311+
std::map<int, TH1F*> fPhiByRunMap; // Phi histograms, valid if processRealData
311312
// Make weight histograms locally. Upload weight histograms to CCDB:
312-
std::vector<TH1F*> fWeightHistograms; // Get all weight histograms with that run number
313-
std::map<int, TH1F*> fPhiWeightHistogramsMap; // Get phi weight histograms
314-
std::map<int, TH1F*> fPtWeightHistogramsMap; // Get pt weight histograms
313+
std::vector<TH1F*> fWeightHistograms; // Get all weight histograms with that run number
314+
std::map<int, TH1F*> fPhiWeightHistogramsMap; // Get phi weight histograms
315+
std::map<int, TH1F*> fPtWeightHistogramsMap; // Get pt weight histograms
315316
// Null weight histograms. Use them when no weight histograms found in the given run number:
316317
TH1F* fDummyPhiWeightHistogram = NULL;
317318
TH1F* fDummyPtWeightHistogram = NULL;
@@ -337,7 +338,14 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
337338
} mc;
338339

339340
struct MultiparticleCorrelationCalculation {
340-
int h1, h2, h3, h4, h5, h6, h7, h8;
341+
int h1 = 0;
342+
int h2 = 0;
343+
int h3 = 0;
344+
int h4 = 0;
345+
int h5 = 0;
346+
int h6 = 0;
347+
int h7 = 0;
348+
int h8 = 0;
341349
// Book Q-vector components:
342350
static constexpr int MaxCorrelator = 4; // <<m>>
343351
static constexpr int MaxHarmonic = 5; // n+1 in vn, in this case n=4 as we need v2, v3, v4
@@ -627,7 +635,6 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
627635
}
628636
weightsFile->GetObject("ccdb_object", baseList);
629637
if (!baseList) {
630-
weightsFile->ls();
631638
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
632639
}
633640

@@ -639,7 +646,9 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
639646
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
640647
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
641648
if (!listWithRuns) {
642-
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
649+
LOGF(warning, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current runnumber = %s\033[0m", __FUNCTION__, __LINE__, runNumber);
650+
histograms = {nullptr};
651+
return histograms;
643652
}
644653
}
645654
} else if (bFileIsInCCDB) {
@@ -648,7 +657,6 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
648657
// My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ => adapt for your case
649658
ccdb->setURL("https://alice-ccdb.cern.ch"); // to be able to use "ccdb" this object in your analysis task, see 4b/ below
650659
baseList = reinterpret_cast<TList*>(ccdb->get<TList>(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()));
651-
baseList->ls();
652660
if (!baseList) {
653661
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
654662
}
@@ -659,7 +667,9 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
659667
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
660668
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
661669
if (!listWithRuns) {
662-
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
670+
LOGF(warning, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current runnumber = %s\033[0m", __FUNCTION__, __LINE__, runNumber);
671+
histograms = {nullptr};
672+
return histograms;
663673
}
664674
}
665675

@@ -683,7 +693,6 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
683693
weightsFile->GetObject("ccdb_object", baseList);
684694

685695
if (!baseList) {
686-
weightsFile->ls();
687696
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
688697
}
689698

@@ -693,7 +702,6 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
693702
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
694703
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
695704
if (!listWithRuns) {
696-
baseList->ls();
697705
LOGF(warning, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current runnumber = %s\033[0m", __FUNCTION__, __LINE__, runNumber);
698706
histograms = {nullptr};
699707
return histograms;
@@ -763,7 +771,7 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
763771
wt.fPtRealByRunMap[ebye.fRunNumber]->SetDirectory(nullptr);
764772
wt.fWeightHistogramsList->Add(wt.fPtRealByRunMap[ebye.fRunNumber]);
765773
}
766-
774+
767775
// Book pt MC sim histogram with this run number:
768776
if (wt.fPtMCByRunMap.find(ebye.fRunNumber) == wt.fPtMCByRunMap.end()) {
769777
wt.fPtMCByRunMap[ebye.fRunNumber] = new TH1F(Form("hPtMC_run%d", ebye.fRunNumber), Form("pt MC sim distribution for run %d", ebye.fRunNumber), static_cast<int>(tc.fPtBins[0]), tc.fPtBins[1], tc.fPtBins[2]);
@@ -773,13 +781,13 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
773781

774782
// Get phi and pt weight histogram with this run number:
775783
if (wt.fWeightSwitch && wt.fPhiWeightHistogramsMap.find(ebye.fRunNumber) == wt.fPhiWeightHistogramsMap.end()) {
776-
784+
777785
TH1F* phiWeightHist = dynamic_cast<TH1F*>(wt.fDummyPhiWeightHistogram->Clone(Form("wPhi_run%d", ebye.fRunNumber)));
778786
TH1F* ptWeightHist = dynamic_cast<TH1F*>(wt.fDummyPtWeightHistogram->Clone(Form("wPt_run%d", ebye.fRunNumber)));
779787

780788
wt.fWeightHistograms = getHistogramsWithWeights(tc.fFileWithWeights.c_str(), stringRunNumber.c_str());
781789

782-
for(TH1F* const hist : wt.fWeightHistograms){
790+
for (auto const& hist : wt.fWeightHistograms) {
783791
if (!hist) {
784792
LOGF(warning, "Fail to loop weight histograms");
785793
continue;
@@ -792,7 +800,7 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
792800
}
793801
}
794802

795-
for(TH1F* const hist : wt.fWeightHistograms){
803+
for (auto const& hist : wt.fWeightHistograms) {
796804
if (!hist) {
797805
LOGF(warning, "Fail to loop weight histograms");
798806
continue;
@@ -887,7 +895,7 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
887895
if (tc.fPrintSwitch) {
888896

889897
LOGF(info, "Run number: %d", ebye.fRunNumber);
890-
898+
891899
LOGF(info, "Centrality: %f", rlCollisionCent);
892900
LOGF(info, "Multiplicity: %f", static_cast<float>(rlCollisionMult));
893901

@@ -1018,7 +1026,7 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
10181026
}
10191027
}
10201028

1021-
// Fail the event cut, skip this collision:
1029+
// Fail the event cut, skip this collision:
10221030
} else {
10231031
return;
10241032
}
@@ -1468,11 +1476,11 @@ struct MultiparticleCumulants { // this name is used in lower-case format to nam
14681476
bookCorrHistograms<eCorrMult>(lCrBins, cr);
14691477

14701478
wt.fDummyPhiWeightHistogram = new TH1F("fDummyPhiWeightHistogram", "Dummy phi weight histogram", tc.fPhiBins[0], tc.fPhiBins[1], tc.fPhiBins[2]);
1471-
for(int i=1; i<=wt.fDummyPhiWeightHistogram->GetNbinsX(); i++){
1479+
for (int i = 1; i <= wt.fDummyPhiWeightHistogram->GetNbinsX(); i++) {
14721480
wt.fDummyPhiWeightHistogram->SetBinContent(i, 1.);
14731481
}
14741482
wt.fDummyPtWeightHistogram = new TH1F("fDummyPtWeightHistogram", "Dummy pt weight histogram", tc.fPtBins[0], tc.fPtBins[1], tc.fPtBins[2]);
1475-
for(int i=1; i<=wt.fDummyPtWeightHistogram->GetNbinsX(); i++){
1483+
for (int i = 1; i <= wt.fDummyPtWeightHistogram->GetNbinsX(); i++) {
14761484
wt.fDummyPtWeightHistogram->SetBinContent(i, 1.);
14771485
}
14781486

0 commit comments

Comments
 (0)