Skip to content

Commit 6c8481d

Browse files
committed
adding or condition possibility for JE event selection
1 parent 9840db8 commit 6c8481d

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

PWGJE/Core/JetDerivedDataUtilities.h

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,31 @@ bool selectCollision(T const& collision, const std::vector<int>& eventSelectionM
9191
if (eventSelectionMaskBits.size() == 0) {
9292
return true;
9393
}
94+
bool isOrCondition = false;
9495
for (auto eventSelectionMaskBit : eventSelectionMaskBits) {
95-
if (!(collision.eventSel() & (1 << eventSelectionMaskBit))) {
96-
return false;
96+
if (eventSelectionMaskBit == -1) {
97+
isOrCondition = true;
98+
continue;
99+
}
100+
if (!isOrCondition) {
101+
if (!(collision.eventSel() & (1ULL << eventSelectionMaskBit))) {
102+
return false;
103+
}
104+
} else {
105+
if (collision.eventSel() & (1ULL << eventSelectionMaskBit)) {
106+
return true;
107+
}
97108
}
98109
}
99-
return true;
110+
return !isOrCondition;
100111
}
101112

102113
bool eventSelectionMasksContainSelection(const std::string& eventSelectionMasks, std::string selection)
103114
{
104115
size_t position = 0;
105116
while ((position = eventSelectionMasks.find(selection, position)) != std::string::npos) {
106-
bool validStart = (position == 0 || eventSelectionMasks[position - 1] == '+');
107-
bool validEnd = (position + selection.length() == eventSelectionMasks.length() || eventSelectionMasks[position + selection.length()] == '+');
117+
bool validStart = (position == 0 || eventSelectionMasks[position - 1] == '+' || eventSelectionMasks[position - 1] == '|');
118+
bool validEnd = (position + selection.length() == eventSelectionMasks.length() || eventSelectionMasks[position + selection.length()] == '+' || eventSelectionMasks[position + selection.length()] == '|');
108119
if (validStart && validEnd) {
109120
return true;
110121
}
@@ -116,6 +127,9 @@ bool eventSelectionMasksContainSelection(const std::string& eventSelectionMasks,
116127
std::vector<int> initialiseEventSelectionBits(const std::string& eventSelectionMasks)
117128
{
118129
std::vector<int> eventSelectionMaskBits;
130+
if (eventSelectionMasks.find('|') != std::string::npos) { // needs to be first if statement evaluated
131+
eventSelectionMaskBits.push_back(-1);
132+
}
119133
if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel8")) {
120134
eventSelectionMaskBits.push_back(JCollisionSel::sel8);
121135
}
@@ -286,7 +300,7 @@ bool selectTrigger(T const& collision, const std::vector<int>& triggerMaskBits)
286300
return true;
287301
}
288302
for (auto triggerMaskBit : triggerMaskBits) {
289-
if (collision.triggerSel() & (1 << triggerMaskBit)) {
303+
if (collision.triggerSel() & (1ULL << triggerMaskBit)) {
290304
return true;
291305
}
292306
}
@@ -299,7 +313,7 @@ bool selectTrigger(T const& collision, int triggerMaskBit)
299313
if (triggerMaskBit == -1) {
300314
return true;
301315
}
302-
return collision.triggerSel() & (1 << triggerMaskBit);
316+
return collision.triggerSel() & (1ULL << triggerMaskBit);
303317
}
304318

305319
bool triggerMasksContainTrigger(const std::string& triggerMasks, std::string trigger)
@@ -410,7 +424,7 @@ bool selectChargedTrigger(T const& collision, int triggerSelection)
410424
if (triggerSelection == -1) {
411425
return true;
412426
}
413-
return (collision.chargedTriggerSel() & (1 << triggerSelection));
427+
return (collision.chargedTriggerSel() & (1ULL << triggerSelection));
414428
}
415429

416430
int initialiseChargedTriggerSelection(const std::string& triggerSelection)
@@ -475,7 +489,7 @@ bool selectFullTrigger(T const& collision, int triggerSelection)
475489
if (triggerSelection == -1) {
476490
return true;
477491
}
478-
return (collision.fullTriggerSel() & (1 << triggerSelection));
492+
return (collision.fullTriggerSel() & (1ULL << triggerSelection));
479493
}
480494

481495
int initialiseFullTriggerSelection(const std::string& triggerSelection)
@@ -570,7 +584,7 @@ bool selectChargedHFTrigger(T const& collision, int triggerSelection)
570584
if (triggerSelection == -1) {
571585
return true;
572586
}
573-
return (collision.chargedHFTriggerSel() & (1 << triggerSelection));
587+
return (collision.chargedHFTriggerSel() & (1ULL << triggerSelection));
574588
}
575589

576590
int initialiseChargedHFTriggerSelection(const std::string& triggerSelection)
@@ -632,16 +646,16 @@ bool applyTrackKinematics(T const& track, float pTMin = 0.15, float pTMax = 100.
632646
template <typename T>
633647
bool selectTrack(T const& track, int trackSelection, bool isEmbedded = false)
634648
{
635-
if (!(track.trackSel() & (1 << JTrackSel::notBadMcTrack))) {
649+
if (!(track.trackSel() & (1ULL << JTrackSel::notBadMcTrack))) {
636650
return false;
637651
}
638-
if (isEmbedded && !(track.trackSel() & (1 << JTrackSel::embeddedTrack))) { // will get rid of non embedded tracks
652+
if (isEmbedded && !(track.trackSel() & (1ULL << JTrackSel::embeddedTrack))) { // will get rid of non embedded tracks
639653
return false;
640654
}
641655
if (trackSelection == -1) {
642656
return true;
643657
}
644-
return (track.trackSel() & (1 << trackSelection));
658+
return (track.trackSel() & (1ULL << trackSelection));
645659
}
646660

647661
int initialiseTrackSelection(const std::string& trackSelection)

0 commit comments

Comments
 (0)