--- PamCut/Collections/EffCollection/EffCollection.h 2009/09/24 18:17:28 1.4 +++ PamCut/Collections/EffCollection/EffCollection.h 2010/01/27 15:59:11 1.8 @@ -12,6 +12,13 @@ #include "../VerboseCollection/VerboseCollection.h" +/*! @enum EffCollection_ErrMethod to select the method of error computation */ +enum EffCollection_ErrMethod { + EFFERR_SERGIO, ///< Flag for Sergio Ricciarini's Fortran routine + EFFERR_ROOT +///< Flag for ROOT TGraphAsymErrors::BayesDivide() +}; + /*! @brief A verbose collection which computes the efficiency of a set of cuts. * * This class subdivides the cuts it contains into two classes: selection and detector @@ -23,7 +30,11 @@ * the cuts. * This class implements specific methods to add selection and detector cuts; cuts added * with the standard #AddCut method will be treated as detector cuts. The same for actions. - * + * Error computation is done either using Sergio Ricciarini's Fortran routine or ROOT's + * TGraphAsimmErrors::BayesDivide(). For both methods, the efficiency is arbitrarily set to + * 1.1 when less than 8 events survive the selection cuts. This is needed to avoid convergence + * problems in Sergio's routine, and the ROOT output has been consequently adapted to this + * convention. * */ class EffCollection: public VerboseCollection { @@ -34,12 +45,15 @@ * * @param collectionName The collection's name. * @param outFileBase The output file base name. If "", no file output will be produced; otherwise, - * a file named outFilebase + "-eff.txt" will be produced, containing the number of - * events surviving the detector cuts (1st column), the selection cuts (2nd column), + * a file named outFilebase + collection's name + ".txt" will be produced, containing + * the number of events surviving the detector cuts (1st column), the selection cuts (2nd column), * the efficiency (3rd column), the lower (4th column) and upper (5th column) length * of the efficiency's error bar. + * @param errMethod The method to use for error computation. Possible values are defined in #EffCollection_ErrMethod. + * @param owns If true, the collection will own the cuts and the actions, ie., it will + * destroy them in its destructor. */ - EffCollection(const char *collectionName, TString outFileBase = ""); + EffCollection(const char *collectionName, TString outFileBase = "", int errMethod = EFFERR_ROOT, bool owns = true); /*! @brief Destructor. */ ~EffCollection() { @@ -52,7 +66,7 @@ * * @param cut The PamCut-derived object to add to the collection. */ - void AddCut(PamCut &cut) { + void AddCut(PamCut *cut) { AddDetectorCut(cut); } @@ -62,7 +76,7 @@ * selection cut. * @param cut The PamCut-derived object to add to the collection. */ - void AddDetectorCut(PamCut &cut); + void AddDetectorCut(PamCut *cut); /*! @brief Adds a selection cut to the collection. * @@ -70,7 +84,7 @@ * selection cut. * @param cut The PamCut-derived object to add to the collection. */ - void AddSelectionCut(PamCut &cut); + void AddSelectionCut(PamCut *cut); /*! @brief Adds an action to the detector cuts queue. * @@ -78,7 +92,7 @@ * * @param action The CollectionAction-derived object to add to the collection. */ - void AddAction(CollectionAction &action) { + void AddAction(CollectionAction *action) { AddDetectorAction(action); } @@ -89,7 +103,7 @@ * * @param action The CollectionAction-derived object to add to the collection. */ - void AddDetectorAction(CollectionAction &action); + void AddDetectorAction(CollectionAction *action); /*! @brief Adds an action to the selection cuts queue. * @@ -98,13 +112,23 @@ * * @param action The CollectionAction-derived object to add to the collection. */ - void AddSelectionAction(CollectionAction &action); + void AddSelectionAction(CollectionAction *action); /*! @brief Applies the selection and detector cuts to the current event. * * @param event The event to analyze. * @return CUTOK if the event survives all the selection and detector cuts. */ + + /*! @brief The pre-analysis task definition. + * + * This override of the Setup() method sets up the selection and detector cuts and actions + * + * @param events The PamLevel2 pointer to the events that will be analyzed. Used only as parameter for + * VerboseCollection::Setup(). + */ + void Setup(PamLevel2 *events); + int ApplyCut(PamLevel2 *event); /*TODO: redefine GetCut and the other methods to comply with the new selection/detector cuts structure. */ @@ -125,6 +149,9 @@ /*! The base name of the output file. */ TString _outFileBase; + /*! The method used for error computation. */ + int _errMethod; + /*! The number of events surviving the detector cuts. */ unsigned int _det;