/[PAMELA software]/PamCut/PamCutBase/PamCutBase.cpp
ViewVC logotype

Annotation of /PamCut/PamCutBase/PamCutBase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri May 29 10:10:28 2009 UTC (15 years, 6 months ago) by pam-fi
Branch: MAIN
Changes since 1.1: +10 -11 lines
Previous commit was outdated; fixed.

1 pam-fi 1.1 /*
2     * PamCutBase.cpp
3     *
4     * Created on: 12-feb-2009
5     * Author: Nicola Mori
6     */
7    
8     /*! @file PamCutBase.cpp Implementation for classes defined in PamCut.h */
9    
10     #include "PamCutBase.h"
11    
12     /* ************** *
13     * PAMCUT
14     * ************** */
15     int PamCut::ApplyCut(PamLevel2 *event) {
16    
17     _nEv++;
18     int result = Check(event);
19     if (result == CUTOK) {
20     _nGood++;
21     OnGood(event);
22     }
23     else {
24     OnBad(event, result);
25     }
26     return result;
27    
28     }
29    
30     void PamCut::Process(PamLevel2 *events, ULong_t firstEvent, ULong_t lastEvent) {
31    
32     // Check the range of events to analyze
33     if (firstEvent > lastEvent) {
34     return;
35     }
36     if (firstEvent < 0 || lastEvent > events->GetEntries() - 1) {
37     return;
38     }
39    
40     // Prepare the counters for the new analysis
41     Setup(events);
42    
43     // Apply the cuts
44     for (ULong_t iev = firstEvent; iev < lastEvent + 1; iev++) {
45     events->GetEntry(iev);
46     ApplyCut(events);
47     }
48    
49     // Closes the analysis
50     Finalize();
51    
52     }
53 pam-fi 1.2 void PamCut::Setup(PamLevel2 *events) {
54 pam-fi 1.1 _nEv = _nGood = 0;
55     }
56    
57     const char* PamCut::GetName() const {
58     return _cutName;
59     }
60    
61     void PamCut::SetName(const char *newName) {
62     _cutName = newName;
63     }
64    
65 pam-fi 1.2 PamCut& PamCut::operator=(const PamCut &rightValue) {
66     _cutName = rightValue._cutName;
67     return *this;
68     }
69 pam-fi 1.1
70     /* ************************ *
71     * PAMCUTCOLLECTION
72     * ************************ */
73    
74     void PamCutCollection::AddCut(PamCut &cut) {
75     _cuts.push_back(&cut);
76     }
77    
78     int PamCutCollection::Check(PamLevel2 *event) {
79    
80     // Apply the cuts
81     if (_cuts.size() == 0) {
82     return CUTOK;
83     }
84    
85     for (unsigned int icut = 0; icut < _cuts.size(); icut++) {
86     if (_cuts[icut]->Check(event) != CUTOK) {
87     return icut;
88     }
89     }
90    
91     return CUTOK;
92     }
93    
94     int PamCutCollection::ApplyCut(PamLevel2 *event) {
95    
96     _nEv++;
97     // Apply the cuts
98     if (_cuts.size() == 0) {
99     _nGood++;
100     OnGood(event);
101     return CUTOK;
102     }
103    
104     for (unsigned int icut = 0; icut < _cuts.size(); icut++) {
105     if (_cuts[icut]->ApplyCut(event) != CUTOK) {
106     OnBad(event, icut);
107     return icut;
108     }
109     }
110    
111     _nGood++;
112     OnGood(event);
113     return CUTOK;
114     }
115    
116     PamCut *PamCutCollection::GetCut(unsigned int iCut) {
117     if (_cuts.size() == 0)
118     return NULL;
119     if (iCut < 0 || iCut > _cuts.size() - 1)
120     return NULL;
121     else
122     return _cuts[iCut];
123     }
124    
125     unsigned int PamCutCollection::GetSize() {
126     return (unsigned int) _cuts.size();
127    
128     }
129    
130     PamCutCollection& PamCutCollection::operator=(const PamCutCollection &rightValue) {
131    
132     PamCut::operator=(rightValue);
133     _cuts = rightValue._cuts;
134     return *this;
135     }
136    
137 pam-fi 1.2 void PamCutCollection::Setup(PamLevel2 *events) {
138 pam-fi 1.1
139     PamCut::Setup(events);
140    
141 pam-fi 1.2 for (unsigned int i = 0; i < GetSize(); i++) {
142 pam-fi 1.1 _cuts[i]->Setup(events);
143     }
144     }
145    
146 pam-fi 1.2 void PamCutCollection::Finalize() {
147 pam-fi 1.1
148 pam-fi 1.2 // PamCut::Finalize() is currently void, but in future it could contain something, so it's good to place a call here.
149 pam-fi 1.1 PamCut::Finalize();
150    
151 pam-fi 1.2 for (unsigned int i = 0; i < GetSize(); i++) {
152 pam-fi 1.1 _cuts[i]->Finalize();
153     }
154     }

  ViewVC Help
Powered by ViewVC 1.1.23