Skip to content

Commit 7a20d21

Browse files
authored
[PWGUD] Update MC workflow in fwdMuonsUPC.cxx (AliceO2Group#9324)
1 parent a92037d commit 7a20d21

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

PWGUD/Tasks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ o2physics_add_dpl_workflow(upc-pion-analysis
194194
COMPONENT_NAME Analysis)
195195

196196
o2physics_add_dpl_workflow(fwd-muons-upc
197-
SOURCES fwdMuonsUPC.cxx
197+
SOURCES FwdMuonsUPC.cxx
198198
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector
199199
COMPONENT_NAME Analysis)
200200

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
/// \file fwdMuonsUPC.cxx
12+
/// \file FwdMuonsUPC.cxx
1313
/// \brief perform some selections on fwd events and saves the results
1414

1515
/// executable name o2-analysis-ud-fwd-muon-upc
@@ -164,7 +164,7 @@ const float kEtaMin = -4.0;
164164
const float kEtaMax = -2.5;
165165
const float kPtMin = 0.;
166166

167-
struct fwdMuonsUPC {
167+
struct FwdMuonsUPC {
168168

169169
// a pdg object
170170
Service<o2::framework::O2DatabasePDG> pdg;
@@ -373,7 +373,7 @@ struct fwdMuonsUPC {
373373

374374
// template function that fills a map with the collision id of each udmccollision as key
375375
// and a vector with the tracks
376-
// map == (key, element) == (udCollisionId, vector(track1, mcPart1, udCollisionId1, track2, mcPart2, udCollisionId2))
376+
// map == (key, element) == (udCollisionId, vector(track1, mcPart1, track2, mcPart2))
377377
template <typename TTracks>
378378
void collectRecoCandID(std::unordered_map<int32_t, std::vector<int32_t>>& tracksPerCand, TTracks& tracks)
379379
{
@@ -383,15 +383,14 @@ struct fwdMuonsUPC {
383383
continue;
384384

385385
if (!tr.has_udMcParticle()) {
386-
// LOGF(info,"tr does not have mc part");
386+
// LOGF(debug,"tr does not have mc part");
387387
continue;
388388
}
389389
// retrieve mc particle from the reco track
390390
auto mcPart = tr.udMcParticle();
391391

392392
tracksPerCand[candId].push_back(tr.globalIndex());
393393
tracksPerCand[candId].push_back(mcPart.globalIndex());
394-
tracksPerCand[candId].push_back(mcPart.udMcCollisionId());
395394
}
396395
}
397396

@@ -643,8 +642,8 @@ struct fwdMuonsUPC {
643642
{
644643

645644
// check that all pairs are mu+mu-
646-
if (McPart1.pdgCode() + McPart2.pdgCode() != 0)
647-
LOGF(info, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode());
645+
if (std::abs(McPart1.pdgCode()) != 13 && std::abs(McPart2.pdgCode()) != 13)
646+
LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode());
648647

649648
// create Lorentz vectors
650649
TLorentzVector p1, p2;
@@ -710,6 +709,11 @@ struct fwdMuonsUPC {
710709
CompleteFwdTracks::iterator const& tr1, aod::UDMcParticles::iterator const& McPart1,
711710
CompleteFwdTracks::iterator const& tr2, aod::UDMcParticles::iterator const& McPart2)
712711
{
712+
713+
// check that all pairs are mu+mu-
714+
if (std::abs(McPart1.pdgCode()) != 13 && std::abs(McPart2.pdgCode()) != 13)
715+
LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode());
716+
713717
// V0 selection
714718
const auto& ampsV0A = cand.amplitudesV0A();
715719
const auto& ampsRelBCsV0A = cand.ampRelBCsV0A();
@@ -783,10 +787,10 @@ struct fwdMuonsUPC {
783787

784788
// print info in case of problems
785789
if (tr1.sign() * McPart1.pdgCode() > 0 || tr2.sign() * McPart2.pdgCode() > 0) {
786-
LOGF(info, "Problem: ");
787-
LOGF(info, "real: %d | %d", (int)tr1.sign(), (int)tr2.sign());
788-
LOGF(info, "mc : %i | %i", (int)McPart1.pdgCode(), (int)McPart2.pdgCode());
789-
LOGF(info, "contrib: %d", (int)cand.numContrib());
790+
LOGF(debug, "Problem: ");
791+
LOGF(debug, "real: %d | %d", (int)tr1.sign(), (int)tr2.sign());
792+
LOGF(debug, "mc : %i | %i", (int)McPart1.pdgCode(), (int)McPart2.pdgCode());
793+
LOGF(debug, "contrib: %d", (int)cand.numContrib());
790794
}
791795

792796
// fill the histos
@@ -890,7 +894,7 @@ struct fwdMuonsUPC {
890894
}
891895
}
892896

893-
PROCESS_SWITCH(fwdMuonsUPC, processData, "", true);
897+
PROCESS_SWITCH(FwdMuonsUPC, processData, "", true);
894898

895899
// process MC Truth
896900
void processMcGen(aod::UDMcCollisions const& mccollisions, aod::UDMcParticles const& McParts)
@@ -912,55 +916,52 @@ struct fwdMuonsUPC {
912916
processMcGenCand(cand, tr1, tr2);
913917
}
914918
}
915-
PROCESS_SWITCH(fwdMuonsUPC, processMcGen, "", false);
919+
PROCESS_SWITCH(FwdMuonsUPC, processMcGen, "", false);
916920

917921
// process reco MC (gen info included)
918922
void processMcReco(CandidatesFwd const& eventCandidates,
919923
CompleteFwdTracks const& fwdTracks,
920-
aod::UDMcCollisions const& mcCandidates,
924+
aod::UDMcCollisions const&,
921925
aod::UDMcParticles const& McParts)
922926
{
923927
std::unordered_map<int32_t, std::vector<int32_t>> tracksPerCandAll;
924928
collectRecoCandID(tracksPerCandAll, fwdTracks);
925929

926930
// loop over the candidates
927931
for (const auto& item : tracksPerCandAll) {
928-
if (item.second.size() != 6) {
929-
// LOGF(info, "error: reco track(s) not gen");
932+
if (item.second.size() != 4) {
933+
LOGF(debug, "number track (reco + gen) = %d", item.second.size());
930934
continue;
931935
}
932936

933-
int32_t trId1 = item.second[0];
934-
int32_t trId2 = item.second[3]; //[2]
935-
936-
int32_t candID = item.first;
937-
auto cand = eventCandidates.iteratorAt(candID);
938-
auto tr1 = fwdTracks.iteratorAt(trId1);
939-
auto tr2 = fwdTracks.iteratorAt(trId2);
937+
// get the reco candidate
938+
auto cand = eventCandidates.iteratorAt(item.first);
940939

941-
auto trMcId1 = item.second[1];
942-
auto trMcId2 = item.second[4];
943-
auto trMc1 = McParts.iteratorAt(trMcId1);
944-
auto trMc2 = McParts.iteratorAt(trMcId2);
940+
// get reco tracks and corresponding gen particles
941+
auto tr1 = fwdTracks.iteratorAt(item.second[0]);
942+
auto trMc1 = McParts.iteratorAt(item.second[1]);
943+
auto tr2 = fwdTracks.iteratorAt(item.second[2]);
944+
auto trMc2 = McParts.iteratorAt(item.second[3]);
945945

946-
auto mcCandID1 = mcCandidates.iteratorAt(item.second[2]);
947-
auto mcCandID2 = mcCandidates.iteratorAt(item.second[5]);
946+
// check that the method used here gets the the MC particles
947+
// as the one used by Nazar
948+
auto nzTrMc1 = McParts.iteratorAt(tr1.udMcParticleId());
949+
auto nzTrMc2 = McParts.iteratorAt(tr2.udMcParticleId());
948950

949-
if (mcCandID1 != mcCandID2) {
950-
// LOGF(info, "mc tracks belong to different collisions");
951-
}
951+
if (nzTrMc1 != trMc1)
952+
LOGF(debug, "diff wrt Nazar!");
953+
if (nzTrMc2 != trMc2)
954+
LOGF(debug, "diff wrt Nazar!");
952955

953-
// auto mcTr1 = McParts.iteratorAt(tr1.udMcParticleId());
954-
// auto mcTr2 = McParts.iteratorAt(tr2.udMcParticleId());
955956
processMcRecoCand(cand, tr1, trMc1, tr2, trMc2);
956957
}
957958
}
958-
PROCESS_SWITCH(fwdMuonsUPC, processMcReco, "", false);
959+
PROCESS_SWITCH(FwdMuonsUPC, processMcReco, "", false);
959960
};
960961

961962
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
962963
{
963964
return WorkflowSpec{
964-
adaptAnalysisTask<fwdMuonsUPC>(cfgc),
965+
adaptAnalysisTask<FwdMuonsUPC>(cfgc),
965966
};
966967
}

0 commit comments

Comments
 (0)