/[PAMELA software]/PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp
ViewVC logotype

Contents of /PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Thu Jul 8 14:00:30 2010 UTC (14 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: MergedFromV8_1, V9, HEAD
Changes since 1.4: +36 -11 lines
Merged from branch V8 (tag MergedToHEAD_1). Tag before the merge: BeforeMergingFromV8_1.

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
16 // Execute the actions placed before the cuts
17 unsigned int iBeforeCuts = 0;
18 //cout << GetName() << endl;
19 if (_actions.size() > 0) {
20 while (_actionsPositions[iBeforeCuts] == -1) {
21 _actions[iBeforeCuts]->OnGood(event);
22 iBeforeCuts++;
23 if (iBeforeCuts == _actions.size())
24 break;
25 }
26 }
27
28 // Apply the cuts
29 if (_cuts.size() == 0) {
30 _nGood++;
31 OnGood(event);
32 return CUTOK;
33 }
34
35 unsigned int firstFailed = _cuts.size();
36 unsigned int iAction = iBeforeCuts;
37 for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) {
38 if (_cuts[iCut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) {
39 firstFailed = iCut;
40 }
41
42 if (iAction < _actions.size()) {
43 if (firstFailed == _cuts.size()) { // No cut has failed yet
44 while (_actionsPositions[iAction] == (int) iCut) {
45 _actions[iAction]->OnGood(event);
46 iAction++;
47 if (iAction == _actions.size())
48 break;
49 }
50 }
51 else {
52 while (_actionsPositions[iAction] == (int) iCut) {
53 _actions[iAction]->OnBad(event, (int) firstFailed);
54 iAction++;
55 if (iAction == _actions.size())
56 break;
57 }
58 }
59
60 }
61 }
62
63 if (firstFailed == _cuts.size()) {
64 _nGood++;
65 OnGood(event);
66 return CUTOK;
67 }
68 else {
69 OnBad(event, firstFailed);
70 return firstFailed;
71 }
72
73 }

  ViewVC Help
Powered by ViewVC 1.1.23