/[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 by pam-fi, Wed May 27 13:30:09 2009 UTC revision 1.5 by pam-fi, Wed Dec 2 13:28:53 2009 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      return;      return;
# Line 37  void PamCut::Process(PamLevel2 *events, Line 40  void PamCut::Process(PamLevel2 *events,
40      return;      return;
41    }    }
42    
   // Prepare the counters for the new analysis  
   Setup(events);  
   
43    // Apply the cuts    // Apply the cuts
44    for (ULong_t iev = firstEvent; iev < lastEvent + 1; iev++) {    for (ULong_t iev = firstEvent; iev < lastEvent + 1; iev++) {
45      events->GetEntry(iev);      events->GetEntry(iev);
# Line 50  void PamCut::Process(PamLevel2 *events, Line 50  void PamCut::Process(PamLevel2 *events,
50    Finalize();    Finalize();
51    
52  }  }
53  void PamCut::Setup(PamLevel2 *events){  void PamCut::Setup(PamLevel2 *events) {
54    _nEv = _nGood = 0;    _nEv = _nGood = 0;
55  }  }
56    
# Line 62  void PamCut::SetName(const char *newName Line 62  void PamCut::SetName(const char *newName
62    _cutName = newName;    _cutName = newName;
63  }  }
64    
65  PamCut& PamCut::operator=(const PamCut &rightValue){  PamCut& PamCut::operator=(const PamCut &rightValue) {
66      _cutName = rightValue._cutName;    _cutName = rightValue._cutName;
67      return *this;    return *this;
68    }  }
69    
70  /* ************************ *  /* ************************ *
71   *     PAMCUTCOLLECTION   *     PAMCUTCOLLECTION
72   * ************************ */   * ************************ */
73    PamCutCollection::~PamCutCollection() {
74    
75  void PamCutCollection::AddCut(PamCut &cut) {    if (_owns) {
76    _cuts.push_back(&cut);      for (unsigned int i = 0; i < _cuts.size(); i++)
77          if (_cuts[i] != NULL) {
78            delete _cuts[i];
79            _cuts[i] = NULL;
80          }
81      }
82    }
83    
84    void PamCutCollection::AddCut(PamCut *cut) {
85      _cuts.push_back(cut);
86  }  }
87    
88  int PamCutCollection::Check(PamLevel2 *event) {  int PamCutCollection::Check(PamLevel2 *event) {
# Line 122  PamCut *PamCutCollection::GetCut(unsigne Line 132  PamCut *PamCutCollection::GetCut(unsigne
132      return _cuts[iCut];      return _cuts[iCut];
133  }  }
134    
135    PamCut *PamCutCollection::GetCut(const char *cutName) {
136      if (_cuts.size() == 0)
137        return NULL;
138      for (unsigned int i = 0; i < _cuts.size(); i++) {
139        if (strcmp(_cuts[i]->GetName(), cutName) == 0)
140          return _cuts[i];
141      }
142    
143      return NULL;
144    }
145    
146  unsigned int PamCutCollection::GetSize() {  unsigned int PamCutCollection::GetSize() {
147    return (unsigned int) _cuts.size();    return (unsigned int) _cuts.size();
148    
# Line 134  PamCutCollection& PamCutCollection::oper Line 155  PamCutCollection& PamCutCollection::oper
155    return *this;    return *this;
156  }  }
157    
158    void PamCutCollection::Setup(PamLevel2 *events) {
 void PamCutCollection::Setup(PamLevel2 *events){  
159    
160    PamCut::Setup(events);    PamCut::Setup(events);
161    
162    for (unsigned int i = 0; i < GetSize(); i++){    for (unsigned int i = 0; i < GetSize(); i++) {
163      _cuts[i]->Setup(events);      _cuts[i]->Setup(events);
164    }    }
165  }  }
166    
167  void PamCutCollection::Finalize(){  void PamCutCollection::Finalize() {
168    
169     // 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.
170    PamCut::Finalize();    PamCut::Finalize();
171    
172    for (unsigned int i = 0; i < GetSize(); i++){    for (unsigned int i = 0; i < GetSize(); i++) {
173      _cuts[i]->Finalize();      _cuts[i]->Finalize();
174    }    }
175  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23