Skip to content

Commit 6a795e2

Browse files
authored
[Common] Fix problems found by Cppcheck (#14178)
1 parent 9761502 commit 6a795e2

File tree

5 files changed

+38
-44
lines changed

5 files changed

+38
-44
lines changed

Common/TableProducer/PID/pidTPCBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ typedef struct Str_dEdx_correction {
100100
for (int i = 0; i < fMatrix.GetNrows(); i++) {
101101
for (int j = 0; j < fMatrix.GetNcols(); j++) {
102102
double param = fMatrix(i, j);
103-
double value1 = i > static_cast<int>(vec1.size()) ? 0 : vec1[i];
104-
double value2 = j > static_cast<int>(vec2.size()) ? 0 : vec2[j];
103+
double value1 = i >= static_cast<int>(vec1.size()) ? 0 : vec1[i];
104+
double value2 = j >= static_cast<int>(vec2.size()) ? 0 : vec2[j];
105105
result += param * value1 * value2;
106106
}
107107
}

Common/TableProducer/selectionStudyTable.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ struct SelectionStudyTable {
105105
if (std::abs(mcPart.pdgCode()) == 3334) {
106106
ptom.push_back(mcPart.pt());
107107
}
108-
if (std::abs(mcPart.pdgCode()) == 3334) {
109-
ptom.push_back(mcPart.pt());
110-
}
111108
// inclusive HF for now
112109
if (std::abs(mcPart.pdgCode()) == 421) {
113110
ptd.push_back(mcPart.pt());

Common/Tasks/qaMuon.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ struct muonQa {
533533
for (size_t i = 0; i < 2; i++) {
534534
std::string topBottom = (i == 0) ? "top" : "bottom";
535535
AxisSpec deAxis = {26, 0, 26, "DE index"};
536-
AxisSpec phiAxis = {16, -180, 180, "#phi (degrees)"};
536+
AxisSpec phiAxisInner = {16, -180, 180, "#phi (degrees)"};
537537
for (size_t j = 0; j < 2; j++) {
538538
std::string sign = (j == 0) ? "positive" : "negative";
539539
for (int chamber = 0; chamber < 10; chamber++) {
@@ -542,17 +542,17 @@ struct muonQa {
542542
residualsHistosPerDE[i][j][chamber]["dx_vs_de"] = registryResidualsMFT.add((histPath + "dx_vs_de").c_str(), "Cluster x residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}});
543543
residualsHistosPerDE[i][j][chamber]["dy_vs_de"] = registryResidualsMFT.add((histPath + "dy_vs_de").c_str(), "Cluster y residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}});
544544

545-
residualsHistosPerDE[i][j][chamber]["dx_vs_phi"] = registryResidualsMFT.add((histPath + "dx_vs_phi").c_str(), "Cluster x residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}});
546-
residualsHistosPerDE[i][j][chamber]["dy_vs_phi"] = registryResidualsMFT.add((histPath + "dy_vs_phi").c_str(), "Cluster y residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}});
545+
residualsHistosPerDE[i][j][chamber]["dx_vs_phi"] = registryResidualsMFT.add((histPath + "dx_vs_phi").c_str(), "Cluster x residual vs. cluster #phi", {HistType::kTH2F, {phiAxisInner, dxAxis}});
546+
residualsHistosPerDE[i][j][chamber]["dy_vs_phi"] = registryResidualsMFT.add((histPath + "dy_vs_phi").c_str(), "Cluster y residual vs. cluster #phi", {HistType::kTH2F, {phiAxisInner, dxAxis}});
547547

548548
// mixed events
549549
histPath = std::string("Alignment/mixed-event/Residuals/MFT/MFT_") + topBottom + "/" + sign + "/CH" + std::to_string(chamber + 1) + "/";
550550
// Delta x and y at cluster
551551
residualsHistosPerDEMixedEvents[i][j][chamber]["dx_vs_de"] = registryResidualsMFT.add((histPath + "dx_vs_de").c_str(), "Cluster x residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}});
552552
residualsHistosPerDEMixedEvents[i][j][chamber]["dy_vs_de"] = registryResidualsMFT.add((histPath + "dy_vs_de").c_str(), "Cluster y residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}});
553553

554-
residualsHistosPerDEMixedEvents[i][j][chamber]["dx_vs_phi"] = registryResidualsMFT.add((histPath + "dx_vs_phi").c_str(), "Cluster x residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}});
555-
residualsHistosPerDEMixedEvents[i][j][chamber]["dy_vs_phi"] = registryResidualsMFT.add((histPath + "dy_vs_phi").c_str(), "Cluster y residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}});
554+
residualsHistosPerDEMixedEvents[i][j][chamber]["dx_vs_phi"] = registryResidualsMFT.add((histPath + "dx_vs_phi").c_str(), "Cluster x residual vs. cluster #phi", {HistType::kTH2F, {phiAxisInner, dxAxis}});
555+
residualsHistosPerDEMixedEvents[i][j][chamber]["dy_vs_phi"] = registryResidualsMFT.add((histPath + "dy_vs_phi").c_str(), "Cluster y residual vs. cluster #phi", {HistType::kTH2F, {phiAxisInner, dxAxis}});
556556
}
557557
}
558558
}
@@ -738,7 +738,7 @@ struct muonQa {
738738
AxisSpec rAbsAxis = {10, 0., 100.0, "R_{abs} (cm)"};
739739
AxisSpec dcaAxis = {400, -10.0, 10.0, "DCA"};
740740
AxisSpec dcaAxisReduced = {40, -10.0, 10.0, "DCA"};
741-
AxisSpec phiAxis = {36, -180.0, 180.0, "#phi (degrees)"};
741+
AxisSpec phiAxisInner = {36, -180.0, 180.0, "#phi (degrees)"};
742742
// dimuons
743743
AxisSpec invMassAxis = {400, 1, 5, "M_{#mu^{+}#mu^{-}} (GeV/c^{2})"};
744744
AxisSpec invMassCorrelationAxis = {80, 0, 8, "M_{#mu^{+}#mu^{-}} (GeV/c^{2})"};
@@ -801,8 +801,8 @@ struct muonQa {
801801
registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosDca_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} DCA", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, dcaAxisReduced}});
802802
registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegDca_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} DCA", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, dcaAxisReduced}});
803803
//
804-
registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosPhi_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} #phi", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, phiAxis}});
805-
registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegPhi_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} #phi", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, phiAxis}});
804+
registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosPhi_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} #phi", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, phiAxisInner}});
805+
registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegPhi_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} #phi", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, phiAxisInner}});
806806
}
807807
// MCH-MID tracks with MCH acceptance cuts
808808
registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}});
@@ -1739,8 +1739,8 @@ struct muonQa {
17391739
float dcaXY = std::sqrt(fgValues.dcaX * fgValues.dcaX + fgValues.dcaY * fgValues.dcaY);
17401740
fgValues.dcaXY = dcaXY;
17411741

1742-
mch::TrackParam trackParam = mch::TrackParam(muon.first());
1743-
float p = trackParam.p();
1742+
mch::TrackParam trackParamInner = mch::TrackParam(muon.first());
1743+
float p = trackParamInner.p();
17441744
fgValues.pDca = p * dcaXY;
17451745
}
17461746

@@ -1806,14 +1806,14 @@ struct muonQa {
18061806
// double pz = pMCH * cos(M_PI / 2 - atan(mft.tgl()));
18071807
double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2));
18081808

1809-
double chi2 = muon.chi2();
1809+
double chi2Inner = muon.chi2();
18101810
double signed1Pt = endPoint == kToDCA ? muon.signed1Pt() : sign / pt;
18111811
SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), signed1Pt);
18121812
std::vector<double> v1{0, 0, 0, 0, 0,
18131813
0, 0, 0, 0, 0,
18141814
0, 0, 0, 0, 0};
18151815
SMatrix55 tcovs(v1.begin(), v1.end());
1816-
o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2};
1816+
o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2Inner};
18171817
track.setParameters(tpars);
18181818
track.setZ(fwdtrack.getZ());
18191819
track.setCovariances(tcovs);

Common/Tools/EventSelectionModule.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,10 @@ class EventSelectionModule
786786
diffVzParMean = *parMeans;
787787
diffVzParSigma = *parSigmas;
788788
LOGP(info, ">>> special treatment for diffVz for light ion run {}", runLightIons);
789-
for (int i = 0; i < 5; i++)
790-
LOGP(info, " mean par {} = {}", i, diffVzParMean[i]);
791-
for (int i = 0; i < 5; i++)
792-
LOGP(info, " sigma par {} = {}", i, diffVzParSigma[i]);
789+
for (int j = 0; j < 5; j++)
790+
LOGP(info, " mean par {} = {}", j, diffVzParMean[j]);
791+
for (int j = 0; j < 5; j++)
792+
LOGP(info, " sigma par {} = {}", j, diffVzParSigma[j]);
793793
break;
794794
}
795795
}
@@ -1044,8 +1044,9 @@ class EventSelectionModule
10441044
}
10451045
}
10461046
}
1047-
} // end of if TOF-matched vertex
1048-
else { // for non-TOF and low-mult vertices, consider nearby nominal bcs
1047+
// end of if TOF-matched vertex
1048+
} else {
1049+
// for non-TOF and low-mult vertices, consider nearby nominal bcs
10491050
int64_t meanBC = globalBC + TMath::Nint(sumHighPtTime / sumHighPtW / bcNS);
10501051
int64_t bestGlobalBC = findBestGlobalBC(meanBC, evselOpts.confSigmaBCforHighPtTracks, vNcontributors[colIndex], col.posZ(), mapGlobalBcVtxZ);
10511052
if (bestGlobalBC > 0) {
@@ -1064,7 +1065,7 @@ class EventSelectionModule
10641065
foundBCindex = bc.globalIndex(); // keep original BC index
10651066
}
10661067
} // end of non-TOF matched vertices
1067-
// sanitity check: if BC was not found
1068+
// sanity check: if BC was not found
10681069
if (foundBCindex == -1) {
10691070
foundBCindex = bc.globalIndex();
10701071
}

