Skip to content

Commit 845da7e

Browse files
authored
[PWGCF] Add closure test
Add closure test Optimize some code
1 parent fbac016 commit 845da7e

File tree

1 file changed

+52
-50
lines changed

1 file changed

+52
-50
lines changed

PWGCF/Flow/Tasks/flowGfwOmegaXi.cxx

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "CommonConstants/PhysicsConstants.h"
4141
#include "Common/Core/trackUtilities.h"
4242
#include "PWGLF/DataModel/LFStrangenessTables.h"
43-
#include "PWGMM/Mult/DataModel/Index.h"
43+
#include "PWGMM/Mult/DataModel/Index.h"
4444
#include "TList.h"
4545
#include <TProfile.h>
4646
#include <TRandom3.h>
@@ -53,16 +53,16 @@ using namespace o2::framework;
5353
using namespace o2::framework::expressions;
5454
namespace
5555
{
56-
std::shared_ptr<TProfile> refc22[10];
57-
std::shared_ptr<TProfile> refc24[10];
58-
std::shared_ptr<TProfile3D> k0sc22[10];
59-
std::shared_ptr<TProfile3D> k0sc24[10];
60-
std::shared_ptr<TProfile3D> lambdac22[10];
61-
std::shared_ptr<TProfile3D> lambdac24[10];
62-
std::shared_ptr<TProfile3D> xic22[10];
63-
std::shared_ptr<TProfile3D> xic24[10];
64-
std::shared_ptr<TProfile3D> omegac22[10];
65-
std::shared_ptr<TProfile3D> omegac24[10];
56+
std::shared_ptr<TProfile> refc22[20];
57+
std::shared_ptr<TProfile> refc24[20];
58+
std::shared_ptr<TProfile3D> k0sc22[20];
59+
std::shared_ptr<TProfile3D> k0sc24[20];
60+
std::shared_ptr<TProfile3D> lambdac22[20];
61+
std::shared_ptr<TProfile3D> lambdac24[20];
62+
std::shared_ptr<TProfile3D> xic22[20];
63+
std::shared_ptr<TProfile3D> xic24[20];
64+
std::shared_ptr<TProfile3D> omegac22[20];
65+
std::shared_ptr<TProfile3D> omegac24[20];
6666
} // namespace
6767

