Skip to content

Commit 88b50f0

Browse files
committed
Implement Vit comments
1 parent 7126d55 commit 88b50f0

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

Common/TableProducer/qVectorsTable.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <TString.h>
4949

5050
#include <chrono>
51+
#include <cmath>
5152
#include <cstddef>
5253
#include <cstdint>
5354
#include <string>
@@ -737,16 +738,16 @@ struct qVectorsTable {
737738
// taking into account that the Q-vector is normalized by 1/M
738739
// and the EsE reduced Q-vector must be normalized to 1/sqrt(M)
739740
if (useDetector["QvectorFT0Cs"]) {
740-
qVecRedFT0C = TMath::Sqrt(qvecReFT0C.at(0) * qvecReFT0C.at(0) + qvecImFT0C.at(0) * qvecImFT0C.at(0)) * TMath::Sqrt(qvecAmp[kFT0C]);
741+
qVecRedFT0C = std::hypot(qvecReFT0C.at(0), qvecImFT0C.at(0)) * std::sqrt(qvecAmp[kFT0C]);
741742
}
742743
if (useDetector["QvectorTPCposs"]) {
743-
qVecRedTpcPos = TMath::Sqrt(qvecReTPCpos.at(0) * qvecReTPCpos.at(0) + qvecImTPCpos.at(0) * qvecImTPCpos.at(0)) * TMath::Sqrt(qvecAmp[kTPCpos]);
744+
qVecRedTpcPos = std::hypot(qvecReTPCpos.at(0), qvecImTPCpos.at(0)) * std::sqrt(qvecAmp[kTPCpos]);
744745
}
745746
if (useDetector["QvectorTPCnegs"]) {
746-
qVecRedTpcNeg = TMath::Sqrt(qvecReTPCneg.at(0) * qvecReTPCneg.at(0) + qvecImTPCneg.at(0) * qvecImTPCneg.at(0)) * TMath::Sqrt(qvecAmp[kTPCneg]);
747+
qVecRedTpcNeg = std::hypot(qvecReTPCneg.at(0), qvecImTPCneg.at(0)) * std::sqrt(qvecAmp[kTPCneg]);
747748
}
748749
if (useDetector["QvectorTPCalls"]) {
749-
qVecRedTpcAll = TMath::Sqrt(qvecReTPCall.at(0) * qvecReTPCall.at(0) + qvecImTPCall.at(0) * qvecImTPCall.at(0)) * TMath::Sqrt(qvecAmp[kTPCall]);
750+
qVecRedTpcAll = std::hypot(qvecReTPCall.at(0), qvecImTPCall.at(0)) * std::sqrt(qvecAmp[kTPCall]);
750751
}
751752
}
752753
qVectorRed(qVecRedFT0C, qVecRedTpcPos, qVecRedTpcNeg, qVecRedTpcAll);

PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,16 @@ struct HfTaskFlowCharmHadrons {
523523
aod::BCsWithTimestamps const&,
524524
float& centrality)
525525
{
526-
const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
526+
float occupancy{-999.f};
527+
if (occEstimator != 0) {
528+
occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
529+
registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange());
530+
}
527531
const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask<true, CentEstimator, aod::BCsWithTimestamps>(collision, centrality, ccdb, registry);
528532
centrality = o2::hf_centrality::getCentralityColl(collision, CentEstimator);
529533

530534
/// monitor the satisfied event selections
531535
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy);
532-
registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange());
533536
return rejectionMask == 0;
534537
}
535538

@@ -713,10 +716,15 @@ struct HfTaskFlowCharmHadrons {
713716
etaCand = candidate.eta();
714717
}
715718

