Skip to content

Commit bc2f00c

Browse files
author
ayatsuji
committed
Update analysis task track rotation
1 parent a23c91f commit bc2f00c

2 files changed

Lines changed: 137 additions & 5 deletions

File tree

PWGDQ/Core/VarManager.h

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#include <TObject.h>
6565
#include <TRandom.h>
6666
#include <TString.h>
67-
6867
#include <KFPTrack.h>
6968
#include <KFPVertex.h>
7069
#include <KFParticle.h>
@@ -1363,6 +1362,8 @@ class VarManager : public TObject
13631362
static void FillGlobalMuonRefitCov(T1 const& muontrack, T2 const& mfttrack, const C& collision, C2 const& mftcov, float* values = nullptr);
13641363
template <int pairType, uint32_t fillMap, typename T1, typename T2>
13651364
static void FillPair(T1 const& t1, T2 const& t2, float* values = nullptr);
1365+
template <int pairType, uint32_t fillMap, typename T1, typename T2>
1366+
static void FillPairRotation(T1 const& t1, T2 const& t2, float* values = nullptr);
13661367
template <int pairType, uint32_t fillMap, typename C, typename T1, typename T2>
13671368
static void FillPairCollision(C const& collision, T1 const& t1, T2 const& t2, float* values = nullptr);
13681369
template <int pairType, uint32_t fillMap, typename C, typename T1, typename T2, typename M, typename P>
@@ -3711,6 +3712,69 @@ void VarManager::FillPair(T1 const& t1, T2 const& t2, float* values)
37113712
}
37123713
}
37133714

