49 |
return CUTOK; |
return CUTOK; |
50 |
} |
} |
51 |
|
|
52 |
unsigned int bunchEnd = -1; |
unsigned int firstFailed = _cuts.size(); |
|
unsigned int nActions = 0; |
|
|
unsigned int firstActionOfBunch = -1; |
|
|
if (_actions.size() > 0) { |
|
|
// Set the bunch end to the position of the first action |
|
|
bunchEnd = _actionsPositions[0]; |
|
|
// Set the position of the first action at the end of the bunch |
|
|
firstActionOfBunch = 0; |
|
|
// Set the number of actions at the end of this bunch of cuts |
|
|
nActions = 1; |
|
|
while (_actionsPositions[nActions] == bunchEnd) |
|
|
nActions++; |
|
|
} |
|
|
|
|
53 |
for (unsigned int icut = 0; icut < _cuts.size(); icut++) { |
for (unsigned int icut = 0; icut < _cuts.size(); icut++) { |
54 |
if (_cuts[icut]->ApplyCut(event) != CUTOK) { |
if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
55 |
// Check if there are actions at the end of the current bunch |
firstFailed = icut; |
56 |
// (last bunch may have no actions at its end) |
break; |
|
if (bunchEnd >= icut) { |
|
|
for (unsigned int i = 0; i < nActions; i++) { |
|
|
_actions[firstActionOfBunch + i]->OnBad(event, icut); |
|
|
} |
|
|
} |
|
|
OnBad(event, icut); |
|
|
return icut; |
|
57 |
} |
} |
58 |
else if (bunchEnd == icut) { |
} |
59 |
// We are at the end of the bunch of cuts, so let's execute the actions |
|
60 |
for (unsigned int i = 0; i < nActions; i++) { |
//Do actions |
61 |
_actions[firstActionOfBunch + i]->OnGood(event); |
if (_actions.size() > 0) { |
62 |
} |
unsigned int lastPosition = _cuts.size(); |
63 |
if (firstActionOfBunch + nActions < _actions.size()) { |
for (unsigned int i = 0; i < _actions.size(); i++) { |
64 |
// Current bunch is done, but actions are not finished yet. Set up the next bunch. |
if (_actionsPositions[i] < firstFailed) |
65 |
// Set the end of the new bunch and the number of actions at this end |
_actions[i]->OnGood(event); |
66 |
firstActionOfBunch += nActions; |
else { // A cut has failed |
67 |
bunchEnd = _actionsPositions[firstActionOfBunch]; |
if (lastPosition == _cuts.size()) // Record the position of the end of the bunch |
68 |
nActions = 1; |
lastPosition = _actionsPositions[i]; |
69 |
while (_actionsPositions[firstActionOfBunch + nActions] == bunchEnd) |
if (_actionsPositions[i] > lastPosition) // Don't do actions at the end of successive bunches |
70 |
nActions++; |
break; |
71 |
|
_actions[i]->OnBad(event, firstFailed); |
72 |
} |
} |
73 |
} |
} |
74 |
} |
} |
75 |
|
|
76 |
_nGood++; |
if (firstFailed == _cuts.size()) { |
77 |
OnGood(event); |
_nGood++; |
78 |
return CUTOK; |
OnGood(event); |
79 |
|
return CUTOK; |
80 |
|
} |
81 |
|
else { |
82 |
|
OnBad(event, firstFailed); |
83 |
|
return firstFailed; |
84 |
|
} |
85 |
} |
} |