Skip to content

Commit bbe899b

Browse files
committed
Fix casts
Fixes C-style, redundant, wrong, and dangerous casts (found by Clang-Tidy and cpplint). - Remove redundant casts. (`readability-redundant-casting`) - Remove `const_cast`. (`cppcoreguidelines-pro-type-const-cast`) - Replace C-style casts with `static_cast`. (`google-readability-casting`, cpplint: `readability/casting`) - Replace unsafe C-style casts with `dynamic_cast`. (`cppcoreguidelines-pro-type-cstyle-cast`) - Replace `static_cast` in downcasts with `dynamic_cast`. (`cppcoreguidelines-pro-type-static-cast-downcast`) - Replace `reinterpret_cast` with `static_cast` or `dynamic_cast`. (`cppcoreguidelines-pro-type-reinterpret-cast`) - Replace two-step casting through `void*` with `reinterpret_cast`. (`bugprone-casting-through-void`)
1 parent 1f1e980 commit bbe899b

122 files changed

Lines changed: 883 additions & 883 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎PWGCF/EbyEFluctuations/Tasks/NetProtonCumulants.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct NetProtonCumulants_Table_QA {
7070

7171
// Filter command***********
7272
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
73-
Filter trackFilter = (nabs(aod::track::eta) < 0.8f) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl);
73+
Filter trackFilter = (nabs(aod::track::eta) < 0.8f) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true))) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl);
7474

7575
// Connect to ccdb
7676
Service<ccdb::BasicCCDBManager> ccdb;

‎PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ struct RobustFluctuationObservables {
16991699
histosEvent.fill(HIST("h2D_diffFoundBC_vs_BC"), collBC, diffFoundBC_vs_BC);
17001700

17011701
if (collision.has_foundBC())
1702-
histosEvent.fill(HIST("h2D_diffFoundBC_vs_BC_inTF"), collBC, static_cast<int64_t>(foundBcInTF) - static_cast<int64_t>(bcInTF));
1702+
histosEvent.fill(HIST("h2D_diffFoundBC_vs_BC_inTF"), collBC, foundBcInTF - bcInTF);
17031703

17041704
// with FT0 conditions
17051705
if (isFT0) {

‎PWGCF/EbyEFluctuations/Tasks/antiprotonCumulantsMc.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct AntiprotonCumulantsMc {
110110

111111
// Filter command for rec (data)***********
112112
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
113-
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy);
113+
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true))) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy);
114114

115115
// filtering collisions and tracks for real data***********
116116
using AodCollisions = soa::Filtered<soa::Join<aod::Collisions, aod::EvSels, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::CentFDDMs>>;
@@ -138,8 +138,8 @@ struct AntiprotonCumulantsMc {
138138
ccdb->setCreatedNotAfter(ccdbNoLaterThan.value);
139139
LOGF(info, "Getting object %s", ccdbPath.value.data());
140140
TList* lst = ccdb->getForTimeStamp<TList>(ccdbPath.value, ccdbNoLaterThan.value);
141-
hRatio2DEtaVsPtProton = reinterpret_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtProton"));
142-
hRatio2DEtaVsPtAntiproton = reinterpret_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtAntiproton"));
141+
hRatio2DEtaVsPtProton = dynamic_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtProton"));
142+
hRatio2DEtaVsPtAntiproton = dynamic_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtAntiproton"));
143143
if (!hRatio2DEtaVsPtProton || !hRatio2DEtaVsPtAntiproton)
144144
LOGF(info, "FATAL!! could not get efficiency---------> check");
145145
}

‎PWGCF/EbyEFluctuations/Tasks/eventMeanPtId.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct EventMeanPtId {
186186
// ccdb->setCreatedNotAfter(ccdbNoLaterThan.value);
187187
// LOGF(info, "Getting object %s", ccdbPath.value.data());
188188
TList* lst = ccdb->getForTimeStamp<TList>(cfgPathCCDB.value, 1);
189-
ptHistogramAllchargeRec = reinterpret_cast<TH2D*>(lst->FindObject("hPtEta_rec"));
189+
ptHistogramAllchargeRec = dynamic_cast<TH2D*>(lst->FindObject("hPtEta_rec"));
190190
}
191191
std::vector<double> ptBinning = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0};
192192
AxisSpec vtxZAxis = {100, -20.0, 20.0, "Z (cm)"};

