Skip to content

Commit 091c4bd

Browse files
author
Pengchong Hu
committed
add nested loops
1 parent 7467239 commit 091c4bd

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

PWGCF/MultiparticleCorrelations/Tasks/multiharmonicCorrelations.cxx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
116116
Configurable<bool> cfInitsim{"cfInitsim", false, "init histograms of sim"};
117117
Configurable<bool> cfUseWeights{"cfUseWeights", true, "use weights"};
118118
Configurable<bool> cfToyModel{"cfToyModel", true, "phi-distribution from toy model"};
119+
Configurable<bool> cfNest{"cfNest", true, "nested loops"};
119120

120121
Configurable<std::vector<float>> cfVertexZ{"cfVertexZ", {-10, 10.}, "vertex z position range: {min, max}[cm], with convention: min <= Vz < max"};
121122
Configurable<std::vector<float>> cfPt{"cfPt", {0.2, 5.0}, "transverse momentum range"};
@@ -171,6 +172,12 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
171172
TProfile* pfour32_centr = NULL;
172173
TProfile* pfour42_centr = NULL;
173174
TComplex Qvector[maxHarmonic][maxPower];
175+
std::vector<float> vecphi;
176+
std::vector<float> vecwei;
177+
TProfile* nestedLoops[maxHarmonic] = {NULL};
178+
TProfile* pv2_nest = NULL;
179+
TProfile* pv3_nest = NULL;
180+
TProfile* pv4_nest = NULL;
174181
} cor;
175182

176183
struct PhiHist {
@@ -486,12 +493,24 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
486493

487494
// before loop over particles
488495
float phi = 0, weight = 1.;
496+
vector<float>().swap(cor.vecphi);
497+
vector<float>().swap(cor.vecwei);
489498
for (int ih = 0; ih < maxHarmonic; ih++) {
490499
for (int ip = 0; ip < maxPower; ip++) {
491500
cor.Qvector[ih][ip] = TComplex(0., 0.);
492501
}
493502
}
494503

504+
/*
505+
for (int ih = 0; ih < maxHarmonic; ih++) {
506+
for (int ip = 0; ip < maxPower; ip++) {
507+
LOGF(info, "Qvector[%d][%d]=%f, ", ih, ip, cor.Qvector[ih][ip].Rho2());
508+
}
509+
LOGF(info, "\n");
510+
}
511+
LOGF(info, "\n\n");
512+
*/
513+
495514
// Main loop over particles:
496515
for (const auto& track : tracks) {
497516

@@ -527,6 +546,7 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
527546
if (cfToyModel) {
528547
phi = f->GetRandom();
529548
}
549+
cor.vecphi.push_back(phi);
530550
if (it != phih.histMap.end()) {
531551
it->second->Fill(phi);
532552
}
@@ -541,6 +561,7 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
541561
} else {
542562
weight = 1;
543563
}
564+
cor.vecwei.push_back(weight);
544565

545566
// ... and corresponding MC truth simulated:
546567
// See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx
@@ -570,6 +591,30 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
570591
}
571592
} // end of for (auto track: tracks)
572593
event.fHistMsel[eAfter]->Fill(msel);
594+
595+
if (cfNest) {
596+
float phi1 = 0., phi2 = 0., weight1 = 1., weight2 = 2.;
597+
for (Int_t c = 0; c < maxHarmonic; c++) {
598+
delete cor.nestedLoops[c];
599+
cor.nestedLoops[c] = new TProfile("", "", 1, 0., 1.);
600+
cor.nestedLoops[c]->Sumw2();
601+
}
602+
for (int i1 = 0; i1 < static_cast<int>(cor.vecphi.size()); i1++) { // nested loop of particles
603+
phi1 = cor.vecphi[i1];
604+
weight1 = cor.vecwei[i1];
605+
for (int i2 = 0; i2 < static_cast<int>(cor.vecphi.size()); i2++) {
606+
if (i2 == i1) {
607+
continue;
608+
}
609+
phi2 = cor.vecphi[i2];
610+
weight2 = cor.vecwei[i2];
611+
cor.nestedLoops[0]->Fill(0.5, TMath::Cos(2 * phi1 - 2 * phi2), weight1 * weight2);
612+
cor.nestedLoops[1]->Fill(0.5, TMath::Cos(3 * phi1 - 3 * phi2), weight1 * weight2);
613+
cor.nestedLoops[2]->Fill(0.5, TMath::Cos(4 * phi1 - 4 * phi2), weight1 * weight2);
614+
}
615+
} // end of two nested loop
616+
}
617+
573618
// calculate correlations
574619
float Mmin = 4.;
575620
if (msel < Mmin)
@@ -593,6 +638,13 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
593638
cor.pfour32_centr->Fill(centr, four32, wFour);
594639
cor.pfour42_centr->Fill(centr, four42, wFour);
595640

