Skip to content

Commit fb1f49f

Browse files
author
Sawan Sawan
committed
optimised code
1 parent b857757 commit fb1f49f

File tree

1 file changed

+86
-50
lines changed

1 file changed

+86
-50
lines changed

PWGLF/Tasks/Resonances/higherMassResonances.cxx

Lines changed: 86 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ using namespace o2;
5757
using namespace o2::framework;
5858
using namespace o2::framework::expressions;
5959
using namespace o2::soa;
60+
using namespace o2::aod::rctsel;
6061
// using namespace o2::constants::physics;
6162
using std::array;
6263

@@ -67,6 +68,16 @@ struct HigherMassResonances {
6768
HistogramRegistry hglue{"hglueball", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
6869
HistogramRegistry hMChists{"hMChists", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
6970

71+
struct RCTCut : ConfigurableGroup {
72+
Configurable<bool> requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"};
73+
Configurable<std::string> cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"};
74+
Configurable<bool> cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"};
75+
Configurable<bool> cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"};
76+
77+
RCTFlagsChecker rctChecker;
78+
};
79+
RCTCut rctCut;
80+
7081
struct : ConfigurableGroup {
7182
// PID and QA
7283
Configurable<bool> qAv0{"qAv0", false, "qAv0"};
@@ -123,6 +134,7 @@ struct HigherMassResonances {
123134
ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 5., 10., 30., 50., 70., 100., 110., 150.}, "Binning of the centrality axis"};
124135

125136
// Configurable for MC
137+
Configurable<bool> isMC{"isMC", false, "Is MC"};
126138
Configurable<bool> allGenCollisions{"allGenCollisions", true, "To fill all generated collisions for the signal loss calculations"};
127139
Configurable<bool> cTVXEvsel{"cTVXEvsel", true, "Triggger selection"};
128140
Configurable<bool> avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"};
@@ -145,23 +157,16 @@ struct HigherMassResonances {
145157
Configurable<int> tpcCrossedrows{"tpcCrossedrows", 70, "TPC crossed rows"};
146158
Configurable<float> tpcCrossedrowsOverfcls{"tpcCrossedrowsOverfcls", 0.8, "TPC crossed rows over findable clusters"};
147159

148-
// Mass and pT axis as configurables
149-
Configurable<float> cPtMin{"cPtMin", 0.0f, "Minimum pT"};
150-
Configurable<float> cPtMax{"cPtMax", 30.0f, "Maximum pT"};
151-
Configurable<int> cPtBins{"cPtBins", 300, "Number of pT bins"};
152-
Configurable<float> cMassMin{"cMassMin", 0.9f, "Minimum mass of glueball"};
153-
Configurable<float> cMassMax{"cMassMax", 3.0f, "Maximum mass of glueball"};
154-
Configurable<int> cMassBins{"cMassBins", 210, "Number of mass bins for glueball"};
155-
Configurable<float> ksMassMin{"ksMassMin", 0.45f, "Minimum mass of K0s"};
156-
Configurable<float> ksMassMax{"ksMassMax", 0.55f, "Maximum mass of K0s"};
157-
Configurable<int> ksMassBins{"ksMassBins", 200, "Number of mass bins for K0s"};
160+
// // Mass and pT axis as configurables
158161
Configurable<int> rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"};
159162
ConfigurableAxis configThnAxisPOL{"configThnAxisPOL", {20, -1.0, 1.0}, "Costheta axis"};
160163
ConfigurableAxis configThnAxisPhi{"configThnAxisPhi", {70, 0.0f, 7.0f}, "Phi axis"}; // 0 to 2pi
164+
ConfigurableAxis ksMassBins{"ksMassBins", {200, 0.45f, 0.55f}, "K0s invariant mass axis"};
165+
ConfigurableAxis cMassBins{"cMassBins", {200, 0.9f, 3.0f}, "Glueball invariant mass axis"};
166+
ConfigurableAxis cPtBins{"cPtBins", {200, 0.0f, 20.0f}, "Glueball pT axis"};
161167
// ConfigurableAxis axisdEdx{"axisdEdx", {20000, 0.0f, 200.0f}, "dE/dx (a.u.)"};
162168
// ConfigurableAxis axisPtfordEbydx{"axisPtfordEbydx", {2000, 0, 20}, "pT (GeV/c)"};
163169
// ConfigurableAxis axisMultdist{"axisMultdist", {3500, 0, 70000}, "Multiplicity distribution"};
164-
// ConfigurableAxis occupancyBins{"occupancyBins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning: occupancy axis"};
165170
} config;
166171

167172
// Service<o2::framework::O2DatabasePDG> PDGdatabase;
@@ -180,16 +185,19 @@ struct HigherMassResonances {
180185

181186
void init(InitContext const&)
182187
{
188+
rctCut.rctChecker.init(
189+
rctCut.cfgEvtRCTFlagCheckerLabel,
190+
rctCut.cfgEvtRCTFlagCheckerZDCCheck,
191+
rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad);
192+
183193
// Axes
184-
AxisSpec k0ShortMassAxis = {config.ksMassBins, config.ksMassMin, config.ksMassMax, "#it{M}_{inv} [GeV/#it{c}^{2}]"};
185-
AxisSpec glueballMassAxis = {config.cMassBins, config.cMassMin, config.cMassMax, "#it{M}_{inv} [GeV/#it{c}^{2}]"};
194+
AxisSpec k0ShortMassAxis = {config.ksMassBins, "#it{M}_{inv} [GeV/#it{c}^{2}]"};
195+
AxisSpec glueballMassAxis = {config.ksMassBins, "#it{M}_{inv} [GeV/#it{c}^{2}]"};
186196
AxisSpec vertexZAxis = {60, -15.f, 15.f, "vrtx_{Z} [cm]"}; // for histogram
187-
AxisSpec ptAxis = {config.cPtBins, config.cPtMin, config.cPtMax, "#it{p}_{T} (GeV/#it{c})"};
188-
// AxisSpec multiplicityAxis = {110, 0.0f, 150.0f, "Multiplicity Axis"};
197+
AxisSpec ptAxis = {config.cPtBins, "#it{p}_{T} (GeV/#it{c})"};
189198
AxisSpec multiplicityAxis = {config.binsCent, "Multiplicity Axis"};
190199
AxisSpec thnAxisPOL{config.configThnAxisPOL, "Configurabel theta axis"};
191200
AxisSpec thnAxisPhi = {config.configThnAxisPhi, "Configurabel phi axis"}; // 0 to 2pi
192-
// AxisSpec occupancyAxis = {occupancyBins, "Occupancy [-40,100]"};
193201

194202
// THnSparses
195203
std::array<int, 4> sparses = {config.activateTHnSparseCosThStarHelicity, config.activateTHnSparseCosThStarProduction, config.activateTHnSparseCosThStarBeam, config.activateTHnSparseCosThStarRandom};
@@ -293,27 +301,28 @@ struct HigherMassResonances {
293301
// }
294302

295303
// For MC
296-
hMChists.add("events_check", "No. of events in the generated MC", kTH1I, {{20, 0, 20}});
297-
hMChists.add("events_checkrec", "No. of events in the reconstructed MC", kTH1I, {{20, 0, 20}});
298-
hMChists.add("Genf1710", "Gen f_{0}(1710)", kTHnSparseF, {multiplicityAxis, ptAxis});
299-
hMChists.add("Recf1710_pt1", "Rec f_{0}(1710) p_{T}", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis});
300-
hMChists.add("Recf1710_pt2", "Rec f_{0}(1710) p_{T}", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis});
301-
hMChists.add("Recf1710_p", "Rec f_{0}(1710) p", kTH1F, {ptAxis});
302-
hMChists.add("h1Recsplit", "Rec p_{T}2", kTH1F, {ptAxis});
303-
304-
hMChists.add("Recf1710_mass", "Rec f_{0}(1710) mass", kTH1F, {glueballMassAxis});
305-
hMChists.add("Genf1710_mass", "Gen f_{0}(1710) mass", kTH1F, {glueballMassAxis});
306-
hMChists.add("GenEta", "Gen Eta", kTHnSparseF, {ptAxis, {100, -1.0f, 1.0f}});
307-
hMChists.add("GenPhi", "Gen Phi", kTH1F, {{70, -3.5f, 3.5f}});
308-
hMChists.add("GenRapidity", "Gen Rapidity", kTHnSparseF, {ptAxis, {100, -1.0f, 1.0f}});
309-
hMChists.add("RecEta", "Rec Eta", kTH1F, {{100, -1.0f, 1.0f}});
310-
hMChists.add("RecPhi", "Rec Phi", kTH1F, {{70, 0.0f, 7.0f}});
311-
hMChists.add("RecRapidity", "Rec Rapidity", kTH1F, {{100, -1.0f, 1.0f}});
312-
hMChists.add("MC_mult", "Multiplicity in MC", kTH1F, {multiplicityAxis});
313-
hMChists.add("MC_mult_after_event_sel", "Multiplicity in MC", kTH1F, {multiplicityAxis});
314-
// hMChists.add("GenPx", "Gen Px", kTH1F, {{100, -10.0f, 10.0f}});
315-
// hMChists.add("GenPy", "Gen Py", kTH1F, {{100, -10.0f, 10.0f}});
316-
// hMChists.add("GenPz", "Gen Pz", kTH1F, {{100, -10.0f, 10.0f}});
304+
if (config.isMC) {
305+
hMChists.add("events_check", "No. of events in the generated MC", kTH1I, {{20, 0, 20}});
306+
hMChists.add("events_checkrec", "No. of events in the reconstructed MC", kTH1I, {{20, 0, 20}});
307+
hMChists.add("Genf1710", "Gen f_{0}(1710)", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL});
308+
hMChists.add("Recf1710_pt1", "Rec f_{0}(1710) p_{T}", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL});
309+
hMChists.add("Recf1710_pt2", "Rec f_{0}(1710) p_{T}", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL});
310+
// hMChists.add("Recf1710_p", "Rec f_{0}(1710) p", kTH1F, {ptAxis});
311+
hMChists.add("h1Recsplit", "Rec p_{T}2", kTH1F, {ptAxis});
312+
// hMChists.add("Recf1710_mass", "Rec f_{0}(1710) mass", kTH1F, {glueballMassAxis});
313+
// hMChists.add("Genf1710_mass", "Gen f_{0}(1710) mass", kTH1F, {glueballMassAxis});
314+
hMChists.add("GenEta", "Gen Eta", kTHnSparseF, {ptAxis, {100, -1.0f, 1.0f}});
315+
hMChists.add("GenPhi", "Gen Phi", kTH1F, {{70, -3.5f, 3.5f}});
316+
hMChists.add("GenRapidity", "Gen Rapidity", kTHnSparseF, {ptAxis, {100, -1.0f, 1.0f}});
317+
hMChists.add("RecEta", "Rec Eta", kTH1F, {{100, -1.0f, 1.0f}});
318+
hMChists.add("RecPhi", "Rec Phi", kTH1F, {{70, 0.0f, 7.0f}});
319+
hMChists.add("RecRapidity", "Rec Rapidity", kTH1F, {{100, -1.0f, 1.0f}});
320+
hMChists.add("MC_mult", "Multiplicity in MC", kTH1F, {multiplicityAxis});
321+
hMChists.add("MC_mult_after_event_sel", "Multiplicity in MC", kTH1F, {multiplicityAxis});
322+
// hMChists.add("GenPx", "Gen Px", kTH1F, {{100, -10.0f, 10.0f}});
323+
// hMChists.add("GenPy", "Gen Py", kTH1F, {{100, -10.0f, 10.0f}});
324+
// hMChists.add("GenPz", "Gen Pz", kTH1F, {{100, -10.0f, 10.0f}});
325+
}
317326
}
318327