‎PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,8 +2440,8 @@ struct KaonIsospinFluctuations {
24402440

24412441
void processSim(MyMcCollisions const& mcCollisions, aod::McParticles const& mcParticles)
24422442
{
2443-
auto finalParticleIdList = (std::vector<int>)cfgFinalParticleIdList;
2444-
auto nonFinalParticleIdList = (std::vector<int>)cfgNonFinalParticleIdList;
2443+
auto finalParticleIdList = std::vector<int>(cfgFinalParticleIdList);
2444+
auto nonFinalParticleIdList = std::vector<int>(cfgNonFinalParticleIdList);
24452445
std::sort(finalParticleIdList.begin(), finalParticleIdList.end());
24462446
std::sort(nonFinalParticleIdList.begin(), nonFinalParticleIdList.end());
24472447

‎PWGCF/EbyEFluctuations/Tasks/netprotcumulants.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct NetProtCumulants {
175175

176176
// Filter command for rec (data)***********
177177
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
178-
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy);
178+
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true))) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy);
179179

180180
// filtering collisions and tracks for real data***********
181181
using AodCollisions = soa::Filtered<soa::Join<aod::Collisions, aod::EvSels, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::CentFDDMs>>;
@@ -203,8 +203,8 @@ struct NetProtCumulants {
203203
ccdb->setCreatedNotAfter(ccdbNoLaterThan.value);
204204
LOGF(info, "Getting object %s", ccdbPath.value.data());
205205
TList* lst = ccdb->getForTimeStamp<TList>(ccdbPath.value, ccdbNoLaterThan.value);
206-
hRatio2DEtaVsPtProton = reinterpret_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtProton"));
207-
hRatio2DEtaVsPtAntiproton = reinterpret_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtAntiproton"));
206+
hRatio2DEtaVsPtProton = dynamic_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtProton"));
207+
hRatio2DEtaVsPtAntiproton = dynamic_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtAntiproton"));
208208
if (!hRatio2DEtaVsPtProton || !hRatio2DEtaVsPtAntiproton)
209209
LOGF(info, "FATAL!! could not get efficiency---------> check");
210210
}

‎PWGCF/EbyEFluctuations/Tasks/netprotonCumulantsMc.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct NetprotonCumulantsMc {
110110

111111
// Filter command for rec (data)***********
112112
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
113-
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy);
113+
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true))) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy);
114114

115115
// filtering collisions and tracks for real data***********
116116
using AodCollisions = soa::Filtered<soa::Join<aod::Collisions, aod::EvSels, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::CentFDDMs>>;
@@ -138,8 +138,8 @@ struct NetprotonCumulantsMc {
138138
ccdb->setCreatedNotAfter(ccdbNoLaterThan.value);
139139
LOGF(info, "Getting object %s", ccdbPath.value.data());
140140
TList* lst = ccdb->getForTimeStamp<TList>(ccdbPath.value, ccdbNoLaterThan.value);
141-
hRatio2DEtaVsPtProton = reinterpret_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtProton"));
142-
hRatio2DEtaVsPtAntiproton = reinterpret_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtAntiproton"));
141+
hRatio2DEtaVsPtProton = dynamic_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtProton"));
142+
hRatio2DEtaVsPtAntiproton = dynamic_cast<TH2F*>(lst->FindObject("hRatio2DEtaVsPtAntiproton"));
143143
if (!hRatio2DEtaVsPtProton || !hRatio2DEtaVsPtAntiproton)
144144
LOGF(info, "FATAL!! could not get efficiency---------> check");
145145
}

