--- PamCut/Collections/SmartCollection/SmartCollection.h 2009/05/27 13:30:09 1.1 +++ PamCut/Collections/SmartCollection/SmartCollection.h 2009/06/17 13:02:39 1.5 @@ -15,13 +15,29 @@ /*! @brief A collection class designed to use CollectionAction objects. * - * The SmartCollection class is designed to handle CollectionAction objects. These - * defines the procedures to do when an event is selected or discarded. A SmartCollection - * handles a vector of these objects, calling CollectionAction::OnGood() for each of them - * when a good event is selected and CollectionAction::OnBad() when a bad one is rejected. - * It will also call the CollectionAction::Setup() and CollectionAction::Finalize() methods - * at the beginning and at the end of the analysis, respectively. + * The SmartCollection class is designed to handle CollectionAction objects. It + * holds a vector of these objects and takes care of calling Setup and Finalize for + * each of them at the beginning and at the end of the analysis, respectively. + * Actions can be added to the SmartCollection by means of the AddAction() method. + * If a bunch of cuts have been already added to the collection, the action will + * be logically placed after the cuts. The SmartCollection will call + * CollectionAction::OnGood() if the cuts preceding the actions are satisfied, and + * CollectionAction::OnBad() if at least one of them fails. An action will not be + * sensitive to cuts added to the collection after the action itself. + * The resulting structure is composed by bunches of cuts intertwined by actions, + * which are "executed" depending on the result of the bunch of cuts that precedes the + * action. Note that CollectionAction::OnBad() is called only for those actions at + * the end of the bunch where the first failed cut is: if after these actions there + * are other bunches of cuts and actions, they will be ignored. + * For example, in the sequence below: * + * | cut1 | cut2 | action1 | action2 | cut3 | cut4 | action3 | ... + * + * action1 and action2 are executed (eg., OnGood is called for them) if cut1 and cut2 + * are both satisfied, then cut3 and cut4 are evaluated and if both of them are satisfied + * then action3 is executed. If, for example, cut 1 or cut2 fail, then OnBad is called for + * action1 and action2; however, cut3, cut4, action3 and all that follows are ignored. The + * analysis goes on with the next event. */ class SmartCollection: public PamCutCollection { @@ -29,14 +45,14 @@ /*! @brief Constructor. * - * @param cutName The cut's name. + * @param collectionName The collection's name. */ - SmartCollection(const char* cutName) : - PamCutCollection(cutName), _actions(0) { + SmartCollection(const char* collectionName) : + PamCutCollection(collectionName), _actions(0) { } /*! @brief Destructor. */ - ~SmartCollection(){ + ~SmartCollection() { } /*! @brief Adds an action to the SmartCollection */ @@ -50,6 +66,21 @@ */ CollectionAction *GetAction(unsigned int iAction); + /*! @brief Searches for an action by name. + * + * @param actionName The name of the action to search for. + * @return pointer to the desired action; NULL if the specified action cannot be found or if no actions are present. + */ + CollectionAction *GetAction(const char *actionName); + + /*! @brief The number of actions in the collection. + * + * @return The number of actions currently in the collection. + */ + unsigned int GetActionsSize(){ + return _actions.size(); + } + /*! @brief The pre-analysis task definition. * * This override of the Setup() method calls Setup() for the base class PamCutCollection, and subsequently for each @@ -67,30 +98,18 @@ */ void Finalize(); - /*! @brief Post-selection tasks. - * - * This routine is automatically called after a good event has been selected by - * ApplyCut(). It will simply call PamCutCollection::OnGood() and then CollectionAction::OnGood() for each - * action in the SmartCollection. - * @param event The event which satisfy the cut. - */ - void OnGood(PamLevel2 *event); - - /*! @brief Post-selection tasks. + /*! Applies the cuts and executes the actions. * - * This routine is automatically called after a bad event has been rejected by - * ApplyCut(). It will simply call PamCutCollection::OnBad() and then CollectionAction::OnBad() for each - * action in the SmartCollection. + * When cuts are applied, a SmartCollection will also execute the actions at the end of the bunches of cuts. * - * @see OnGood - * @param event The event which don't satisfy the cut. - * @param selectionResult The return value of the Check() routine. + * @param event The event to analyze. */ - void OnBad(PamLevel2 *event, int selectionResult); + int ApplyCut(PamLevel2 *event); -private: +protected: std::vector _actions; + std::vector _actionsPositions; };