641+
if (cfNest) {
642+
cor.pv2_nest->Fill(centr, cor.nestedLoops[0]->GetBinContent(1), wTwo);
643+
cor.pv3_nest->Fill(centr, cor.nestedLoops[1]->GetBinContent(1), wTwo);
644+
cor.pv4_nest->Fill(centr, cor.nestedLoops[2]->GetBinContent(1), wTwo);
645+
646+
LOGF(info, "v22=%f, v22_nest=%f", v22, cor.nestedLoops[0]->GetBinContent(1));
647+
}
596648
} // end of template <eRecSim rs, typename T1, typename T2> void Steer(T1 const& collision, T2 const& tracks)
597649

598650
// *) Initialize and book all objects:
@@ -827,6 +879,9 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
827879
cor.pv42_centr = new TProfile("pv42", "profile of v_{4}^{2}", 9, quantiles);
828880
cor.pfour32_centr = new TProfile("pfour32", "profile of v_{2}^{2}*v_{3}^{2}", 9, quantiles);
829881
cor.pfour42_centr = new TProfile("pfour42", "profile of v_{2}^{2}*v_{4}^{2}", 9, quantiles);
882+
cor.pv2_nest = new TProfile("pv2_nest", "profile of v_{2} from nest", 9, quantiles);
883+
cor.pv3_nest = new TProfile("pv3_nest", "profile of v_{3} from nest", 9, quantiles);
884+
cor.pv4_nest = new TProfile("pv4_nest", "profile of v_{4} from nest", 9, quantiles);
830885
cor.pv22_centr->GetYaxis()->SetTitle("v_{2}^{2}");
831886
cor.pv32_centr->GetYaxis()->SetTitle("v_{3}^{2}");
832887
cor.pv42_centr->GetYaxis()->SetTitle("v_{4}^{2}");
@@ -837,11 +892,22 @@ struct MultiharmonicCorrelations { // this name is used in lower-case format to
837892
cor.pfour42_centr->GetYaxis()->SetTitle("v_{2}^{2}v_{4}^{2}");
838893
cor.pfour32_centr->GetXaxis()->SetTitle("centrality");
839894
cor.pfour42_centr->GetXaxis()->SetTitle("centrality");
895+
cor.pv2_nest->GetYaxis()->SetTitle("v_{2}");
896+
cor.pv3_nest->GetYaxis()->SetTitle("v_{3}");
897+
cor.pv4_nest->GetYaxis()->SetTitle("v_{4}");
898+
cor.pv2_nest->GetXaxis()->SetTitle("centrality");
899+
cor.pv3_nest->GetXaxis()->SetTitle("centrality");
900+
cor.pv4_nest->GetXaxis()->SetTitle("centrality");
840901
cor.fCorrelationVariablesList->Add(cor.pv22_centr);
841902
cor.fCorrelationVariablesList->Add(cor.pv32_centr);
842903
cor.fCorrelationVariablesList->Add(cor.pv42_centr);
843904
cor.fCorrelationVariablesList->Add(cor.pfour32_centr);
844905
cor.fCorrelationVariablesList->Add(cor.pfour42_centr);
906+
if (cfNest) {
907+
cor.fCorrelationVariablesList->Add(cor.pv2_nest);
908+
cor.fCorrelationVariablesList->Add(cor.pv3_nest);
909+
cor.fCorrelationVariablesList->Add(cor.pv4_nest);
910+
}
845911

846912
// init of phi hist for different runs
847913
for (const int& run : targetRuns) {

0 commit comments

Comments
 (0)