‎PWGCF/EbyEFluctuations/Tasks/v0ptHadPiKaProt.cxx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ struct V0ptHadPiKaProt {
285285
ccdb->setCreatedNotAfter(ccdbNoLaterThan.value);
286286
LOGF(info, "Getting object %s", ccdbPath.value.data());
287287
TList* lst = ccdb->getForTimeStamp<TList>(ccdbPath.value, ccdbNoLaterThan.value);
288-
hWeightPhiFunctionVzEtaPhi = reinterpret_cast<TH3D*>(lst->FindObject("hWeightPhiFunctionVzEtaPhi"));
288+
hWeightPhiFunctionVzEtaPhi = dynamic_cast<TH3D*>(lst->FindObject("hWeightPhiFunctionVzEtaPhi"));
289289
if (!hWeightPhiFunctionVzEtaPhi)
290290
LOGF(info, "FATAL!! could not get phi weights---------> check");
291291
}
@@ -299,10 +299,10 @@ struct V0ptHadPiKaProt {
299299
ccdb->setCreatedNotAfter(ccdbNoLaterThanPtEff.value);
300300
LOGF(info, "Getting object %s", ccdbPathPtEff.value.data());
301301
TList* lst = ccdb->getForTimeStamp<TList>(ccdbPathPtEff.value, ccdbNoLaterThanPtEff.value);
302-
hEffAllCharged = reinterpret_cast<TH1D*>(lst->FindObject("hEffAllCharged"));
303-
hEffPion = reinterpret_cast<TH1D*>(lst->FindObject("hEffPion"));
304-
hEffKaon = reinterpret_cast<TH1D*>(lst->FindObject("hEffKaon"));
305-
hEffProton = reinterpret_cast<TH1D*>(lst->FindObject("hEffProton"));
302+
hEffAllCharged = dynamic_cast<TH1D*>(lst->FindObject("hEffAllCharged"));
303+
hEffPion = dynamic_cast<TH1D*>(lst->FindObject("hEffPion"));
304+
hEffKaon = dynamic_cast<TH1D*>(lst->FindObject("hEffKaon"));
305+
hEffProton = dynamic_cast<TH1D*>(lst->FindObject("hEffProton"));
306306
if (!hEffAllCharged || !hEffPion || !hEffKaon || !hEffProton)
307307
LOGF(info, "FATAL!! could not get efficiency files---------> !!! check !!!");
308308
}

‎PWGCF/Femto3D/Core/femto3dPairTask.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ Type getBinIndex(float const& value, std::vector<float> const& binning, int cons
102102
for (unsigned int i = 0; i < binning.size() - 1; i++) {
103103
if (value >= binning[i] && binning[i + 1] > value) {
104104
if (NsubBins < 2) {
105-
res = (Type)i;
105+
res = static_cast<Type>(i);
106106
break;
107107
} else {
108108
float subBinWidth = (binning[i + 1] - binning[i]) / NsubBins;
109109
int subBin = std::floor((value - binning[i]) / subBinWidth);
110110
int delimeter = std::pow(10, std::to_string(NsubBins).size());
111111

112-
res = (Type)i + (Type)subBin / delimeter;
112+
res = static_cast<Type>(i) + static_cast<Type>(subBin) / delimeter;
113113
break;
114114
}
115115
}

‎PWGCF/Femto3D/Tools/checkPacking.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ bool process(const TString& outputName, const int nevents = 100000)
7373
LOG(info) << "Bin width = " << T::bin_width << " vs histo " << hgaus->GetXaxis()->GetBinWidth(1);
7474
hgaus->SetLineColor(2);
7575
hgaus->SetLineStyle(1);
76-
TH1F* hgausPacked = static_cast<TH1F*>(hgaus->Clone("hgausPacked"));
76+
TH1F* hgausPacked = dynamic_cast<TH1F*>(hgaus->Clone("hgausPacked"));
7777
hgausPacked->SetLineColor(4);
7878
hgausPacked->SetLineStyle(2);
7979

80-
TH1F* huniform = static_cast<TH1F*>(hgaus->Clone("huniform"));
80+
TH1F* huniform = dynamic_cast<TH1F*>(hgaus->Clone("huniform"));
8181
huniform->SetLineColor(2);
8282
huniform->SetLineStyle(1);
83-
TH1F* huniformPacked = static_cast<TH1F*>(hgaus->Clone("huniformPacked"));
83+
TH1F* huniformPacked = dynamic_cast<TH1F*>(hgaus->Clone("huniformPacked"));
8484
huniformPacked->SetLineColor(4);
8585
huniformPacked->SetLineStyle(2);
8686

0 commit comments

Comments
 (0)