6868
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
@@ -202,6 +202,31 @@ struct FlowGfwOmegaXi {
202202
ccdb->setCaching(true);
203203
ccdb->setCreatedNotAfter(cfgnolaterthan.value);
204204

205+
// Set the pt, mult and phi Axis;
206+
o2::framework::AxisSpec axisPt = cfgaxisPt;
207+
nPtBins = axisPt.binEdges.size() - 1;
208+
fPtAxis = new TAxis(nPtBins, &(axisPt.binEdges)[0]);
209+
210+
o2::framework::AxisSpec axisXiPt = cfgaxisPtXi;
211+
nXiPtBins = axisXiPt.binEdges.size() - 1;
212+
fXiPtAxis = new TAxis(nXiPtBins, &(axisXiPt.binEdges)[0]);
213+
214+
o2::framework::AxisSpec axisV0Pt = cfgaxisPtV0;
215+
nV0PtBins = axisV0Pt.binEdges.size() - 1;
216+
fV0PtAxis = new TAxis(nV0PtBins, &(axisV0Pt.binEdges)[0]);
217+
218+
o2::framework::AxisSpec axisMult = axisMultiplicity;
219+
int nMultBins = axisMult.binEdges.size() - 1;
220+
fMultAxis = new TAxis(nMultBins, &(axisMult.binEdges)[0]);
221+
222+
fOmegaMass = new TAxis(cfgmassbins[3], 1.63, 1.71);
223+
224+
fXiMass = new TAxis(cfgmassbins[2], 1.3, 1.37);
225+
226+
fK0sMass = new TAxis(cfgmassbins[0], 0.4, 0.6);
227+
228+
fLambdaMass = new TAxis(cfgmassbins[1], 1.08, 1.16);
229+
205230
// Add some output objects to the histogram registry
206231
registry.add("hPhi", "", {HistType::kTH1D, {cfgaxisPhi}});
207232
registry.add("hPhicorr", "", {HistType::kTH1D, {cfgaxisPhi}});
@@ -273,7 +298,7 @@ struct FlowGfwOmegaXi {
273298
registry.add("Lambdac24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisLambdaMassforflow, axisMultiplicity}});
274299
// for Jackknife
275300
if (cfgDoJackknife) {
276-
for (int i = 1; i <= 10; i++) {
301+
for (int i = 1; i <= nPtBins; i++) {
277302
refc22[i - 1] = registry.add<TProfile>(Form("Jackknife/REF/c22_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}});
278303
refc24[i - 1] = registry.add<TProfile>(Form("Jackknife/REF/c24_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}});
279304
xic22[i - 1] = registry.add<TProfile3D>(Form("Jackknife/Xi/Xic22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}});
@@ -311,31 +336,6 @@ struct FlowGfwOmegaXi {
311336
registry.add("MC/densityMCRecXi", "", {HistType::kTHnSparseF, {cfgaxisPtXi, cfgaxisNch, cfgaxisLocalDensity, axisXiMass}});
312337
registry.add("MC/densityMCRecOmega", "", {HistType::kTHnSparseF, {cfgaxisPtXi, cfgaxisNch, cfgaxisLocalDensity, axisOmegaMass}});
313338

314-
// Set the pt, mult and phi Axis;
315-
o2::framework::AxisSpec axisPt = cfgaxisPt;
316-
nPtBins = axisPt.binEdges.size() - 1;
317-
fPtAxis = new TAxis(nPtBins, &(axisPt.binEdges)[0]);
318-
319-
o2::framework::AxisSpec axisXiPt = cfgaxisPtXi;
320-
nXiPtBins = axisXiPt.binEdges.size() - 1;
321-
fXiPtAxis = new TAxis(nXiPtBins, &(axisXiPt.binEdges)[0]);
322-
323-
o2::framework::AxisSpec axisV0Pt = cfgaxisPtV0;
324-
nV0PtBins = axisV0Pt.binEdges.size() - 1;
325-
fV0PtAxis = new TAxis(nV0PtBins, &(axisV0Pt.binEdges)[0]);
326-
327-
o2::framework::AxisSpec axisMult = axisMultiplicity;
328-
int nMultBins = axisMult.binEdges.size() - 1;
329-
fMultAxis = new TAxis(nMultBins, &(axisMult.binEdges)[0]);
330-
331-
fOmegaMass = new TAxis(cfgmassbins[3], 1.63, 1.71);
332-
333-
fXiMass = new TAxis(cfgmassbins[2], 1.3, 1.37);
334-
335-
fK0sMass = new TAxis(cfgmassbins[0], 0.4, 0.6);
336-
337-
fLambdaMass = new TAxis(cfgmassbins[1], 1.08, 1.16);
338-
339339
// Data
340340
fGFW->AddRegion("reffull", -0.8, 0.8, 1, 1); // ("name", etamin, etamax, ptbinnum, bitmask)eta region -0.8 to 0.8
341341
fGFW->AddRegion("refN10", -0.8, -0.4, 1, 1);
@@ -608,20 +608,21 @@ struct FlowGfwOmegaXi {
608608
{
609609
if (correctionsLoaded)
610610
return;
611-
if (cfgAcceptance.size() == 5) {
612-
for (int i = 0; i <= 4; i++) {
611+
int nspecies = 5
612+
if (cfgAcceptance.size() == nspecies) {
613+
for (int i = 0; i <= nspecies - 1; i++) {
613614
mAcceptance.push_back(ccdb->getForTimeStamp<GFWWeights>(cfgAcceptance[i], timestamp));
614615
}
615-
if (mAcceptance.size() == 5)
616+
if (mAcceptance.size() == nspecies)
616617
LOGF(info, "Loaded acceptance weights");
617618
else
618619
LOGF(warning, "Could not load acceptance weights");
619620
}
620-
if (cfgEfficiency.size() == 5) {
621-
for (int i = 0; i <= 4; i++) {
621+
if (cfgEfficiency.size() == nspecies) {
622+
for (int i = 0; i <= nspecies - 1; i++) {
622623
mEfficiency.push_back(ccdb->getForTimeStamp<TH1D>(cfgEfficiency[i], timestamp));
623624
}
624-
if (mEfficiency.size() == 5)
625+
if (mEfficiency.size() == nspecies)
625626
LOGF(info, "Loaded efficiency histogram");
626627
else
627628
LOGF(fatal, "Could not load efficiency histogram");
@@ -632,15 +633,16 @@ struct FlowGfwOmegaXi {
632633
template <typename TrackObject>
633634
bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, TrackObject track, float vtxz, int ispecies)
634635
{
636+
int nspecies = 5;
635637
float eff = 1.;
636-
if (mEfficiency.size() == 5)
638+
if (mEfficiency.size() == nspecies)
637639
eff = mEfficiency[ispecies]->GetBinContent(mEfficiency[ispecies]->FindBin(track.pt()));
638640
else
639641
eff = 1.0;
640642
if (eff == 0)
641643
return false;
642644
weight_nue = 1. / eff;
643-
if (mAcceptance.size() == 5)
645+
if (mAcceptance.size() == nspecies)
644646
weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz);
645647
else
646648
weight_nua = 1;
@@ -651,11 +653,11 @@ struct FlowGfwOmegaXi {
651653
bool setCurrentLocalDensityWeights(float& weight_loc, TrackObject track, double locDensity, int ispecies)
652654
{
653655
auto cfgLocDenPara = (std::vector<std::vector<double>>){cfgLocDenParaK0s, cfgLocDenParaLambda, cfgLocDenParaXi, cfgLocDenParaOmega};
654-
if (track.pt() < 0.9 || track.pt() > 10) {
656+
int ptbin = fXiPtAxis->FindBin(track.pt());
657+
if (ptbin == 0 || ptbin == (fXiPtAxis->GetNBins() + 1)) {
655658
weight_loc = 1.0;
656659
return true;
657660
}
658-
int ptbin = fXiPtAxis->FindBin(track.pt());
659661
double paraA = cfgLocDenPara[ispecies - 1][2 * ptbin - 2];
660662
double paraB = cfgLocDenPara[ispecies - 1][2 * ptbin - 1];
661663
double density = locDensity * 200 / (2 * cfgDeltaPhiLocDen + 1);
@@ -1087,16 +1089,16 @@ struct FlowGfwOmegaXi {
10871089
}
10881090
}
10891091
}
1090-
10911092
}
10921093
PROCESS_SWITCH(FlowGfwOmegaXi, processData, "", true);
10931094

1094-
void processMC(aod::McCollisions::iterator const&, soa::Join<aod::McParticles, aod::ParticlesToTracks> const& tracksGen, soa::SmallGroups<soa::Join<aod::McCollisionLabels, AodCollisions>> const& collisionsRec, AodTracks const&) {
1095+
void processMC(aod::McCollisions::iterator const&, soa::Join<aod::McParticles, aod::ParticlesToTracks> const& tracksGen, soa::SmallGroups<soa::Join<aod::McCollisionLabels, AodCollisions>> const& collisionsRec, AodTracks const&)
1096+
{
10951097
fGFW->Clear();
10961098
int nch = 0;
10971099
double cent = -1;
10981100
TH1D* hLocalDensity = new TH1D("hphi", "hphi", 400, -constants::math::TwoPI, constants::math::TwoPI);
1099-
for (auto& collision : collisionsRec) {
1101+
for (const auto& collision : collisionsRec) {
11001102
if (!collision.sel8())
11011103
return;
11021104
if (eventSelected(collision, cent))

0 commit comments

Comments
 (0)