1 |
/* |
2 |
* SmartBlindCollection.cpp |
3 |
* |
4 |
* Created on: 16-mag-2009 |
5 |
* Author: Nicola Mori |
6 |
*/ |
7 |
|
8 |
/*! @file SmartCollection.cpp The SmartBlindCollection class implementation file */ |
9 |
|
10 |
#include "SmartBlindCollection.h" |
11 |
|
12 |
int SmartBlindCollection::ApplyCut(PamLevel2 *event) { |
13 |
|
14 |
_nEv++; |
15 |
if (_cuts.size() == 0) { |
16 |
_nGood++; |
17 |
OnGood(event); |
18 |
return CUTOK; |
19 |
} |
20 |
|
21 |
unsigned int firstFailed = _cuts.size(); |
22 |
for (unsigned int icut = 0; icut < _cuts.size(); icut++) { |
23 |
if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
24 |
firstFailed = icut; |
25 |
} |
26 |
} |
27 |
|
28 |
//Do actions |
29 |
if (_actions.size() > 0) { |
30 |
for (unsigned int i = 0; i < _actions.size(); i++) { |
31 |
if (_actionsPositions[i] < firstFailed) |
32 |
_actions[i]->OnGood(event); |
33 |
else |
34 |
_actions[i]->OnBad(event, firstFailed); |
35 |
} |
36 |
} |
37 |
|
38 |
if (firstFailed == _cuts.size()) { |
39 |
_nGood++; |
40 |
OnGood(event); |
41 |
return CUTOK; |
42 |
} |
43 |
else { |
44 |
OnBad(event, firstFailed); |
45 |
return firstFailed; |
46 |
} |
47 |
|
48 |
} |