319328
template <typename Collision>
@@ -699,6 +708,10 @@ struct HigherMassResonances {
699708
return;
700709
}
701710

711+
if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(collision)) {
712+
return;
713+
}
714+
702715
// auto occupancyNumber = collision.trackOccupancyInTimeRange();
703716
// if (applyOccupancyCut && occupancyNumber < occupancyCut) {
704717
// return;
@@ -839,6 +852,13 @@ struct HigherMassResonances {
839852
// return;
840853
// }
841854

855+
if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(c1)) {
856+
return;
857+
}
858+
if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(c2)) {
859+
return;
860+
}
861+
842862
for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) {
843863

844864
if (t1.size() == 0 || t2.size() == 0) {
@@ -963,7 +983,10 @@ struct HigherMassResonances {
963983
float multiplicityGen = 0.0;
964984
void processGen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups<EventCandidatesMC>& collisions)
965985
{
966-
TLorentzVector genvec;
986+
if (config.isMC == false) {
987+
return;
988+
}
989+
TLorentzVector lResonance_gen;
967990
hMChists.fill(HIST("events_check"), 0.5);
968991
if (std::abs(mcCollision.posZ()) < config.cutzvertex) {
969992
hMChists.fill(HIST("events_check"), 1.5);
@@ -1049,12 +1072,19 @@ struct HigherMassResonances {
10491072
if (std::abs(kCurrentDaughter.pdgCode()) == 310) {
10501073
passKs = true;
10511074
hMChists.fill(HIST("events_check"), 9.5);
1075+
fourVecDau1 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassK0Short);
10521076
}
10531077
}
10541078
if (passKs) {
1055-
genvec.SetPtEtaPhiE(mcParticle.pt(), mcParticle.eta(), mcParticle.phi(), mcParticle.e());
1056-
hMChists.fill(HIST("Genf1710_mass"), genvec.M());
1057-
hMChists.fill(HIST("Genf1710"), multiplicityGen, mcParticle.pt());
1079+
lResonance_gen.SetPtEtaPhiE(mcParticle.pt(), mcParticle.eta(), mcParticle.phi(), mcParticle.e());
1080+
fourVecMother = ROOT::Math::PxPyPzMVector(lResonance_gen.Px(), lResonance_gen.Py(), lResonance_gen.Pz(), lResonance_gen.M());
1081+
ROOT::Math::Boost boost{fourVecMother.BoostToCM()};
1082+
fourVecDauCM = boost(fourVecDau1); // boost the frame of daughter to the center of mass frame
1083+
1084+
auto helicity_gen = fourVecDau1.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(fourVecDau1.Vect().Mag2()));
1085+
1086+
hMChists.fill(HIST("Genf1710"), multiplicityGen, mcParticle.pt(), lResonance_gen.M(), helicity_gen);
1087+
// hMChists.fill(HIST("Genf1710_mass"), lResonance_gen.M());
10581088
}
10591089
}
10601090
}
@@ -1065,11 +1095,11 @@ struct HigherMassResonances {
10651095
std::vector<int> gindex1, gindex2;
10661096
void processRec(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const&, V0TrackCandidatesMC const& V0s, aod::McParticles const&, aod::McCollisions const& /*mcCollisions*/)
10671097
{
1098+
if (config.isMC == false) {
1099+
return;
1100+
}
10681101

10691102
TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance;
1070-
// lDecayDaughter1.SetXYZM(0.0,0.0,0.0,0.0);
1071-
// lDecayDaughter2.SetXYZM(0.0,0.0,0.0,0.0);
1072-
// lDecayDaughter1.SetXYZM(0.0,0.0,0.0,0.0);
10731103
auto multiplicity = collision.centFT0C();
10741104
hMChists.fill(HIST("MC_mult"), multiplicity);
10751105

@@ -1226,7 +1256,7 @@ struct HigherMassResonances {
12261256
pvec0 = std::array{v01.px(), v01.py(), v01.pz()};
12271257
pvec1 = std::array{v02.px(), v02.py(), v02.pz()};
12281258
auto arrMomrec = std::array{pvec0, pvec1};
1229-
auto motherP = mothertrack1.p();
1259+
// auto motherP = mothertrack1.p();
12301260
// auto motherE = mothertrack1.e();
12311261
// auto genMass = std::sqrt(motherE * motherE - motherP * motherP);
12321262
auto recMass = RecoDecay::m(arrMomrec, std::array{o2::constants::physics::MassK0Short, o2::constants::physics::MassK0Short});
@@ -1235,12 +1265,18 @@ struct HigherMassResonances {
12351265
lDecayDaughter1.SetXYZM(v01.px(), v01.py(), v01.pz(), o2::constants::physics::MassK0Short);
12361266
lDecayDaughter2.SetXYZM(v02.px(), v02.py(), v02.pz(), o2::constants::physics::MassK0Short);
12371267
lResonance = lDecayDaughter1 + lDecayDaughter2;
1238-
1239-
hMChists.fill(HIST("Recf1710_p"), motherP);
1240-
hMChists.fill(HIST("Recf1710_mass"), recMass);
1241-
hMChists.fill(HIST("Recf1710_pt1"), multiplicity, mothertrack1.pt(), recMass);
1268+
// fourVecDau1, fourVecMother, fourVecDauCM
1269+
fourVecMother = ROOT::Math::PxPyPzMVector(lResonance.Px(), lResonance.Py(), lResonance.Pz(), lResonance.M());
1270+
fourVecDau1 = ROOT::Math::PxPyPzMVector(lDecayDaughter1.Px(), lDecayDaughter1.Py(), lDecayDaughter1.Pz(), o2::constants::physics::MassK0Short);
1271+
ROOT::Math::Boost boost{fourVecMother.BoostToCM()};
1272+
fourVecDauCM = boost(fourVecDau1); // boost the frame of daughter to the center of mass frame
1273+
auto helicity_rec = fourVecDau1.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(fourVecDau1.Vect().Mag2()));
1274+
1275+
// hMChists.fill(HIST("Recf1710_p"), motherP);
1276+
// hMChists.fill(HIST("Recf1710_mass"), recMass);
1277+
hMChists.fill(HIST("Recf1710_pt1"), multiplicity, mothertrack1.pt(), recMass, helicity_rec);
12421278
// hMChists.fill(HIST("Genf1710_mass"), genMass);
1243-
hMChists.fill(HIST("Recf1710_pt2"), multiplicity, lResonance.Pt(), recMass);
1279+
hMChists.fill(HIST("Recf1710_pt2"), multiplicity, lResonance.Pt(), recMass, helicity_rec);
12441280

12451281
hMChists.fill(HIST("RecRapidity"), mothertrack1.y());
12461282
hMChists.fill(HIST("RecPhi"), mothertrack1.phi());

0 commit comments

Comments
 (0)