Skip to content

Commit 27519b9

Browse files
authored
[PWGEM/Dilepton] update studyDCAFitter.cxx (#16576)
1 parent d21f330 commit 27519b9

2 files changed

Lines changed: 66 additions & 34 deletions

File tree

PWGEM/Dilepton/DataModel/lmeeMLTables.h

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -346,22 +346,26 @@ using EMMLLCascPair = EMMLLCascPairs::iterator;
346346

347347
namespace emmldilepton
348348
{
349-
DECLARE_SOA_INDEX_COLUMN(EMMLEvent, emmlevent); //! index to event table
350-
DECLARE_SOA_COLUMN(Signed1Pt1, signed1Pt1, float); //! q/pt of lepton1 at PV
351-
DECLARE_SOA_COLUMN(Eta1, eta1, float); //! eta of lepton1 at PV
352-
DECLARE_SOA_COLUMN(ImpParXY1, impParXY1, float); //! impact parameter for lepton1 in XY plane
353-
DECLARE_SOA_COLUMN(ImpParZ1, impParZ1, float); //! impact parameter for lepton1 in Z plane
354-
DECLARE_SOA_COLUMN(ImpParCYY1, impParCYY1, float); //! sigma of impact parameter for lepton1 in XY
355-
DECLARE_SOA_COLUMN(ImpParCZY1, impParCZY1, float); //! sigma of impact parameter for lepton1, correlaion term
356-
DECLARE_SOA_COLUMN(ImpParCZZ1, impParCZZ1, float); //! sigma of impact parameter for lepton1 in Z
357-
358-
DECLARE_SOA_COLUMN(Signed1Pt2, signed1Pt2, float); //! q/pt of lepton2 at PV
359-
DECLARE_SOA_COLUMN(Eta2, eta2, float); //! eta of lepton1 at PV
360-
DECLARE_SOA_COLUMN(ImpParXY2, impParXY2, float); //! impact parameter for lepton2 in XY plane
361-
DECLARE_SOA_COLUMN(ImpParZ2, impParZ2, float); //! impact parameter for lepton2 in Z plane
362-
DECLARE_SOA_COLUMN(ImpParCYY2, impParCYY2, float); //! sigma of impact parameter for lepton2 in XY
363-
DECLARE_SOA_COLUMN(ImpParCZY2, impParCZY2, float); //! sigma of impact parameter for lepton2, correlaion term
364-
DECLARE_SOA_COLUMN(ImpParCZZ2, impParCZZ2, float); //! sigma of impact parameter for lepton2 in Z
349+
DECLARE_SOA_INDEX_COLUMN(EMMLEvent, emmlevent); //! index to event table
350+
DECLARE_SOA_COLUMN(Signed1Pt1, signed1Pt1, float); //! q/pt of lepton1 at PV
351+
DECLARE_SOA_COLUMN(Eta1, eta1, float); //! eta of lepton1 at PV
352+
DECLARE_SOA_COLUMN(ImpParXY1, impParXY1, float); //! impact parameter for lepton1 in XY plane
353+
DECLARE_SOA_COLUMN(ImpParZ1, impParZ1, float); //! impact parameter for lepton1 in Z plane
354+
DECLARE_SOA_COLUMN(ImpParCYY1, impParCYY1, float); //! sigma of impact parameter for lepton1 in XY
355+
DECLARE_SOA_COLUMN(ImpParCZY1, impParCZY1, float); //! sigma of impact parameter for lepton1, correlaion term
356+
DECLARE_SOA_COLUMN(ImpParCZZ1, impParCZZ1, float); //! sigma of impact parameter for lepton1 in Z
357+
DECLARE_SOA_COLUMN(IsCorrectCollision1, isCorrectCollision1, bool); //! lepton1 is associated to correct collision.
358+
DECLARE_SOA_COLUMN(PdgCodeMother1, pdgCodeMother1, int); //! pdg code of mother of lepton1
359+
360+
DECLARE_SOA_COLUMN(Signed1Pt2, signed1Pt2, float); //! q/pt of lepton2 at PV
361+
DECLARE_SOA_COLUMN(Eta2, eta2, float); //! eta of lepton1 at PV
362+
DECLARE_SOA_COLUMN(ImpParXY2, impParXY2, float); //! impact parameter for lepton2 in XY plane
363+
DECLARE_SOA_COLUMN(ImpParZ2, impParZ2, float); //! impact parameter for lepton2 in Z plane
364+
DECLARE_SOA_COLUMN(ImpParCYY2, impParCYY2, float); //! sigma of impact parameter for lepton2 in XY
365+
DECLARE_SOA_COLUMN(ImpParCZY2, impParCZY2, float); //! sigma of impact parameter for lepton2, correlaion term
366+
DECLARE_SOA_COLUMN(ImpParCZZ2, impParCZZ2, float); //! sigma of impact parameter for lepton2 in Z
367+
DECLARE_SOA_COLUMN(IsCorrectCollision2, isCorrectCollision2, bool); //! lepton is associated to correct collision.
368+
DECLARE_SOA_COLUMN(PdgCodeMother2, pdgCodeMother2, int); //! pdg code of mother of lepton1
365369

366370
DECLARE_SOA_COLUMN(Mass, mass, float); //! invariant mass of dilepton
367371
DECLARE_SOA_COLUMN(Pt, pt, float); //! dilepton pair pt
@@ -384,14 +388,14 @@ DECLARE_SOA_COLUMN(PdgCodeCommonMother, pdgCodeCommonMother, int); //! pdg code
384388

385389
DECLARE_SOA_TABLE(EMMLDielectronsAtSV, "AOD", "EMMLEESV", //!
386390
emmldilepton::EMMLEventId,
387-
emmldilepton::Signed1Pt1, emmldilepton::Eta1, emmldilepton::ImpParXY1, emmldilepton::ImpParZ1, emmldilepton::ImpParCYY1, emmldilepton::ImpParCZY1, emmldilepton::ImpParCZZ1,
388-
emmldilepton::Signed1Pt2, emmldilepton::Eta2, emmldilepton::ImpParXY2, emmldilepton::ImpParZ2, emmldilepton::ImpParCYY2, emmldilepton::ImpParCZY2, emmldilepton::ImpParCZZ2,
391+
emmldilepton::Signed1Pt1, emmldilepton::Eta1, emmldilepton::ImpParXY1, emmldilepton::ImpParZ1, emmldilepton::ImpParCYY1, emmldilepton::ImpParCZY1, emmldilepton::ImpParCZZ1, emmldilepton::IsCorrectCollision1, emmldilepton::PdgCodeMother1,
392+
emmldilepton::Signed1Pt2, emmldilepton::Eta2, emmldilepton::ImpParXY2, emmldilepton::ImpParZ2, emmldilepton::ImpParCYY2, emmldilepton::ImpParCZY2, emmldilepton::ImpParCZZ2, emmldilepton::IsCorrectCollision2, emmldilepton::PdgCodeMother2,
389393
emmldilepton::Mass, emmldilepton::Pt, emmldilepton::Rapidity,
390394
emmldilepton::Chi2PCA,
391395
emmldilepton::CPA, emmldilepton::CPAXY, emmldilepton::CPARZ,
392396
emmldilepton::Lxy, emmldilepton::Lz, emmldilepton::Lxyz,
393397
emmldilepton::LxyErr, emmldilepton::LzErr, emmldilepton::LxyzErr,
394-
emmldilepton::DileptonType, emmldilepton::PdgCodeCommonMother);
398+
emmldilepton::DileptonType);
395399

396400
// iterators
397401
using EMMLDielectronAtSV = EMMLDielectronsAtSV::iterator;

PWGEM/Dilepton/Tasks/studyDCAFitter.cxx

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <array>
5454
#include <cmath>
5555
#include <cstdint>
56+
#include <random>
5657
#include <string>
5758
#include <string_view>
5859
#include <utility>
@@ -80,6 +81,7 @@ struct studyDCAFitter {
8081
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
8182
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
8283
// Configurable<std::string> mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"};
84+
Configurable<float> cfgDownSampling{"cfgDownSampling", 1.1, "down sampling for wrongly found SV"};
8385

8486
struct : ConfigurableGroup {
8587
std::string prefix = "electronCut";
@@ -153,6 +155,10 @@ struct studyDCAFitter {
153155
mRunNumber = 0;
154156
d_bz = 0;
155157

158+
std::random_device seed_gen;
159+
engine = std::mt19937(seed_gen());
160+
dist01 = std::uniform_real_distribution<float>(0.0f, 1.0f);
161+
156162
addHistograms();
157163
}
158164

@@ -167,6 +173,9 @@ struct studyDCAFitter {
167173
o2::dataformats::DCA mDcaInfoCov;
168174
o2::dataformats::VertexBase mVtx;
169175

176+
std::mt19937 engine;
177+
std::uniform_real_distribution<float> dist01;
178+
170179
template <typename TBC>
171180
void initCCDB(TBC const& bc)
172181
{
@@ -411,11 +420,11 @@ struct studyDCAFitter {
411420
auto t1mc = t1.template mcParticle_as<aod::McParticles>();
412421
auto t2mc = t2.template mcParticle_as<aod::McParticles>();
413422

414-
int mcCommonMotherid = FindCommonMother(t1mc, t2mc, mcParticles);
423+
int mcCommonMotherId = FindCommonMother(t1mc, t2mc, mcParticles);
415424
int hfee_type = IsHF(t1mc, t2mc, mcParticles);
416425

417-
if (mcCommonMotherid > -1) {
418-
auto cmp = mcParticles.rawIteratorAt(mcCommonMotherid);
426+
if (mcCommonMotherId > -1) {
427+
auto cmp = mcParticles.rawIteratorAt(mcCommonMotherId);
419428
switch (std::abs(cmp.pdgCode())) {
420429
case 23:
421430
if constexpr (signType == 0) { // ULS
@@ -495,7 +504,6 @@ struct studyDCAFitter {
495504
fRegistry.fill(HIST("Pair/PV/b2c2e_b2e_diffb/lsmm/hs"), v12.M(), v12.Pt(), pair_dca);
496505
}
497506
break;
498-
499507
default:
500508
break;
501509
} // end of switch for HFee
@@ -583,19 +591,22 @@ struct studyDCAFitter {
583591
float pteeAtSV = RecoDecay::sqrtSumOfSquares(pvecSum[0], pvecSum[1]);
584592
float yeeAtSV = RecoDecay::y(pvecSum, meeAtSV);
585593

586-
int pdgCodeCM = 0;
587-
588-
auto t1mc = t1.template mcParticle_as<aod::McParticles>();
589-
auto t2mc = t2.template mcParticle_as<aod::McParticles>();
594+
auto t1mc = t1.template mcParticle_as<aod::McParticles>(); // true lepton
595+
auto t2mc = t2.template mcParticle_as<aod::McParticles>(); // true lepton
596+
bool isCorrectCollision1 = t1mc.mcCollisionId() == collision.mcCollisionId();
597+
bool isCorrectCollision2 = t2mc.mcCollisionId() == collision.mcCollisionId();
598+
int pdgCodeMother1 = 0;
599+
int pdgCodeMother2 = 0;
590600

591-
int mcCommonMotherid = FindCommonMother(t1mc, t2mc, mcParticles);
601+
int mcCommonMotherId = FindCommonMother(t1mc, t2mc, mcParticles);
592602
int hfee_type = IsHF(t1mc, t2mc, mcParticles);
593603
bool keepSignal = false;
594604
uint8_t dileptonType = 0;
595605

596-
if (mcCommonMotherid > -1) {
597-
auto cmp = mcParticles.rawIteratorAt(mcCommonMotherid);
598-
pdgCodeCM = cmp.pdgCode();
606+
if (mcCommonMotherId > -1) {
607+
auto cmp = mcParticles.rawIteratorAt(mcCommonMotherId);
608+
pdgCodeMother1 = cmp.pdgCode();
609+
pdgCodeMother2 = cmp.pdgCode();
599610
switch (std::abs(cmp.pdgCode())) {
600611
case 23:
601612
keepSignal = true;
@@ -678,6 +689,10 @@ struct studyDCAFitter {
678689
} // end of switch for LF
679690
} else if (hfee_type > -1) {
680691
keepSignal = true;
692+
auto t1mcMother = t1mc.template mothers_first_as<aod::McParticles>();
693+
auto t2mcMother = t2mc.template mothers_first_as<aod::McParticles>();
694+
pdgCodeMother1 = t1mcMother.pdgCode();
695+
pdgCodeMother2 = t2mcMother.pdgCode();
681696
switch (hfee_type) {
682697
case static_cast<int>(EM_HFeeType::kCe_Ce):
683698
dileptonType = 3;
@@ -765,18 +780,26 @@ struct studyDCAFitter {
765780
} else {
766781
keepSignal = true;
767782
dileptonType = 0; // bkg
783+
auto t1mcMother = t1mc.template mothers_first_as<aod::McParticles>();
784+
auto t2mcMother = t2mc.template mothers_first_as<aod::McParticles>();
785+
pdgCodeMother1 = t1mcMother.pdgCode();
786+
pdgCodeMother2 = t2mcMother.pdgCode();
768787
}
769788

770789
if (keepSignal) {
790+
if (dileptonType == 0 && dist01(engine) > cfgDownSampling) { // random sampling, if necessary
791+
return;
792+
}
793+
771794
dileptonTable(eventTable.lastIndex() + 1,
772-
signed1Pt1, eta1, dcaXY1, dcaZ1, CYY1, CZY1, CZZ1,
773-
signed1Pt2, eta2, dcaXY2, dcaZ2, CYY2, CZY2, CZZ2,
795+
signed1Pt1, eta1, dcaXY1, dcaZ1, CYY1, CZY1, CZZ1, isCorrectCollision1, pdgCodeMother1,
796+
signed1Pt2, eta2, dcaXY2, dcaZ2, CYY2, CZY2, CZZ2, isCorrectCollision2, pdgCodeMother2,
774797
meeAtSV, pteeAtSV, yeeAtSV,
775798
chi2PCA,
776799
cpa, cpaXY, cpaRZ,
777800
lxy, lz, lxyz,
778801
lxyErr, lzErr, lxyzErr,
779-
dileptonType, pdgCodeCM);
802+
dileptonType);
780803
}
781804
}
782805

@@ -825,6 +848,11 @@ struct studyDCAFitter {
825848
if (std::abs(mctrack.pdgCode()) != 11) {
826849
continue;
827850
}
851+
852+
auto mcMother = mctrack.template mothers_first_as<aod::McParticles>();
853+
if (std::abs(mcMother.pdgCode()) > 1e+9) {
854+
continue;
855+
}
828856
if (!(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) {
829857
continue;
830858
}

0 commit comments

Comments
 (0)