diff --git a/PWGCF/Core/CorrelationContainer.cxx b/PWGCF/Core/CorrelationContainer.cxx index 42b80c92b58..f004c881635 100644 --- a/PWGCF/Core/CorrelationContainer.cxx +++ b/PWGCF/Core/CorrelationContainer.cxx @@ -28,8 +28,11 @@ #include "TF1.h" #include "THn.h" #include "Framework/HistogramSpec.h" +#include "CommonConstants/MathConstants.h" +using namespace o2; using namespace o2::framework; +using namespace o2::constants::math; ClassImp(CorrelationContainer); @@ -486,9 +489,6 @@ TH2* CorrelationContainer::getPerTriggerYield(CorrelationContainer::CFStep step, THnBase* trackSameAll = nullptr; TH2* eventSameAll = nullptr; - Long64_t totalEvents = 0; - Int_t nCorrelationFunctions = 0; - getHistsZVtxMult(step, ptTriggerMin, ptTriggerMax, &trackSameAll, &eventSameAll); TAxis* multAxis = trackSameAll->GetAxis(3); @@ -1498,8 +1498,8 @@ void CorrelationContainer::symmetrizepTBins() for (Int_t i4 = 1; i4 <= target->GetAxis(4)->GetNbins(); i4++) { Int_t binEta = target->GetAxis(0)->FindBin(-target->GetAxis(0)->GetBinCenter(i0)); Double_t phi = -target->GetAxis(4)->GetBinCenter(i4); - if (phi < -M_PI / 2) { - phi += M_PI * 2; + if (phi < -PIHalf) { + phi += TwoPI; } Int_t binPhi = target->GetAxis(4)->FindBin(phi); diff --git a/PWGCF/Core/PairCuts.h b/PWGCF/Core/PairCuts.h index 5c394c4aa00..b90094f30e2 100644 --- a/PWGCF/Core/PairCuts.h +++ b/PWGCF/Core/PairCuts.h @@ -16,6 +16,7 @@ #include "Framework/Logger.h" #include "Framework/HistogramRegistry.h" +#include "CommonConstants/MathConstants.h" // Functions which cut on particle pairs (decays, conversions, two-track cuts) // @@ -23,6 +24,7 @@ using namespace o2; using namespace o2::framework; +using namespace constants::math; class PairCuts { @@ -266,41 +268,41 @@ double PairCuts::getInvMassSquaredFast(T const& track1, double m0_1, T const& tr const float pt1 = track1.pt(); const float pt2 = track2.pt(); - float tantheta1 = 1e10; + float tantheta1 = 1e10f; - if (eta1 < -1e-10 || eta1 > 1e-10) { - float expTmp = 1.0 - eta1 + eta1 * eta1 / 2 - eta1 * eta1 * eta1 / 6 + eta1 * eta1 * eta1 * eta1 / 24; - tantheta1 = 2.0 * expTmp / (1.0 - expTmp * expTmp); + if (eta1 < -1e-10f || eta1 > 1e-10f) { + float expTmp = 1.0f - eta1 + eta1 * eta1 / 2.0f - eta1 * eta1 * eta1 / 6.0f + eta1 * eta1 * eta1 * eta1 / 24.0f; + tantheta1 = 2.0f * expTmp / (1.0f - expTmp * expTmp); } - float tantheta2 = 1e10; - if (eta2 < -1e-10 || eta2 > 1e-10) { - float expTmp = 1.0 - eta2 + eta2 * eta2 / 2 - eta2 * eta2 * eta2 / 6 + eta2 * eta2 * eta2 * eta2 / 24; - tantheta2 = 2.0 * expTmp / (1.0 - expTmp * expTmp); + float tantheta2 = 1e10f; + if (eta2 < -1e-10f || eta2 > 1e-10f) { + float expTmp = 1.0f - eta2 + eta2 * eta2 / 2.0f - eta2 * eta2 * eta2 / 6.0f + eta2 * eta2 * eta2 * eta2 / 24.0f; + tantheta2 = 2.0f * expTmp / (1.0f - expTmp * expTmp); } - float e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1); - float e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2); + float e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0f + 1.0f / tantheta1 / tantheta1); + float e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0f + 1.0f / tantheta2 / tantheta2); // fold onto 0...pi float deltaPhi = std::fabs(phi1 - phi2); - while (deltaPhi > M_PI * 2) { - deltaPhi -= M_PI * 2; + while (deltaPhi > TwoPI) { + deltaPhi -= TwoPI; } - if (deltaPhi > M_PI) { - deltaPhi = M_PI * 2 - deltaPhi; + if (deltaPhi > PI) { + deltaPhi = TwoPI - deltaPhi; } float cosDeltaPhi = 0; - if (deltaPhi < M_PI / 3) { + if (deltaPhi < PI / 3.0f) { cosDeltaPhi = 1.0 - deltaPhi * deltaPhi / 2 + deltaPhi * deltaPhi * deltaPhi * deltaPhi / 24; - } else if (deltaPhi < 2 * M_PI / 3) { - cosDeltaPhi = -(deltaPhi - M_PI / 2) + 1.0 / 6 * std::pow((deltaPhi - M_PI / 2), 3); + } else if (deltaPhi < 2.0f * PI / 3.0f) { + cosDeltaPhi = -(deltaPhi - PI / 2) + 1.0 / 6 * std::pow((deltaPhi - PI / 2), 3); } else { - cosDeltaPhi = -1.0 + 1.0 / 2.0 * (deltaPhi - M_PI) * (deltaPhi - M_PI) - 1.0 / 24.0 * std::pow(deltaPhi - M_PI, 4); + cosDeltaPhi = -1.0f + 1.0f / 2.0f * (deltaPhi - PI) * (deltaPhi - PI) - 1.0f / 24.0f * std::pow(deltaPhi - PI, 4.0f); } - double mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * (std::sqrt(e1squ * e2squ) - (pt1 * pt2 * (cosDeltaPhi + 1.0 / tantheta1 / tantheta2))); + double mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2.0f * (std::sqrt(e1squ * e2squ) - (pt1 * pt2 * (cosDeltaPhi + 1.0f / tantheta1 / tantheta2))); //LOGF(debug, "%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2); @@ -324,14 +326,14 @@ float PairCuts::getDPhiStar(T const& track1, T const& track2, float radius, int float dphistar = phi1 - phi2 - charge1 * std::asin(0.015 * magField * radius / pt1) + charge2 * std::asin(0.015 * magField * radius / pt2); - if (dphistar > M_PI) { - dphistar = M_PI * 2 - dphistar; + if (dphistar > PI) { + dphistar = TwoPI - dphistar; } - if (dphistar < -M_PI) { - dphistar = -M_PI * 2 - dphistar; + if (dphistar < -PI) { + dphistar = -TwoPI - dphistar; } - if (dphistar > M_PI) { // might look funny but is needed - dphistar = M_PI * 2 - dphistar; + if (dphistar > PI) { // might look funny but is needed + dphistar = TwoPI - dphistar; } return dphistar; diff --git a/PWGCF/Tasks/correlations.cxx b/PWGCF/Tasks/correlations.cxx index e6471f0f956..59ee6ca4224 100644 --- a/PWGCF/Tasks/correlations.cxx +++ b/PWGCF/Tasks/correlations.cxx @@ -16,6 +16,7 @@ #include "Framework/StepTHn.h" #include "Framework/HistogramRegistry.h" #include "Framework/RunningWorkflowInfo.h" +#include "CommonConstants/MathConstants.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -44,6 +45,7 @@ using Hash = Hashes::iterator; using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace constants::math; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; @@ -73,7 +75,7 @@ struct CorrelationTask { O2_DEFINE_CONFIGURABLE(cfgNoMixedEvents, int, 5, "Number of mixed events per event") ConfigurableAxis axisVertex{"axisVertex", {7, -7, 7}, "vertex axis for histograms"}; - ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -M_PI / 2, M_PI / 2 * 3}, "delta phi axis for histograms"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; ConfigurableAxis axisDeltaEta{"axisDeltaEta", {40, -2, 2}, "delta eta axis for histograms"}; ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt trigger axis for histograms"}; ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0}, "pt associated axis for histograms"}; @@ -254,11 +256,11 @@ struct CorrelationTask { } float deltaPhi = track1.phi() - track2.phi(); - if (deltaPhi > 1.5 * M_PI) { - deltaPhi -= M_PI * 2; + if (deltaPhi > 1.5f * PI) { + deltaPhi -= TwoPI; } - if (deltaPhi < -0.5 * M_PI) { - deltaPhi += M_PI * 2; + if (deltaPhi < -PIHalf) { + deltaPhi += TwoPI; } target->getPairHist()->Fill(CorrelationContainer::kCFStepReconstructed, @@ -454,11 +456,11 @@ struct CorrelationTask { } float deltaPhi = track1.phi() - track2.phi(); - if (deltaPhi > 1.5 * M_PI) { - deltaPhi -= M_PI * 2; + if (deltaPhi > 1.5f * PI) { + deltaPhi -= TwoPI; } - if (deltaPhi < -0.5 * M_PI) { - deltaPhi += M_PI * 2; + if (deltaPhi < -PIHalf) { + deltaPhi += TwoPI; } same->getPairHist()->Fill(CorrelationContainer::kCFStepReconstructed, diff --git a/Tutorials/src/mcHistograms.cxx b/Tutorials/src/mcHistograms.cxx index d5bf49c12f0..b0fd18cbc1e 100644 --- a/Tutorials/src/mcHistograms.cxx +++ b/Tutorials/src/mcHistograms.cxx @@ -15,10 +15,13 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" +#include "CommonConstants/MathConstants.h" + #include "Common/Core/MC.h" using namespace o2; using namespace o2::framework; +using namespace constants::math; // Simple access to collision struct VertexDistribution { @@ -34,7 +37,7 @@ struct VertexDistribution { // Grouping between MC particles and collisions struct AccessMcData { - OutputObj phiH{TH1F("phi", "phi", 100, 0., 2. * M_PI)}; + OutputObj phiH{TH1F("phi", "phi", 100, 0., TwoPI)}; OutputObj etaH{TH1F("eta", "eta", 102, -2.01, 2.01)}; // group according to McCollisions @@ -58,7 +61,7 @@ struct AccessMcData { // Access from tracks to MC particle struct AccessMcTruth { OutputObj etaDiff{TH1F("etaDiff", ";eta_{MC} - eta_{Rec}", 100, -2, 2)}; - OutputObj phiDiff{TH1F("phiDiff", ";phi_{MC} - phi_{Rec}", 100, -M_PI, M_PI)}; + OutputObj phiDiff{TH1F("phiDiff", ";phi_{MC} - phi_{Rec}", 100, -PI, PI)}; // group according to reconstructed Collisions void process(soa::Join::iterator const& collision, soa::Join const& tracks, @@ -75,11 +78,11 @@ struct AccessMcTruth { if (MC::isPhysicalPrimary(particle)) { etaDiff->Fill(particle.eta() - track.eta()); auto delta = particle.phi() - track.phi(); - if (delta > M_PI) { - delta -= 2 * M_PI; + if (delta > PI) { + delta -= TwoPI; } - if (delta < -M_PI) { - delta += 2 * M_PI; + if (delta < -PI) { + delta += TwoPI; } phiDiff->Fill(delta); }