Skip to content

Commit 16f84fe

Browse files
authored
PWG-UD: UDTurials03[a,b] and UDTutorials04 (#3722)
* veto only on forward tracks with good timeing * add function to detect rho-> mu mu Mc events * protect cases with missing associations * improve processing of Mc truth * minor updates * replace UDTutorials03 with UDTutorials03a and UDTutorials03b * clang-format * clang-format * remove unused variable * clang-format
1 parent 8bc1c8e commit 16f84fe

File tree

9 files changed

+1695
-122
lines changed

9 files changed

+1695
-122
lines changed

PWGUD/Core/DGSelector.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class DGSelector
5454
// forward tracks
5555
LOGF(debug, "FwdTracks %i", fwdtracks.size());
5656
if (!diffCuts.withFwdTracks()) {
57-
// only consider tracks with MID (good timing)
5857
for (auto& fwdtrack : fwdtracks) {
5958
LOGF(info, " %i / %f / %f / %f / %f", fwdtrack.trackType(), fwdtrack.eta(), fwdtrack.pt(), fwdtrack.p(), fwdtrack.trackTimeRes());
59+
// only consider tracks with MID (good timing)
6060
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) {
6161
return 2;
6262
}
@@ -158,12 +158,14 @@ class DGSelector
158158
}
159159

160160
// no activity in muon arm
161-
LOGF(debug, "FwdTracks %i", fwdtracks.size());
162-
for (auto& fwdtrack : fwdtracks) {
163-
LOGF(debug, " %i / %f / %f / %f", fwdtrack.trackType(), fwdtrack.eta(), fwdtrack.pt(), fwdtrack.p());
164-
}
165-
if (fwdtracks.size() > 0) {
166-
return 2;
161+
if (!diffCuts.withFwdTracks()) {
162+
for (auto& fwdtrack : fwdtracks) {
163+
LOGF(info, " %i / %f / %f / %f / %f", fwdtrack.trackType(), fwdtrack.eta(), fwdtrack.pt(), fwdtrack.p(), fwdtrack.trackTimeRes());
164+
// only consider tracks with MID (good timing)
165+
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) {
166+
return 2;
167+
}
168+
}
167169
}
168170

169171
// number of tracks

PWGUD/Core/UDHelpers.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,25 @@ bool isPythiaCDE(T MCparts)
596596
return false;
597597
}
598598

599+
// -----------------------------------------------------------------------------
600+
// In rho -> mu+ + mu- events generated with STARlight the stack starts with
601+
// 443013, 13, -13 or 443013, -13, 13
602+
template <typename T>
603+
bool isSTARLightRhomumu(T MCparts)
604+
{
605+
if (MCparts.size() < 3) {
606+
return false;
607+
} else {
608+
if (MCparts.iteratorAt(0).pdgCode() != 443013)
609+
return false;
610+
if (abs(MCparts.iteratorAt(1).pdgCode()) != 13)
611+
return false;
612+
if (MCparts.iteratorAt(2).pdgCode() != -MCparts.iteratorAt(1).pdgCode())
613+
return false;
614+
}
615+
return true;
616+
}
617+
599618
// -----------------------------------------------------------------------------
600619
// In pp events produced with GRANIITTI the stack starts with
601620
// 22212/22212/99/22212/2212/99/90
@@ -630,6 +649,30 @@ bool isGraniittiCDE(T MCparts)
630649
return true;
631650
}
632651

652+
// -----------------------------------------------------------------------------
653+
// function to select MC events of interest
654+
template <typename T>
655+
int isOfInterest(T MCparts)
656+
{
657+
658+
// PYTHIA CDE
659+
if (isPythiaCDE(MCparts)) {
660+
return 1;
661+
}
662+
663+
// GRANIITTI CDE
664+
if (isGraniittiCDE(MCparts)) {
665+
return 2;
666+
}
667+
668+
// STARLIGHT rho -> mu+ + mu-
669+
if (isSTARLightRhomumu(MCparts)) {
670+
return 3;
671+
}
672+
673+
return 0;
674+
}
675+
633676
// -----------------------------------------------------------------------------
634677
// Invariant mass of GRANIITTI generated event
635678
template <typename T>

