/[PAMELA software]/PamCut/CollectionActions/CollectionAction/CollectionAction.h
ViewVC logotype

Contents of /PamCut/CollectionActions/CollectionAction/CollectionAction.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Wed May 27 13:30:09 2009 UTC (15 years, 6 months ago) by pam-fi
Branch: DEV
CVS Tags: v0r00
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
First import

1 /*
2 * CollectionAction.h
3 *
4 * Created on: 13-mag-2009
5 * Author: Nicola Mori
6 */
7
8 /*! @file CollectionAction.h The CollectionAction class definition file */
9
10 #ifndef COLLECTIONACTION_H_
11 #define COLLECTIONACTION_H_
12
13 #include <PamLevel2.h>
14
15 /*! @brief An abstract class that defines the interface of a generic collection action.
16 *
17 * The CollectionAction abstract class defines an interface for a generic action object
18 * which can be used to implement common actions that can be done by collections, like
19 * filling histograms or saving selected events. The structure of this class mimicks that
20 * of a standard collection: it has a Setup() and a Finalize() methods that are meant
21 * to be called at the beginning and at the end of the selection procedure, respectively. In
22 * Setup() one can prepare the analysis actions like instantiating a histogram object (this
23 * can be done also in the constructor), while in Finalize() the analysis can be closed by,
24 * eg., writing histograms on a file and closing that file.
25 * The two methods OnGood() and OnBad() have exactly the same purpose they have in a
26 * Collection: to define action to perform each time an event is selected as good or bad.
27 * The class SmartCollection is specially designed to handle CollectionAction objects: see
28 * the documentation of SmartCollection for info on how these objects are handled.
29 */
30 class CollectionAction {
31 public:
32
33 /*! @brief Constructor.
34 *
35 * @param actionName The action's name.
36 */
37 CollectionAction(const char *actionName) :
38 _actionName(actionName) {
39 }
40 /*! @brief Destructor. */
41 ~CollectionAction() {
42 }
43
44 /*! @brief The initialization routine.
45 *
46 * In this routine the initialization procedure is to be defined. SmartCollection objects will call
47 * Setup() for each CollectionAction object they hold during SmartCollection::Setup().
48 * This method is intended for some possible post-constructor initialization, like those who
49 * need to know the PamLevel2 object (eg., clone trees selection). This method is likely to be
50 * unnecessary most of the times, so it is implemented as a void function and it's not pure virtual.
51 *
52 * @param events The PamLevel2 events which will be analyzed by the collection hosting the action.
53 */
54 virtual void Setup(PamLevel2 *events) {
55 }
56
57 /*! @brief Routine for selected events.
58 *
59 * The concrete implementations define what to do when an event is selected. This is conceptually the
60 * same as PamCut::OnGood(). Call to this method is automatically done in SmartCollection::OnGood().
61 *
62 * @param event The selected event.
63 */
64 virtual void OnGood(PamLevel2 *event) = 0;
65
66 /*! @brief Routine for discarded events.
67 *
68 * The concrete implementations define what to do when an event is discarded. This is conceptually the
69 * same as PamCut::OnBad(). Call to this method is automatically done in SmartCollection::OnBad(). This
70 * method is not pure virtual, since many times there's nothing to do when a cut fails; this way, it's not
71 * necessary to implement it in derived classes. Current implementation is void.
72 *
73 * @param event The selected event.
74 * @param selectionResult The code describing the reason of cut's failure (collections will automatically pass
75 * the index of the failed cut as selectionResult).
76 */
77 virtual void OnBad(PamLevel2 *event, int selectionResult) {
78 }
79
80 /*! @brief The finalization routine.
81 *
82 * This method is intended to be called at the end of the analysis. Its implementations contain the finalizing
83 * procedures, like writing histograms to file or printing reports. It is automatically called by SmartCollection::Finalize().
84 */
85 virtual void Finalize() = 0;
86
87 private:
88 const char* _actionName;
89 };
90
91 #endif /* COLLECTIONACTION_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23