Skip to content

Commit 1dadae1

Browse files
committed
change flow code in femtoDream
1 parent df7e33a commit 1dadae1

File tree

1 file changed

+57
-79
lines changed

1 file changed

+57
-79
lines changed

PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h

Lines changed: 57 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,26 @@ class FemtoDreamCollisionSelection
229229

230230
/// Initializes histograms for the flow calculation
231231
/// \param registry Histogram registry to be passed
232-
void initFlow(HistogramRegistry* registry, bool doQnSeparation, int mumQnBins = 10, int binPt = 100, int binEta = 32)
232+
void initFlow(HistogramRegistry* registry, bool doQnSeparation, int mumQnBins = 10, int centBins = 10)
233233
{
234234
if (!mCutsSet) {
235235
LOGF(error, "Event selection not set - quitting!");
236236
}
237-
mReQthisEvt = new TH2D("ReQthisEvt", "", binPt, 0., 5., binEta, -0.8, 0.8);
238-
mImQthisEvt = new TH2D("ImQthisEvt", "", binPt, 0., 5., binEta, -0.8, 0.8);
239-
mReQ2thisEvt = new TH2D("ReQ2thisEvt", "", binPt, 0., 5., binEta, -0.8, 0.8);
240-
mImQ2thisEvt = new TH2D("ImQ2thisEvt", "", binPt, 0., 5., binEta, -0.8, 0.8);
241-
mMQthisEvt = new TH2D("MQthisEvt", "", binPt, 0., 5., binEta, -0.8, 0.8);
242-
mMQWeightthisEvt = new TH2D("MQWeightthisEvt", "", binPt, 0., 5., binEta, -0.8, 0.8);
243237

244238
mHistogramQn = registry;
245-
mHistogramQn->add<TProfile>("Event/profileC22", "; cent; c22", kTProfile, {{10, 0, 100}}, "s");
246-
mHistogramQn->add<TProfile>("Event/profileC24", "; cent; c24", kTProfile, {{10, 0, 100}}, "s");
239+
mHistogramQn->add("Event/hN2allQn", ";centrality; #sum Re(Q_{2,A} Q_{2,B}^{*})", kTH1F, {{centBins, 0, 100}});
240+
mHistogramQn->add("Event/hD2allQn", ";centrality; #sum (W_{A} W_{B})", kTH1F, {{centBins, 0, 100}});
241+
mHistogramQn->get<TH1>(HIST("Event/hN2allQn"))->Sumw2();
242+
mHistogramQn->get<TH1>(HIST("Event/hD2allQn"))->Sumw2();
247243

248244
if (doQnSeparation) {
249245
for (int iqn(0); iqn < mumQnBins; ++iqn) {
250-
profilesC22.push_back(mHistogramQn->add<TProfile>(("Qn/profileC22_" + std::to_string(iqn)).c_str(), "; cent; c22", kTProfile, {{10, 0, 100}}, "s"));
246+
hN2.push_back(mHistogramQn->add(("Qn/hN2_" + std::to_string(iqn)).c_str(), ";centrality; #sum Re(Q_{2,A} Q_{2,B}^{*})", kTH1F, {{centBins, 0, 100}}));
247+
hD2.push_back(mHistogramQn->add(("Qn/hD2_" + std::to_string(iqn)).c_str(), ";centrality; #sum (W_{A} W_{B})", kTH1F, {{centBins, 0, 100}}));
248+
}
249+
for (int iqn(0); iqn < mumQnBins; ++iqn) {
250+
std::get<std::shared_ptr<TH1>>(hN2[iqn])->Sumw2();
251+
std::get<std::shared_ptr<TH1>>(hD2[iqn])->Sumw2();
251252
}
252253
}
253254
return;
@@ -421,84 +422,66 @@ class FemtoDreamCollisionSelection
421422
mHistogramQn->fill(HIST("Event/psiEP"), psiEP);
422423
}
423424

