/[PAMELA software]/PamCut/Collections/SmartCollection/SmartCollection.h
ViewVC logotype

Annotation of /PamCut/Collections/SmartCollection/SmartCollection.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Tue Oct 27 10:24:00 2009 UTC (15 years, 1 month ago) by pam-fi
Branch: MAIN
CVS Tags: Root_V8, MergedToHEAD_1, nuclei_reproc, MergedFromV8_1, BeforeMergingFromV8_1
Branch point for: V8
Changes since 1.6: +8 -7 lines
File MIME type: text/plain
New ownership feature added.

1 pam-fi 1.1 /*
2     * SmartCollection.h
3     *
4     * Created on: 14-mag-2009
5     * Author: Nicola Mori
6     */
7    
8     /*! @file SmartCollection.h The SmartCollection class definition file */
9    
10     #ifndef SMARTCOLLECTION_H_
11     #define SMARTCOLLECTION_H_
12    
13     #include "../../PamCutBase/PamCutBase.h"
14     #include "../../CollectionActions/CollectionAction/CollectionAction.h"
15    
16     /*! @brief A collection class designed to use CollectionAction objects.
17     *
18 pam-fi 1.3 * The SmartCollection class is designed to handle CollectionAction objects. It
19     * holds a vector of these objects and takes care of calling Setup and Finalize for
20     * each of them at the beginning and at the end of the analysis, respectively.
21     * Actions can be added to the SmartCollection by means of the AddAction() method.
22     * If a bunch of cuts have been already added to the collection, the action will
23     * be logically placed after the cuts. The SmartCollection will call
24     * CollectionAction::OnGood() if the cuts preceding the actions are satisfied, and
25     * CollectionAction::OnBad() if at least one of them fails. An action will not be
26     * sensitive to cuts added to the collection after the action itself.
27     * The resulting structure is composed by bunches of cuts intertwined by actions,
28     * which are "executed" depending on the result of the bunch of cuts that precedes the
29     * action. Note that CollectionAction::OnBad() is called only for those actions at
30     * the end of the bunch where the first failed cut is: if after these actions there
31     * are other bunches of cuts and actions, they will be ignored.
32     * For example, in the sequence below:
33 pam-fi 1.1 *
34 pam-fi 1.3 * | cut1 | cut2 | action1 | action2 | cut3 | cut4 | action3 | ...
35     *
36     * action1 and action2 are executed (eg., OnGood is called for them) if cut1 and cut2
37     * are both satisfied, then cut3 and cut4 are evaluated and if both of them are satisfied
38     * then action3 is executed. If, for example, cut 1 or cut2 fail, then OnBad is called for
39     * action1 and action2; however, cut3, cut4, action3 and all that follows are ignored. The
40     * analysis goes on with the next event.
41 pam-fi 1.1 */
42     class SmartCollection: public PamCutCollection {
43    
44     public:
45    
46     /*! @brief Constructor.
47     *
48 pam-fi 1.2 * @param collectionName The collection's name.
49 pam-fi 1.7 * @param owns If true, the collection will own the cuts and the actions, ie., it will
50     * destroy them in its destructor.
51 pam-fi 1.1 */
52 pam-fi 1.7 SmartCollection(const char* collectionName, bool owns = true) :
53     PamCutCollection(collectionName, owns), _actions(0) {
54 pam-fi 1.1 }
55    
56     /*! @brief Destructor. */
57 pam-fi 1.7 ~SmartCollection();
58 pam-fi 1.1
59     /*! @brief Adds an action to the SmartCollection */
60 pam-fi 1.7 virtual void AddAction(CollectionAction *action);
61 pam-fi 1.1
62     /*! @brief Returns the iAction-th action.
63     *
64     * @param iAction The index of the desired CollectionAction, defined as the insertion order
65     * (from 0 to \#actions-1, see AddAction()).
66     * @return pointer to the iAction-th action; NULL if the specified action cannot be found or if no actions are present.
67     */
68     CollectionAction *GetAction(unsigned int iAction);
69    
70 pam-fi 1.5 /*! @brief Searches for an action by name.
71     *
72     * @param actionName The name of the action to search for.
73     * @return pointer to the desired action; NULL if the specified action cannot be found or if no actions are present.
74     */
75     CollectionAction *GetAction(const char *actionName);
76    
77     /*! @brief The number of actions in the collection.
78     *
79     * @return The number of actions currently in the collection.
80     */
81 pam-fi 1.7 unsigned int GetActionsSize() {
82 pam-fi 1.5 return _actions.size();
83     }
84    
85 pam-fi 1.1 /*! @brief The pre-analysis task definition.
86     *
87     * This override of the Setup() method calls Setup() for the base class PamCutCollection, and subsequently for each
88     * action contained in the SmartCollection.
89     *
90     * @param events The PamLevel2 pointer to the events that will be analyzed. Used only as parameter for
91     * CollectionAction::Setup().
92     */
93     void Setup(PamLevel2 *events);
94    
95     /*! @brief The post-analysis task definition.
96     *
97     * This override of the Finalize() method calls PamCutCollection::Finalize() and then the Finalize() method of
98     * each action contained in the SmartCollection.
99     */
100     void Finalize();
101    
102 pam-fi 1.3 /*! Applies the cuts and executes the actions.
103 pam-fi 1.1 *
104 pam-fi 1.3 * When cuts are applied, a SmartCollection will also execute the actions at the end of the bunches of cuts.
105 pam-fi 1.1 *
106 pam-fi 1.3 * @param event The event to analyze.
107 pam-fi 1.1 */
108 pam-fi 1.3 int ApplyCut(PamLevel2 *event);
109 pam-fi 1.1
110 pam-fi 1.3 protected:
111 pam-fi 1.1
112 pam-fi 1.6 /*! @brief The vector containing the actions */
113 pam-fi 1.1 std::vector<CollectionAction*> _actions;
114 pam-fi 1.6
115     /*! The vector of actions' positions
116     *
117     * An action is placed after N cuts, so that the SmartCollection, after applying N cuts, has to
118     * perform the action. The numbers N for each action are stored here: the element i is N for the
119     * i-th action in #_actions.
120     */
121 pam-fi 1.7 std::vector<int> _actionsPositions;
122 pam-fi 1.1
123     };
124    
125     #endif /* SMARTCOLLECTION_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23