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

Diff of /PamCut/PamCutBase/PamCutBase.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by pam-fi, Wed May 27 13:30:09 2009 UTC revision 1.7 by pam-fi, Thu Mar 18 14:41:13 2010 UTC
# Line 29  int PamCut::ApplyCut(PamLevel2 *event) { Line 29  int PamCut::ApplyCut(PamLevel2 *event) {
29    
30  void PamCut::Process(PamLevel2 *events, ULong_t firstEvent, ULong_t lastEvent) {  void PamCut::Process(PamLevel2 *events, ULong_t firstEvent, ULong_t lastEvent) {
31    
32      // Prepare the collection for the new analysis
33      Setup(events);
34    
35    // Check the range of events to analyze    // Check the range of events to analyze
36    if (firstEvent > lastEvent) {    if (firstEvent > lastEvent) {
37        Finalize();
38      return;      return;
39    }    }
40    if (firstEvent < 0 || lastEvent > events->GetEntries() - 1) {    if (firstEvent < 0 || lastEvent > events->GetEntries() - 1) {
41        Finalize();
42      return;      return;
43    }    }
44    
   // Prepare the counters for the new analysis  
   Setup(events);  
   
45    // Apply the cuts    // Apply the cuts
46    for (ULong_t iev = firstEvent; iev < lastEvent + 1; iev++) {    for (_currEv = firstEvent; _currEv < lastEvent + 1; _currEv++) {
47      events->GetEntry(iev);      events->GetEntry(_currEv);
48      ApplyCut(events);      ApplyCut(events);
49    }    }
50    
# Line 50  void PamCut::Process(PamLevel2 *events, Line 52  void PamCut::Process(PamLevel2 *events,
52    Finalize();    Finalize();
53    
54  }  }
55  void PamCut::Setup(PamLevel2 *events){  void PamCut::Setup(PamLevel2 *events) {
56    _nEv = _nGood = 0;    _nEv = _nGood = 0;
57  }  }
58    
# Line 62  void PamCut::SetName(const char *newName Line 64  void PamCut::SetName(const char *newName
64    _cutName = newName;    _cutName = newName;
65  }  }
66    
67  PamCut& PamCut::operator=(const PamCut &rightValue){  PamCut& PamCut::operator=(const PamCut &rightValue) {
68      _cutName = rightValue._cutName;    _cutName = rightValue._cutName;
69      return *this;    return *this;
70    }  }
71    
72  /* ************************ *  /* ************************ *
73   *     PAMCUTCOLLECTION   *     PAMCUTCOLLECTION
74   * ************************ */   * ************************ */
75    PamCutCollection::~PamCutCollection() {
76    
77  void PamCutCollection::AddCut(PamCut &cut) {    if (_owns) {
78    _cuts.push_back(&cut);      for (unsigned int i = 0; i < _cuts.size(); i++)
79          if (_cuts[i] != NULL) {
80            delete _cuts[i];
81            _cuts[i] = NULL;
82          }
83      }
84    }
85    
86    void PamCutCollection::AddCut(PamCut *cut) {
87      _cuts.push_back(cut);
88  }  }
89    
90  int PamCutCollection::Check(PamLevel2 *event) {  int PamCutCollection::Check(PamLevel2 *event) {
# Line 122  PamCut *PamCutCollection::GetCut(unsigne Line 134  PamCut *PamCutCollection::GetCut(unsigne
134      return _cuts[iCut];      return _cuts[iCut];
135  }  }
136    
137    PamCut *PamCutCollection::GetCut(const char *cutName) {
138      if (_cuts.size() == 0)
139        return NULL;
140      for (unsigned int i = 0; i < _cuts.size(); i++) {
141        if (strcmp(_cuts[i]->GetName(), cutName) == 0)
142          return _cuts[i];
143      }
144    
145      return NULL;
146    }
147    
148  unsigned int PamCutCollection::GetSize() {  unsigned int PamCutCollection::GetSize() {
149    return (unsigned int) _cuts.size();    return (unsigned int) _cuts.size();
150    
# Line 134  PamCutCollection& PamCutCollection::oper Line 157  PamCutCollection& PamCutCollection::oper
157    return *this;    return *this;
158  }  }
159    
160    void PamCutCollection::Setup(PamLevel2 *events) {
 void PamCutCollection::Setup(PamLevel2 *events){  
161    
162    PamCut::Setup(events);    PamCut::Setup(events);
163    
164    for (unsigned int i = 0; i < GetSize(); i++){    for (unsigned int i = 0; i < GetSize(); i++) {
165      _cuts[i]->Setup(events);      _cuts[i]->Setup(events);
166    }    }
167  }  }
168    
169  void PamCutCollection::Finalize(){  void PamCutCollection::Finalize() {
170    
171     // PamCut::Finalize() is currently void, but in future it could contain something, so it's good to place a call here.    // PamCut::Finalize() is currently void, but in future it could contain something, so it's good to place a call here.
172    PamCut::Finalize();    PamCut::Finalize();
173    
174    for (unsigned int i = 0; i < GetSize(); i++){    for (unsigned int i = 0; i < GetSize(); i++) {
175      _cuts[i]->Finalize();      _cuts[i]->Finalize();
176    }    }
177  }  }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.23