Common/Tools/PID/pidTPCModule.h

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ typedef struct Str_dEdx_correction {
189189
for (int i = 0; i < fMatrix.GetNrows(); i++) {
190190
for (int j = 0; j < fMatrix.GetNcols(); j++) {
191191
double param = fMatrix(i, j);
192-
double value1 = i > static_cast<int>(vec1.size()) ? 0 : vec1[i];
193-
double value2 = j > static_cast<int>(vec2.size()) ? 0 : vec2[j];
192+
double value1 = i >= static_cast<int>(vec1.size()) ? 0 : vec1[i];
193+
double value2 = j >= static_cast<int>(vec2.size()) ? 0 : vec2[j];
194194
result += param * value1 * value2;
195195
}
196196
}
@@ -201,14 +201,10 @@ typedef struct Str_dEdx_correction {
201201
class pidTPCModule
202202
{
203203
public:
204-
pidTPCModule()
205-
{
206-
// constructor
207-
}
208204
o2::aod::pid::pidTPCConfigurables pidTPCopts;
209205

210206
// TPC PID Response
211-
o2::pid::tpc::Response* response;
207+
o2::pid::tpc::Response* response{nullptr};
212208

213209
// Network correction for TPC PID response
214210
ml::OnnxModel network;
@@ -237,13 +233,13 @@ class pidTPCModule
237233
pidTPCopts = external_pidtpcopts;
238234

239235
if (pidTPCopts.useCorrecteddEdx.value) {
240-
LOGF(info, "***************************************************");
241-
LOGF(info, " WARNING: YOU HAVE SWITCHED ON 'corrected dEdx!");
242-
LOGF(info, " This mode is still in development and it is meant");
243-
LOGF(info, " ONLY FOR EXPERTS at this time. Please switch ");
244-
LOGF(info, " this option off UNLESS you are absolutely SURE");
245-
LOGF(info, " of what you're doing! You've been warned!");
246-
LOGF(info, "***************************************************");
236+
LOGF(warning, "***************************************************");
237+
LOGF(warning, " WARNING: YOU HAVE SWITCHED ON 'corrected dEdx!");
238+
LOGF(warning, " This mode is still in development and it is meant");
239+
LOGF(warning, " ONLY FOR EXPERTS at this time. Please switch ");
240+
LOGF(warning, " this option off UNLESS you are absolutely SURE");
241+
LOGF(warning, " of what you're doing! You've been warned!");
242+
LOGF(warning, "***************************************************");
247243
}
248244

249245
if (pidTPCopts.skipTPCOnly.value == -1) {
@@ -262,7 +258,7 @@ class pidTPCModule
262258
pidTPCopts.skipTPCOnly.value = 1;
263259

264260
// loop over devices in this execution
265-
auto& workflows = context.services().template get<o2::framework::RunningWorkflowInfo const>();
261+
auto const& workflows = context.services().template get<o2::framework::RunningWorkflowInfo const>();
266262
for (o2::framework::DeviceSpec const& device : workflows.devices) {
267263
// Look for propagation service
268264
if (device.name.compare("propagation-service") == 0) {
@@ -544,7 +540,7 @@ class pidTPCModule
544540
constexpr int ExpectedInputDimensionsNNV3 = 8;
545541
constexpr auto NetworkVersionV2 = "2";
546542
constexpr auto NetworkVersionV3 = "3";
547-
for (int i = 0; i < NParticleTypes; i++) { // Loop over particle number for which network correction is used
543+
for (int j = 0; j < NParticleTypes; j++) { // Loop over particle number for which network correction is used
548544
for (auto const& trk : tracks) {
549545
if (!trk.hasTPC()) {
550546
continue;
@@ -557,7 +553,7 @@ class pidTPCModule
557553
track_properties[counter_track_props] = trk.tpcInnerParam();
558554
track_properties[counter_track_props + 1] = trk.tgl();
559555
track_properties[counter_track_props + 2] = trk.signed1Pt();
560-
track_properties[counter_track_props + 3] = o2::track::pid_constants::sMasses[i];
556+
track_properties[counter_track_props + 3] = o2::track::pid_constants::sMasses[j];
561557
track_properties[counter_track_props + 4] = trk.has_collision() ? mults[trk.collisionId()] / 11000. : 1.;
562558
track_properties[counter_track_props + 5] = std::sqrt(nNclNormalization / trk.tpcNClsFound());
563559
if (input_dimensions == ExpectedInputDimensionsNNV2 && networkVersion == NetworkVersionV2) {
@@ -587,9 +583,9 @@ class pidTPCModule
587583
float* output_network = network.evalModel(track_properties);
588584
auto stop_network_eval = std::chrono::high_resolution_clock::now();
589585
duration_network += std::chrono::duration<float, std::ratio<1, 1000000000>>(stop_network_eval - start_network_eval).count();
590-
for (uint64_t i = 0; i < prediction_size; i += output_dimensions) {
591-
for (int j = 0; j < output_dimensions; j++) {
592-
network_prediction[i + j + prediction_size * loop_counter] = output_network[i + j];
586+
for (uint64_t k = 0; k < prediction_size; k += output_dimensions) {
587+
for (int l = 0; l < output_dimensions; l++) {
588+
network_prediction[k + l + prediction_size * loop_counter] = output_network[k + l];
593589
}
594590
}
595591

0 commit comments

Comments
 (0)