Skip to content

Commit 893bf75

Browse files
committed
Fix angle calculation
1 parent ee8d206 commit 893bf75

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

PWGCF/Flow/Tasks/flowEseTask.cxx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct FlowEseTask {
104104
Configurable<float> cfgV0EtaMax{"cfgV0EtaMax", 0.5, "maximum rapidity"};
105105
Configurable<float> cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"};
106106

107-
Configurable<bool> cfgQAv0{"cfgQAv0", true, "QA plot"};
107+
Configurable<bool> cfgQAv0{"cfgQAv0", false, "QA plot"};
108108

109109
Configurable<int> cfgDaughTPCnclsMin{"cfgDaughTPCnclsMin", 70, "minimum fired crossed rows"};
110110
Configurable<float> cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 5, "proton nsigma for TPC"};
@@ -125,7 +125,7 @@ struct FlowEseTask {
125125
Configurable<bool> cfgUSESP{"cfgUSESP", false, "cfg for sp"};
126126
Configurable<float> cfgPhiDepSig{"cfgPhiDepSig", 0.2, "cfg for significance on phi dependent study"};
127127

128-
Configurable<bool> cfgShiftCorr{"cfgShiftCorr", true, "additional shift correction"};
128+
Configurable<bool> cfgShiftCorr{"cfgShiftCorr", false, "additional shift correction"};
129129
Configurable<bool> cfgShiftCorrDef{"cfgShiftCorrDef", false, "additional shift correction definition"};
130130
Configurable<std::string> cfgShiftPath{"cfgShiftPath", "Users/j/junlee/Qvector/QvecCalib/Shift", "Path for Shift"};
131131

@@ -511,6 +511,18 @@ struct FlowEseTask {
511511
return true;
512512
}
513513

514+
double safeATan2(double y, double x)
515+
{
516+
if (x != 0)
517+
return std::atan2(y, x);
518+
if (y == 0)
519+
return 0;
520+
if (y > 0)
521+
return o2::constants::math::PIHalf;
522+
else
523+
return -o2::constants::math::PIHalf;
524+
}
525+
514526
template <typename TCollision>
515527
void fillShiftCorrection(TCollision const& collision, int nmode)
516528
{
@@ -668,7 +680,7 @@ struct FlowEseTask {
668680
qvecRefAInd = refAId * 4 + 3 + (nmode - 2) * cfgNQvec * 4;
669681
qvecRefBInd = refBId * 4 + 3 + (nmode - 2) * cfgNQvec * 4;
670682

671-
for (const auto& v0 : V0s) {
683+
for (auto& v0 : V0s) { // o2-linter: disable=const-ref-in-for-loop(need to modify v0)
672684
auto postrack = v0.template posTrack_as<TrackCandidates>();
673685
auto negtrack = v0.template negTrack_as<TrackCandidates>();
674686

@@ -717,7 +729,7 @@ struct FlowEseTask {
717729
protonBoostedVec = boost(protonVec);
718730

719731
angle = protonBoostedVec.Pz() / protonBoostedVec.P();
720-
psi = std::atan2(collision.qvecIm()[qvecDetInd], collision.qvecRe()[qvecDetInd]) / static_cast<float>(nmode);
732+
psi = safeATan2(collision.qvecIm()[qvecDetInd], collision.qvecRe()[qvecDetInd]) / static_cast<float>(nmode);
721733
relphi = TVector2::Phi_0_2pi(static_cast<float>(nmode) * (LambdaVec.Phi() - psi));
722734

723735
if (cfgShiftCorr) {
@@ -975,8 +987,6 @@ struct FlowEseTask {
975987
if (!eventSelected(collision)) {
976988
return;
977989
}
978-
histos.fill(HIST("QA/CentDist"), centrality, 1.0);
979-
histos.fill(HIST("QA/PVzDist"), collision.posZ(), 1.0);
980990

981991
if (cfgShiftCorr) {
982992
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
@@ -1062,7 +1072,7 @@ struct FlowEseTask {
10621072
continue;
10631073
if (std::abs(mcParticle.eta()) > kEtaAcceptance) // main acceptance
10641074
continue;
1065-
histos.fill(HIST("hSparseMCGenWeight"), centclass, RecoDecay::constrainAngle(deltaPhi), std::pow(std::cos(2.0 * RecoDecay::constrainAngle(deltaPhi)), 2.0), mcParticle.pt(), mcParticle.eta());
1075+
histos.fill(HIST("hSparseMCGenWeight"), centclass, RecoDecay::constrainAngle(deltaPhi, 0, 2), std::pow(std::cos(2.0 * RecoDecay::constrainAngle(deltaPhi, 0, 2)), 2.0), mcParticle.pt(), mcParticle.eta());
10661076
nCh++;
10671077
bool validGlobal = false;
10681078
bool validAny = false;
@@ -1079,11 +1089,11 @@ struct FlowEseTask {
10791089
}
10801090
// if valid global, fill
10811091
if (validGlobal) {
1082-
histos.fill(HIST("hSparseMCRecWeight"), centclass, RecoDecay::constrainAngle(deltaPhi), std::pow(std::cos(2.0 * RecoDecay::constrainAngle(deltaPhi)), 2.0), mcParticle.pt(), mcParticle.eta());
1092+
histos.fill(HIST("hSparseMCRecWeight"), centclass, RecoDecay::constrainAngle(deltaPhi, 0, 2), std::pow(std::cos(2.0 * RecoDecay::constrainAngle(deltaPhi, 0, 2)), 2.0), mcParticle.pt(), mcParticle.eta());
10831093
}
10841094
if (validAny) {
1085-
histos.fill(HIST("hSparseMCRecAllTrackWeight"), centclass, RecoDecay::constrainAngle(deltaPhi), std::pow(std::cos(2.0 * RecoDecay::constrainAngle(deltaPhi)), 2.0), mcParticle.pt(), mcParticle.eta());
1086-
histos.fill(HIST("hEventPlaneAngleRec"), RecoDecay::constrainAngle(deltaPhi));
1095+
histos.fill(HIST("hSparseMCRecAllTrackWeight"), centclass, RecoDecay::constrainAngle(deltaPhi, 0, 2), std::pow(std::cos(2.0 * RecoDecay::constrainAngle(deltaPhi, 0, 2)), 2.0), mcParticle.pt(), mcParticle.eta());
1096+
histos.fill(HIST("hEventPlaneAngleRec"), RecoDecay::constrainAngle(deltaPhi, 0, 2));
10871097
}
10881098
// if any track present, fill
10891099
}

0 commit comments

Comments
 (0)