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

Annotation of /PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri Jun 5 13:14:34 2009 UTC (15 years, 6 months ago) by pam-fi
Branch: MAIN
Changes since 1.1: +54 -36 lines
Changes to the handling of actions.

1 pam-fi 1.1 /*
2     * SmartBlindCollection.cpp
3     *
4     * Created on: 16-mag-2009
5     * Author: Nicola Mori
6     */
7    
8 pam-fi 1.2 /*! @file SmartCollection.cpp The SmartBlindCollection class implementation file */
9 pam-fi 1.1
10     #include "SmartBlindCollection.h"
11    
12 pam-fi 1.2 int SmartBlindCollection::ApplyCut(PamLevel2 *event) {
13 pam-fi 1.1
14 pam-fi 1.2 _nEv++;
15     if (_cuts.size() == 0) {
16     _nGood++;
17     OnGood(event);
18     return CUTOK;
19     }
20 pam-fi 1.1
21 pam-fi 1.2 unsigned int bunchEnd = -1;
22     unsigned int nActions = 0;
23     unsigned int firstActionOfBunch = -1;
24     if (_actions.size() > 0) {
25     // Set the bunch end to the position of the first action
26     bunchEnd = _actionsPositions[0];
27     // Set the position of the first action at the end of the bunch
28     firstActionOfBunch = 0;
29     // Set the number of actions at the end of this bunch of cuts
30     nActions = 1;
31     while (_actionsPositions[nActions] == bunchEnd)
32     nActions++;
33     }
34 pam-fi 1.1
35 pam-fi 1.2 int firstFailed = CUTOK;
36     for (unsigned int icut = 0; icut < _cuts.size(); icut++) {
37     if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == CUTOK) {
38     firstFailed = icut;
39     }
40     if (bunchEnd == icut) {
41     if (firstFailed == CUTOK) {
42     for (unsigned int i = 0; i < nActions; i++) {
43     _actions[firstActionOfBunch + i]->OnGood(event);
44     }
45     }
46     else {
47     for (unsigned int i = 0; i < nActions; i++) {
48     _actions[firstActionOfBunch + i]->OnBad(event, icut);
49     }
50     }
51    
52     if (firstActionOfBunch + nActions < _actions.size()) {
53     // Current bunch is done, but actions are not finished yet. Set up the next bunch.
54     // Set the end of the new bunch and the number of actions at this end
55     firstActionOfBunch += nActions;
56     bunchEnd = _actionsPositions[firstActionOfBunch];
57     nActions = 1;
58     while (_actionsPositions[firstActionOfBunch + nActions] == bunchEnd)
59     nActions++;
60     }
61     }
62 pam-fi 1.1 }
63    
64 pam-fi 1.2 if (firstFailed == CUTOK) {
65     _nGood++;
66     OnGood(event);
67 pam-fi 1.1 }
68 pam-fi 1.2 else {
69     OnBad(event, firstFailed);
70 pam-fi 1.1 }
71 pam-fi 1.2 return firstFailed;
72 pam-fi 1.1
73     }

  ViewVC Help
Powered by ViewVC 1.1.23