9 |
|
|
10 |
#include "SmartCollection.h" |
#include "SmartCollection.h" |
11 |
|
|
12 |
SmartCollection::~SmartCollection(){ |
SmartCollection::~SmartCollection() { |
13 |
if (_owns){ |
if (_owns) { |
14 |
for (unsigned int i = 0; i < _actions.size(); i++) |
for (unsigned int i = 0; i < _actions.size(); i++) |
15 |
if (_actions[i] != NULL){ |
if (_actions[i] != NULL) { |
16 |
delete _actions[i]; |
delete _actions[i]; |
17 |
_actions[i] = NULL; |
_actions[i] = NULL; |
18 |
} |
} |
19 |
} |
} |
20 |
} |
} |
21 |
|
|
22 |
void SmartCollection::AddAction(CollectionAction *action) { |
void SmartCollection::AddAction(CollectionAction *action) { |
85 |
} |
} |
86 |
|
|
87 |
unsigned int firstFailed = _cuts.size(); |
unsigned int firstFailed = _cuts.size(); |
88 |
|
unsigned int iAction = iBeforeCuts; |
89 |
for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) { |
for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) { |
90 |
if (_cuts[iCut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
if (_cuts[iCut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
91 |
firstFailed = iCut; |
firstFailed = iCut; |
92 |
|
// Apply the bad actions at the end of the bunch |
93 |
|
if (iAction < _actions.size()) { |
94 |
|
unsigned int lastPosition = _actionsPositions[iAction]; |
95 |
|
for (; iAction < _actions.size(); iAction++) { |
96 |
|
if (_actionsPositions[iAction] > (int) lastPosition) // Don't do actions at the end of successive bunches |
97 |
|
break; |
98 |
|
_actions[iAction]->OnBad(event, (int) firstFailed); |
99 |
|
|
100 |
|
} |
101 |
|
} |
102 |
break; |
break; |
103 |
} |
} |
104 |
} |
else if (iAction < _actions.size()) { |
105 |
|
// Do the good actions if we are at the end of the bunch |
106 |
//Do actions |
while (_actionsPositions[iAction] == (int) iCut) { |
107 |
if (_actions.size() > 0) { |
_actions[iAction]->OnGood(event); |
108 |
unsigned int lastPosition = _cuts.size(); |
iAction++; |
109 |
for (unsigned int i = iBeforeCuts; i < _actions.size(); i++) { |
if (iAction == _actions.size()) |
|
if (_actionsPositions[i] < (int) firstFailed) |
|
|
_actions[i]->OnGood(event); |
|
|
else { // A cut has failed |
|
|
if (lastPosition == _cuts.size()) // Record the position of the end of the bunch |
|
|
lastPosition = _actionsPositions[i]; |
|
|
if (_actionsPositions[i] > (int) lastPosition) // Don't do actions at the end of successive bunches |
|
110 |
break; |
break; |
|
_actions[i]->OnBad(event, (int) firstFailed); |
|
111 |
} |
} |
112 |
} |
} |
113 |
} |
} |