424-
/// \todo to be implemented!
425-
/// Fill cumulants histo for flow calculation
426-
/// Reset hists event-by-event
427-
/// \tparam T1 type of the collision
428-
/// \tparam T2 type of the tracks
429-
/// \param tracks All tracks
430-
template <typename T1, typename T2>
431-
bool fillCumulants(T1 const& col, T2 const& tracks, float fHarmonic = 2.f)
432-
{
433-
int numOfTracks = col.numContrib();
434-
if (numOfTracks < 3)
435-
return false;
436-
437-
mReQthisEvt->Reset();
438-
mImQthisEvt->Reset();
439-
mReQ2thisEvt->Reset();
440-
mImQ2thisEvt->Reset();
441-
mMQthisEvt->Reset();
442-
mMQWeightthisEvt->Reset();
443-
444-
for (auto const& track : tracks) {
445-
double weight = 1; // Will implement NUA&NUE correction
446-
double phi = track.phi();
447-
double pt = track.pt();
448-
double eta = track.eta();
449-
double cosnphi = weight * TMath::Cos(fHarmonic * phi);
450-
double sinnphi = weight * TMath::Sin(fHarmonic * phi);
451-
double cos2nphi = weight * TMath::Cos(2 * fHarmonic * phi);
452-
double sin2nphi = weight * TMath::Sin(2 * fHarmonic * phi);
453-
mReQthisEvt->Fill(pt, eta, cosnphi);
454-
mImQthisEvt->Fill(pt, eta, sinnphi);
455-
mReQ2thisEvt->Fill(pt, eta, cos2nphi);
456-
mImQ2thisEvt->Fill(pt, eta, sin2nphi);
457-
mMQthisEvt->Fill(pt, eta);
458-
mMQWeightthisEvt->Fill(pt, eta, weight);
459-
}
460-
return true;
461-
}
462-
463425
/// \todo to be implemented!
464426
/// Do cumulants for flow calculation
465427
/// \tparam T type of the collision
466428
/// \param doQnSeparation to fill flow in divied qn bins
467429
/// \param qnBin should be <int> in 0-9
468430
/// \param fEtaGap eta gap for flow cumulant
469431
template <typename T1, typename T2>
470-
void doCumulants(T1 const& col, T2 const& tracks, float centrality, bool doQnSeparation = false, int numQnBins = 10, float fEtaGap = 0.3f, int binPt = 100, int binEta = 32)
432+
void doCumulants(T1 const& col, T2 const& tracks, float centrality, bool doQnSeparation = false, int numQnBins = 10, float fEtaGap = 0.5f, float ptMin = 0.2f, float ptMax = 5.0f, float harmonic = 2.0f)
471433
{
472-
if (!fillCumulants(col, tracks))
434+
int numOfTracks = col.numContrib();
435+
if (numOfTracks < 3)
473436
return;
474437

475-
if (mMQthisEvt->Integral(1, binPt, 1, binEta) < 2)
476-
return;
438+
double Q2A_re = 0., Q2A_im = 0., WA = 0.;
439+
double Q2B_re = 0., Q2B_im = 0., WB = 0.;
477440

478-
double allReQ = mReQthisEvt->Integral(1, binPt, 1, binEta);
479-
double allImQ = mImQthisEvt->Integral(1, binPt, 1, binEta);
480-
TComplex Q(allReQ, allImQ);
481-
TComplex QStar = TComplex::Conjugate(Q);
441+
int nA = 0, nB = 0;
482442

483-
double posEtaRe = mReQthisEvt->Integral(1, binPt, mReQthisEvt->GetYaxis()->FindBin(fEtaGap + 1e-6), binEta);
484-
double posEtaIm = mImQthisEvt->Integral(1, binPt, mImQthisEvt->GetYaxis()->FindBin(fEtaGap + 1e-6), binEta);
485-
if (mMQthisEvt->Integral(1, binPt, mMQthisEvt->GetYaxis()->FindBin(fEtaGap + 1e-6), binEta) < 2)
486-
return;
487-
float posEtaMQ = mMQWeightthisEvt->Integral(1, binPt, mMQthisEvt->GetYaxis()->FindBin(fEtaGap + 1e-6), binEta);
488-
TComplex posEtaQ = TComplex(posEtaRe, posEtaIm);
489-
TComplex posEtaQStar = TComplex::Conjugate(posEtaQ);
443+
for (auto const& trk : tracks) {
444+
const double pt = trk.pt();
445+
const double eta = trk.eta();
446+
if (pt < ptMin || pt > ptMax) {
447+
continue;
448+
}
449+
450+
const double w = 1.0; // TODO: NUA/NUE weight if you want
451+
const double phi = trk.phi();
452+
const double c = w * TMath::Cos(harmonic * phi);
453+
const double s = w * TMath::Sin(harmonic * phi);
454+
455+
if (eta > fEtaGap) {
456+
Q2A_re += c;
457+
Q2A_im += s;
458+
WA += w;
459+
nA++;
460+
} else if (eta < -1* fEtaGap) {
461+
Q2B_re += c;
462+
Q2B_im += s;
463+
WB += w;
464+
nB++;
465+
}
466+
}
490467

491-
double negEtaRe = mReQthisEvt->Integral(1, binPt, 1, mReQthisEvt->GetYaxis()->FindBin(-1 * fEtaGap - 1e-6));
492-
double negEtaIm = mImQthisEvt->Integral(1, binPt, 1, mImQthisEvt->GetYaxis()->FindBin(-1 * fEtaGap - 1e-6));
493-
if (mMQthisEvt->Integral(1, binPt, 1, mMQthisEvt->GetYaxis()->FindBin(-1 * fEtaGap - 1e-6)) < 2)
468+
// need at least 1 track on each side to form pairs; for stability, require >=2
469+
if (nA < 2 || nB < 2) {
494470
return;
495-
float negEtaMQ = mMQWeightthisEvt->Integral(1, binPt, 1, mMQthisEvt->GetYaxis()->FindBin(-1 * fEtaGap - 1e-6));
496-
TComplex negEtaQ = TComplex(negEtaRe, negEtaIm);
497-
TComplex negEtaQStar = TComplex::Conjugate(negEtaQ);
471+
}
472+
const double D2_evt = WA * WB;
473+
if (D2_evt <= 0.) {
474+
return;
475+
}
476+
477+
// N2_evt = Re(Q2A * conj(Q2B)) = Q2A_re*Q2B_re + Q2A_im*Q2B_im
478+
const double N2_evt = Q2A_re * Q2B_re + Q2A_im * Q2B_im;
498479

499-
mHistogramQn->get<TProfile>(HIST("Event/profileC22"))->Fill(centrality, (negEtaQ * posEtaQStar).Re() / (negEtaMQ * posEtaMQ), (negEtaMQ * posEtaMQ));
480+
mHistogramQn->fill(HIST("Event/hN2allQn"), centrality, N2_evt);
481+
mHistogramQn->fill(HIST("Event/hD2allQn"), centrality, D2_evt);
500482
if (doQnSeparation && mQnBin >= 0 && mQnBin < numQnBins) {
501-
std::get<std::shared_ptr<TProfile>>(profilesC22[mQnBin])->Fill(centrality, (negEtaQ * posEtaQStar).Re() / (negEtaMQ * posEtaMQ), (negEtaMQ * posEtaMQ));
483+
std::get<std::shared_ptr<TH1>>(hN2[mQnBin])->Fill(centrality, N2_evt);
484+
std::get<std::shared_ptr<TH1>>(hD2[mQnBin])->Fill(centrality, D2_evt);
502485
}
503486
return;
504487
}
@@ -516,13 +499,8 @@ class FemtoDreamCollisionSelection
516499
float mSphericityPtmin = 0.f;
517500
int mQnBin = -999;
518501
HistogramRegistry* mHistogramQn = nullptr; ///< For flow cumulant output
519-
std::vector<HistPtr> profilesC22; /// Pofile Histograms of c22 per Qn bin
520-
TH2D* mReQthisEvt = nullptr; ///< For flow cumulant in an event
521-
TH2D* mImQthisEvt = nullptr; ///< For flow cumulant in an event
522-
TH2D* mReQ2thisEvt = nullptr; ///< For flow cumulant in an event
523-
TH2D* mImQ2thisEvt = nullptr; ///< For flow cumulant in an event
524-
TH2D* mMQthisEvt = nullptr; ///< For flow cumulant in an event
525-
TH2D* mMQWeightthisEvt = nullptr; ///< For flow cumulant in an event
502+
std::vector<HistPtr> hN2; ///< Histograms of c22 per Qn bin
503+
std::vector<HistPtr> hD2; ///< Histograms of c22 per Qn bin
526504
};
527505
} // namespace o2::analysis::femtoDream
528506

0 commit comments

Comments
 (0)