|
45 | 45 | #include <TDirectory.h> |
46 | 46 | #include <TFile.h> |
47 | 47 | #include <TFormula.h> |
| 48 | +#include <TH2.h> |
48 | 49 | #include <TH3.h> |
49 | 50 | #include <THn.h> |
50 | 51 | #include <TList.h> |
@@ -238,6 +239,8 @@ struct TwoParticleCorrelationsMpi { |
238 | 239 |
|
239 | 240 | std::vector<YieldTemplate> yieldTemplates; |
240 | 241 | std::vector<std::unique_ptr<TH3D>> pairAcceptanceMaps; |
| 242 | + std::vector<std::unique_ptr<TH2D>> pairAcceptanceEtaVertexMaps; |
| 243 | + int pairAcceptanceSchemaVersion = 0; |
241 | 244 | const TList* loadedCcdbYieldTemplateObject = nullptr; |
242 | 245 | bool eventSeedEstimatorEnabled = false; |
243 | 246 |
|
@@ -726,31 +729,45 @@ struct TwoParticleCorrelationsMpi { |
726 | 729 | const auto* schemaVersion = dynamic_cast<const TNamed*>(findObject("pairAcceptanceSchemaVersion")); |
727 | 730 | const auto* normalization = dynamic_cast<const TNamed*>(findObject("pairAcceptanceNormalization")); |
728 | 731 | const auto* axes = dynamic_cast<const TNamed*>(findObject("pairAcceptanceAxes")); |
729 | | - if (schemaVersion == nullptr || TString(schemaVersion->GetTitle()) != "2" || normalization == nullptr || axes == nullptr) { |
730 | | - LOGF(fatal, "Unsupported or missing multiplicity-only pair-acceptance metadata in %s", source.c_str()); |
| 732 | + const TString schema = schemaVersion != nullptr ? schemaVersion->GetTitle() : ""; |
| 733 | + if (schemaVersion == nullptr || (schema != "2" && schema != "3") || normalization == nullptr || axes == nullptr) { |
| 734 | + LOGF(fatal, "Unsupported or missing pair-acceptance metadata in %s", source.c_str()); |
731 | 735 | return; |
732 | 736 | } |
733 | 737 |
|
734 | 738 | const int nMultiplicityBins = AxisSpec(axisMultiplicity).getNbins(); |
735 | 739 | pairAcceptanceMaps.clear(); |
736 | | - pairAcceptanceMaps.resize(nMultiplicityBins); |
| 740 | + pairAcceptanceEtaVertexMaps.clear(); |
| 741 | + pairAcceptanceSchemaVersion = schema.Atoi(); |
| 742 | + if (pairAcceptanceSchemaVersion == 2) { |
| 743 | + pairAcceptanceMaps.resize(nMultiplicityBins); |
| 744 | + } else { |
| 745 | + pairAcceptanceEtaVertexMaps.resize(nMultiplicityBins); |
| 746 | + } |
737 | 747 | for (int multBin = 0; multBin < nMultiplicityBins; ++multBin) { |
738 | | - auto* inputMap = dynamic_cast<TH3D*>(findObject(Form("pairAcceptance_mult_%d", multBin))); |
739 | | - if (inputMap == nullptr) { |
740 | | - LOGF(fatal, "Missing pairAcceptance_mult_%d in %s", multBin, source.c_str()); |
741 | | - pairAcceptanceMaps.clear(); |
742 | | - return; |
743 | | - } |
744 | | - auto* clone = dynamic_cast<TH3D*>(inputMap->Clone(Form("loadedPairAcceptance_mult_%d", multBin))); |
745 | | - if (clone == nullptr) { |
746 | | - LOGF(fatal, "Could not clone pairAcceptance_mult_%d from %s as TH3D", multBin, source.c_str()); |
747 | | - pairAcceptanceMaps.clear(); |
748 | | - return; |
| 748 | + if (pairAcceptanceSchemaVersion == 2) { |
| 749 | + auto* inputMap = dynamic_cast<TH3D*>(findObject(Form("pairAcceptance_mult_%d", multBin))); |
| 750 | + auto* clone = inputMap != nullptr ? dynamic_cast<TH3D*>(inputMap->Clone(Form("loadedPairAcceptance_mult_%d", multBin))) : nullptr; |
| 751 | + if (clone == nullptr) { |
| 752 | + LOGF(fatal, "Missing or invalid pairAcceptance_mult_%d in %s", multBin, source.c_str()); |
| 753 | + pairAcceptanceMaps.clear(); |
| 754 | + return; |
| 755 | + } |
| 756 | + clone->SetDirectory(nullptr); |
| 757 | + pairAcceptanceMaps[multBin].reset(clone); |
| 758 | + } else { |
| 759 | + auto* inputMap = dynamic_cast<TH2D*>(findObject(Form("pairAcceptanceEtaVertex_mult_%d", multBin))); |
| 760 | + auto* clone = inputMap != nullptr ? dynamic_cast<TH2D*>(inputMap->Clone(Form("loadedPairAcceptanceEtaVertex_mult_%d", multBin))) : nullptr; |
| 761 | + if (clone == nullptr) { |
| 762 | + LOGF(fatal, "Missing or invalid pairAcceptanceEtaVertex_mult_%d in %s", multBin, source.c_str()); |
| 763 | + pairAcceptanceEtaVertexMaps.clear(); |
| 764 | + return; |
| 765 | + } |
| 766 | + clone->SetDirectory(nullptr); |
| 767 | + pairAcceptanceEtaVertexMaps[multBin].reset(clone); |
749 | 768 | } |
750 | | - clone->SetDirectory(nullptr); |
751 | | - pairAcceptanceMaps[multBin].reset(clone); |
752 | 769 | } |
753 | | - LOGF(info, "Loaded %zu multiplicity-only pair-acceptance maps from %s", pairAcceptanceMaps.size(), source.c_str()); |
| 770 | + LOGF(info, "Loaded %d schema-%d pair-acceptance maps from %s", nMultiplicityBins, pairAcceptanceSchemaVersion, source.c_str()); |
754 | 771 | } |
755 | 772 |
|
756 | 773 | void loadLocalYieldTemplates() |
@@ -871,23 +888,32 @@ struct TwoParticleCorrelationsMpi { |
871 | 888 | } |
872 | 889 | } |
873 | 890 |
|
874 | | - const TH3D* findPairAcceptanceMap(double multiplicity) const |
| 891 | + int findPairAcceptanceMultiplicityBin(double multiplicity) const |
875 | 892 | { |
876 | 893 | const auto& edges = AxisSpec(axisMultiplicity).binEdges; |
877 | 894 | const auto upper = std::upper_bound(edges.begin(), edges.end(), multiplicity); |
878 | | - const int multBin = static_cast<int>(std::distance(edges.begin(), upper)) - 1; |
879 | | - if (multBin < 0 || multBin >= static_cast<int>(pairAcceptanceMaps.size())) { |
880 | | - return nullptr; |
881 | | - } |
882 | | - return pairAcceptanceMaps[multBin].get(); |
| 895 | + return static_cast<int>(std::distance(edges.begin(), upper)) - 1; |
883 | 896 | } |
884 | 897 |
|
885 | 898 | double getPairAcceptance(double multiplicity, double deltaPhi, double deltaEta, double posZ) const |
886 | 899 | { |
887 | | - const auto* map = findPairAcceptanceMap(multiplicity); |
888 | | - if (!map) { |
| 900 | + const int multBin = findPairAcceptanceMultiplicityBin(multiplicity); |
| 901 | + if (pairAcceptanceSchemaVersion == 3) { |
| 902 | + if (multBin < 0 || multBin >= static_cast<int>(pairAcceptanceEtaVertexMaps.size()) || pairAcceptanceEtaVertexMaps[multBin] == nullptr) { |
| 903 | + return 0.0; |
| 904 | + } |
| 905 | + const auto* map = pairAcceptanceEtaVertexMaps[multBin].get(); |
| 906 | + const int etaBin = map->GetXaxis()->FindFixBin(deltaEta); |
| 907 | + const int vertexBin = map->GetYaxis()->FindFixBin(posZ); |
| 908 | + if (etaBin < 1 || etaBin > map->GetNbinsX() || vertexBin < 1 || vertexBin > map->GetNbinsY()) { |
| 909 | + return 0.0; |
| 910 | + } |
| 911 | + return map->GetBinContent(etaBin, vertexBin); |
| 912 | + } |
| 913 | + if (multBin < 0 || multBin >= static_cast<int>(pairAcceptanceMaps.size()) || pairAcceptanceMaps[multBin] == nullptr) { |
889 | 914 | return 0.0; |
890 | 915 | } |
| 916 | + const auto* map = pairAcceptanceMaps[multBin].get(); |
891 | 917 | const int phiBin = map->GetXaxis()->FindFixBin(deltaPhi); |
892 | 918 | const int etaBin = map->GetYaxis()->FindFixBin(deltaEta); |
893 | 919 | const int vertexBin = map->GetZaxis()->FindFixBin(posZ); |
|
0 commit comments