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

Annotation of /PamCut/Collections/MaskedCollection/MaskedCollection.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Mon Sep 5 12:58:34 2011 UTC (13 years, 3 months ago) by pam-fi
Branch: MAIN
CVS Tags: V9, HEAD
Added to repository.

1 pam-fi 1.1 /*
2     * MaskedCollection.cpp
3     *
4     * Created on: 19-apr-2011
5     * Author: Nicola Mori
6     */
7    
8     /*! @file MaskedCollection.cpp The MaskedCollection class implementation file */
9    
10     #include "MaskedCollection.h"
11    
12     void MaskedCollection::AddCut(PamCut *cut) {
13     VerboseCollection::AddCut(cut);
14     _mask.push_back(false);
15     }
16    
17     void MaskedCollection::AddInverseCut(PamCut *cut) {
18     VerboseCollection::AddCut(cut);
19     _mask.push_back(true);
20     }
21    
22     // This is basically SmartCollection::ApplyCut with added mask support
23     int MaskedCollection::ApplyCut(PamLevel2 *event) {
24    
25     _nEv++;
26    
27     // Execute the actions placed before the cuts
28     unsigned int iBeforeCuts = 0;
29     //cout << GetName() << endl;
30     if (_actions.size() > 0) {
31     while (_actionsPositions[iBeforeCuts] == -1) {
32     _actions[iBeforeCuts]->OnGood(event);
33     iBeforeCuts++;
34     if (iBeforeCuts == _actions.size())
35     break;
36     }
37     }
38    
39     // Apply the cuts
40     if (_cuts.size() == 0) {
41     _nGood++;
42     OnGood(event);
43     return CUTOK;
44     }
45    
46     unsigned int firstFailed = _cuts.size();
47     unsigned int iAction = iBeforeCuts;
48     bool cutResult;
49     for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) {
50     cutResult = (_cuts[iCut]->ApplyCut(event) == CUTOK);
51     if (_mask[iCut])
52     cutResult = !cutResult;
53     if (!cutResult && firstFailed == _cuts.size()) {
54     firstFailed = iCut;
55     // Apply the bad actions at the end of the bunch
56     if (iAction < _actions.size()) {
57     unsigned int lastPosition = _actionsPositions[iAction];
58     for (; iAction < _actions.size(); iAction++) {
59     if (_actionsPositions[iAction] > (int) lastPosition) // Don't do actions at the end of successive bunches
60     break;
61     _actions[iAction]->OnBad(event, (int) firstFailed);
62    
63     }
64     }
65     break;
66     }
67     else if (iAction < _actions.size()) {
68     // Do the good actions if we are at the end of the bunch
69     while (_actionsPositions[iAction] == (int) iCut) {
70     _actions[iAction]->OnGood(event);
71     iAction++;
72     if (iAction == _actions.size())
73     break;
74     }
75     }
76     }
77    
78     if (firstFailed == _cuts.size()) {
79     _nGood++;
80     OnGood(event);
81     return CUTOK;
82     }
83     else {
84     OnBad(event, firstFailed);
85     return firstFailed;
86     }
87     }

  ViewVC Help
Powered by ViewVC 1.1.23