3715+
//change_start: rotation pair
3716+
template <int pairType, uint32_t fillMap, typename T1, typename T2>
3717+
void VarManager::FillPairRotation(T1 const& t1, T2 const& t2, float* values)
3718+
{
3719+
if (!values) {
3720+
values = fgValues;
3721+
}
3722+
3723+
float m1 = o2::constants::physics::MassElectron;
3724+
float m2 = o2::constants::physics::MassElectron;
3725+
if constexpr (pairType == kDecayToMuMu) {
3726+
m1 = o2::constants::physics::MassMuon;
3727+
m2 = o2::constants::physics::MassMuon;
3728+
}
3729+
3730+
if constexpr (pairType == kDecayToPiPi) {
3731+
m1 = o2::constants::physics::MassPionCharged;
3732+
m2 = o2::constants::physics::MassPionCharged;
3733+
}
3734+
3735+
if constexpr (pairType == kDecayToKPi) {
3736+
m1 = o2::constants::physics::MassKaonCharged;
3737+
m2 = o2::constants::physics::MassPionCharged;
3738+
// Make the TPC information of the kaon available for pair histograms
3739+
values[kPin_leg1] = t1.tpcInnerParam();
3740+
values[kTPCnSigmaKa_leg1] = t1.tpcNSigmaKa();
3741+
}
3742+
3743+
if constexpr (pairType == kElectronMuon) {
3744+
m2 = o2::constants::physics::MassMuon;
3745+
}
3746+
3747+
double dphi = gRandom->Uniform(0., 2. * TMath::Pi());
3748+
double rotationphi2 = t2.phi() + dphi;
3749+
3750+
if (rotationphi2 > 2. * TMath::Pi()) rotationphi2 -= 2. * TMath::Pi();
3751+
3752+
values[kCharge] = t1.sign() + t2.sign();
3753+
values[kCharge1] = t1.sign();
3754+
values[kCharge2] = t2.sign();
3755+
ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), m1);
3756+
ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), rotationphi2, m2);
3757+
ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
3758+
values[kMass] = v12.M();
3759+
values[kPt] = v12.Pt();
3760+
values[kEta] = v12.Eta();
3761+
// values[kPhi] = v12.Phi();
3762+
values[kPhi] = v12.Phi() > 0 ? v12.Phi() : v12.Phi() + 2. * M_PI;
3763+
values[kRap] = -v12.Rapidity();
3764+
double Ptot1 = TMath::Sqrt(v1.Px() * v1.Px() + v1.Py() * v1.Py() + v1.Pz() * v1.Pz());
3765+
double Ptot2 = TMath::Sqrt(v2.Px() * v2.Px() + v2.Py() * v2.Py() + v2.Pz() * v2.Pz());
3766+
values[kDeltaPtotTracks] = Ptot1 - Ptot2;
3767+
3768+
values[kPt1] = t1.pt();
3769+
values[kEta1] = t1.eta();
3770+
values[kPhi1] = t1.phi();
3771+
values[kPt2] = t2.pt();
3772+
values[kEta2] = t2.eta();
3773+
values[kPhi2] = rotationphi2;
3774+
3775+
}
3776+
3777+
37143778
template <int pairType, uint32_t fillMap, typename C, typename T1, typename T2>
37153779
void VarManager::FillPairCollision(const C& collision, T1 const& t1, T2 const& t2, float* values)
37163780
{

PWGDQ/Tasks/tableReader_withAssoc.cxx

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,19 +1469,22 @@ struct AnalysisSameEventPairing {
14691469

14701470
if (fEnableBarrelHistos) {
14711471
names = {
1472+
//change define histname
14721473
Form("PairsBarrelSEPM_%s", objArray->At(icut)->GetName()),
14731474
Form("PairsBarrelSEPP_%s", objArray->At(icut)->GetName()),
1474-
Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName())};
1475-
histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data());
1475+
Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName()),
1476+
Form("PairsBarrelTRPM_%s", objArray->At(icut)->GetName())};
1477+
histNames += Form("%s;%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data(), names[3].Data());
14761478
names.push_back(Form("PairsBarrelSEPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
14771479
names.push_back(Form("PairsBarrelSEPP_ambiguousextra_%s", objArray->At(icut)->GetName()));
14781480
names.push_back(Form("PairsBarrelSEMM_ambiguousextra_%s", objArray->At(icut)->GetName()));
1479-
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
1481+
names.push_back(Form("PairsBarrelTRPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
1482+
histNames += Form("%s;%s;%s;%s;", names[4].Data(), names[5].Data(), names[6].Data(), names[7].Data());
14801483
if (fEnableBarrelMixingHistos) {
14811484
names.push_back(Form("PairsBarrelMEPM_%s", objArray->At(icut)->GetName()));
14821485
names.push_back(Form("PairsBarrelMEPP_%s", objArray->At(icut)->GetName()));
14831486
names.push_back(Form("PairsBarrelMEMM_%s", objArray->At(icut)->GetName()));
1484-
histNames += Form("%s;%s;%s;", names[6].Data(), names[7].Data(), names[8].Data());
1487+
histNames += Form("%s;%s;%s;", names[8].Data(), names[9].Data(), names[10].Data());
14851488
}
14861489
fTrackHistNames[icut] = names;
14871490

@@ -2127,6 +2130,71 @@ struct AnalysisSameEventPairing {
21272130
} // end loop (pair cuts)
21282131
}
21292132
} // end loop (cuts)
2133+
2134+
//edit
2135+
//rotation 20 times
2136+
if constexpr (TPairType == VarManager::kDecayToEE) {
2137+
twoTrackFilter = a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & a1.isBarrelSelectedPrefilter_raw() & a2.isBarrelSelectedPrefilter_raw() & fTrackFilterMask;
2138+
2139+
if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue
2140+
continue;
2141+
}
2142+
2143+
auto t1 = a1.template reducedtrack_as<TTracks>();
2144+
auto t2 = a2.template reducedtrack_as<TTracks>();
2145+
sign1 = t1.sign();
2146+
sign2 = t2.sign();
2147+
// store the ambiguity number of the two dilepton legs in the last 4 digits of the two-track filter
2148+
// TODO: Make sure that we do not work with more than 28 track bits
2149+
if (t1.barrelAmbiguityInBunch() > 1) {
2150+
twoTrackFilter |= (static_cast<uint32_t>(1) << 28);
2151+
}
2152+
if (t2.barrelAmbiguityInBunch() > 1) {
2153+
twoTrackFilter |= (static_cast<uint32_t>(1) << 29);
2154+
}
2155+
if (t1.barrelAmbiguityOutOfBunch() > 1) {
2156+
twoTrackFilter |= (static_cast<uint32_t>(1) << 30);
2157+
}
2158+
if (t2.barrelAmbiguityOutOfBunch() > 1) {
2159+
twoTrackFilter |= (static_cast<uint32_t>(1) << 31);
2160+
}
2161+
2162+
for (int icut = 0; icut < ncuts; icut++) {
2163+
if (twoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
2164+
isAmbiInBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 28)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 29));
2165+
isAmbiOutOfBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
2166+
isUnambiguous = !(isAmbiInBunch || isAmbiOutOfBunch);
2167+
isLeg1Ambi = (twoTrackFilter & (static_cast<uint32_t>(1) << 28) || (twoTrackFilter & (static_cast<uint32_t>(1) << 30)));
2168+
isLeg2Ambi = (twoTrackFilter & (static_cast<uint32_t>(1) << 29) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31)));
2169+
if constexpr (TPairType == VarManager::kDecayToEE) {
2170+
if (isLeg1Ambi && isLeg2Ambi) {
2171+
std::pair<uint32_t, uint32_t> iPair(a1.reducedtrackId(), a2.reducedtrackId());
2172+
if (fAmbiguousPairs.find(iPair) != fAmbiguousPairs.end()) {
2173+
if (fAmbiguousPairs[iPair] & (static_cast<uint32_t>(1) << icut)) { // if this pair is already stored with this cut
2174+
isAmbiExtra = true;
2175+
} else {
2176+
fAmbiguousPairs[iPair] |= static_cast<uint32_t>(1) << icut;
2177+
}
2178+
} else {
2179+
fAmbiguousPairs[iPair] = static_cast<uint32_t>(1) << icut;
2180+
}
2181+
}
2182+
}
2183+
if (sign1 * sign2 < 0) {
2184+
for (int i = 0; i < 20; i++) {
2185+
VarManager::FillPairRotation<TPairType, TTrackFillMap>(t1, t2);
2186+
if constexpr (TPairType == VarManager::kDecayToEE) {
2187+
fHistMan->FillHistClass(Form("PairsBarrelTRPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
2188+
if (isAmbiExtra) {
2189+
fHistMan->FillHistClass(Form("PairsBarrelTRPM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
2190+
}
2191+
}
2192+
}
2193+
}
2194+
}
2195+
}
2196+
}
2197+
//end
21302198
} // end loop over pairs of track associations
21312199
VarManager::fgValues[VarManager::kNPairsPerEvent] = fNPairPerEvent;
21322200
if (fEnableBarrelHistos && fConfigQA) {

0 commit comments

Comments
 (0)