/[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.2 - (show annotations) (download)
Fri May 29 10:10:30 2009 UTC (15 years, 6 months ago) by pam-fi
Branch: MAIN
Changes since 1.1: +7 -1 lines
File MIME type: text/plain
Previous commit was outdated; fixed.

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 virtual ~CollectionAction() {
42
43 }
44
45 /*! @brief The initialization routine.
46 *
47 * In this routine the initialization procedure is to be defined. SmartCollection objects will call
48 * Setup() for each CollectionAction object they hold during SmartCollection::Setup().
49 * This method is intended for some possible post-constructor initialization, like those who
50 * need to know the PamLevel2 object (eg., clone trees selection). This method is likely to be
51 * unnecessary most of the times, so it is implemented as a void function and it's not pure virtual.
52 *
53 * @param events The PamLevel2 events which will be analyzed by the collection hosting the action.
54 */
55 virtual void Setup(PamLevel2 *events) {
56 }
57
58 /*! @brief Routine for selected events.
59 *
60 * The concrete implementations define what to do when an event is selected. This is conceptually the
61 * same as PamCut::OnGood(). Call to this method is automatically done in SmartCollection::OnGood().
62 *
63 * @param event The selected event.
64 */
65 virtual void OnGood(PamLevel2 *event) = 0;
66
67 /*! @brief Routine for discarded events.
68 *
69 * The concrete implementations define what to do when an event is discarded. This is conceptually the
70 * same as PamCut::OnBad(). Call to this method is automatically done in SmartCollection::OnBad(). This
71 * method is not pure virtual, since many times there's nothing to do when a cut fails; this way, it's not
72 * necessary to implement it in derived classes. Current implementation is void.
73 *
74 * @param event The selected event.
75 * @param selectionResult The code describing the reason of cut's failure (collections will automatically pass
76 * the index of the failed cut as selectionResult).
77 */
78 virtual void OnBad(PamLevel2 *event, int selectionResult) {
79 }
80
81 /*! @brief The finalization routine.
82 *
83 * This method is intended to be called at the end of the analysis. Its implementations contain the finalizing
84 * procedures, like writing histograms to file or printing reports. It is automatically called by SmartCollection::Finalize().
85 */
86 virtual void Finalize() = 0;
87
88 /*! @brief Returns the action name. */
89 const char *GetName(){
90 return _actionName;
91 }
92
93 private:
94 const char* _actionName;
95 };
96
97 #endif /* COLLECTIONACTION_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23