@@ -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