719+
float const cosNPhi = std::cos(harmonic * phiCand);
720+
float const sinNPhi = std::sin(harmonic * phiCand);
721+
float const cosDeltaPhi = std::cos(harmonic * (phiCand - evtPl));
722+
716723
// If TPC is used for the SP estimation, the tracks of the hadron candidate must be removed from the corresponding TPC Q vector to avoid self-correlations
717724
bool subtractDaugsFromQVec = (qVecDetector == QvecEstimator::TPCNeg ||
718725
qVecDetector == QvecEstimator::TPCPos ||
719726
qVecDetector == QvecEstimator::TPCTot);
727+
float scalprodCand{-999.f};
720728
if (subtractDaugsFromQVec) {
721729

722730
std::vector<float> tracksQx;
@@ -730,17 +738,13 @@ struct HfTaskFlowCharmHadrons {
730738
}
731739

732740
// subtract daughters' contribution from the (normalized) Q-vector
733-
for (std::size_t iTrack = 0; iTrack < tracksQx.size(); ++iTrack) {
734-
xQVec -= tracksQx[iTrack];
735-
yQVec -= tracksQy[iTrack];
736-
}
741+
float xQVecDaugSubtr = xQVec - std::accumulate(tracksQx.begin(), tracksQx.end(), 0.0);
742+
float yQVecDaugSubtr = yQVec - std::accumulate(tracksQy.begin(), tracksQy.end(), 0.0);
743+
scalprodCand = cosNPhi * xQVecDaugSubtr + sinNPhi * yQVecDaugSubtr;
744+
} else {
745+
scalprodCand = cosNPhi * xQVec + sinNPhi * yQVec;
737746
}
738747

739-
float const cosNPhi = std::cos(harmonic * phiCand);
740-
float const sinNPhi = std::sin(harmonic * phiCand);
741-
float const scalprodCand = cosNPhi * xQVec + sinNPhi * yQVec;
742-
float const cosDeltaPhi = std::cos(harmonic * (phiCand - evtPl));
743-
744748
if (fillMassPtMlTree || fillMassPtMlSpCentTree) {
745749
if (downSampleFactor < 1.) {
746750
float const pseudoRndm = ptCand * 1000. - static_cast<int64_t>(ptCand * 1000);
@@ -771,16 +775,13 @@ struct HfTaskFlowCharmHadrons {
771775
}
772776

773777
// subtract daughters' contribution from the (normalized) Q-vector
774-
for (std::size_t iTrack = 0; iTrack < tracksRedQx.size(); ++iTrack) {
775-
xRedQVec -= tracksRedQx[iTrack];
776-
yRedQVec -= tracksRedQy[iTrack];
777-
}
778-
778+
const float redQVecXDaugSubtr = xRedQVec - std::accumulate(tracksRedQx.begin(), tracksRedQx.end(), 0.0);
779+
const float redQVecYDaugSubtr = yRedQVec - std::accumulate(tracksRedQy.begin(), tracksRedQy.end(), 0.0);
779780
if (qVecRedDetector.value == QvecEstimator::TPCTot || qVecRedDetector.value == QvecEstimator::TPCPos || qVecRedDetector.value == QvecEstimator::TPCNeg) {
780781
// Correct for track multiplicity
781-
redQVec = std::sqrt(xRedQVec * xRedQVec + yRedQVec * yRedQVec) * amplRedQVec / std::sqrt(amplRedQVec - tracksRedQx.size());
782+
redQVec = std::hypot(redQVecXDaugSubtr, redQVecYDaugSubtr) * amplRedQVec / std::sqrt(amplRedQVec - tracksRedQx.size());
782783
} else {
783-
redQVec = std::sqrt(xRedQVec * xRedQVec + yRedQVec * yRedQVec) * std::sqrt(amplRedQVec);
784+
redQVec = std::hypot(redQVecXDaugSubtr, redQVecYDaugSubtr) * std::sqrt(amplRedQVec);
784785
}
785786
}
786787
if (storeRedQVec) {
@@ -952,8 +953,11 @@ struct HfTaskFlowCharmHadrons {
952953

953954
centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator);
954955
if (storeResoOccu) {
955-
const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
956-
registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange());
956+
float occupancy{-999.f};
957+
if (occEstimator != 0) {
958+
occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
959+
registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange());
960+
}
957961
const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask<true, o2::hf_centrality::CentralityEstimator::None, aod::BCsWithTimestamps>(collision, centrality, ccdb, registry);
958962
std::vector<int> evtSelFlags = getEventSelectionFlags(rejectionMask);
959963
registry.fill(HIST("spReso/hSparseReso"), centrality, xQVecFT0c * xQVecFV0a + yQVecFT0c * yQVecFV0a,

0 commit comments

Comments
 (0)