|
33 | 33 | #include <Rtypes.h> |
34 | 34 | #include <RtypesCore.h> |
35 | 35 |
|
| 36 | +#include <algorithm> |
36 | 37 | #include <array> |
37 | 38 | #include <cmath> |
38 | 39 | #include <cstddef> |
@@ -75,7 +76,9 @@ int VarManager::fgCalibrationType = 0; // 0 - no calibration, 1 - |
75 | 76 | bool VarManager::fgUseInterpolatedCalibration = true; // use interpolated calibration histograms (default: true) |
76 | 77 | int VarManager::fgEfficiencyType = 0; // type of efficiency to be applied, default is no efficiency |
77 | 78 | TObject* VarManager::fgEfficiencyHist = nullptr; // histogram for efficiency |
78 | | - |
| 79 | +TObject* VarManager::fgPosiPhiMap = nullptr; |
| 80 | +TObject* VarManager::fgNegaPhiMap = nullptr; |
| 81 | +bool VarManager::fgUsePhiCorrection = false; |
79 | 82 | //__________________________________________________________________ |
80 | 83 | VarManager::VarManager() : TObject() |
81 | 84 | { |
@@ -453,6 +456,76 @@ void VarManager::FillEfficiency(float* values) |
453 | 456 | } |
454 | 457 | } |
455 | 458 |
|
| 459 | +void VarManager::SetPhiMap(TObject* hposi, TObject* hnega, bool option) |
| 460 | +{ |
| 461 | + fgPosiPhiMap = hposi; |
| 462 | + fgNegaPhiMap = hnega; |
| 463 | + fgUsePhiCorrection = option; |
| 464 | +} |
| 465 | + |
| 466 | +double VarManager::SampleRotationPhi(double pt, double eta, int charge) |
| 467 | +{ |
| 468 | + // each type only alarm once |
| 469 | + static bool warnedEmptyPhi = false; |
| 470 | + |
| 471 | + if (!fgUsePhiCorrection) { |
| 472 | + return gRandom->Uniform(0., o2::constants::math::TwoPI); |
| 473 | + } else { |
| 474 | + |
| 475 | + TH3D* hMap = nullptr; |
| 476 | + if (charge > 0) { |
| 477 | + hMap = dynamic_cast<TH3D*>(fgPosiPhiMap); |
| 478 | + } else { |
| 479 | + hMap = dynamic_cast<TH3D*>(fgNegaPhiMap); |
| 480 | + } |
| 481 | + |
| 482 | + if (!hMap) { |
| 483 | + LOGF(fatal, "Phi map is not a TH3D"); |
| 484 | + } |
| 485 | + // TH3 axes: X=pT, Y=phi, Z=eta |
| 486 | + int ptBin = hMap->GetXaxis()->FindBin(pt); |
| 487 | + int etaBin = hMap->GetZaxis()->FindBin(eta); |
| 488 | + |
| 489 | + ptBin = std::clamp(ptBin, 1, hMap->GetNbinsX()); |
| 490 | + etaBin = std::clamp(etaBin, 1, hMap->GetNbinsZ()); |
| 491 | + |
| 492 | + TH1D* hPhi = hMap->ProjectionY( |
| 493 | + Form("hTRPhi_tmp_charge%d_ptbin%d_etabin%d", |
| 494 | + charge, ptBin, etaBin), |
| 495 | + ptBin, |
| 496 | + ptBin, |
| 497 | + etaBin, |
| 498 | + etaBin); |
| 499 | + |
| 500 | + if (!hPhi || hPhi->Integral(1, hPhi->GetNbinsX()) <= 0.) { |
| 501 | + if (!warnedEmptyPhi) { |
| 502 | + LOGF(warn, |
| 503 | + "Empty phi distribution for " |
| 504 | + "pt=%f, eta=%f, charge=%d, ptBin=%d, etaBin=%d. " |
| 505 | + "Falling back to uniform phi sampling.", |
| 506 | + pt, |
| 507 | + eta, |
| 508 | + charge, |
| 509 | + ptBin, |
| 510 | + etaBin); |
| 511 | + |
| 512 | + warnedEmptyPhi = true; |
| 513 | + } |
| 514 | + |
| 515 | + delete hPhi; |
| 516 | + |
| 517 | + return gRandom->Uniform( |
| 518 | + 0., o2::constants::math::TwoPI); |
| 519 | + } |
| 520 | + |
| 521 | + const double phi = |
| 522 | + RecoDecay::constrainAngle(hPhi->GetRandom()); |
| 523 | + |
| 524 | + delete hPhi; |
| 525 | + return phi; |
| 526 | + } |
| 527 | +} |
| 528 | + |
456 | 529 | //__________________________________________________________________ |
457 | 530 | std::tuple<float, float, float, float, float> VarManager::BimodalityCoefficientUnbinned(const std::vector<float>& data) |
458 | 531 | { |
|
0 commit comments