Skip to content

Commit 54c13e3

Browse files
sawenzelclaude
andcommitted
Use std::abs for floating-point values in TRD and ITS studies
This fixes unqualified abs() calls on floats that resolve to the integer abs and truncate. - 11 calls in TRD TrackBasedCalib and ITS studies (Efficiency, AvgClusSize) called int abs(int) on a float. - They now call std::abs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1e95e93 commit 54c13e3

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎Detectors/ITSMFT/ITS/postprocessing/studies/src/AvgClusSize.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "SimulationDataFormat/MCCompLabel.h"
3636
#include "DetectorsCommonDataFormats/DetID.h"
3737

38+
#include <cmath>
3839
#include <numeric>
3940
#include <TH1F.h>
4041
#include <TH2F.h>
@@ -461,7 +462,7 @@ void AvgClusSizeStudy::process(o2::globaltracking::RecoContainer& recoData)
461462
}
462463

463464
mOutputNtupleAll->Fill(dPosACS, dNegACS, cosPA, v0R, eta, dauDCA, dPospvDCA, dNegpvDCA, v0pvDCA, alphaArm, pT, calcV0HypoMass(v0, PID::Pion, PID::Pion), calcV0HypoMass(v0, PID::Proton, PID::Pion), calcV0HypoMass(v0, PID::Pion, PID::Proton), (float)V0PdgCode);
464-
if ((cosPA > params.cosPAmin || params.disableCosPA) && (v0R < params.Rmax || params.disableRmax) && (v0R > params.Rmin || params.disableRmin) && (dauDCA < params.prongDCAmax || params.disableProngDCAmax) && (dPospvDCA > params.dauPVDCAmin || params.disableDauPVDCAmin) && (dNegpvDCA > params.dauPVDCAmin || params.disableDauPVDCAmin) && (v0pvDCA < params.v0PVDCAmax || params.disableV0PVDCAmax) && (abs(bgV0HypoMass - backgroundV0.getMass()) > params.bgV0window || params.disableMassHypoth) && (abs(tgV0HypoMass - targetV0.getMass()) < params.tgV0window || params.disableMassHypoth)) {
465+
if ((cosPA > params.cosPAmin || params.disableCosPA) && (v0R < params.Rmax || params.disableRmax) && (v0R > params.Rmin || params.disableRmin) && (dauDCA < params.prongDCAmax || params.disableProngDCAmax) && (dPospvDCA > params.dauPVDCAmin || params.disableDauPVDCAmin) && (dNegpvDCA > params.dauPVDCAmin || params.disableDauPVDCAmin) && (v0pvDCA < params.v0PVDCAmax || params.disableV0PVDCAmax) && (std::abs(bgV0HypoMass - backgroundV0.getMass()) > params.bgV0window || params.disableMassHypoth) && (std::abs(tgV0HypoMass - targetV0.getMass()) < params.tgV0window || params.disableMassHypoth)) {
465466
mOutputNtupleCut->Fill(dPosACS, dNegACS, cosPA, v0R, eta, dauDCA, dPospvDCA, dNegpvDCA, v0pvDCA, alphaArm, pT, calcV0HypoMass(v0, PID::Pion, PID::Pion), calcV0HypoMass(v0, PID::Proton, PID::Pion), calcV0HypoMass(v0, PID::Pion, PID::Proton), (float)V0PdgCode);
466467
if (eta > params.etaMin && eta < params.etaMax) {
467468
fillEtaBin(eta, dPosACS, 0);

‎Detectors/ITSMFT/ITS/postprocessing/studies/src/Efficiency.cxx‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <TString.h>
4646
#include <TAttMarker.h>
4747
#include <TArrayD.h>
48+
#include <cmath>
4849
#include <numeric>
4950

5051
#define NLAYERS 3
@@ -902,11 +903,11 @@ void EfficiencyStudy::countDuplicatedAfterCuts()
902903
o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
903904
phiOriginal = clusOriginalPointGlob.phi(); // * 180 / M_PI;
904905

905-
if (abs(clusOriginalPointGlob.y()) < 0.5) { ///// excluding gap between bottom and top barrels
906+
if (std::abs(clusOriginalPointGlob.y()) < 0.5) { ///// excluding gap between bottom and top barrels
906907
continue;
907908
}
908909

909-
if (abs(clusOriginalPointGlob.z()) >= 10) { /// excluding external z
910+
if (std::abs(clusOriginalPointGlob.z()) >= 10) { /// excluding external z
910911
continue;
911912
}
912913

@@ -1139,10 +1140,10 @@ void EfficiencyStudy::studyDCAcutsMC()
11391140
}
11401141
/// checking the DCA for 20 different sigma ranges
11411142
for (int i = 0; i < 20; i++) {
1142-
if (abs(dcaXY[layerDuplicated] - clusDuplicatedDCA[0]) < (i + 1) * sigmaDcaXY[layerDuplicated] && abs(dcaZ[layerDuplicated] - clusDuplicatedDCA[1]) < (i + 1) * sigmaDcaZ[layerDuplicated]) { // check if the DCA is within the cut i*sigma
1143+
if (std::abs(dcaXY[layerDuplicated] - clusDuplicatedDCA[0]) < (i + 1) * sigmaDcaXY[layerDuplicated] && std::abs(dcaZ[layerDuplicated] - clusDuplicatedDCA[1]) < (i + 1) * sigmaDcaZ[layerDuplicated]) { // check if the DCA is within the cut i*sigma
11431144

11441145
if (mVerboseOutput) {
1145-
LOGP(info, "Check DCA ok: {} < {}; {} < {}", abs(meanDCAxyDuplicated[layerDuplicated] - clusDuplicatedDCA[0]), (i + 1) * sigmaDCAxyDuplicated[layerDuplicated], abs(meanDCAzDuplicated[layerDuplicated] - clusDuplicatedDCA[1]), (i + 1) * sigmaDCAzDuplicated[layerDuplicated]);
1146+
LOGP(info, "Check DCA ok: {} < {}; {} < {}", std::abs(meanDCAxyDuplicated[layerDuplicated] - clusDuplicatedDCA[0]), (i + 1) * sigmaDCAxyDuplicated[layerDuplicated], std::abs(meanDCAzDuplicated[layerDuplicated] - clusDuplicatedDCA[1]), (i + 1) * sigmaDCAzDuplicated[layerDuplicated]);
11461147
}
11471148
nDCAMatches[i]++;
11481149
bool isGoodMatch = false;
@@ -2279,11 +2280,11 @@ void EfficiencyStudy::getEfficiency(bool isMC)
22792280
o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
22802281
phiOriginal = clusOriginalPointGlob.phi(); // * 180 / M_PI;
22812282

2282-
if (abs(clusOriginalPointGlob.y()) < 0.5) { ///// excluding gap between bottom and top barrels
2283+
if (std::abs(clusOriginalPointGlob.y()) < 0.5) { ///// excluding gap between bottom and top barrels
22832284
continue;
22842285
}
22852286

2286-
if (abs(clusOriginalPointGlob.z()) >= 10) { /// excluding external z
2287+
if (std::abs(clusOriginalPointGlob.z()) >= 10) { /// excluding external z
22872288
continue;
22882289
}
22892290

‎Detectors/TRD/calibration/src/TrackBasedCalib.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "CommonConstants/GeomConstants.h"
2626
#include "DataFormatsTPC/TrackTPC.h"
2727
#include "ReconstructionDataFormats/TrackTPCITS.h"
28+
#include <cmath>
2829
#include <fairlogger/Logger.h>
2930

3031
using namespace o2::trd;
@@ -149,7 +150,7 @@ int TrackBasedCalib::filldEdx(gsl::span<const TrackTRD>& tracks, bool isTPCTRD)
149150
float tgl = trkIn.getTgl();
150151
float snp = trkIn.getSnpAt(o2::math_utils::sector2Angle(trkltSec), trackletCalib.getX(), bz);
151152

152-
if (abs(snp) > 1.) {
153+
if (std::abs(snp) > 1.) {
153154
continue;
154155
}
155156

0 commit comments

Comments
 (0)