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

Diff of /PamCut/Collections/EffCollection/EffCollection.cpp

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

revision 1.7 by pam-fi, Thu Oct 1 10:34:34 2009 UTC revision 1.12 by pam-fi, Mon Sep 5 12:59:52 2011 UTC
# Line 11  Line 11 
11  #include "TGraphAsymmErrors.h"  #include "TGraphAsymmErrors.h"
12    
13  extern "C" {  extern "C" {
14  bool efficiency_(Int_t*, Int_t*, Double_t*, Double_t*, Double_t*);  /*! @brief Fortran routine by Sergio Ricciarini which computes errors on the efficiency.
15  }   *
16     * This routine has been developed to carefully evaluate the error bars on the efficiency,
17  EffCollection::EffCollection(const char *collectionName, TString outFileBase, int errMethod) :   * which must have a value between 0 and 1. See the appendix of Sergio's PhD thesis for more
18    VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase(   * details.
19        outFileBase), _errMethod(errMethod), _det(0), _sel(0) {   * The important thing is that the computed efficiency will have the unphysical value 1.1
20     * if there are less than 8 events in the efficiency sample (eg., the sample used to compute the
21     * efficiency). This is necessary to have a reliable estimate of the errors.
22     *
23     * @param sel Pointer to an Int_t variable containing the number of events in the efficiency sample.
24     * @param det Pointer to an Int_t variable containing the number of events in the efficiency sample
25     *            which satisfied the set of cuts  for which the efficiency is being measured.
26     * @param eff Pointer to a Double_t variable where the computed efficiency will be returned.
27     * @param errLow Pointer to a Double_t variable where the length of the lower error bar will
28     *               be returned.
29     * @param errHigh Pointer to a Double_t variable where the length of the upper error bar will
30     *               be returned.
31     * @return Not clear at this point... ignore it.
32     */
33    bool efficiency_(Int_t* sel, Int_t* det, Double_t* eff, Double_t* errLow, Double_t* errHigh);
34    }
35    
36    EffCollection::EffCollection(const char *collectionName, TString outFileBase, int errMethod, bool owns) :
37      VerboseCollection(collectionName, false), _selCollection("selCollection",owns), _detCollection("detCollection",
38          owns), _outFileBase(outFileBase), _errMethod(errMethod), _det(0), _sel(0) {
39    
40  }  }
41    
42  void EffCollection::AddDetectorCut(PamCut &cut) {  void EffCollection::AddDetectorCut(PamCut *cut) {
43    _detCollection.AddCut(cut);    _detCollection.AddCut(cut);
44  }  }
45    
46  void EffCollection::AddSelectionCut(PamCut &cut) {  void EffCollection::AddSelectionCut(PamCut *cut) {
47    _selCollection.AddCut(cut);    _selCollection.AddCut(cut);
48  }  }
49    
50  void EffCollection::AddDetectorAction(CollectionAction &action) {  void EffCollection::AddDetectorAction(CollectionAction *action) {
51    _detCollection.AddAction(action);    _detCollection.AddAction(action);
52  }  }
53    
54  void EffCollection::AddSelectionAction(CollectionAction &action) {  void EffCollection::AddSelectionAction(CollectionAction *action) {
55    _selCollection.AddAction(action);    _selCollection.AddAction(action);
56  }  }
57    
58    void EffCollection::Setup(PamLevel2 *events){
59      // Base class have a single vector for cuts and another for actions. Here the cuts and actions
60      // are not contained inside these vectors but rather inside two SmartCollection object members.
61      // So we must call their Setup().
62      _selCollection.Setup(events);
63      _detCollection.Setup(events);
64    
65      // We call also base class' Setup(), which will likely do nothing since _sel and _det are empty.
66      VerboseCollection::Setup(events);
67    
68    }
69    
70  int EffCollection::ApplyCut(PamLevel2 *event) {  int EffCollection::ApplyCut(PamLevel2 *event) {
71    
72    _nEv++;    _nEv++;
# Line 55  void EffCollection::Finalize() { Line 86  void EffCollection::Finalize() {
86    // Let's add all the cuts to the vector of the collection before calling VerboseCollection::Finalize    // Let's add all the cuts to the vector of the collection before calling VerboseCollection::Finalize
87    for (unsigned int i = 0; i < _selCollection.GetSize(); i++)    for (unsigned int i = 0; i < _selCollection.GetSize(); i++)
88      _cuts.push_back(_selCollection.GetCut(i));      _cuts.push_back(_selCollection.GetCut(i));
89      for (unsigned int i = 0; i < _selCollection.GetActionsSize(); i++){
90        _actions.push_back(_selCollection.GetAction(i));
91        _actionsPositions.push_back(_selCollection.GetActionPosition(i));
92      }
93    for (unsigned int i = 0; i < _detCollection.GetSize(); i++)    for (unsigned int i = 0; i < _detCollection.GetSize(); i++)
94      _cuts.push_back(_detCollection.GetCut(i));      _cuts.push_back(_detCollection.GetCut(i));
95    // Now all the cuts are in place, and VerboseCollection can print its report    for (unsigned int i = 0; i < _detCollection.GetActionsSize(); i++){
96        _actions.push_back(_detCollection.GetAction(i));
97        _actionsPositions.push_back(_detCollection.GetActionPosition(i) + _selCollection.GetSize());
98      }
99    
100      // Now all the cuts and actions are in place, and VerboseCollection can print its report and call Finalize() for
101      // every cut and action (calling SmartCollection::Finalize().
102    VerboseCollection::Finalize();    VerboseCollection::Finalize();
103    
104    // Compute the error    // Compute the error

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

  ViewVC Help
Powered by ViewVC 1.1.23