PWGUD/TableProducer/DGBCCandProducer.cxx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ struct tracksWGTInBCs {
6262
void processBarrel(BCs const& bcs, CCs const& collisions, TCs const& tracks, ATs const& ambTracks)
6363
{
6464
// run number
65+
if (bcs.size() <= 0) {
66+
return;
67+
}
6568
int rnum = bcs.iteratorAt(0).runNumber();
6669

6770
// container to sort tracks with good timing according to their matching/closest BC
@@ -73,7 +76,7 @@ struct tracksWGTInBCs {
7376
for (auto const& track : tracks) {
7477
registry.get<TH1>(HIST("barrel/Tracks"))->Fill(0., 1.);
7578

76-
// is this track aPV track?
79+
// is this track a PV track?
7780
if (track.isPVContributor()) {
7881
registry.get<TH1>(HIST("barrel/Tracks"))->Fill(1., 1.);
7982
}
@@ -96,17 +99,23 @@ struct tracksWGTInBCs {
9699

97100
// compute the BC closest in time
98101
auto firstCompatibleBC = ambTracksSlice.begin().bc().begin().globalBC();
99-
LOGF(debug, "Track time %f", track.trackTime());
102+
LOGF(debug, "First compatible BC %d Track time %f", firstCompatibleBC, track.trackTime());
100103
closestBC = (uint64_t)(firstCompatibleBC +
101104
(track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS));
102105
} else {
103106
// this track is not ambiguous, has hence a unique association to a collision/BC
107+
if (!track.has_collision()) {
108+
continue;
109+
}
104110
auto collision = track.collision_as<CCs>();
111+
if (!collision.has_foundBC()) {
112+
continue;
113+
}
105114
closestBC = collision.foundBC_as<BCs>().globalBC();
106115
}
107116

108117
// update tracksInBCList
109-
LOGF(debug, "Closest BC %d", closestBC);
118+
LOGF(debug, "Updating tracksInBCList with %d", closestBC);
110119
tracksInBCList[closestBC].emplace_back((int32_t)track.globalIndex());
111120
}
112121
}
@@ -129,8 +138,8 @@ struct tracksWGTInBCs {
129138
break;
130139
}
131140
}
132-
tracksWGTInBCs(indBCToSave, rnum, tracksInBC.first, tracksInBC.second);
133141
LOGF(debug, " BC %i/%u with %i tracks with good timing", indBCToSave, tracksInBC.first, tracksInBC.second.size());
142+
tracksWGTInBCs(indBCToSave, rnum, tracksInBC.first, tracksInBC.second);
134143
}
135144
LOGF(debug, "barrel done");
136145
}
@@ -142,6 +151,9 @@ struct tracksWGTInBCs {
142151
void processForward(BCs& bcs, CCs& collisions, aod::FwdTracks& fwdTracks, aod::AmbiguousFwdTracks& ambFwdTracks)
143152
{
144153
// run number
154+
if (bcs.size() <= 0) {
155+
return;
156+
}
145157
int rnum = bcs.iteratorAt(0).runNumber();
146158

147159
// container to sort forward tracks according to their matching/closest BC
@@ -176,11 +188,18 @@ struct tracksWGTInBCs {
176188
(fwdTrack.trackTime() / o2::constants::lhc::LHCBunchSpacingNS));
177189
} else {
178190
// this track is not ambiguous, has hence a unique association to a collision/BC
191+
if (!fwdTrack.has_collision()) {
192+
continue;
193+
}
179194
auto collision = fwdTrack.collision_as<CCs>();
180-
closestBC = collision.bc_as<BCs>().globalBC();
195+
if (!collision.has_foundBC()) {
196+
continue;
197+
}
198+
closestBC = collision.foundBC_as<BCs>().globalBC();
181199
}
182200

183201
// update tracksInBCList
202+
LOGF(debug, "Updating fwdTracksInBCList with %d", closestBC);
184203
fwdTracksInBCList[closestBC].emplace_back((int32_t)fwdTrack.globalIndex());
185204
}
186205
}
@@ -205,7 +224,7 @@ struct tracksWGTInBCs {
205224
fwdTracksWGTInBCs(indBCToSave, rnum, fwdTracksInBC.first, fwdTracksInBC.second);
206225
LOGF(debug, " BC %i/%u with %i forward tracks with good timing", indBCToSave, fwdTracksInBC.first, fwdTracksInBC.second.size());
207226
}
208-
LOGF(debug, "fwd done");
227+
LOGF(debug, "forward done");
209228
}
210229
PROCESS_SWITCH(tracksWGTInBCs, processForward, "Process forward tracks", false);
211230

@@ -539,6 +558,7 @@ struct DGBCCandProducer {
539558
bcnum = tibc.bcnum();
540559
}
541560
}
561+
542562
bool withCollision = false;
543563
while (bc2go || tibc2go) {
544564
LOGF(debug, "Testing bc %d/%d/%d", bcnum, bc.globalBC(), tibc.bcnum());

0 commit comments

Comments
 (0)