Skip to content

Commit

Permalink
PWGEM/PhotonMeson: clean up histograms (AliceO2Group#3712)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsekihat authored Oct 28, 2023
1 parent 900cce5 commit 5c53d74
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
14 changes: 5 additions & 9 deletions PWGEM/PhotonMeson/Core/HistogramsLibrary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ void o2::aod::emphotonhistograms::DefineHistograms(THashList* list, const char*
list->Add(new TH1F("hNclsITS", "number of ITS clusters", 8, -0.5, 7.5));
list->Add(new TH1F("hChi2ITS", "chi2/number of ITS clusters", 360, 0, 36));
list->Add(new TH1F("hITSClusterMap", "ITS cluster map", 128, -0.5, 127.5));
list->Add(new TH2F("hXY", "X vs. Y;X;Y", 200, 0, 200, 100, -50, 50));
list->Add(new TH2F("hZX", "Z vs. X;Z;X", 200, -100, 100, 200, 0, 200));
list->Add(new TH2F("hZY", "Z vs. Y;Z;Y", 200, -100, 100, 100, -50, 50));
list->Add(new TH2F("hXY", "X vs. Y;X (cm);Y (cm)", 100, 0, 100, 100, -50, 50));
list->Add(new TH2F("hZX", "Z vs. X;Z (cm);X (cm)", 200, -100, 100, 100, 0, 100));
list->Add(new TH2F("hZY", "Z vs. Y;Z (cm);Y (cm)", 200, -100, 100, 100, -50, 50));
list->Add(new TH2F("hDCAxyZ", "DCAxy vs. Z;Z (cm);DCA_{xy} (cm)", 200, -100, +100, 100, -50, 50));
}
if (TString(histClass) == "V0") {
Expand All @@ -75,19 +75,15 @@ void o2::aod::emphotonhistograms::DefineHistograms(THashList* list, const char*
list->Add(new TH2F("hAPplot", "AP plot;#alpha;q_{T} (GeV/c)", 200, -1.0f, +1.0f, 250, 0.0f, 0.25f));
list->Add(new TH2F("hMassGamma", "hMassGamma;R_{xy} (cm);m_{ee} (GeV/c^{2})", 200, 0.0f, 100.0f, 100, 0.0f, 0.1f));
list->Add(new TH2F("hMassGamma_recalc", "recalc. hMassGamma;R_{xy} (cm);m_{ee} (GeV/c^{2})", 200, 0.0f, 100.0f, 100, 0.0f, 0.1f));
list->Add(new TH2F("hMassGammaKF_SV_Rxy", "recalc. hMassGamma KF SV;R_{xy} (cm);m_{ee} (GeV/c^{2})", 200, 0.0f, 100.0f, 100, 0.0f, 0.1f));
list->Add(new TH2F("hMassGammaKF_PV_SV", "hMassGamma;m_{ee} at PV (GeV/c^{2});m_{ee} at SV (GeV/c^{2})", 100, 0.0f, 0.1f, 100, 0.0f, 0.1f));
list->Add(new TH2F("hMassGammaKF_SV_PsiPair", "#psi_{pair} for photon conversion;#psi_{pair} (rad.);m_{ee} at SV (GeV/c^{2})", 150, 0, TMath::PiOver2(), 100, 0.0f, 0.1f));
list->Add(new TH2F("hMassGammaKF_SV_PhiV", "#varphi_{V} for photon conversion;#varphi_{V} (rad.);m_{ee} at SV (GeV/c^{2})", 100, 0, TMath::Pi(), 100, 0.0f, 0.1f));
list->Add(new TH2F("hGammaRxy", "conversion point in XY;V_{x} (cm);V_{y} (cm)", 400, -100.0f, 100.0f, 400, -100.0f, 100.0f));
list->Add(new TH2F("hGammaRxy_recalc", "recalc. conversion point in XY;V_{x} (cm);V_{y} (cm)", 400, -100.0f, 100.0f, 400, -100.0f, 100.0f));
list->Add(new TH2F("hKFChi2vsR", "KF chi2 vs. recalc. conversion point in XY;R_{xy} (cm);KF chi2/NDF", 200, 0.0f, 200.0f, 100, 0.f, 100.0f));
list->Add(new TH2F("hKFChi2vsX", "KF chi2 vs. recalc. conversion point in X;X (cm);KF chi2/NDF", 200, -100.0f, 100.0f, 100, 0.f, 100.0f));
list->Add(new TH2F("hKFChi2vsY", "KF chi2 vs. recalc. conversion point in Y;Y (cm);KF chi2/NDF", 200, -100.0f, 100.0f, 100, 0.f, 100.0f));
list->Add(new TH2F("hKFChi2vsZ", "KF chi2 vs. recalc. conversion point in Z;Z (cm);KF chi2/NDF", 200, -100.0f, 100.0f, 100, 0.f, 100.0f));
list->Add(new TH1F("hNgamma", "Number of #gamma candidates per collision", 101, -0.5f, 100.5f));
list->Add(new TH2F("hCorrTgl", "correlation of track tgl between e^{+} and e^{-};e^{-} track tgl;e^{+} track tgl", 300, -1.5f, 1.5f, 300, -1.5f, 1.5f));
list->Add(new TH2F("hCorrZ", "correlation of track iu z between e^{+} and e^{-};e^{-} track iu Z (cm);e^{+} track iu Z (cm)", 400, -100.f, 100.f, 400, -100.f, 100.f));
// list->Add(new TH2F("hCorrTgl", "correlation of track tgl between e^{+} and e^{-};e^{-} track tgl;e^{+} track tgl", 300, -1.5f, 1.5f, 300, -1.5f, 1.5f));
// list->Add(new TH2F("hCorrZ", "correlation of track iu z between e^{+} and e^{-};e^{-} track iu Z (cm);e^{+} track iu Z (cm)", 400, -100.f, 100.f, 400, -100.f, 100.f));

if (TString(subGroup) == "mc") {
list->Add(new TH1F("hPt_Photon_Primary", "pT;p_{T} (GeV/c)", 1000, 0.0f, 10)); // for MC efficiency
Expand Down
4 changes: 0 additions & 4 deletions PWGEM/PhotonMeson/Core/HistogramsLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,12 @@ void FillHistClass(THashList* list, const char* subGroup, T const& obj)
reinterpret_cast<TH2F*>(list->FindObject("hAPplot"))->Fill(obj.alpha(), obj.qtarm());
reinterpret_cast<TH2F*>(list->FindObject("hMassGamma"))->Fill(obj.v0radius(), obj.mGamma());
reinterpret_cast<TH2F*>(list->FindObject("hMassGamma_recalc"))->Fill(obj.recalculatedVtxR(), obj.mGamma());
// reinterpret_cast<TH2F*>(list->FindObject("hMassGammaKF_SV_Rxy"))->Fill(obj.recalculatedVtxR(), obj.mGammaKFSV());
reinterpret_cast<TH2F*>(list->FindObject("hGammaRxy"))->Fill(obj.vx(), obj.vy());
reinterpret_cast<TH2F*>(list->FindObject("hGammaRxy_recalc"))->Fill(obj.recalculatedVtxX(), obj.recalculatedVtxY());
reinterpret_cast<TH2F*>(list->FindObject("hKFChi2vsR"))->Fill(obj.recalculatedVtxR(), obj.chiSquareNDF());
reinterpret_cast<TH2F*>(list->FindObject("hKFChi2vsX"))->Fill(obj.recalculatedVtxX(), obj.chiSquareNDF());
reinterpret_cast<TH2F*>(list->FindObject("hKFChi2vsY"))->Fill(obj.recalculatedVtxY(), obj.chiSquareNDF());
reinterpret_cast<TH2F*>(list->FindObject("hKFChi2vsZ"))->Fill(obj.recalculatedVtxZ(), obj.chiSquareNDF());
// reinterpret_cast<TH2F*>(list->FindObject("hMassGammaKF_PV_SV"))->Fill(obj.mGammaKFPV(), obj.mGammaKFSV());
// reinterpret_cast<TH2F*>(list->FindObject("hMassGammaKF_SV_PsiPair"))->Fill(abs(obj.psipair()), obj.mGammaKFSV());
// reinterpret_cast<TH2F*>(list->FindObject("hMassGammaKF_SV_PhiV"))->Fill(obj.phiv(), obj.mGammaKFSV());
} else if constexpr (htype == EMHistType::kV0Leg) {
reinterpret_cast<TH1F*>(list->FindObject("hPt"))->Fill(obj.pt());
reinterpret_cast<TH1F*>(list->FindObject("hQoverPt"))->Fill(obj.sign() / obj.pt());
Expand Down
42 changes: 33 additions & 9 deletions PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct PhotonConversionBuilder {
Configurable<float> maxchi2its{"maxchi2its", 5.0, "max chi2/NclsITS"};
Configurable<float> maxpt_itsonly{"maxpt_itsonly", 0.15, "max pT for ITSonly tracks at SV"};
Configurable<float> maxTPCNsigmaEl{"maxTPCNsigmaEl", 4.0, "max. TPC n sigma for electron"};
Configurable<float> kfMassConstrain{"kfMassConstrain", -1.f, "mass constrain for the KFParticle mother particle"};

int mRunNumber;
float d_bz;
Expand Down Expand Up @@ -331,8 +332,9 @@ struct PhotonConversionBuilder {
KFParticle gammaKF;
gammaKF.SetConstructMethod(2);
gammaKF.Construct(GammaDaughters, 2);
// gammaKF.SetNonlinearMassConstraint(0.0f);

if (kfMassConstrain > -0.1) {
gammaKF.SetNonlinearMassConstraint(kfMassConstrain);
}
KFPVertex kfpVertex = createKFPVertexFromCollision(collision);
KFParticle KFPV(kfpVertex);

Expand Down Expand Up @@ -403,6 +405,7 @@ struct PhotonConversionBuilder {
return;
}
pca_map[std::make_tuple(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex())] = pca_kf;
cospa_map[std::make_tuple(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex())] = cospa_kf;

if (filltable) {
registry.fill(HIST("V0/hAP"), alpha, qt);
Expand Down Expand Up @@ -455,8 +458,9 @@ struct PhotonConversionBuilder {
}

Preslice<aod::V0s> perCollision = o2::aod::v0::collisionId;

std::map<std::tuple<int64_t, int64_t, int64_t, int64_t>, float> pca_map; //(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> pca
std::map<std::tuple<int64_t, int64_t, int64_t, int64_t>, float> pca_map; //(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> pca
std::map<std::tuple<int64_t, int64_t, int64_t, int64_t>, float> cospa_map; //(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> cospa
std::vector<std::pair<int64_t, int64_t>> stored_v0Ids; //(pos.globalIndex(), ele.globalIndex())

void process(aod::Collisions const& collisions, aod::V0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const&)
{
Expand All @@ -468,45 +472,65 @@ struct PhotonConversionBuilder {
auto v0s_per_coll = v0s.sliceBy(perCollision, collision.globalIndex());
// LOGF(info, "n v0 = %d", v0s_per_coll.size());
for (auto& v0 : v0s_per_coll) {
// LOGF(info, "collision.globalIndex() = %d, v0.globalIndex() = %d, v0.posTrackId() = %d, v0.negTrackId() = %d", collision.globalIndex(), v0.globalIndex(), v0.posTrackId() , v0.negTrackId());
fillV0Table<aod::Collisions, MyTracksIU>(v0, false);
} // end of v0 loop
} // end of collision loop

stored_v0Ids.reserve(pca_map.size()); // number of photon candidates per DF

// find minimal pca
for (const auto& [key, value] : pca_map) {
auto v0Id = std::get<0>(key);
// auto collisionId = std::get<1>(key);
auto collisionId = std::get<1>(key);
auto posId = std::get<2>(key);
auto eleId = std::get<3>(key);
float v0pca = value;
float cospa = cospa_map[key];
bool is_closest_v0 = true;
bool is_most_aligned_v0 = true;

for (const auto& [key_tmp, value_tmp] : pca_map) {
auto v0Id_tmp = std::get<0>(key_tmp);
auto collisionId_tmp = std::get<1>(key_tmp);
auto posId_tmp = std::get<2>(key_tmp);
auto eleId_tmp = std::get<3>(key_tmp);
float v0pca_tmp = value_tmp;
float cospa_tmp = cospa_map[key_tmp];

if (eleId == eleId_tmp && posId == posId_tmp) { // skip exactly the same V0
if (v0Id == v0Id_tmp) { // skip exactly the same v0
continue;
}

if (collisionId != collisionId_tmp && eleId == eleId_tmp && posId == posId_tmp && cospa < cospa_tmp) { // same ele and pos, but attached to different collision
// LOGF(info, "!reject! | collision id = %d | posid1 = %d , eleid1 = %d , posid2 = %d , eleid2 = %d , cospa1 = %f , cospa2 = %f", collisionId, posId, eleId, posId_tmp, eleId_tmp, cospa, cospa_tmp);
is_most_aligned_v0 = false;
break;
}

if ((eleId == eleId_tmp || posId == posId_tmp) && v0pca > v0pca_tmp) {
// LOGF(info, "!reject! | collision id = %d | posid1 = %d , eleid1 = %d , posid2 = %d , eleid2 = %d , pca1 = %f , pca2 = %f", collisionId, posId, eleId, posId_tmp, eleId_tmp, v0pca, v0pca_tmp);
is_closest_v0 = false;
break;
}
} // end of pca_map loop
} // end of pca_map tmp loop

if (is_closest_v0) {
bool is_stored = std::find(stored_v0Ids.begin(), stored_v0Ids.end(), std::make_pair(posId, eleId)) != stored_v0Ids.end();
if (is_closest_v0 && is_most_aligned_v0 && !is_stored) {
auto v0 = v0s.rawIteratorAt(v0Id);
// auto collision = collisions.rawIteratorAt(collisionId);
// auto pos = tracks.rawIteratorAt(posId);
// auto ele = tracks.rawIteratorAt(eleId);
// LOGF(info, "!accept! | collision id = %d | posid1 = %d , eleid1 = %d , pca1 = %f", collisionId, posId, eleId, v0pca);
// LOGF(info, "!accept! | collision id = %d | v0id1 = %d , posid1 = %d , eleid1 = %d , pca1 = %f , cospa = %f", collisionId, v0Id, posId, eleId, v0pca, cospa);
fillV0Table<aod::Collisions, MyTracksIU>(v0, true);
stored_v0Ids.emplace_back(std::make_pair(posId, eleId));
}
} // end of pca_map loop
// LOGF(info, "pca_map.size() = %d", pca_map.size());
pca_map.clear();
cospa_map.clear();
stored_v0Ids.clear();
stored_v0Ids.shrink_to_fit();
} // end of process
};

Expand Down
8 changes: 7 additions & 1 deletion PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGamma.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ struct Pi0EtaToGammaGamma {
ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.);
ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.);
ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;

if (abs(v12.Rapidity()) > maxY) {
continue;
}
Expand Down Expand Up @@ -433,6 +432,13 @@ struct Pi0EtaToGammaGamma {
ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.);
if constexpr (pairtype == PairType::kPCMDalitz) {
v2.SetM(g2.mee());
auto pos_sv = g1.template posTrack_as<aod::V0Legs>();
auto ele_sv = g1.template negTrack_as<aod::V0Legs>();
auto pos_pv = g2.template posTrack_as<aod::EMPrimaryTracks>();
auto ele_pv = g2.template negTrack_as<aod::EMPrimaryTracks>();
if (pos_sv.trackId() == pos_pv.trackId() || ele_sv.trackId() == ele_pv.trackId()) {
continue;
}
}
ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
if (abs(v12.Rapidity()) > maxY) {
Expand Down
4 changes: 2 additions & 2 deletions PWGEM/PhotonMeson/Tasks/pcmQC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ struct PCMQC {
if (cut.IsSelected<aod::V0Legs>(v0)) {
o2::aod::emphotonhistograms::FillHistClass<EMHistType::kV0>(list_v0_cut, "", v0);
nv0++;
reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrTgl"))->Fill(ele.tgl(), pos.tgl());
reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrZ"))->Fill(ele.z(), pos.z());
// reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrTgl"))->Fill(ele.tgl(), pos.tgl());
// reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrZ"))->Fill(ele.z(), pos.z());
for (auto& leg : {pos, ele}) {
o2::aod::emphotonhistograms::FillHistClass<EMHistType::kV0Leg>(list_v0leg_cut, "", leg);
}
Expand Down
4 changes: 2 additions & 2 deletions PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ struct PCMQCMC {
reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hConvPoint_diffZ_recalc"))->Fill(elemc.vz(), v0.recalculatedVtxZ() - elemc.vz());

nv0++;
reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrTgl"))->Fill(ele.tgl(), pos.tgl());
reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrZ"))->Fill(ele.z(), pos.z());
// reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrTgl"))->Fill(ele.tgl(), pos.tgl());
// reinterpret_cast<TH1F*>(fMainList->FindObject("V0")->FindObject(cut.GetName())->FindObject("hCorrZ"))->Fill(ele.z(), pos.z());
for (auto& leg : {pos, ele}) {
o2::aod::emphotonhistograms::FillHistClass<EMHistType::kV0Leg>(list_v0leg_cut, "", leg);
}
Expand Down

0 comments on commit 5c53d74

Please sign in to comment.