1 |
/* |
2 |
* EffCollection.h |
3 |
* |
4 |
* Created on: 10/ago/2009 |
5 |
* Author: Nicola Mori |
6 |
*/ |
7 |
|
8 |
/*! @file EffCollection.h The EffCollection class definition file. */ |
9 |
|
10 |
#ifndef EFFCOLLECTION_H_ |
11 |
#define EFFCOLLECTION_H_ |
12 |
|
13 |
#include "../VerboseCollection/VerboseCollection.h" |
14 |
|
15 |
/*! @enum Flags to select the method of error computation */ |
16 |
enum EffRigCollection_ErrMethod { |
17 |
EFFRIG_SERGIO, ///< Flag for Sergio Ricciarini's Fortran routine |
18 |
EFFRIG_ROOT |
19 |
///< Flag for ROOT TGraphAsymErrors::BayesDivide() |
20 |
}; |
21 |
|
22 |
/*! @brief A verbose collection which computes the efficiency of a set of cuts. |
23 |
* |
24 |
* This class subdivides the cuts it contains into two classes: selection and detector |
25 |
* cuts; detector cuts are evaluated after selection cuts. The collection will compute the |
26 |
* efficiency of the whole detector cuts set evaluated using an efficiency sample selected |
27 |
* by the selection cuts. Actions will be divided in selection and detector actions as well: |
28 |
* adding a selection action, it will be placed after all the selection cuts inserted since |
29 |
* the action insertion, and before all detector cuts. Detector actions are placed after all |
30 |
* the cuts. |
31 |
* This class implements specific methods to add selection and detector cuts; cuts added |
32 |
* with the standard #AddCut method will be treated as detector cuts. The same for actions. |
33 |
* Error computation is done either using Sergio Ricciarini's Fortran routine or ROOT's |
34 |
* TGraphAsimmErrors::BayesDivide(). For both methods, the efficiency is arbitrarily set to |
35 |
* 1.1 when less than 8 events survive the selection cuts. This is needed to avoid convergence |
36 |
* problems in Sergio's routine, and the ROOT output has been consequently adapted to this |
37 |
* convention. |
38 |
* |
39 |
*/ |
40 |
class EffCollection: public VerboseCollection { |
41 |
|
42 |
public: |
43 |
|
44 |
/*! @brief Constructor. |
45 |
* |
46 |
* @param collectionName The collection's name. |
47 |
* @param outFileBase The output file base name. If "", no file output will be produced; otherwise, |
48 |
* a file named outFilebase + "-eff.txt" will be produced, containing the number of |
49 |
* events surviving the detector cuts (1st column), the selection cuts (2nd column), |
50 |
* the efficiency (3rd column), the lower (4th column) and upper (5th column) length |
51 |
* of the efficiency's error bar. |
52 |
* @param errMethod The method to use for error computation. Possible values are defined in #EffRigCollection_ErrMethod. |
53 |
*/ |
54 |
EffCollection(const char *collectionName, TString outFileBase = "", int errMethod = EFFRIG_ROOT); |
55 |
|
56 |
/*! @brief Destructor. */ |
57 |
~EffCollection() { |
58 |
|
59 |
} |
60 |
|
61 |
/*! @brief Adds a detector cut to the collection. |
62 |
* |
63 |
* For EffCollection, cuts added wit #AddCut will be treated as detector cuts. |
64 |
* |
65 |
* @param cut The PamCut-derived object to add to the collection. |
66 |
*/ |
67 |
void AddCut(PamCut &cut) { |
68 |
AddDetectorCut(cut); |
69 |
} |
70 |
|
71 |
/*! @brief Adds a detector cut to the collection. |
72 |
* |
73 |
* Adds a detector cut. Calling #AddCut will add a detector cut as well, and not a |
74 |
* selection cut. |
75 |
* @param cut The PamCut-derived object to add to the collection. |
76 |
*/ |
77 |
void AddDetectorCut(PamCut &cut); |
78 |
|
79 |
/*! @brief Adds a selection cut to the collection. |
80 |
* |
81 |
* Adds a selection cut. Notice that calling #AddCut will add a detector cut , and not a |
82 |
* selection cut. |
83 |
* @param cut The PamCut-derived object to add to the collection. |
84 |
*/ |
85 |
void AddSelectionCut(PamCut &cut); |
86 |
|
87 |
/*! @brief Adds an action to the detector cuts queue. |
88 |
* |
89 |
* For EffCollection, actions added wit #AddAction will be inserted in the detector cuts queue. |
90 |
* |
91 |
* @param action The CollectionAction-derived object to add to the collection. |
92 |
*/ |
93 |
void AddAction(CollectionAction &action) { |
94 |
AddDetectorAction(action); |
95 |
} |
96 |
|
97 |
/*! @brief Adds an action to the detector cuts queue. |
98 |
* |
99 |
* Adds a detector action, ie., an action placed in the detector cuts queue. Calling #AddAction will |
100 |
* add a detector action as well, and not a selection action. |
101 |
* |
102 |
* @param action The CollectionAction-derived object to add to the collection. |
103 |
*/ |
104 |
void AddDetectorAction(CollectionAction &action); |
105 |
|
106 |
/*! @brief Adds an action to the selection cuts queue. |
107 |
* |
108 |
* Adds a selection action, ie., an action placed in the selection cuts queue. Notice that calling |
109 |
* #AddAction will add a detector action, and not a selection action. |
110 |
* |
111 |
* @param action The CollectionAction-derived object to add to the collection. |
112 |
*/ |
113 |
void AddSelectionAction(CollectionAction &action); |
114 |
|
115 |
/*! @brief Applies the selection and detector cuts to the current event. |
116 |
* |
117 |
* @param event The event to analyze. |
118 |
* @return CUTOK if the event survives all the selection and detector cuts. |
119 |
*/ |
120 |
int ApplyCut(PamLevel2 *event); |
121 |
|
122 |
/*TODO: redefine GetCut and the other methods to comply with the new selection/detector cuts structure. */ |
123 |
|
124 |
/*! @brief The post analysis task. |
125 |
* |
126 |
*/ |
127 |
void Finalize(); |
128 |
|
129 |
protected: |
130 |
|
131 |
/*! This collection contains the selection cuts. */ |
132 |
SmartCollection _selCollection; |
133 |
|
134 |
/*! This collection contains the detector cuts. */ |
135 |
SmartCollection _detCollection; |
136 |
|
137 |
/*! The base name of the output file. */ |
138 |
TString _outFileBase; |
139 |
|
140 |
/*! The method used for error computation. */ |
141 |
int _errMethod; |
142 |
|
143 |
/*! The number of events surviving the detector cuts. */ |
144 |
unsigned int _det; |
145 |
|
146 |
/*! The number of events surviving the selection cuts. */ |
147 |
unsigned int _sel; |
148 |
|
149 |
}; |
150 |
|
151 |
#endif /* EFFCOLLECTION_H_ */ |